Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .github/workflows/ci-ready.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ jobs:
matrix:
python: ["3.10", "3.11"]
runs-on: ubuntu-latest
# About 10 minutes today; a slowdown past 30 fails the job instead of running for hours.
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -64,9 +66,17 @@ jobs:
continue-on-error: true
run: python -m pytest -q tests/repository/test_architecture_anchors.py::test_architecture_anchors_resolve_to_existing_sources_and_checks
- name: Tests (smoke + unit)
id: parallel-tests
# Four workers match the standard runner's CPUs; durations keep slow tests visible.
run: >-
pytest -rs --deselect
pytest -rs -n 4 --durations=30 -m "not serial" --deselect
tests/repository/test_architecture_anchors.py::test_architecture_anchors_resolve_to_existing_sources_and_checks
- name: Tests that inspect every user process (serial)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This step is skipped if the parallel pytest step fails. The old single invocation still ran the cleanup test after an unrelated failure, but with the split it can disappear from that run’s evidence. Could you give the parallel step an ID and run the serial step after either of its outcomes, unless cancelled? Keep any parallel failure visible in the final job result.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code, acting for @Dong1017.

Fixed in feccc5c5. The parallel step now has id: parallel-tests. The serial step runs when !cancelled() and that outcome is success or failure, so a parallel failure no longer drops the process-cleanup test from the run, and the job still fails. This uses the same !cancelled() form as host-compatibility. actionlint 1.7.12 passes on the workflow. The branch also merges current main (a60322b8, #850, which does not touch these paths). New head: 4cc681cbb0672385fcf392e7d8211cbd0cbea53d.

# Run after either parallel outcome; a parallel failure still fails the job.
if: >-
${{ !cancelled() && (steps.parallel-tests.outcome == 'success'
|| steps.parallel-tests.outcome == 'failure') }}
run: pytest -rs -m serial

dashboard-browser:
if: ${{ github.event_name == 'pull_request' && !github.event.pull_request.draft }}
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@

### Changed

- The ready-lane `full-check` job runs the suite on four `pytest-xdist` workers and
reports the 30 slowest tests (Refs #862). The `dev` extra pins `pytest-xdist==3.8.0`.
Tests marked `serial` run afterwards in one process; see [tests](tests/README.md).
The job now times out after 30 minutes.
- Rename the internal Harness service Profile receipt module from `serving._profile` to
`serving.profile_receipt`. Profile receipts and offline replay retain their existing format.
- The Python `inferrsi.harness.api.Harness` wrapper is retired (Refs #766).
Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,16 @@ prerelease = true
[project.optional-dependencies]
# PyYAML is a core dependency; the skills extra stays as a compatibility alias.
skills = ["PyYAML>=6.0"]
dev = ["pytest>=7.4", "ruff>=0.6", "PyYAML>=6.0", "jsonschema>=4.18"]
dev = ["pytest>=7.4", "pytest-xdist==3.8.0", "ruff>=0.6", "PyYAML>=6.0", "jsonschema>=4.18"]
image = ["numpy>=1.24", "Pillow>=10", "scikit-image>=0.21"]

[tool.pytest.ini_options]
testpaths = ["tests"]
pythonpath = ["src", "."]
addopts = "-q"
markers = [
"serial: inspects every process of the current user, so CI runs it outside pytest-xdist workers",
]

[tool.ruff]
line-length = 100
Expand Down
4 changes: 4 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Run `python -m pytest` from the repository root on Linux for the full suite.
Pass a directory to run one module, for example `python -m pytest tests/harness`.
CI runs `pytest -n 4 -m "not serial"` with `pytest-xdist`, then `pytest -m serial`.
Mark a test `serial` when it inspects every process of the current user, because
processes from another worker can change its result. Tests must not depend on
collection time, since each worker collects the suite and all workers must agree.
Windows can collect the suite and run the portable parallel-round cases with
`python -m pytest tests/harness/test_parallel_round.py::TestPortableParallelRound`.
Parallel-round execution tests that need POSIX directory descriptors run on Linux.
Expand Down
2 changes: 2 additions & 0 deletions tests/benchmark/test_moe_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,8 @@ def test_reused_pid_is_not_signalled(monkeypatch):


@pytest.mark.skipif(sys.platform != "linux", reason="real /proc and detached process sessions")
# The cleanup scan reads every same-user process; another worker's ssh makes it unverifiable.
@pytest.mark.serial
def test_deadline_cleans_detached_workers_but_preserves_unrelated_process(tmp_path):
token = uuid.uuid4().hex
script = tmp_path / "fake_torchrun.py"
Expand Down
4 changes: 3 additions & 1 deletion tests/fixtures/serving_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import argparse
import ctypes
import hashlib
import json
import os
import socket
Expand Down Expand Up @@ -199,7 +200,8 @@ def create_plan(directory, *, mode="hot", fault=None):
}
plan = {
"mode": mode,
"device_id": "cpu-" + directory.name,
# Leases live in the shared temp directory, so concurrent fixtures need distinct devices.
"device_id": "cpu-" + hashlib.sha256(str(directory).encode()).hexdigest()[:16],
"cwd": str(directory),
"adapter": [python, script, "adapter"],
"variants": variants,
Expand Down
3 changes: 2 additions & 1 deletion tests/harness/test_profile_evidence.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ def test_invalid_evidence_fails_closed(tmp_path):
[
(b'{"traceEvents":[', "chrome-trace-json-v1"),
(b"event,duration\nkernel,20\n", "chrome-trace-json-v1"),
(gzip.compress(_TRACE)[:-8], "chrome-trace-gzip-v1"),
# mtime=0 keeps the test ID identical across parallel collection workers.
(gzip.compress(_TRACE, mtime=0)[:-8], "chrome-trace-gzip-v1"),
(_TRACE, "chrome-trace-gzip-v1"),
],
)
Expand Down
12 changes: 10 additions & 2 deletions tests/harness/test_service_backfill_recovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,15 @@ def test_backfill_publication_charges_only_proven_work(campaign, monkeypatch, cr
target = submit(campaign, version="publish-clock", a=90)["latest_observation"]
root = campaign["root"]
before = service_io.read(root / "state.json")
# One wall-clock origin: the budget depends only on the synthetic offsets and credits,
# not on how long the host takes to run the commands.
origin = time.time()
if crash is None:
before["deadline"] = time.time() + 40
before["deadline"] = origin + 40
atomic_write_json(root / "state.json", before)
offset = 0
validations = []
clock = SimpleNamespace(time=lambda: time.time() + offset, monotonic=lambda: offset)
clock = SimpleNamespace(time=lambda: origin + offset, monotonic=lambda: offset)
monkeypatch.setattr(service_backfill, "time", clock)
monkeypatch.setattr(optimization, "time", clock)
validate = service_backfill._validated
Expand Down Expand Up @@ -277,6 +280,11 @@ def slow_write(path, document):
abs=0.2,
)
assert status["remaining_seconds"] - status["remaining_search_seconds"] == pytest.approx(30)
# Inside the 30 s final reserve, the search budget is exhausted.
offset += status["remaining_seconds"] - 10
reserved = call(campaign, "status")
assert reserved["remaining_seconds"] == pytest.approx(10)
assert reserved["remaining_search_seconds"] == 0


@pytest.mark.parametrize("phase", ["during_validation", "before_index", "after_index", "report"])
Expand Down
Loading