Repository navigation
test: give each xdist worker its own default unit-test SQLite file (#4051) - #4079
Conversation
…4051) tests/unit/conftest.py defaulted TRINITY_DB_PATH (and the retained-results dir and chat-session marker) with os.environ.setdefault(..., pid). The xdist controller loads that conftest first, so the value carried the controller's pid, every worker inherited it, and each worker's setdefault was a no-op: under CI's -n auto all workers shared one SQLite file, contrary to the backend-unit-test.yml comment that says conftest pins it per PID. A value this conftest defaulted is now recorded in TRINITY_UNIT_TESTS_DEFAULTED_ENV, and a process that inherits it re-derives it from its own pid. A value set from outside is still left alone. The CI comment is now accurate as written. The new test fails under -n 2 without the fix (all three paths carry another process's pid) and passes with it; a serial run passes either way. Fixes #4051 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Review via /review (pre-landing structural review). Self-review by the PR author's session; obasilakis is requested as the independent reviewer. /review ReportBranch:
Execution coverage (Step 2.5)
Fix mutation: with Critical FindingsNone. Informational Findings[I1] The CI workflow comment is left as-is (Confidence: 8/10) Clean Categories
Summary
|
|
Resolve by merging |
|
Resolve by running |
# Conflicts: # tests/registry.json
obasilakis
left a comment
There was a problem hiding this comment.
/review + /validate-pr: APPROVE on code (lane B). Needs a rebase.
- BLOCKER (mechanical)
tests/registry.json:3: conflicts withdev; no CI has run. - Mutation: reverting
conftest.pyto merge-base and running the new test with-n 2fails all 3 cases, each naming the controller pid. With the fix: 3 passed under-n 2and serially. Externally setTRINITY_DB_PATHstill left alone (_defaulted_by_us). - WARN #4051 AC3 (serial vs
-n autofull unit tier on one seed) not done, as the body says. Tests that passed only via a shared DB file may change result; CI's-n autorun is the first data point. - INFO
tests/unit/conftest.py:85-104: temp DB / retained-results dir / chat-session file never cleaned up (pre-existing); now one set per worker plus controller.
Ran /review + /validate-pr (report-only mode).
…cal, per the merge-train note on the PR Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
merge-train: merged |
Summary
tests/unit/conftest.pydefaultedTRINITY_DB_PATHwithos.environ.setdefault(..., os.getpid()). The same applied toTRINITY_RETAINED_RESULTS_DIRandTRINITY_CHAT_SESSION_FILE. The xdist controller loads that conftest first, so the value carried the controller's pid. Every worker inherited it, and each worker'ssetdefaultwas a no-op, so under CI's-n autoall workers shared one SQLite file.A value this conftest defaulted is now recorded in
TRINITY_UNIT_TESTS_DEFAULTED_ENV, and any process that inherits it re-derives the value from its own pid. A value set from outside (a developer's ownTRINITY_DB_PATH) is still left alone. This makes the existing comment inbackend-unit-test.ymltrue as written ("conftest pins TRINITY_DB_PATH per PID ... which is what makes per-worker DB state correct"). The workflow file is not edited.Tests
tests/unit/test_4051_per_worker_unit_db.pyasserts that each defaulted path carries this process's pid:-n 2without the fix: all three cases fail, each naming another process's pid.-n 2with the fix: they pass.-n autois where the test bites.Not done locally: the issue's third criterion, comparing the full unit tier serial vs
-n autoon one seed. The full tier is long, and network-dependent files time out in my environment ondevtoo. CI's-n autorun of this PR is the first data point.Fixes #4051
🤖 Generated with Claude Code