Skip to content

PostgresTestClusterOptions

Namespace: Ankus.Testing

Assembly: Ankus.Testing.dll

Configures one isolated PostgreSQL test-cluster invocation.

public sealed class PostgresTestClusterOptions

Inheritance: object

public PostgresTestClusterOptions()

Gets or sets the base directory under which per-invocation PGDATA directories are created. The ankus test command uses its own invocation directory beneath –pgdata when supplied, or temporary storage otherwise, so it can clean up aborted hosts.

public string DataDirectoryBase { get; init; }

Value: string

Gets or sets the database created for extension tests.

public string DatabaseName { get; init; }

Value: string

Gets or sets the configured PostgreSQL installation used by the cluster.

public required PostgresInstallation Installation { get; init; }

Value: PostgresInstallation

Gets the directory where server logs remain available after cluster shutdown.

public string LogDirectory { get; init; }

Value: string

A server log stays for seven days after its last write. The first cluster a process starts in the directory removes older server logs and extension build logs that the test fixtures named; other files are left alone.

Gets the exact TCP port, from 1 through 65535, or null to reserve an automatic port. A requested port never changes silently when it is occupied.

public int? Port { get; init; }

Value: int?

Gets additional settings appended to postgresql.auto.conf after the harness defaults, allowing extension settings to override them.

public IReadOnlyList<string> PostgreSqlConfiguration { get; init; }

Value: IReadOnlyList<string>

The harness defaults include fsync = off, as PostgreSQL’s own test clusters use; supply fsync = on to test behavior that depends on it.

Gets environment variables added to every PostgreSQL process invocation.

public IReadOnlyDictionary<string, string?> ProcessEnvironment { get; init; }

Value: IReadOnlyDictionary<string, string>

Gets the Unix account that owns the cluster’s data and runs its server through sudo -u, or null to use the account running the tests.

public string? RunAs { get; init; }

Value: string

This corresponds to cargo pgrx test –runas; ankus test –runas selects it for every cluster in the run. The account creates the data and socket directories and runs initdb and pg_ctl, so it must be able to create directories in DataDirectoryBase and read the installation and extension files. The server log is read back through sudo into LogDirectory. Windows does not support another account.

Gets or sets the architecture-independent PostgreSQL data directory supplied to initdb -L.

public string? SharedDirectory { get; init; }

Value: string

Gets the independent timeout used for shutdown, even when a test’s cancellation token has been canceled.

public TimeSpan ShutdownTimeout { get; init; }

Value: TimeSpan

It bounds the server’s stop. Checking whether the server is still running has its own allowance.

Gets the maximum time allowed for initialization, server readiness and creation of the test database.

public TimeSpan StartupTimeout { get; init; }

Value: TimeSpan

The default is 180 seconds, the default timeout of PostgreSQL’s own TAP test framework (PG_TEST_TIMEOUT_DEFAULT), because these steps share one budget on hosts whose disks may be busy.

Gets whether the server runs under Valgrind’s Memcheck tool.

public bool UseValgrind { get; init; }

Value: bool

This corresponds to pgrx’s USE_VALGRIND and ankus test –valgrind. Valgrind must be on PATH, and Windows is not supported. Memory errors appear in the server log between VALGRINDERROR-BEGIN and VALGRINDERROR-END markers. Startup gets an extra minute beyond StartupTimeout.

Gets the bootstrap database superuser name, independent of the operating system account name. The default, postgres, matches the clusters ankus start creates, PostgreSQL’s installers and its official container image.

public string UserName { get; init; }

Value: string