| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Arbiter.Test.StateMachine
Description
Parameterized stateful property-based tests for the core job engine, using
hedgehog. Works against any MonadArbiter backend via a passed runner and a
raw-connection accessor.
Generates random sequences of engine operations against the real database (insert at varying priority, scheduled insert, claim, ack, cancel, suspend, resume, promote, retry, extend-lease, move-to-DLQ, retry-from-DLQ, batch insertcancelDLQ, dedup insert, and the reaper) and checks the core invariants after every step:
- at most one in-flight job per group (the serialization guarantee)
- no job exceeds its
max_attempts - no duplicate live
dedup_key - no concurrency key has more claimed-in-flight jobs than its effective cap
- every group summary column matches its recompute from the main table
Generated inserts also carry rate-limit keys and concurrency slots.
A second property (prop_concurrent) generates N independent branches of
self-contained actions, runs them concurrently under a gap-free serialization
detector (a row trigger that fires inside every claim), then quiesces with a
reaper tick and asserts both the detector log and the full settled oracle are
clean. All contention is in the generated, shrinkable model.
Deterministic guards back the known-critical races.
Synopsis
- stateMachineSpec :: ArbiterC sm => (forall a. sm a -> IO a) -> Text -> Text -> (forall a. (Connection -> IO a) -> IO a) -> IO () -> Spec
- data SMPayload = SMPayload {}
- holViolTbl :: Text -> Text -> Text
- holInstallSql :: Text -> Text -> [Text]
- holRemoveSql :: Text -> Text -> [Text]
Documentation
Source #stateMachineSpec :: ArbiterC sm => (forall a. sm a -> IO a) -> Text -> Text -> (forall a. (Connection -> IO a) -> IO a) -> IO () -> Spec
Arguments
| :: ArbiterC sm | |
| => (forall a. sm a -> IO a) | Runner |
| -> Text | schemaName |
| -> Text | tableName |
| -> (forall a. (Connection -> IO a) -> IO a) | Raw-connection accessor |
| -> IO () | Reset (truncate) action |
| -> Spec |
Parameterized state-machine property suite. The runner executes a backend
action against the real database. withConn exposes a raw Connection for
the oracle and HOL-detector SQL. reset truncates the test tables.
A payload carrying optional concurrency and rate-limit keys.
Instances
Source #holViolTbl :: Text -> Text -> Text
Names of the head-of-line detector's table, function, and trigger.