Documentation
¶
Index ¶
- Constants
- func AwaitUntil(duration time.Duration, resolution time.Duration, f func() error) error
- func ColoredPrintf(msg string)
- func Debug(i interface{})
- func FindOpenTcpPort() (string, error)
- func IsEmpty(m *sync.Map) bool
- func PrintLogs(container *Container)
- func PrintMap(m *sync.Map) string
- func ReadEnvFile(path string) (map[string]string, error)
- func ReadFile(path string) ([]string, error)
- func RunProcessWithLogs(cmd *exec.Cmd, logHandler func(msg string)) error
- type AfterHandler
- type BeforeHandler
- type Compose
- type ComposeConfig
- type Container
- type ContainerStatus
- type ContainerStatusCode
- type Endpoints
- type Environment
- type EnvironmentConfig
- type ServiceConfig
- type ServiceEntry
- type ServiceHandler
Constants ¶
View Source
const ( ProjectID = "tests" DefaultLabel = "integration" DefaultNetwork = "tests" EnvHostOverride = "HOST_OVERRIDE" )
Variables ¶
This section is empty.
Functions ¶
func AwaitUntil ¶
func FindOpenTcpPort ¶
Types ¶
type AfterHandler ¶
type AfterHandler func()
type BeforeHandler ¶
type BeforeHandler func() error
type Compose ¶
type Compose struct {
// contains filtered or unexported fields
}
Compose an API to access docker-compose
func NewCompose ¶
func NewCompose(params ComposeConfig) (*Compose, error)
func (*Compose) Start ¶
func (c *Compose) Start(services ...*ServiceConfig) error
type ComposeConfig ¶
type ComposeConfig struct { // Env the global config for this composes' execution Env *EnvironmentConfig // Services maps service names to their config, for those managed by this composes' execution Services map[string]*ServiceConfig }
ComposeConfig config needed to get docker-compose and the testing framework going
type Container ¶
type Container struct { Config *types.Container ServiceConfig *ServiceConfig // contains filtered or unexported fields }
Container wrapped API for docker containers
func (*Container) GetEndpoints ¶
GetEndpoints returns the public host, and map of private ports to list of public ports.
func (*Container) GetStatus ¶
func (c *Container) GetStatus() *ContainerStatus
type ContainerStatus ¶
type ContainerStatus struct { Error error Code ContainerStatusCode }
type ContainerStatusCode ¶
type ContainerStatusCode uint8
const ( Error ContainerStatusCode = iota Running Exited Unhealthy NotReady )
type Environment ¶
type Environment struct { // Services maps service names to their data (output of their handlers). See ServiceHandler Services map[string]interface{} // contains filtered or unexported fields }
func StartEnvironment ¶
func StartEnvironment(config *EnvironmentConfig, entries ...*ServiceEntry) *Environment
func (*Environment) Shutdown ¶
func (e *Environment) Shutdown()
Shutdown MUST be used by tests' cleanup functions or there may be container leaks
func (*Environment) StartServices ¶
func (e *Environment) StartServices(entries ...*ServiceEntry) error
func (*Environment) StopServices ¶
func (e *Environment) StopServices(services ...string) error
type EnvironmentConfig ¶
type EnvironmentConfig struct { // UpTimeout timeout for docker-compose up UpTimeout time.Duration // DownTimeout timeout for docker-compose down DownTimeout time.Duration // ComposeFilePaths the path to the compose-YAML file(s) ComposeFilePaths []string // Optional custom container label name Label string // If true it will ignore any existing containers that are running due to a previous run NoCleanup bool // If true it will not shut down the containers after the test NoShutdown bool }
EnvironmentConfig global-level (i.e. for all containers) config for the testing framework
type ServiceConfig ¶
type ServiceConfig struct { // Name Service name (must correspond to the name found in the compose file) Name string // EnvironmentVars optional set of key-value pairs to pass to the service (note, these must be globally unique) EnvironmentVars map[string]string // Optional custom network name Network string }
ServiceConfig service/container-level config needed for docker-compose purposes
type ServiceEntry ¶
type ServiceEntry struct { //Name see ServiceConfig.Name Name string // DisableShutdownLogs set to true to disable printing logs for this container on shutdown (optional) DisableShutdownLogs bool // Handler Function to extract relevant data from the service's container for the test's needs (optional, but // usually needed by tests/consumers) Handler ServiceHandler // Before Function to run before container startup (optional) Before BeforeHandler // Before Function to run after container shutdown (optional) After AfterHandler // EnvironmentVars env variables for the service EnvironmentVars map[string]string // Network optional network name, otherwise defaults to the Network const Network string }
type ServiceHandler ¶
Click to show internal directories.
Click to hide internal directories.