Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions requirements/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ click==8.4.2
# via
# pip-tools
# towncrier
# wait-for-it
coverage==7.15.1
# via
# -r requirements/test-common.in
Expand Down Expand Up @@ -336,8 +335,6 @@ valkey==6.1.1
# via -r requirements/lint.in
virtualenv==21.6.1
# via pre-commit
wait-for-it==2.3.0
# via -r requirements/test-common-base.in
wheel==0.47.0
# via pip-tools
yarl==1.24.2
Expand Down
3 changes: 0 additions & 3 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ click==8.4.2
# via
# pip-tools
# towncrier
# wait-for-it
coverage==7.15.1
# via
# -r requirements/test-common.in
Expand Down Expand Up @@ -326,8 +325,6 @@ valkey==6.1.1
# via -r requirements/lint.in
virtualenv==21.6.1
# via pre-commit
wait-for-it==2.3.0
# via -r requirements/test-common-base.in
wheel==0.47.0
# via pip-tools
yarl==1.24.2
Expand Down
1 change: 0 additions & 1 deletion requirements/test-common-base.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ pytest-cov
pytest-mock
pytest-timeout
setuptools-git
wait-for-it
4 changes: 0 additions & 4 deletions requirements/test-common-base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ attrs==26.1.0
# via aiohttp
backports-asyncio-runner==1.2.0
# via pytest-asyncio
click==8.4.2
# via wait-for-it
coverage==7.15.1
# via pytest-cov
exceptiongroup==1.3.1
Expand Down Expand Up @@ -85,8 +83,6 @@ typing-extensions==4.16.0
# exceptiongroup
# multidict
# pytest-asyncio
wait-for-it==2.3.0
# via -r requirements/test-common-base.in
yarl==1.24.2
# via aiohttp

Expand Down
4 changes: 0 additions & 4 deletions requirements/test-common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ blockbuster==1.5.26
# via -r requirements/test-common.in
cffi==2.1.0
# via cryptography
click==8.4.2
# via wait-for-it
coverage==7.15.1
# via
# -r requirements/test-common.in
Expand Down Expand Up @@ -146,8 +144,6 @@ typing-extensions==4.16.0
# typing-inspection
typing-inspection==0.4.2
# via pydantic
wait-for-it==2.3.0
# via -r requirements/test-common-base.in
yarl==1.24.2
# via aiohttp
zlib-ng==1.0.0
Expand Down
4 changes: 0 additions & 4 deletions requirements/test-ft.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ cffi==2.1.0
# via
# cryptography
# pycares
click==8.4.2
# via wait-for-it
coverage==7.15.1
# via
# -r requirements/test-common.in
Expand Down Expand Up @@ -174,8 +172,6 @@ typing-extensions==4.16.0 ; python_version < "3.13"
# typing-inspection
typing-inspection==0.4.2
# via pydantic
wait-for-it==2.3.0
# via -r requirements/test-common-base.in
yarl==1.24.2
# via
# -r requirements/runtime-deps.in
Expand Down
4 changes: 0 additions & 4 deletions requirements/test-mobile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ cffi==2.1.0 ; sys_platform != "android" and sys_platform != "ios"
# via
# -r requirements/test-mobile.in
# pycares
click==8.4.2
# via wait-for-it
coverage==7.15.1
# via pytest-cov
exceptiongroup==1.3.1
Expand Down Expand Up @@ -121,8 +119,6 @@ typing-extensions==4.16.0 ; python_version < "3.13"
# exceptiongroup
# multidict
# pytest-asyncio
wait-for-it==2.3.0
# via -r requirements/test-common-base.in
yarl==1.24.2
# via
# -r requirements/runtime-deps.in
Expand Down
4 changes: 0 additions & 4 deletions requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ cffi==2.1.0
# via
# cryptography
# pycares
click==8.4.2
# via wait-for-it
coverage==7.15.1
# via
# -r requirements/test-common.in
Expand Down Expand Up @@ -176,8 +174,6 @@ typing-inspection==0.4.2
# via pydantic
uvloop==0.22.1 ; platform_system != "Windows" and implementation_name == "cpython"
# via -r requirements/base.in
wait-for-it==2.3.0
# via -r requirements/test-common-base.in
yarl==1.24.2
# via
# -r requirements/runtime-deps.in
Expand Down
5 changes: 0 additions & 5 deletions tests/autobahn/Dockerfile.autobahn
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
FROM crossbario/autobahn-testsuite:25.10.1

RUN apt-get update && apt-get install python3 python3-pip -y
RUN pip3 install wait-for-it

CMD ["wstest", "--mode", "fuzzingserver", "--spec", "/config/fuzzingserver.json"]
66 changes: 35 additions & 31 deletions tests/autobahn/test_autobahn.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import json
import pprint
import socket
import subprocess
import time
from collections.abc import Iterator
from pathlib import Path
from typing import TYPE_CHECKING
Expand All @@ -9,16 +11,27 @@
from pytest import TempPathFactory

if TYPE_CHECKING:
from python_on_whales import DockerException, docker
from python_on_whales import docker
else:
python_on_whales = pytest.importorskip("python_on_whales")
DockerException = python_on_whales.DockerException
docker = python_on_whales.docker

# (Test number, test status, test report)
Result = tuple[str, str, dict[str, object] | None]


def wait_for_port(port: int, timeout: float = 15.0) -> None:
deadline = time.monotonic() + timeout
while True:
try:
with socket.create_connection(("localhost", port), timeout=1):
return
except OSError:
if time.monotonic() >= deadline: # pragma: no cover
raise
time.sleep(0.5)


@pytest.fixture(scope="session")
def report_dir(tmp_path_factory: TempPathFactory) -> Path:
return tmp_path_factory.mktemp("reports")
Expand Down Expand Up @@ -70,34 +83,28 @@ def process_xfail(

@pytest.mark.autobahn
def test_client(report_dir: Path, request: pytest.FixtureRequest) -> None:
client = subprocess.Popen(
(
"wait-for-it",
"-s",
"localhost:9001",
"--",
"coverage",
"run",
"-a",
"tests/autobahn/client/client.py",
)
autobahn_container = docker.run(
detach=True,
image="autobahn-testsuite",
name="autobahn",
remove=True,
volumes=[
(request.path.parent / "client", "/config"),
(report_dir, "/reports"),
],
networks=("host",),
command=(
"wstest",
"--mode",
"fuzzingserver",
"--spec",
"/config/fuzzingserver.json",
),
)
try:
autobahn_container = docker.run(
detach=True,
image="autobahn-testsuite",
name="autobahn",
publish=[(9001, 9001)],
remove=True,
volumes=[
(request.path.parent / "client", "/config"),
(report_dir, "/reports"),
],
)
client.wait()
wait_for_port(9001)
subprocess.run(("coverage", "run", "-a", "tests/autobahn/client/client.py"))
finally:
client.terminate()
client.wait()
autobahn_container.stop()

results = get_test_results(report_dir / "clients", "aiohttp")
Expand Down Expand Up @@ -137,6 +144,7 @@ def test_server(report_dir: Path, request: pytest.FixtureRequest) -> None:
("coverage", "run", "-a", "tests/autobahn/server/server.py")
)
try:
wait_for_port(9001)
docker.run(
image="autobahn-testsuite",
name="autobahn",
Expand All @@ -147,10 +155,6 @@ def test_server(report_dir: Path, request: pytest.FixtureRequest) -> None:
],
networks=("host",),
command=(
"wait-for-it",
"-s",
"localhost:9001",
"--",
"wstest",
"--mode",
"fuzzingclient",
Expand Down
Loading