fix(tests): patch _get_session_service directly to eliminate parallel-worker race condition #9213

Merged
HAL9000 merged 1 commits from fix/flaky-session-tell-tests into master 2026-04-28 06:59:24 +00:00

1 Commits

Author SHA1 Message Date
HAL9000 8313096b47 fix(tests): patch _get_session_service directly to eliminate parallel-worker race condition
CI / benchmark-publish (push) Failing after 43s
CI / lint (push) Successful in 52s
CI / quality (push) Successful in 1m0s
CI / typecheck (push) Successful in 1m21s
CI / security (push) Successful in 1m33s
CI / helm (push) Successful in 26s
CI / push-validation (push) Successful in 25s
CI / build (push) Successful in 37s
CI / integration_tests (push) Successful in 3m46s
CI / unit_tests (push) Successful in 4m31s
CI / e2e_tests (push) Successful in 3m47s
CI / docker (push) Successful in 1m32s
CI / coverage (push) Successful in 11m25s
CI / status-check (push) Successful in 5s
CI / benchmark-publish (pull_request) Has been skipped
CI / coverage (pull_request) Successful in 11m39s
CI / build (pull_request) Successful in 1m17s
CI / unit_tests (pull_request) Successful in 6m34s
CI / e2e_tests (pull_request) Successful in 4m47s
CI / status-check (pull_request) Waiting to run
CI / push-validation (pull_request) Successful in 29s
CI / typecheck (pull_request) Successful in 1m55s
CI / quality (pull_request) Successful in 1m56s
CI / integration_tests (pull_request) Successful in 5m36s
CI / helm (pull_request) Successful in 34s
CI / lint (pull_request) Successful in 1m29s
CI / security (pull_request) Successful in 1m56s
CI / docker (pull_request) Successful in 1m35s
The root cause was a race condition in parallel Behave workers caused by
mutating a module-level singleton (_service) in
cleveragents.cli.commands.session. Concurrent cleanup in one worker could
reset _service to None while another worker was still using it, leading to
intermittent tell command test failures and exit code 1.

The fix patches the _get_session_service function directly in the affected
test steps (session_cli_coverage_boost_steps.py and
session_cli_uncovered_branches_steps.py) to avoid mutating the module-level
_service, and adds a reset call in features/environment.py's after_scenario
to ensure the singleton is cleared between scenarios, preventing stale
service instances from leaking across tests.

Closes #9121
2026-04-28 06:30:26 +00:00