test(bruno): poll for eventual consistency instead of fixed sleeps - #30
Merged
Conversation
Replace the 18 fixed setTimeout sleeps in the Bruno e2e suite with predicate-based polling capped by an env-tunable timeout (ADR-0015). - Add shared pollUntil/pollApp/pollEngine helpers in bruno/collection.bru (collection-level pre-request, axios-based; the sandbox has no fetch). - Command steps gate on the read-model precondition that makes the command valid (contractId, status/orderId, inbox listing); read/assert steps poll their own assertion against the app read model or the engine-rest query. - Add pollTimeoutMs/pollIntervalMs to the local environment. - Pin the Bruno CLI to @usebruno/cli@4.0.0 in CI, AGENTS.md and the Conductor run command; sandbox capabilities can shift between majors. Suite verified green against a live stack: 39/39 requests, 67/67 assertions.
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.
Why
Every command endpoint returns
202 Acceptedand its effect (process wait state → read-model write) lands some unbounded, environment-dependent time later. The Bruno suite bridged that with 18 fixedsetTimeoutsleeps, which race the projection and flake under CI load while wasting minutes in the common case.What
Replace the sleeps with predicate-based polling capped by an env-tunable timeout (see new ADR-0015).
bruno/collection.bru(collection-levelscript:pre-request,axios-based — the sandbox has nofetch):pollUntil/pollApp(app read model) /pollEngine(/engine-restquery).contractId != nullbefore sign-contract,status == "ORDERED" && orderIdbefore report-handover/withdraw, the inbox listing the item before clarify-alternative).pollTimeoutMs/pollIntervalMsinenvironments/local.bru).@usebruno/cli@4.0.0in CI,AGENTS.md, and the Conductor run command — sandbox capabilities can shift between majors.Verification
Full suite green against a live stack: 39/39 requests, 7/7 tests, 67/67 assertions in ~3.2s (vs ~40s of sleeps).
Only the interval sleep inside
collection.bruremains; nofetch(in any.bru.