kafkatesting

package module
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2020 License: MIT Imports: 13 Imported by: 0

README

kafka-testing-go

Library enabling easy testing of your applications interacting with kafka.

Uses testcontainers-go to start a docker container running zookeeper and a kafka broker and provides easy means to start, stop and interact with it.

Usage

ctx := context.Background()

kafkaURL, terminateKafka, err := kafkatesting.StartKafka(ctx)

if err != nil {
    // handle error
}

// use kafkaURL to access kafka
...

// stop containers after tests are done
terminateKafka(ctx)

Documentation

Index

Constants

View Source
const DefaultTimeout = 15 * time.Second
View Source
const DockerComposeFile = `` /* 1279-byte string literal not displayed */

Variables

This section is empty.

Functions

func GetFreePort

func GetFreePort(host string) (int, error)

inspired by https://github.com/phayes/freeport

func GetFreePortFallback

func GetFreePortFallback(host string) (int, error)

func GetOutboundIP

func GetOutboundIP() string

Get preferred outbound ip of this machine see https://stackoverflow.com/questions/23558425/how-do-i-get-the-local-ip-address-in-go

func StartKafka

func StartKafka(ctx context.Context) (kafkaUrl string, terminateFunction func(context.Context), err error)

func StartKafkaContainer

func StartKafkaContainer(ctx context.Context) (kafkaUrl string, terminateFunction func(context.Context), err error)

deprecated

func StartKafkaWithEnv

func StartKafkaWithEnv(ctx context.Context, env map[string]string) (kafkaUrl string, terminateFunction func(context.Context), err error)

Types

type Waiter

type Waiter struct {
	Timeout time.Duration
	Sleep   time.Duration
}

func NewDefaultWaiter

func NewDefaultWaiter() *Waiter

func (Waiter) WaitFor

func (w Waiter) WaitFor(check func() (interface{}, error)) (interface{}, error)

Jump to

Keyboard shortcuts

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