Skip to content

Commit ca4b326

Browse files
committed
test: start embedded Radicale on a free port
Under plain pytest -n 8 several workers each started Radicale on 5232, and one worker's stop() took down the server another was using. The xdist_group workaround only helped with --dist loadgroup. caldav 3.7, already the minimum, honours the port and closes what stop() used to leak, so the workarounds go. Prompt: [pick from the task list: "calendaring: embedded Radicale fails to start under pytest -n 8"] Assisted-By: Claude Opus 5.5 <noreply@anthropic.com> Reviewed-by: Tobias Brox <tobias@redpill-linpro.com>
1 parent 31a252f commit ca4b326

2 files changed

Lines changed: 2 additions & 14 deletions

File tree

‎CONTRIBUTING.md‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ make test
3333

3434
`make dev` also installs caldav and the embedded Xandikos and Radicale
3535
servers, which the CalDAV backend's conformance tests run against (they are
36-
skipped when missing). Radicale listens on its default port, 5232, whatever
37-
caldav's test helper is told, so that port must be free.
36+
skipped when missing).
3837

3938
### Testing against more CalDAV servers
4039

‎tests/conftest.py‎

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,7 @@ def serve(module: str, factory: str, config: dict[str, Any]) -> Iterator[Any]:
3737
server = getattr(testing, factory)(config)
3838
server.start()
3939
yield server
40-
# stop() leaves these open (RadicaleServer one end of its socketpair,
41-
# XandikosServer its thread's event loop): https://github.com/python-caldav/caldav/issues/797
42-
leftovers = [getattr(server, name, None) for name in ("shutdown_socket_out", "xapp_loop")]
4340
server.stop()
44-
for leftover in leftovers:
45-
if leftover is not None:
46-
leftover.close()
4741

4842

4943
@pytest.fixture(scope="session")
@@ -53,9 +47,7 @@ def xandikos_server() -> Iterator[Any]:
5347

5448
@pytest.fixture(scope="session")
5549
def radicale_server() -> Iterator[Any]:
56-
# RadicaleServer does not pass its port on to Radicale, which then
57-
# listens on its default, 5232: https://github.com/python-caldav/caldav/issues/797
58-
yield from serve("radicale", "RadicaleServer", {})
50+
yield from serve("radicale", "RadicaleServer", {"port": free_port()})
5951

6052

6153
# --- caldav's test servers ----------------------------------------------
@@ -146,9 +138,6 @@ def pytest_collection_modifyitems(config: pytest.Config, items: list[pytest.Item
146138
for name in (params.params.get(key) for key in ("caldav_server", "where")) if params else ():
147139
if name in servers:
148140
item.add_marker(pytest.mark.xdist_group(name))
149-
# Radicale always listens on 5232, and stop() shuts down whichever one answers there
150-
if "radicale_server" in getattr(item, "fixturenames", ()):
151-
item.add_marker(pytest.mark.xdist_group("Radicale"))
152141

153142

154143
def wait_out_search_cache(backend: Any, monkeypatch: pytest.MonkeyPatch) -> None:

0 commit comments

Comments
 (0)