arbiter-test-0.1.0.0
arbiter-test
Safe HaskellNone
LanguageGHC2024

Arbiter.Test.Worker

Description

Worker conformance suites, instantiated for each backend. Build the schema with setupOnce with notify on. Empty it in mkEnv and mkFreshEnv with cleanupData or cleanupOnce.

Synopsis

Documentation

workerSpec :: forall payload (m :: Type -> Type) env. (Eq payload, QueueOperation m payload, RegistryAdmissionPolicies (RegistryOf m), RegistryTables (RegistryOf m), ResultOf m payload ~ Maybe [Text], Show payload) => TestBackend payload m env -> SpecSource #

Worker-pool suite. The queue under test declares Maybe [Text] as its result type.

listenerSpec :: forall payload (m :: Type -> Type) env. (QueueOperation m payload, RegistryAdmissionPolicies (RegistryOf m), RegistryTables (RegistryOf m), ResultOf m payload ~ ()) => TestBackend payload m env -> SpecSource #

Env-owned LISTEN hub suite. A poll-only test runs jobs with the listener removed. The queue under test declares () as its result type. The queue table needs notify triggers and mkEnv must give an env with a shared listener. It terminates other connections on the database whose LISTEN query names the schema.

multiQueueListenerSpec :: forall payloadA payloadB m env. (QueueOperation m payloadA, QueueOperation m payloadB, RegistryAdmissionPolicies (RegistryOf m), RegistryTables (RegistryOf m), ResultOf m payloadA ~ (), ResultOf m payloadB ~ ()) => TestBackend payloadA m env -> Text -> (Text -> payloadB) -> ((JobRead payloadB -> m ()) -> JobHandler m payloadB ()) -> SpecSource #

Arguments

:: forall payloadA payloadB m env. (QueueOperation m payloadA, QueueOperation m payloadB, RegistryAdmissionPolicies (RegistryOf m), RegistryTables (RegistryOf m), ResultOf m payloadA ~ (), ResultOf m payloadB ~ ()) 
=> TestBackend payloadA m env 
-> Text

Queue B table name, also its LISTEN channel prefix.

-> (Text -> payloadB)

Construct a queue B payload.

-> ((JobRead payloadB -> m ()) -> JobHandler m payloadB ())

Adapt a queue B job action into the backend's handler shape.

-> Spec 

Env-owned LISTEN hub suite for two queues sharing one env, one worker pool per queue. Checks that a shared hub wakes each pool for its own queue only. The backend's queue is queue A. Queue A gets its notify trigger from setupOnce with notify on. Queue B gets its notify trigger from addQueueTable with notify on. mkFreshEnv must give an env with a listener.

deadlineSpec :: forall payload (m :: Type -> Type) env. (Eq payload, QueueOperation m payload, RegistryAdmissionPolicies (RegistryOf m), RegistryTables (RegistryOf m), ResultOf m payload ~ ()) => TestBackend payload m env -> SpecSource #

Deadline suite. The queue under test declares () as its result type.

cronSpec :: forall payload (m :: Type -> Type) env. (Eq payload, QueueOperation m payload, Show payload) => TestBackend payload m env -> SpecSource #

Cron scheduler suite.

reclaimSpec :: forall payload (m :: Type -> Type) env. (Eq payload, QueueOperation m payload, RegistryAdmissionPolicies (RegistryOf m), RegistryTables (RegistryOf m), ResultOf m payload ~ ()) => TestBackend payload m env -> SpecSource #

Reclaim, heartbeat theft, and worker-loop exception safety suite. The queue under test declares () as its result type.

connectionRecoverySpec :: forall payload (m :: Type -> Type) env. (Eq payload, QueueOperation m payload, RegistryAdmissionPolicies (RegistryOf m), RegistryTables (RegistryOf m), ResultOf m payload ~ ()) => TestBackend payload m env -> SpecSource #

Connection recovery suite. The queue under test declares () as its result type. It terminates other connections on the database whose query names the schema.

lifecycleSpec :: forall payload (m :: Type -> Type) env. (Eq payload, QueueOperation m payload, RegistryAdmissionPolicies (RegistryOf m), RegistryTables (RegistryOf m), ResultOf m payload ~ Maybe [Text], Show payload) => TestBackend payload m env -> SpecSource #

Worker lifecycle suite. The queue under test declares Maybe [Text] as its result type.

data TestBackend payload (m :: Type -> Type) envSource #

A backend's payloads, envs, and runner for the generic worker suites.

Constructors

TestBackend 

Fields

plainHandler :: forall {k} job m (r :: k) conn. (job -> m r) -> conn -> job -> m rSource #

A backend handler that ignores the connection argument.

statementCommand :: MonadArbiter m => Text -> m ()Source #

Run a command through executeStatement and discard its row count.