testcontainers

package
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetupElasticsearchContainer

func SetupElasticsearchContainer(ctx context.Context, url *string) (cleanup, error)

func SetupKafkaContainer

func SetupKafkaContainer(ctx context.Context, brokers *[]string) (cleanup, error)

func SetupKafkaSASLContainer added in v1.5.0

func SetupKafkaSASLContainer(ctx context.Context, brokers *[]string, user SASLUser) (cleanup, error)

SetupKafkaSASLContainer starts a Kafka broker that requires SASL authentication on the listener the tests connect to, and accepts the given user over PLAIN, SCRAM-SHA-256 and SCRAM-SHA-512. One broker therefore covers every mechanism, and a test selects one by configuring the client.

The module names the external listener PLAINTEXT and writes that name into the advertised listeners, so the name stays while the security protocol behind it becomes SASL_PLAINTEXT. The inter broker and controller listeners stay unauthenticated: the broker only has to authenticate the clients under test.

func SetupOpenSearchContainer

func SetupOpenSearchContainer(ctx context.Context, url *string) (cleanup, error)

func SetupPostgresContainer

func SetupPostgresContainer(ctx context.Context, url *string, image PostgresImage, configFile ...string) (cleanup, error)

func SetupPostgresPrimaryReplica added in v1.3.0

func SetupPostgresPrimaryReplica(ctx context.Context, primaryURL, replicaURL *string) (cleanup, error)

SetupPostgresPrimaryReplica starts a Postgres primary together with a physical streaming replica of it, on a shared docker network, and writes their connection strings to primaryURL and replicaURL.

Both run Postgres 17 with wal2json, built from testdata/pg-wal2json. That combination is required and not otherwise available in this repo: logical decoding on a standby needs Postgres 16+, while the debezium/postgres images used by the rest of the suite only ship wal2json up to their 14 tag.

The returned cleanup tears down both containers and the network.

Types

type PostgresImage

type PostgresImage string
const (
	Postgres14         PostgresImage = "debezium/postgres:14-alpine"
	Postgres17         PostgresImage = "debezium/postgres:17-alpine"
	PgvectorPostgres17 PostgresImage = "pgvector/pgvector:pg17"
)

type SASLUser added in v1.5.0

type SASLUser struct {
	Username string
	Password string
}

SASLUser is the set of credentials the SASL enabled broker accepts.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL