Test the last-item race without relying on lucky timing
Two customers can both buy the last unit when the stock check and reservation are separate. Build a barrier-controlled concurrency case around a single remaining item.
- Focused work estimate
- 4h + prerequisites
- Priority in the scenario
- High
- Engineering practice
- Concurrency testing · Database invariants · Fault isolation · Payment safety
Estimated field mix
- Quality engineering60%
- Database engineering40%
Field percentages are editorial estimates of the ticket's engineering focus. They total 100%; they are not measured time, proficiency scores, or ownership evidence.
Review it, then add it to your workspace.
The board opens an editable draft; nothing is saved until you confirm it. Sign-in and workspace permissions apply, and Demo boards remain ephemeral.
Project context
A small commerce team has happy-path browser tests but still ships rounding and retry defects. Model a fictional shop using synthetic products, a local payment double, and explicit cart rules before adding regression coverage.
Setup prerequisites
- Create or provide a local checkout fixture application.
- Model products, tax rules, inventory, and a payment-provider double using synthetic data.
Preceding work
Complete these dependencies, or supply their agreed outputs before taking this ticket.
Acceptance criteria
- Two isolated customers reach the reservation boundary before either proceeds.
- Exactly one reservation succeeds and inventory never becomes negative.
- The losing checkout receives a recoverable stock message and creates no captured payment.
Implementation constraints
- Use an explicit local test barrier, not sleep-based synchronization.
- Assert final database and provider states after both requests settle.
Verification to include
- Repeat the controlled race with each customer released first.
- Run against a deliberately non-atomic fixture reservation and demonstrate that the invariant assertion fails.
Deliverables
- Deterministic inventory race harness and invariant report
Rollout and recovery
Keep the barrier available only in local test composition; add the regression before changing reservation code.
Value of the work
For the engineer: Practice risk-based test selection, stable browser automation, and diagnosis of intermittent failures.
For the team: Review whether a test suite catches business regressions and explains failures without creating noisy release gates.
Evidence boundaries
Outcome Evidence: Tests, patches, and runbooks are requested deliverables. They become Outcome Evidence only through a qualified Mission and immutable Evidence IDs.
Ownership Evidence: Independent adaptation must be observed under a declared verification policy and cite immutable Evidence IDs. Completing a planning ticket establishes no Ownership Evidence.