Skip to content

Add pytest integration test verifying a worker appears after application startup - #38

Draft
DeltaRule with Copilot wants to merge 3 commits into
mainfrom
copilot/add-worker-connection-test
Draft

Add pytest integration test verifying a worker appears after application startup#38
DeltaRule with Copilot wants to merge 3 commits into
mainfrom
copilot/add-worker-connection-test

Conversation

Copilot AI commented Mar 15, 2026

Copy link
Copy Markdown
Contributor

The pytest suite started both workers but never asserted a worker was actually visible in the admin API. A timing race also existed: conftest.py waited only for the proc-worker's own gRPC port, not for the Subscribe handshake (which runs in a separate goroutine) to complete.

tests/conftest.py

  • Added _wait_for_worker() — polls GET /admin/workers with the admin key until the named worker appears, bridging the gap between "gRPC port open" and "Subscribe completed"
  • live_server (local mode) now calls _wait_for_worker("session-proc-1") after _wait_for_port; fails fast with a clear message if the worker doesn't register within 30 s
  • Added proc_worker_id to both the live_server yield dict and the settings fixture ("session-proc-1" locally, "" in external/CI mode)

tests/test_apis.py

  • Added test_admin_workers_shows_connected_worker: asserts ≥1 worker is Available after startup; when proc_worker_id is known (local mode), also asserts that specific worker is present by ID
def test_admin_workers_shows_connected_worker(settings):
    response = requests.get(url, headers=_auth_header(settings["admin_key"]))
    workers = response.json()
    assert len(workers) >= 1          # at least one worker connected
    assert any(w["status"] == "Available" for w in workers)

    worker_id = settings.get("proc_worker_id", "")
    if worker_id:
        assert worker_id in {w["worker_id"] for w in workers}

💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

Co-authored-by: DeltaRule <83079740+DeltaRule@users.noreply.github.com>
Copilot AI changed the title [WIP] Add test to verify worker connections Add TestHandleAdminWorkers: verify subscribed workers appear as Available in admin API Mar 15, 2026
Copilot AI requested a review from DeltaRule March 15, 2026 16:01
Co-authored-by: DeltaRule <83079740+DeltaRule@users.noreply.github.com>
Copilot AI changed the title Add TestHandleAdminWorkers: verify subscribed workers appear as Available in admin API Add pytest integration test verifying a worker appears after application startup Mar 15, 2026
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.

2 participants