Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run test_requesting_large_resources_via_ssl separately #3181

Merged
merged 4 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,22 @@ jobs:
nox-session: ['']
include:
- experimental: false
# integration
# 3.8 and 3.9 have a known issue with large SSL requests that we work around:
# https://github.com/urllib3/urllib3/pull/3181#issuecomment-1794830698
- python-version: "3.8"
os: ubuntu-latest
experimental: false
nox-session: test_integration
- python-version: "3.9"
os: ubuntu-latest
experimental: false
nox-session: test_integration
- python-version: "3.12"
os: ubuntu-latest
experimental: false
nox-session: test_integration
# pypy
- python-version: "pypy-3.8"
os: ubuntu-latest
experimental: false
Expand All @@ -56,6 +72,7 @@ jobs:
experimental: false
nox-session: test-pypy
- python-version: "3.x"
# brotli
os: ubuntu-latest
experimental: false
nox-session: test_brotlipy
Expand Down
4 changes: 4 additions & 0 deletions changelog/3181.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Note to redistributors: the urllib3 test suite has been separated in
two. To run integration tests, you now need to run the tests a second
time with the `--integration` pytest flag, as in this example: `nox
-rs test-3.12 -- --integration`.
10 changes: 9 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def tests_impl(
session: nox.Session,
extras: str = "socks,brotli,zstd",
byte_string_comparisons: bool = True,
integration: bool = False,
) -> None:
# Install deps and the package itself.
session.install("-r", "dev-requirements.txt")
Expand Down Expand Up @@ -44,6 +45,7 @@ def tests_impl(
*("--memray", "--hide-memray-summary") if memray_supported else (),
"-v",
"-ra",
*(("--integration",) if integration else ()),
f"--color={'yes' if 'GITHUB_ACTIONS' in os.environ else 'auto'}",
"--tb=native",
"--durations=10",
Expand All @@ -59,7 +61,13 @@ def test(session: nox.Session) -> None:
tests_impl(session)


@nox.session(python=["3"])
@nox.session(python="3")
def test_integration(session: nox.Session) -> None:
"""Run integration tests"""
tests_impl(session, integration=True)


@nox.session(python="3")
def test_brotlipy(session: nox.Session) -> None:
"""Check that if 'brotlipy' is installed instead of 'brotli' or
'brotlicffi' that we still don't blow up.
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ python_classes = ["Test", "*TestCase"]
markers = [
"limit_memory: Limit memory with memray",
"requires_network: This test needs access to the Internet",
"integration: Slow integrations tests not run by default",
]
log_level = "DEBUG"
filterwarnings = [
Expand Down
26 changes: 26 additions & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,32 @@
from .tz_stub import stub_timezone_ctx


def pytest_addoption(parser: pytest.Parser) -> None:
parser.addoption(
"--integration",
action="store_true",
default=False,
help="run integration tests only",
)


def pytest_collection_modifyitems(
config: pytest.Config, items: list[pytest.Item]
) -> None:
integration_mode = bool(config.getoption("--integration"))
skip_integration = pytest.mark.skip(
reason="skipping, need --integration option to run"
)
skip_normal = pytest.mark.skip(
reason="skipping non integration tests in --integration mode"
)
for item in items:
if "integration" in item.keywords and not integration_mode:
item.add_marker(skip_integration)
elif integration_mode and "integration" not in item.keywords:
item.add_marker(skip_normal)


class ServerConfig(typing.NamedTuple):
scheme: str
host: str
Expand Down
6 changes: 1 addition & 5 deletions test/with_dummyserver/test_socketlevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import shutil
import socket
import ssl
import sys
import tempfile
import time
import typing
Expand Down Expand Up @@ -1584,10 +1583,7 @@ def socket_handler(listener: socket.socket) -> None:
pool.request("GET", "/", retries=False, timeout=LONG_TIMEOUT)
assert server_closed.wait(LONG_TIMEOUT), "The socket was not terminated"

@pytest.mark.skipif(
os.environ.get("CI") == "true" and sys.implementation.name == "pypy",
reason="too slow to run in CI",
)
@pytest.mark.integration
@pytest.mark.parametrize(
"preload_content,read_amt", [(True, None), (False, None), (False, 2**31)]
)
Expand Down