Repository navigation
Commit 459ab16
authored
fix(tests): WAL-pinning for all inline NullRunRuntime creations (#63)
* fix(tests): pin test_runtime WAL to tmp_path to avoid cross-Python flake
The test_runtime fixture in test_protect_branches.py built a
real NullRunRuntime(api_key, _test_mode=True) without going
through the mock_api conftest. The runtime's Transport.start()
calls _replay_from_wal() which reads /tmp/nullrun.wal (the
default NULLRUN_WAL_PATH fallback). If a previous test run in
a different Python version (3.10 or 3.12) had persisted a
non-empty WAL, the 3.11 worker would replay those events to a
real HTTP endpoint, get HTTP 401, and the fixture would fail
at setup with NullRunAuthError:
nullrun.breaker.exceptions.NullRunAuthError: Invalid API key
This bit CI on 2026-07-11 (run 29156199607): tests 3.10 + 3.12
passed, test 3.11 failed with that error in the fixture setup
of test_enforce_sensitive_tool_dict_with_fallback_fail_open.
The 3.10/3.12 runs cleared the global /tmp/nullrun.wal by
reading it first, so 3.11 picked up the next writer. Order-
dependent; flaky on the matrix.
Pin NULLRUN_WAL_PATH to a tmp_path-scoped file so each test
session reads its own fresh empty WAL. Resolves the flake
without touching SDK source (no production code change).
Verified locally:
- pytest tests/test_protect_branches.py -> 43/43 pass
- with pre-seeded stale /tmp/nullrun.wal, the previously
failing test now passes.
No public API change. No SDK_MIN_VERSION bump. Backends on
1.0.0 keep working unchanged. Recommended: 0.13.6 (no
version bump needed for a test-only fix).
* fix(tests): WAL-pinning for all inline NullRunRuntime creations
Follows up on commit 41a16f7 which pinned NULLRUN_WAL_PATH for
the test_runtime fixture only. Other tests in
test_protect_branches.py / test_runtime_branches.py /
test_toolbox_langgraph.py build NullRunRuntime inline (no
fixture) and were still picking up a stale WAL from a previous
test run, causing HTTP 401 `NullRunAuthError` in 3.12 (CI
run 29158094827, job `test (3.12)`).
This commit:
1. Adds a shared `make_test_runtime` factory fixture to
conftest.py that pins NULLRUN_WAL_PATH to tmp_path, stubs
_do_flush / _do_flush_locked / _client, and resets the
singleton around the factory.
2. Replaces 4 inline `NullRunRuntime(api_key=..., _test_mode=True)`
calls in test_protect_branches.py with `make_test_runtime()`,
including:
- test_protect_async_kill_re_raises_WorkflowKilledInterrupt
- test_get_protected_runtime_falls_back_to_get_runtime
3. Patches the local _make_test_runtime / _make_runtime_with_mocked_auth
helpers in test_runtime_branches.py to set NULLRUN_WAL_PATH
per-call (via tempfile.mkdtemp) before constructing the
runtime.
4. Extends the autouse _test_runtime fixture in
test_toolbox_langgraph.py to take tmp_path and pin
NULLRUN_WAL_PATH, matching conftest::make_test_runtime.
Verified locally on 3.11:
- pytest tests/ -n auto:
1219 passed, 1 failed, 7 skipped
(1 failure: test_actions.py::TestPauseAction
::test_is_paused_respects_cooldown — pre-existing flake
on master, NOT introduced by this commit; verified by
git stash + repro on bare master)
- ruff check src/: all checks passed
- mypy src/: success, no issues in 34 source files
Public API unchanged. No SDK_MIN_VERSION bump. Backends on
1.0.0 keep working unchanged. Recommended: 0.13.6 (no version
bump needed).1 parent 6563f73 commit 459ab16
4 files changed
Lines changed: 90 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
41 | 49 | | |
42 | 50 | | |
| 51 | + | |
43 | 52 | | |
44 | 53 | | |
45 | 54 | | |
| |||
437 | 446 | | |
438 | 447 | | |
439 | 448 | | |
440 | | - | |
| 449 | + | |
441 | 450 | | |
442 | 451 | | |
443 | 452 | | |
444 | 453 | | |
445 | 454 | | |
446 | | - | |
| 455 | + | |
447 | 456 | | |
448 | 457 | | |
449 | 458 | | |
| |||
542 | 551 | | |
543 | 552 | | |
544 | 553 | | |
545 | | - | |
| 554 | + | |
546 | 555 | | |
547 | 556 | | |
548 | 557 | | |
549 | 558 | | |
550 | | - | |
| 559 | + | |
551 | 560 | | |
552 | 561 | | |
553 | 562 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
33 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
34 | 48 | | |
35 | 49 | | |
36 | 50 | | |
| |||
357 | 371 | | |
358 | 372 | | |
359 | 373 | | |
360 | | - | |
| 374 | + | |
361 | 375 | | |
| 376 | + | |
362 | 377 | | |
363 | 378 | | |
364 | 379 | | |
| |||
372 | 387 | | |
373 | 388 | | |
374 | 389 | | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
375 | 394 | | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
376 | 400 | | |
377 | 401 | | |
378 | 402 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
21 | 28 | | |
| 29 | + | |
22 | 30 | | |
23 | 31 | | |
24 | 32 | | |
| |||
0 commit comments