Skip to content

Commit 71870d4

Browse files
committed
fix(ci): exclude k8s/live from auto-collection to unblock Providers Tests (k8s) job
The parallel ci-tests-providers target passes -m "not serial" to filter out tests that require a live cluster. tests/providers/k8s/live/conftest.py registers a pytest_collection_modifyitems hook that stamps the serial marker on every item in the session — not just items under live/ — so when pytest descends into that directory the entire 1261-item collection gets marked serial and -m "not serial" deselects all of them → exit code 5 (no tests ran). Fix 1 (primary): add tests/providers/k8s/live to pyproject.toml norecursedirs, mirroring the existing tests/providers/aws/live entry. This prevents pytest from descending into live/ during the parallel leg. The serial ci-tests-providers-serial target points pytest at the path explicitly so live tests remain reachable when --run-k8s is passed. Fix 2 (defensive): scope the pytest_collection_modifyitems hook in live/conftest.py to items whose path is under the live/ directory. This ensures that if the directory is ever included in a broader collection again the hook cannot silently poison non-live tests. Verified locally: 1217 items collected, 1214 passed, 3 pre-existing failures in statefulset_handler and coverage_gaps tests unrelated to this change.
1 parent d6eb4ba commit 71870d4

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

pyproject.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,15 @@ include-package-data = true
476476
testpaths = ["tests", "src/orb/k8s_legacy/tests"]
477477
norecursedirs = [
478478
"tests/providers/aws/live",
479+
# k8s live tests require a real cluster; the parallel ci-tests-providers
480+
# target passes -m "not serial" which would deselect every test if
481+
# live/conftest.py's pytest_collection_modifyitems hook is allowed to run
482+
# (it bulk-stamps serial on all collected items in the session). Excluding
483+
# this subtree from auto-discovery mirrors the aws/live pattern and keeps
484+
# the parallel leg collecting only the mocked/unit/contract tests. The
485+
# serial ci-tests-providers-serial target points pytest at the path
486+
# explicitly so live tests are still reachable when --run-k8s is passed.
487+
"tests/providers/k8s/live",
479488
# Legacy k8s regression tests require a live cluster + kubeconfig; their
480489
# conftest calls `delete_pods_in_namespace()` at collection time, which
481490
# crashes in headless CI without a real kube context. Run them

tests/providers/k8s/live/conftest.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,26 @@
2828

2929

3030
def pytest_collection_modifyitems(config: pytest.Config, items: list[pytest.Item]) -> None:
31-
"""Apply the ``serial`` marker to every test collected in this subtree.
31+
"""Apply the ``serial`` marker to tests collected in this subtree.
32+
33+
The hook is scoped to items whose node-id starts with this directory so
34+
that it does not accidentally mark tests from other directories (e.g.
35+
unit/, mocked/, contract/) as serial when pytest collects multiple paths
36+
in a single invocation. Without the path guard every test in the session
37+
would receive the serial marker, causing -m "not serial" to deselect the
38+
entire suite and producing a 0-item run.
3239
3340
``pytestmark`` at module level is not picked up by conftest-level
3441
discovery; the collection hook is the canonical place to bulk-apply
3542
markers across a directory subtree.
3643
"""
44+
import pathlib
45+
46+
live_dir = str(pathlib.Path(__file__).parent)
3747
marker = pytest.mark.serial
3848
for item in items:
39-
item.add_marker(marker)
49+
if str(item.fspath).startswith(live_dir):
50+
item.add_marker(marker)
4051

4152

4253
# ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)