Skip to content

test(bruno): poll for eventual consistency instead of fixed sleeps - #30

Merged
emaarco merged 1 commit into
mainfrom
emaarco/bruno-poll-eventual-consistency
Aug 21, 2026
Merged

test(bruno): poll for eventual consistency instead of fixed sleeps#30
emaarco merged 1 commit into
mainfrom
emaarco/bruno-poll-eventual-consistency

Conversation

@emaarco

@emaarco emaarco commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Why

Every command endpoint returns 202 Accepted and its effect (process wait state → read-model write) lands some unbounded, environment-dependent time later. The Bruno suite bridged that with 18 fixed setTimeout sleeps, 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).

  • Shared helpers in bruno/collection.bru (collection-level script:pre-request, axios-based — the sandbox has no fetch): pollUntil / pollApp (app read model) / pollEngine (/engine-rest query).
  • Command steps gate on the read-model precondition that makes the command valid (contractId != null before sign-contract, status == "ORDERED" && orderId before report-handover/withdraw, the inbox listing the item before clarify-alternative).
  • Read/assert steps poll their own assertion against the app read model or the engine query.
  • Budgets are env-driven (pollTimeoutMs / pollIntervalMs in environments/local.bru).
  • 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.

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.bru remains; no fetch( in any .bru.

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.
@emaarco
emaarco enabled auto-merge (squash) August 21, 2026 07:08
@emaarco
emaarco merged commit 518bd7b into main Aug 21, 2026
5 checks passed
@emaarco
emaarco deleted the emaarco/bruno-poll-eventual-consistency branch August 21, 2026 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant