fix(tests): group ClickHouse integration tests under xdist - #893
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe ClickHouse launcher and evaluator integration tests now support configurable endpoints, synchronized startup, TCP readiness checks, xdist grouping, worker-level readiness logging, and propagation of the resolved ClickHouse URL to Intake services. ChangesClickHouse integration test coordination
Sequence Diagram(s)sequenceDiagram
participant TestFixture
participant ClickHouseScript
participant Docker
participant PytestWorkers
participant IntakeServices
TestFixture->>ClickHouseScript: start with configured endpoint
ClickHouseScript->>Docker: lock, inspect, and start container
Docker-->>ClickHouseScript: configured ports become available
TestFixture->>TestFixture: wait for TCP readiness
TestFixture->>PytestWorkers: report reachable endpoint
TestFixture->>IntakeServices: pass NMP_INTAKE_CLICKHOUSE_URL
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@services/intake/scripts/spans/run_clickhouse.sh`:
- Around line 41-44: Restrict the conflict handling in the container startup
flow to cases where the specific ${container_name} is confirmed running after
docker run fails. Before proceeding to docker exec, recheck the container with
the existing docker-ps mechanism and only swallow the error when it is running;
propagate port-binding and other failures instead.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 61308ed5-777b-429f-94af-3d7ebaf0dacd
📒 Files selected for processing (1)
services/intake/scripts/spans/run_clickhouse.sh
|
72b386a to
80b5937
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
plugins/nemo-evaluator/tests/integration/test_publish_to_intake.py (1)
66-66: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDuplicated
CLICKHOUSE_CI_LOG_KEYstring constant across two files. Same literal independently declared in both; if one drifts,pytest_testnodedownsilently drops messages with no error.
plugins/nemo-evaluator/tests/integration/test_publish_to_intake.py#L66: keep as the single source of truth (or move to a shared module) and import it fromconftest.py.plugins/nemo-evaluator/tests/integration/conftest.py#L37: importCLICKHOUSE_CI_LOG_KEYfromtest_publish_to_intake.py(or shared module) instead of redeclaring the literal.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@plugins/nemo-evaluator/tests/integration/test_publish_to_intake.py` at line 66, Use a single source of truth for CLICKHOUSE_CI_LOG_KEY: retain the definition in plugins/nemo-evaluator/tests/integration/test_publish_to_intake.py:66, and update plugins/nemo-evaluator/tests/integration/conftest.py:37 to import and reuse it instead of redeclaring the literal.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@plugins/nemo-evaluator/tests/integration/test_publish_to_intake.py`:
- Around line 151-172: Update the _clickhouse fixture so _file_lock protects
only the startup subprocess.run call, allowing xdist workers to use the shared
container concurrently. Replace the unconditional docker rm -f teardown with
coordination that removes CLICKHOUSE_CONTAINER only after the final worker
releases the shared session, preserving the container for workers still using
it.
---
Nitpick comments:
In `@plugins/nemo-evaluator/tests/integration/test_publish_to_intake.py`:
- Line 66: Use a single source of truth for CLICKHOUSE_CI_LOG_KEY: retain the
definition in
plugins/nemo-evaluator/tests/integration/test_publish_to_intake.py:66, and
update plugins/nemo-evaluator/tests/integration/conftest.py:37 to import and
reuse it instead of redeclaring the literal.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: fd8b601a-23b0-404e-a829-c8ed95a10e79
📒 Files selected for processing (3)
plugins/nemo-evaluator/tests/integration/conftest.pyplugins/nemo-evaluator/tests/integration/test_publish_to_intake.pyservices/intake/scripts/spans/run_clickhouse.sh
80b5937 to
1e98be5
Compare
45eb944 to
88a1994
Compare
tylersbray
left a comment
There was a problem hiding this comment.
Just a nit at this point, no biggie. Thanks.
Signed-off-by: Ryan S <267728323+ironcommit@users.noreply.github.com>
88a1994 to
43acce2
Compare
Summary
loadgroupscheduler.xdist_group("nmp_intake_clickhouse"), so those tests stay on one worker.loadgroupby adding their dynamic markers early enough for xdist to see them.--dist, so unit/default runs can actually useloadscopewhile integration runs useloadgroup.Root cause
The failing CI job hit a test-infrastructure race, not an application-code failure. The publish-to-intake tests use a session-scoped fixture that starts a fixed local ClickHouse container and removes it at fixture teardown.
With xdist, session scope is per worker, not global across all workers. If ClickHouse-backed tests are split across workers, each worker can independently start and tear down the same singleton container. That can produce startup conflicts or let one worker remove the container while another worker still needs it.
--dist loadgroupis the xdist mode that honorsxdist_groupmarkers, but it does not infer shared fixtures by itself. The test suite has to mark tests that share an external resource.The repo also had a root
pytest_xdist_make_schedulerhook that always returnedLoadGroupScheduling, regardless of the requested--distvalue. This patch teaches that hook to honorloadscopevs.loadgroup, so the Makefile split is real rather than just command-line text.Fix
PYTEST_DISTconfigurable inMakefile.loadscopefor normal fixture locality.test-integrationandtest-integration-ciwithloadgroup.xdist_group("nmp_intake_clickhouse")to any test whose fixture closure includes_clickhouse.tryfirst=Trueso the markers exist before xdist reads them for scheduling.pytest_xdist_make_schedulerto returnLoadGroupSchedulingonly for--dist loadgroup,LoadScopeSchedulingfor--dist loadscope, and otherwise fall through to xdist defaults.Test plan
make -n test-unit PYTEST_WORKERS=2shows--dist loadscope.make -n test-integration PYTEST_WORKERS=2shows--dist loadgroup.uv run --frozen ruff check conftest.py plugins/nemo-evaluator/tests/integration/conftest.py plugins/nemo-deployments/tests/integration/conftest.pyuv run --frozen pytest packages/nmp_common/tests/observability/test_otel.py::TestLoggingIntegration::test_initialize_obs_configures_plain_logging_by_default -v --no-cov -n 2 --dist loadscopeshowsscheduling tests via LoadScopeScheduling.uv run --frozen pytest plugins/nemo-evaluator/tests/integration/test_publish_to_intake.py -v --no-cov -n 2 --dist loadgroupshowsscheduling tests via LoadGroupSchedulingand groups tests under@nmp_intake_clickhouse.uv run --frozen pytest plugins/nemo-deployments/tests/integration/backends/docker/test_docker_backend.py::test_volume_lifecycle -v --no-cov -n 2 --dist loadgroupshowsscheduling tests via LoadGroupSchedulingand groups the test under@nemo_deployments_docker_integration.The original failing commit touched unrelated frontend files; this PR addresses the pre-existing integration-test infrastructure flake exposed by that CI run.