arbiter-test-0.1.0.0
arbiter-test
Safe HaskellNone
LanguageGHC2024

Arbiter.Test.Setup

Description

Schema setup, teardown, and connection helpers for the arbiter test suites.

Synopsis

Documentation

cleanupData :: Text -> Text -> Connection -> IO ()Source #

Truncate the queue's tables and the schema-wide tables, except rate-limit policies.

cleanupOnce :: ByteString -> Text -> Text -> IO ()Source #

cleanupData on a fresh connection.

withConn :: ByteString -> (Connection -> IO a) -> IO aSource #

Run an action on a fresh connection that is closed afterwards.

terminateBackendsMatching :: ByteString -> Text -> IO ()Source #

Terminate every other backend on this database whose last query matches the LIKE pattern.

terminatePid :: ByteString -> Int32 -> IO ()Source #

Terminate one backend by pid.

listenerConnectionCount :: ByteString -> Text -> IO IntSource #

Count distinct backends whose last query is a LISTEN that names this schema.

execute_ :: Connection -> Text -> IO ()Source #

Run a statement with no parameters (test setup only).

toQuery :: Text -> QuerySource #

A postgresql-simple query from rendered SQL text.

execStatement :: MonadArbiter m => Text -> Params -> m Int64Source #

Run a pre-rendered statement with ? placeholders and positional parameters (test setup only).

execQuery :: MonadArbiter m => Text -> Params -> RowCodec a -> m [a]Source #

Run a pre-rendered query with ? placeholders, positional parameters and a decoder (test setup only).

setupOnce :: ByteString -> Text -> Text -> Bool -> IO ()Source #

Arguments

:: ByteString 
-> Text 
-> Text 
-> Bool

Install the job-arrival notify trigger

-> IO () 

Connect and rebuild the schema once, for a suite's outer bracket. It drops the schema with CASCADE and creates it again.

addQueueTable :: ByteString -> Text -> Text -> Bool -> IO ()Source #

Arguments

:: ByteString 
-> Text 
-> Text 
-> Bool

Install the job-arrival notify trigger

-> IO () 

Add one more job-queue table to an existing schema.

createSharedPool :: ByteString -> IO (Pool Connection)Source #

A single-stripe pool of the default size for tests.

createPoolOf :: Int -> ByteString -> IO (Pool Connection)Source #

A single-stripe pool of the given size for tests.

createPoolWith :: Int -> IO conn -> (conn -> IO ()) -> IO (Pool conn)Source #

A single-stripe pool of the given size over any connect and release actions.

sharedPoolSize :: IntSource #

The default test pool size.

concurrencyPoolSize :: IntSource #

The pool size for suites that race many claimers.

stateMachinePoolSize :: IntSource #

The pool size for the state-machine suite.

truncateToMicros :: UTCTime -> UTCTimeSource #

Truncate to microsecond precision to match PostgreSQL timestamptz.

mkTime :: Integer -> Int -> Int -> Int -> Int -> Int -> UTCTimeSource #

A UTCTime from calendar and clock components.

seedConcurrencyPolicySQL :: Text -> Text -> Int32 -> [Text]Source #

Seed a concurrency policy's default limit and clear any override, as SQL statements.

drainWith :: IO [a] -> IO [a]Source #

Repeat a batch action until it returns empty, accumulating the results.

quietHubLog :: HubLogSource #

A hub logger that swallows warn and error output.