Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Await ¶
Await returns the value a background writer sends on done, failing fast instead of hanging until the go test timeout when the writer is stuck.
func WaitForLockWait ¶
WaitForLockWait blocks until some backend is waiting on a lock in a statement matching queryLike (a SQL LIKE pattern; "" matches any), which proves the writer under test is queued behind the footprint.
Types ¶
type Footprint ¶
Footprint stands in for the editor command's lock footprint on one plan so the race tests of legacy writers run before the command exists: the plan row FOR UPDATE, then its executions ordered FOR UPDATE, then its accounts FOR SHARE. It does NOT take the command's first two lock levels, the identity advisory lock and the sorted provider advisory locks (LockPlanProvidersTx). The embedded Tx is the command's transaction: Exec applies the command's writes (SetManaged, inserted roots) and Commit/Rollback end it. Executions lists the rows the footprint locked, i.e. what the command captured: a writer that committed before the footprint must appear here.
Swap contract for the ExecutePlanScheduleCommand race tests: replace HoldCommandFootprint with the real command paused after its capture, wrapped as a *Footprint (Tx = the command's transaction, Executions = its captured set). Then (1) the notifier claim queues first on the provider advisory lock, so its WaitForLockWait pattern changes from "%FOR UPDATE%" to the advisory wait (wait_event 'advisory'; match the pg_advisory_xact_lock statement); (2) the direct Exec/QueryRow calls of the retry, prune and account-delete tests become the command's own writes and reads; every other assertion stays.
func HoldCommandFootprint ¶
HoldCommandFootprint opens the footprint on planID. The transaction rolls back at test end unless the test ended it first.
type LockDB ¶
type LockDB interface {
Begin(ctx context.Context) (pgx.Tx, error)
QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
}
LockDB is the slice of a pool the lock helpers need. The config store's dbConn and a *pgxpool.Pool both satisfy it.
type PostgresContainer ¶
type PostgresContainer struct {
Container testcontainers.Container
Config *database.Config
DB *database.Connection
}
PostgresContainer wraps a testcontainers PostgreSQL instance.
func RequirePostgresContainer ¶
func RequirePostgresContainer(ctx context.Context, t *testing.T) *PostgresContainer
RequirePostgresContainer starts a PostgreSQL test container for t, skipping the test only when this environment has no usable Docker provider and failing loudly for every other error.
Drawing that line is the whole point (issue #1597). "No usable Docker daemon" is an environment fact and the one legitimate reason to skip, so it is probed explicitly before anything is started. Past that probe the daemon answered a health check, which makes a container that still refuses to come up -- a missing image, a database that never accepts connections -- a real failure. Reporting it as a skip would turn a broken run green, which is indistinguishable from a run that had nothing to say.
The probe owns the whole environment side of that line, so a daemon that is present but unhealthy skips too, rather than failing.
Callers remain responsible for Cleanup, matching SetupPostgresContainer.
func SetupPostgresContainer ¶
SetupPostgresContainer creates and starts a PostgreSQL test container.
func (*PostgresContainer) Cleanup ¶
func (c *PostgresContainer) Cleanup(ctx context.Context) error
Cleanup terminates the test container and closes database connection.
func (*PostgresContainer) ResetDatabase ¶
func (c *PostgresContainer) ResetDatabase(ctx context.Context) error
ResetDatabase drops and recreates all tables (useful for clean state).
func (*PostgresContainer) TruncateTables ¶
func (c *PostgresContainer) TruncateTables(ctx context.Context, tables ...string) error
TruncateTables removes all data from tables (useful between tests).