Documentation
¶
Index ¶
Constants ¶
const ( // TestKafkaAlias is both the network alias and the container hostname. The // two must match: the broker advertises its own hostname on the internal // listener, so peers only resolve it if that hostname is DNS-resolvable on // the test network. TestKafkaAlias = "kafka" // TestKafkaInternalPort is the BROKER listener, reachable container-to-container. // The host-facing PLAINTEXT listener (9093) is owned by the module. TestKafkaInternalPort = "9092" // TestKafkaImage must be a KRaft-capable confluent-local image (>= 7.4.0). // The module's starter script sources /etc/confluent/docker/bash-config, so // apache/kafka images will not work here. TestKafkaImage = "confluentinc/confluent-local:7.5.0" )
const ( TestNetworkAlias = "checkout-app" TestDbName = "checkout" TestUsername = "checkout" TestDBPassword = "not-a-real-db-passwd" TestAuthPassword = "not-a-real-auth-passwd" TestHTTPPort = "8000/tcp" // matches cmd.DefaultServerPort TestPostgresPort = "5432/tcp" )
Variables ¶
This section is empty.
Functions ¶
func CreateNetwork ¶
func CreateNetwork(t *testing.T, ctx context.Context) *testcontainers.DockerNetwork
Create a Docker network for the integration test
func MakeRandomizedTestItem ¶
Types ¶
type KafkaContainer ¶
type KafkaContainer struct {
// contains filtered or unexported fields
}
func StartKafka ¶
func StartKafka(t *testing.T, ctx context.Context, netName string, withLogger bool, ) *KafkaContainer
StartKafka runs a single-node KRaft broker attached to netName.
func (*KafkaContainer) Broker ¶
func (k *KafkaContainer) Broker() string
Broker returns the first host-reachable bootstrap address.
func (*KafkaContainer) Brokers ¶
func (k *KafkaContainer) Brokers() []string
Brokers returns host-reachable bootstrap addresses, for clients constructed inside the test process.
func (*KafkaContainer) CreateTopics ¶
func (k *KafkaContainer) CreateTopics(t *testing.T, ctx context.Context, partitions int32, topics ...string)
CreateTopics provisions topics up front so tests do not race broker-side auto creation. Producing to a missing topic fails with UNKNOWN_TOPIC_OR_PARTITION unless the client opts in via kgo.AllowAutoTopicCreation, and even then the first attempt races the metadata refresh. Already-existing topics are ignored.
Prefer partitions > 1. A single-partition topic orders every record globally, which makes a test pass regardless of whether the producer sets a partition key — exactly the bug such a test should be catching.
func (*KafkaContainer) InternalBroker ¶
func (k *KafkaContainer) InternalBroker() string
InternalBroker returns the in-network bootstrap address, for clients running in sibling containers on the same network.
type PGContainer ¶
type PGContainer struct {
// contains filtered or unexported fields
}
func StartPostgres ¶
type Stack ¶
type Stack struct {
// contains filtered or unexported fields
}
func (*Stack) NotifierURL ¶
NotifierURL returns the notifier's base URL. Only valid when the stack was built with EnableEvents.