barrier-concurrency-testing
Barrier Concurrency Testing
Deterministic race condition testing -- no flaky timing-based tests.
Instead of setTimeout (flaky) or sleep (slow), use barriers to pause execution at exact interleave points. The test controls when each concurrent operation proceeds, making race condition tests deterministic and reproducible on every run.
When to use: Testing concurrent operations, flush conflicts, parallel mutations, race windows between read and write, lock contention scenarios, any code where timing affects correctness.
When not to use: Sequential-only code, simple unit tests, UI components, read-only operations, code with no concurrency concerns.
Rationalizations (Do Not Skip)
| Rationalization | Why It's Wrong | Required Action |
|---|---|---|
| "setTimeout is good enough" | Timing-based tests are inherently flaky -- they pass 99 times, fail on CI | Use barriers for deterministic control |
| "It passed 10 times, it's fine" | Heisenbugs hide in timing windows that haven't been hit yet | Barrier at every interleave point |
| "We don't have race conditions" | Any concurrent code has race windows | Write a barrier test to prove it |
| "Barriers are too complex" | 15 lines of setup prevents hours of debugging flaky failures | Copy the pattern from references |
More from apankov1/quality-engineering
pairwise-test-coverage
Combinatorial testing with a greedy pairwise matrix generator. Covers all factor pairs in near-minimal test cases.
18breaking-change-detector
Audit 6 categories of breaking changes with executable checks for contracts, API diffs, serialized state, and event types.
17websocket-client-resilience
Client-side WebSocket resilience patterns: backoff with jitter, circuit breakers, heartbeat hysteresis, command acknowledgment, sequence gap detection, and mobile-aware timeouts.
17fault-injection-testing
Use when testing what happens when things fail — storage errors, network timeouts, API 500s, service outages. Provides circuit breaker state machine, retry policies with exponential backoff, fault injection, and queue preservation assertions. Trigger on: 'circuit breaker test', 'retry logic', 'exponential backoff', 'what happens if the API fails', 'simulate network failure', 'fault injection', 'resilience test', 'queue preservation after crash', 'graceful degradation'. Skip for: happy-path unit tests, UI testing, or code review.
15zod-contract-testing
Validates Zod schema parsing at boundaries. Tests valid/invalid inputs, schema evolution, refinement coverage, and compound state matrices (2^N optional field combinations).
13model-based-testing
Tests state machine transitions with XState-style patterns. Validates transition matrices, guard truth tables, context mutations, and terminal state handling.
13