barrier-concurrency-testing

Deterministic race condition testing using barriers and deferred promises. Use when writing tests for concurrent operations, race conditions, parallel processing, or when existing timing-based tests are flaky. Trigger on: 'race condition test', 'concurrent writes', 'parallel test', 'flaky timing test', 'deterministic interleaving', 'barrier synchronization', 'sequence continuity', 'test items preserved during concurrent operations'. Replaces setTimeout-based timing with reproducible barrier control. Skip for: sequential logic, single-threaded tests, or API endpoint testing.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "barrier-concurrency-testing" with this command: npx skills add apankov1/quality-engineering/apankov1-quality-engineering-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)

RationalizationWhy It's WrongRequired Action
"setTimeout is good enough"Timing-based tests are inherently flaky -- they pass 99 times, fail on CIUse barriers for deterministic control
"It passed 10 times, it's fine"Heisenbugs hide in timing windows that haven't been hit yetBarrier at every interleave point
"We don't have race conditions"Any concurrent code has race windowsWrite a barrier test to prove it
"Barriers are too complex"15 lines of setup prevents hours of debugging flaky failuresCopy the pattern from references

What To Protect (Start Here)

Before generating barrier tests, identify which concurrency decisions apply to your code:

DecisionQuestion to AnswerIf Yes → Use
Concurrent writes must not lose dataCan two writes to the same resource happen simultaneously?assertPreservesConcurrentItems
Failed operations must not corrupt stateCan a failure leave behind partial or inconsistent state?assertPreservesOnFailure
Event/message ordering must be preservedDoes processing order affect correctness?assertSequenceContinuity
Retry state must reset on new inputCan stale retry counts or error flags affect new operations?assertRetryCountReset

Do not generate tests for decisions the human hasn't confirmed. A barrier test without a named invariant is coverage theater — it proves the barrier works, not that the system is correct.


Included Utilities

// Barrier infrastructure + invariant assertions + test data generators
import {
  createBarrier,
  createTrackedBarrier,
  releaseAllBarriers,
  assertPreservesConcurrentItems,
  assertPreservesOnFailure,
  assertSequenceContinuity,
  assertLastSequenceCorrect,
  assertRetryCountReset,
  createTestItems,
} from './test-fixtures.ts';

Violation Rules

inadequate_barrier_coverage

Race conditions MUST have barrier tests at each interleave point. If there are N interleave points in the code, there must be N barrier test cases. Severity: must-fail

flaky_timing_test

NEVER use setTimeout, sleep, or arbitrary delays for concurrency testing. Use barriers for deterministic control. Severity: must-fail


Companion Skills

This skill provides deterministic timing control for concurrency tests, not concurrency architecture guidance. For broader methodology:

  • Search concurrency on skills.sh for lock-free patterns, actor models, and thread safety analysis
  • Concurrent state machines need transition coverage — use model-based-testing for N*N transition matrices and guard truth tables
  • Concurrent failure recovery needs resilience testing — use fault-injection-testing for circuit breaker, retry policy, and queue preservation under concurrent load

Quick Reference

ScenarioPatternExample
Block before transactionbarrier.wait() in transaction startVerify concurrent writes preserved
Block during I/Odeferred.promise as mock returnVerify queue depth during processing
Multiple interleave pointsMultiple barriers, release in sequenceTest all orderings of concurrent ops
CleanupafterEach(() => releaseAllBarriers())Prevent test hangs

See patterns.md for full code examples, deferred promise alternative, and framework adaptation guide.

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

pairwise-test-coverage

No summary provided by upstream source.

Repository SourceNeeds Review
General

breaking-change-detector

No summary provided by upstream source.

Repository SourceNeeds Review
General

fault-injection-testing

No summary provided by upstream source.

Repository SourceNeeds Review