Skip to content

fix(tests): give each xdist worker its own static server port, and refuse a server for another checkout - #274

Draft
schloerke wants to merge 2 commits into
schloerke/lock-refreshfrom
schloerke/test-server-per-worker
Draft

schloerke wants to merge 2 commits into
schloerke/lock-refreshfrom
schloerke/test-server-per-worker

Conversation

@schloerke

@schloerke schloerke commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on posit-dev/shinylive#273.

The static_server fixture served _shinylive/ on one fixed port (8100) and reused any server it found already listening there. This caused two problems:

  • Under xdist, the server could disappear in the middle of a run. The first worker started the server and the others reused it. When that first worker finished, its fixture stopped the server while the other workers were still running tests. Each worker now uses its own port: 8100 plus its number (gw0 → 8100, gw1 → 8101). Without xdist the port is still 8100.
  • Another checkout's build could stand in for this one. Two checkouts (or Conductor workspaces) running tests at once shared port 8100, so one checkout's tests could run against the other's build without anyone noticing. tests/static_server.py now adds an X-Served-From header with the folder it serves. The fixture reuses a running server only if that header matches this checkout's _shinylive/. Otherwise the test fails and names the port and the folder being served.

A server you start by hand with python tests/static_server.py 8100 _shinylive is still reused. A plain python -m http.server is not, because it does not send the header.

…fuse a server for another checkout

The session's static server used one fixed port. Under xdist, the worker that started it stopped it when that worker finished, while other workers were still using it. Each worker now uses 8100 plus its number.

A server already on the port was reused without checking what it served, so another checkout's build could stand in for this one. static_server.py now names its directory in an X-Served-From header, and the fixture fails with a clear message when that is not this checkout's _shinylive/.
@schloerke
schloerke added this pull request to stack #264 November 10, 2026 19:06
@schloerke schloerke changed the title schloerke/test server per worker fix(tests): give each xdist worker its own static server port, and refuse a server for another checkout Nov 10, 2026
@schloerke
schloerke marked this pull request as draft November 10, 2026 19:06
@github-actions

Copy link
Copy Markdown
Contributor

Unit tests only — the pure-logic modules in src/. The React components, hooks, engine proxies and service worker are covered by the pytest + Playwright suites in tests/, which are not measured here.

Coverage report

St.❔
Category Percentage Covered / Total
🟢 Statements 100% 1994/1994
🟢 Branches 100% 400/400
🟢 Functions 100% 96/96
🟢 Lines 100% 1994/1994

Test suite run success

342 tests passing in 20 suites.

Report generated by 🧪jest coverage report action from e29d9c7

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant