Documentation
¶
Overview ¶
Package integrationstack starts or stops the named Postgres and Alertmanager testcontainers used by integration tests. Host ports are assigned by the runtime (ephemeral); tests resolve them via PublishedTCPPort which queries podman/docker port. Redis is NOT part of the shared stack - each test suite creates its own ephemeral Redis via testdb.CreateTestRedis() to enable parallel test execution.
Index ¶
- Constants
- func EnsureContainersOnly(ctx context.Context) error
- func EnsureRunning(ctx context.Context) error
- func PublishedTCPPort(containerName, containerTCPPort string) (host string, port uint, found bool)
- func RunMigrations(ctx context.Context) error
- func RunMigrationsWithLock(ctx context.Context) error
- func Stop(_ context.Context) error
Constants ¶
const ( PostgresContainerName = "flightctl-integration-postgres" AlertmanagerContainerName = "flightctl-integration-alertmanager" )
Container names for integration stack services. Note: Redis is NOT part of the shared stack - each test suite creates its own ephemeral Redis.
Variables ¶
This section is empty.
Functions ¶
func EnsureContainersOnly ¶
EnsureContainersOnly starts containers without running migrations. Use this when you need to run migrations separately (e.g., from Makefile).
func EnsureRunning ¶
EnsureRunning starts Postgres and Alertmanager with reuse if they are not already running, then runs database migrations using the flightctl-db-migrate binary (same code path as production). If both containers are running and Postgres credentials match FLIGHTCTL_* env, skips container start. Migrations are run with a file lock to prevent parallel test suites from deadlocking on CREATE INDEX. If credentials differ from running containers, removes them so init SQL applies. Note: Redis is NOT started here - each test suite creates its own ephemeral Redis via testdb.CreateTestRedis().
func PublishedTCPPort ¶
PublishedTCPPort resolves the host-published TCP port for a named container.
func RunMigrations ¶
RunMigrations sets up database users and runs migrations against the integration Postgres container. This matches the exact production flow used by Helm and Quadlet deployments: 1. Run setup_database_users.sql to create both migrator and app users with privileges 2. Run flightctl-db-migrate to apply schema migrations The process is idempotent - users are created only if they don't exist, and migrations use the schema_migrations table to skip already-applied migrations. No host dependencies required - psql runs inside the Postgres container via podman exec.
func RunMigrationsWithLock ¶
RunMigrationsWithLock runs migrations with a file lock to prevent parallel test suites from deadlocking when they all try to run CREATE INDEX statements simultaneously. The lock file is stored in /tmp and is automatically released when the process exits. A sentinel file tracks which database instance has been migrated to avoid redundant runs.
Types ¶
This section is empty.