Repository navigation
fix(tests): repair tests and fixtures drifted behind merged changes (#3442, #3272) - #3468
Merged
Merged
Conversation
…ifted (#3442, #3272, #2420) A full suite run against a freshly rebuilt stack failed 7 of 10 tiers; one product bug came out of it (#3441) and the rest was test rot: - scheduler fixture: add `chain_depth` and `claim_token` to the hand-mirrored `schedule_executions` DDL (70 failures -> 243 passing) - test_deploy_writable_templates: restore the parent-package attributes the re-import rebinds, not only the sys.modules entries, so later files stop patching one module object while the code reads another (#3272) - test_subscriptions: delete only the suite's own `test-` subscriptions and skip the no-subscription case when the operator has real ones, instead of wiping every subscription on the instance; test_subscription_auto_switch restores the setting it found (#2420, first two criteria) - test_circuit_breaker: assert the platform-alert seam the dormant alert moved to in #3246 - test_1661_sanitizer_linear: pin the agent sanitizer's known-value cache so an ambient TRINITY_TEST_PASSWORD cannot redact the key under test - test_ip_rate_limit_fix: give the fastapi stub the `status` module services.rate_limiter now imports - test_operator_queue: answer with a decision the item actually offers - test_parallel_task: `queued` is a legitimate first status Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 9, 2026
Merged
Closed
5 tasks done
vybe
pushed a commit
that referenced
this pull request
Oct 21, 2026
…a fresh module copy (#3390) (#3848) #3468 (36711e7) already fixed the 40 failures #3390 named: putting the pre-#3468 test_deploy_writable_templates.py back still fails 41 tests (ent666 x21, ent477 git_refresh_hook x10, ent477 definitions_endpoint x6, retention_floor x4). This closes the class those 40 belonged to. A test that evicts `pkg.mod` and re-imports it rebinds the package attribute `pkg.mod` to the fresh copy, and monkeypatch.delitem, patch.dict and every hand-written snapshot restore put back only the sys.modules entry. The rest of the run then holds two copies of one module: a later test patches one while the code under test reads the other. Five recurrences so far (#3272, #3470, #2572, trinity-enterprise#752, #2859). A probe over the whole unit island found 64 files that leave such a split. - tests/module_split_guard.py: scan() finds a split, Guard repairs it, unbind() drops a stale binding, evict() is the eviction that leaves no split behind (a package takes its loaded submodules with it, #2859). - tests/unit/conftest.py runs the Guard around every test, after the item's last teardown: - a split whose sys.modules entry is still the pre-test module is repaired, by putting the attribute back to its pre-test value; - a split the test made by replacing the entry fails the file's last test, judged once its module fixtures have torn down, so a module fixture that restores its own copy is not a leak; - collection-time splits are left alone. Healing them toward sys.modules broke four test_ent692_skill_sources_mcp tests, because the entry was a test file's private copy. - TRINITY_SPLIT_GUARD=off switches the guard off. It is the control arm of the guard's end-to-end test. - The conftest's own _POP_PREFIXES pops now drop the package binding of backend modules. Before, `from services import task_execution_service` (pull_coordination_service.py) kept handing out the popped copy. - tests/lint_sys_modules.py stops recommending raw monkeypatch.delitem. A delitem of a dotted or computed name is now flagged outside tests/unit/, where nothing repairs it (3 root files baselined), and the hint points at evict(). - Fixed the two files that left a copy in sys.modules for good: test_session_operations (db.sessions) and test_audit_retention_prune (db.audit). Both now use monkeypatch.setitem. - test_deploy_writable_templates.py: #3468's inline loop becomes evict(). The other 62 polluting files need no edit: the guard repairs them. Proof on the real class, with the pre-#3468 polluter back plus the 4 victim files, -p no:randomly: 121 passed with the guard; 41 failed with TRINITY_SPLIT_GUARD=off. Fixes #3390 Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Test-only change. A full
tests/run-full.shagainst a freshly rebuilt local stack failed 7 of 10 tiers. Triage found one product bug (filed as #3441) and a set of tests and fixtures that had drifted behind merged product changes or depended on the state of the machine they ran on. This PR fixes the test side.Fixes #3442
Fixes #3272
Related to #2420 (first two acceptance criteria only — the
TRINITY_TEST_ALLOW_DESTRUCTIVEguard, the README note and the guard's own test are not in this PR)What changed
tests/scheduler_tests/conftest.pyschedule_executionsDDL lackedchain_depthandclaim_token; 70 of 243 failedtests/unit/test_deploy_writable_templates.pyservices.*modules and re-imported; teardown restoredsys.modulesbut left the parent-package attributes pointing at the fresh objects, so later files patched one module and the code read another (#3272)monkeypatchbefore eviction so teardown restores ittests/test_subscriptions.pytest_create_agent_no_subscriptionsdeleted every subscription on the target instance (#2420)test-subscriptions; skips with a named reason when operator-owned ones remain.test_create_agent_with_subscriptionaccepts an operator-owned subscription as a valid auto-assign targettests/test_subscription_auto_switch.pytests/integration/test_circuit_breaker.pydb.create_operator_queue_itemfor the dormant alertcreate_platform_operator_queue_item, one row per subject)tests/unit/test_1661_sanitizer_linear.pyTestChainedPairscases failed whenever the environment held a sensitive-named variable whose value was the wordpassword(whichtests/setup-env.shproduces on an install with that admin password)tests/test_ip_rate_limit_fix.pyfastapistub had nostatus, whichservices.rate_limiternow importsstarlette.statusconstantstests/test_operator_queue.pyapprove; 422 when that item is an approval with its own optionstests/test_parallel_task.pyqueuedqueuedaccepted as the legitimate first stateTest run report (2026-10-09,
dev@f6bedcd81, all images rebuilt)Verdict of the run that prompted this: FAILED (
run-full.shexit 1). Preflight was green 5/5.fastapi.statusstub; the rest stale assertions and three order-dependent flakesOne finding was reclassified during the fix: the dormant-alert failure looked like a possible product regression (
NoEventLoopErrorin the log) but is a stale test — the alert is filed correctly through the new seam; the logged error is only the follow-up broadcast having no event loop in a sync test.Verification
Run from this branch:
pytest tests/scheduler_tests— 243 passed (was 70 failed)pytest tests/unit/(full tier,setup-env.shsourced) — 1 failed, 24,878 passed (was 86 failed). The one failure,test_1968_trigger_execution_id.py::test_service_does_not_recreate_a_passed_execution(services.monitoring_alertshas no attributeMonitoringAlertService), passes 3 of 3 in isolation — a separate order-dependent contamination with a different culprit, not addressed heretest_deploy_writable_templates.pyfollowed by each former victim (test_ent477_definitions_endpoint,test_ent477_git_refresh_hook,test_ent666_objective_join,test_retention_floor) — all passTRINITY_TEST_PASSWORD=password pytest tests/unit/test_1661_sanitizer_linear.py— 185 passedpytest tests/integration/test_circuit_breaker.py— 34 passedpytest tests/test_ip_rate_limit_fix.py— 14 passedpytest tests/test_subscriptions.py tests/test_subscription_auto_switch.pyagainst a live stack holding a real subscription — 27 passed, 1 skipped; the subscription and the auto-switch value were unchanged afterwardspytest tests/test_avatars.py "tests/test_operator_queue.py::TestRespondToQueueItem"— 37 passedpytest tests/security— 6 passed, 5 skippedtests/lint_sys_modules.py— no new violationsNot re-run: the full
run-full.shend to end on this branch, andtest_parallel_task.py(the change only widens an accepted-status list).Not fixed here
test_avatars.pyfailures from the full run did not reproduce in isolation on this branch (37 passed); cause not established.test_email_authwhitelist auth,test_shared_foldersdefaults,test_nevermined_paymentsinfo).api.logbreaking the summary row,pytest-randomlyin the venv, the scheduler fixture being a hand copy).🤖 Generated with Claude Code