Repository navigation
make two timing-dependent bus-core tests deterministic - #365
Open
adenhertog wants to merge 3 commits into
Open
adenhertog wants to merge 3 commits into
adenhertog wants to merge 3 commits into
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… tests Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This branch has not been deployed
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
Make two timing-dependent bus-core tests deterministic so they stop failing on loaded CI runners.
Background
The dispatcher spec "when it is stopped after a send timed out" failed on CircleCI build 1359 (stop() took 28 ms, expected at least 30 ms).
workflow/started.spec.tssleeps 2 s per step inside a 5 sbeforeAlltimeout.Problem
stop()took after polling for the timeout warning every 5 ms, so less time was left on a busy runner.started.spec.tsslept a fixed 2 s after each message, which can exceed the test timeout in a loaded full run with coverage.Approach
The slow send now waits on a promise the test controls. The test asserts
stop()hasn't resolved while that send is pending, releases it, and assertsstop()then resolves.started.spec.tsuses anInMemoryQueueandawait queue.idle()instead ofsleep.The dispatcher's "started with a periodic task" test (failed on build 1371) and its "told a message was scheduled" test use Jest fake timers and a fixed jitter, asserting what ran at exact points in time instead of measuring real elapsed time.
"when sending is paused and there is nothing to probe" and "when probes keep failing" also use fake timers, so their pause gaps are exact (including the wake timer's 1 ms margin) instead of real-time upper bounds.
"stopped after a send timed out" now samples whether
stop()resolved right after the send finished, so it fails ifstop()waits the fullsendTimeoutMs.Tests only. The dispatcher spec passed 20 runs in a loop; unit suite, lint and format check pass.
This is original work under the clean-room policy, not ported, translated or copied from another messaging framework
No changeset needed (tests only, no user-facing change)
Docs: none needed (tests only)
🤖 Generated with Claude Code