Scenario-based concurrency harness for OTP processes.
This module coordinates multi-threaded test scenarios against a target process (typically a GenServer) while keeping isolation, cleanup, chaos injection, performance validation, telemetry, and invariant checks in one place.
High level usage:
scenario =
Supertester.ConcurrentHarness.simple_genserver_scenario(
MyServer,
[:increment, :decrement],
5,
chaos: Supertester.ConcurrentHarness.chaos_inject_crash(),
performance_expectations: [max_time_ms: 100],
invariant: fn server, _ctx ->
assert {:ok, state} = Supertester.GenServerHelpers.get_server_state_safely(server)
assert state.count >= 0
end
)
assert {:ok, report} = Supertester.ConcurrentHarness.run(scenario)The returned report contains thread events, chaos + mailbox + performance diagnostics, and emits telemetry for start/stop/chaos/mailbox/perf events.
Summary
Functions
Chaos hook helper that injects a crash into the primary subject.
Chaos hook helper that kills supervisor children while the scenario runs.
Default invariant that simply returns :ok.
Converts a property helper configuration into a runnable scenario.
Runs a concurrent scenario and returns a diagnostic report.
Runs a scenario while enforcing additional performance bounds externally.
Builds a scenario for a GenServer module with repeated operation scripts.
Types
@type scenario() :: Supertester.ConcurrentHarness.Scenario.t() | map() | keyword()
@type thread_script() :: [operation()]
Functions
@spec chaos_inject_crash( Supertester.ChaosHelpers.crash_spec(), keyword() ) :: chaos_fun()
Chaos hook helper that injects a crash into the primary subject.
Chaos hook helper that kills supervisor children while the scenario runs.
Default invariant that simply returns :ok.
@spec from_property_config(module(), map(), keyword()) :: Supertester.ConcurrentHarness.Scenario.t()
Converts a property helper configuration into a runnable scenario.
Runs a concurrent scenario and returns a diagnostic report.
Runs a scenario while enforcing additional performance bounds externally.
@spec simple_genserver_scenario( module(), [term() | operation()], pos_integer(), keyword() ) :: Supertester.ConcurrentHarness.Scenario.t()
Builds a scenario for a GenServer module with repeated operation scripts.
Options
:server_opts- options passed tostart_link/1:default_operation-:callor:castfor bare terms (default::call):call_timeout_ms- timeout forGenServer.call/3(default: 1_000):timeout_ms- overall scenario timeout (default: 5_000):invariant- function offn pid, ctx -> term end:cleanup- custom cleanup callback:metadata- map merged into report metadata:mailbox- keyword list passed to mailbox monitoring:chaos- function(pid, ctx) -> anyinjected while threads execute:performance_expectations- keyword list forwarded toassert_expectations/2