Skip to content

Commit 79cc3c2

Browse files
committed
ci: apply the pytest per-test timeout and stop the SSE role test from blocking
Wire the already-defined per-test timeout into the default pytest arguments so a stuck test fails fast instead of running to the job limit, and pass timeout=1 to the streaming request endpoint in the role-enforcement test so its assertion (the role gate does not reject a viewer) runs without waiting out the stream's default 300s duration.
1 parent e80744b commit 79cc3c2

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

makefiles/common.mk

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,18 @@ COVERAGE_REPORT := coverage.xml
5252
COVERAGE_HTML := htmlcov
5353

5454
# Test settings
55-
PYTEST_ARGS := -v --tb=short --durations=10
56-
PYTEST_COV_ARGS := --cov=$(PACKAGE_ROOT) --cov-report=term-missing --cov-branch
57-
PYTEST_TIMEOUT := --timeout=300
55+
PYTEST_TIMEOUT := --timeout=$(shell yq '.ci.test_timeout' $(PROJECT_CONFIG) 2>/dev/null || echo "300")
5856
PYTEST_MAXFAIL := --maxfail=5
57+
PYTEST_ARGS := -v --tb=short --durations=25 $(PYTEST_TIMEOUT)
58+
COVERAGE_THRESHOLD := $(shell yq '.ci.coverage_threshold' $(PROJECT_CONFIG) 2>/dev/null || echo "70")
59+
PYTEST_COV_ARGS := --cov=$(PACKAGE_ROOT) --cov-report=term-missing --cov-branch
60+
# --cov-fail-under is intentionally absent from PYTEST_COV_ARGS. Individual CI
61+
# test legs (unit-only, integration-only, infrastructure-only, providers-only) each
62+
# cover a fraction of the package; enforcing the threshold per-leg would fail every
63+
# leg that doesn't happen to exercise the other layers. The combined threshold is
64+
# enforced by the ci-tests-coverage-check target which first runs `coverage combine`
65+
# to merge all per-leg .coverage files before applying --fail-under.
66+
PYTEST_COV_FAIL_UNDER := --cov-fail-under=$(COVERAGE_THRESHOLD)
5967

6068
# Documentation settings
6169
DOCS_DIR := docs

tests/unit/api/test_role_enforcement.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,11 @@ def _app_with_no_rank_user(router) -> FastAPI:
472472
(requests_router, "GET", "/requests/return", None),
473473
(requests_router, "GET", "/requests/req-1/status", None),
474474
(requests_router, "POST", "/requests/status", {"request_ids": ["req-1"]}),
475-
(requests_router, "GET", "/requests/req-1/stream", None),
475+
# ?timeout=1 keeps the SSE stream from blocking on its 300s default: this
476+
# test only asserts the role gate does not 403, which fires before the
477+
# stream generator runs. Without the override the generator loops until
478+
# pytest-timeout kills it at 300s, dominating the whole unit leg.
479+
(requests_router, "GET", "/requests/req-1/stream?timeout=1", None),
476480
# machines router
477481
(machines_router, "GET", "/machines/", None),
478482
(machines_router, "GET", "/machines/m-1/status", None),

0 commit comments

Comments
 (0)