Documentation ¶
Index ¶
- func ForSQL(port nat.Port, driver string, url func(nat.Port) string) *waitForSql
- type ExecStrategy
- func (ws ExecStrategy) WaitUntilReady(ctx context.Context, target StrategyTarget) error
- func (ws *ExecStrategy) WithExitCodeMatcher(exitCodeMatcher func(exitCode int) bool) *ExecStrategy
- func (ws *ExecStrategy) WithPollInterval(pollInterval time.Duration) *ExecStrategy
- func (ws *ExecStrategy) WithStartupTimeout(startupTimeout time.Duration) *ExecStrategy
- type ExitStrategy
- type HTTPStrategy
- func (ws *HTTPStrategy) WaitUntilReady(ctx context.Context, target StrategyTarget) (err error)
- func (ws *HTTPStrategy) WithAllowInsecure(allowInsecure bool) *HTTPStrategy
- func (ws *HTTPStrategy) WithBody(reqdata io.Reader) *HTTPStrategy
- func (ws *HTTPStrategy) WithMethod(method string) *HTTPStrategy
- func (ws *HTTPStrategy) WithPollInterval(pollInterval time.Duration) *HTTPStrategy
- func (ws *HTTPStrategy) WithPort(port nat.Port) *HTTPStrategy
- func (ws *HTTPStrategy) WithResponseMatcher(matcher func(body io.Reader) bool) *HTTPStrategy
- func (ws *HTTPStrategy) WithStartupTimeout(startupTimeout time.Duration) *HTTPStrategy
- func (ws *HTTPStrategy) WithStatusCodeMatcher(statusCodeMatcher func(status int) bool) *HTTPStrategy
- func (ws *HTTPStrategy) WithTLS(useTLS bool, tlsconf ...*tls.Config) *HTTPStrategy
- type HealthStrategy
- type HostPortStrategy
- type LogStrategy
- func (ws *LogStrategy) WaitUntilReady(ctx context.Context, target StrategyTarget) (err error)
- func (ws *LogStrategy) WithOccurrence(o int) *LogStrategy
- func (ws *LogStrategy) WithPollInterval(pollInterval time.Duration) *LogStrategy
- func (ws *LogStrategy) WithStartupTimeout(startupTimeout time.Duration) *LogStrategy
- type MultiStrategy
- type Strategy
- type StrategyTarget
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ExecStrategy ¶
type ExecStrategy struct { // additional properties ExitCodeMatcher func(exitCode int) bool PollInterval time.Duration // contains filtered or unexported fields }
Example ¶
ctx := context.Background() req := testcontainers.ContainerRequest{ Image: "localstack/localstack:latest", WaitingFor: wait.ForExec([]string{"awslocal", "dynamodb", "list-tables"}), } localstack, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{ ContainerRequest: req, Started: true, }) if err != nil { panic(err) } defer localstack.Terminate(ctx) // nolint: errcheck // Here you have a running container
Output:
func ForExec ¶
func ForExec(cmd []string) *ExecStrategy
ForExec is a convenience method to assign ExecStrategy
func NewExecStrategy ¶
func NewExecStrategy(cmd []string) *ExecStrategy
NewExecStrategy constructs an Exec strategy ...
func (ExecStrategy) WaitUntilReady ¶
func (ws ExecStrategy) WaitUntilReady(ctx context.Context, target StrategyTarget) error
func (*ExecStrategy) WithExitCodeMatcher ¶
func (ws *ExecStrategy) WithExitCodeMatcher(exitCodeMatcher func(exitCode int) bool) *ExecStrategy
func (*ExecStrategy) WithPollInterval ¶
func (ws *ExecStrategy) WithPollInterval(pollInterval time.Duration) *ExecStrategy
WithPollInterval can be used to override the default polling interval of 100 milliseconds
func (*ExecStrategy) WithStartupTimeout ¶
func (ws *ExecStrategy) WithStartupTimeout(startupTimeout time.Duration) *ExecStrategy
type ExitStrategy ¶
type ExitStrategy struct { // additional properties PollInterval time.Duration // contains filtered or unexported fields }
ExitStrategy will wait until container exit
func ForExit ¶
func ForExit() *ExitStrategy
ForExit is the default construction for the fluid interface.
For Example: wait.
ForExit(). WithPollInterval(1 * time.Second)
func NewExitStrategy ¶
func NewExitStrategy() *ExitStrategy
NewExitStrategy constructs with polling interval of 100 milliseconds without timeout by default
func (*ExitStrategy) WaitUntilReady ¶
func (ws *ExitStrategy) WaitUntilReady(ctx context.Context, target StrategyTarget) (err error)
WaitUntilReady implements Strategy.WaitUntilReady
func (*ExitStrategy) WithExitTimeout ¶
func (ws *ExitStrategy) WithExitTimeout(exitTimeout time.Duration) *ExitStrategy
WithExitTimeout can be used to change the default exit timeout
func (*ExitStrategy) WithPollInterval ¶
func (ws *ExitStrategy) WithPollInterval(pollInterval time.Duration) *ExitStrategy
WithPollInterval can be used to override the default polling interval of 100 milliseconds
type HTTPStrategy ¶
type HTTPStrategy struct { // additional properties Port nat.Port Path string StatusCodeMatcher func(status int) bool ResponseMatcher func(body io.Reader) bool UseTLS bool AllowInsecure bool TLSConfig *tls.Config // TLS config for HTTPS Method string // http method Body io.Reader // http request body PollInterval time.Duration // contains filtered or unexported fields }
Example ¶
https://github.com/testcontainers/testcontainers-go/issues/183
ctx := context.Background() req := testcontainers.ContainerRequest{ Image: "gogs/gogs:0.11.91", ExposedPorts: []string{"3000/tcp"}, WaitingFor: wait.ForHTTP("/").WithPort("3000/tcp"), } gogs, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{ ContainerRequest: req, Started: true, }) if err != nil { panic(err) } defer gogs.Terminate(ctx) // nolint: errcheck // Here you have a running container
Output:
func ForHTTP ¶
func ForHTTP(path string) *HTTPStrategy
ForHTTP is a convenience method similar to Wait.java https://github.com/testcontainers/testcontainers-java/blob/1d85a3834bd937f80aad3a4cec249c027f31aeb4/core/src/main/java/org/testcontainers/containers/wait/strategy/Wait.java
func NewHTTPStrategy ¶
func NewHTTPStrategy(path string) *HTTPStrategy
NewHTTPStrategy constructs a HTTP strategy waiting on port 80 and status code 200
func (*HTTPStrategy) WaitUntilReady ¶
func (ws *HTTPStrategy) WaitUntilReady(ctx context.Context, target StrategyTarget) (err error)
WaitUntilReady implements Strategy.WaitUntilReady
func (*HTTPStrategy) WithAllowInsecure ¶
func (ws *HTTPStrategy) WithAllowInsecure(allowInsecure bool) *HTTPStrategy
func (*HTTPStrategy) WithBody ¶
func (ws *HTTPStrategy) WithBody(reqdata io.Reader) *HTTPStrategy
func (*HTTPStrategy) WithMethod ¶
func (ws *HTTPStrategy) WithMethod(method string) *HTTPStrategy
func (*HTTPStrategy) WithPollInterval ¶
func (ws *HTTPStrategy) WithPollInterval(pollInterval time.Duration) *HTTPStrategy
WithPollInterval can be used to override the default polling interval of 100 milliseconds
func (*HTTPStrategy) WithPort ¶
func (ws *HTTPStrategy) WithPort(port nat.Port) *HTTPStrategy
func (*HTTPStrategy) WithResponseMatcher ¶
func (ws *HTTPStrategy) WithResponseMatcher(matcher func(body io.Reader) bool) *HTTPStrategy
func (*HTTPStrategy) WithStartupTimeout ¶
func (ws *HTTPStrategy) WithStartupTimeout(startupTimeout time.Duration) *HTTPStrategy
func (*HTTPStrategy) WithStatusCodeMatcher ¶
func (ws *HTTPStrategy) WithStatusCodeMatcher(statusCodeMatcher func(status int) bool) *HTTPStrategy
func (*HTTPStrategy) WithTLS ¶
func (ws *HTTPStrategy) WithTLS(useTLS bool, tlsconf ...*tls.Config) *HTTPStrategy
type HealthStrategy ¶
type HealthStrategy struct { // additional properties PollInterval time.Duration // contains filtered or unexported fields }
HealthStrategy will wait until the container becomes healthy
func ForHealthCheck ¶
func ForHealthCheck() *HealthStrategy
ForHealthCheck is the default construction for the fluid interface.
For Example: wait.
ForHealthCheck(). WithPollInterval(1 * time.Second)
func NewHealthStrategy ¶
func NewHealthStrategy() *HealthStrategy
NewHealthStrategy constructs with polling interval of 100 milliseconds and startup timeout of 60 seconds by default
func (*HealthStrategy) WaitUntilReady ¶
func (ws *HealthStrategy) WaitUntilReady(ctx context.Context, target StrategyTarget) (err error)
WaitUntilReady implements Strategy.WaitUntilReady
func (*HealthStrategy) WithPollInterval ¶
func (ws *HealthStrategy) WithPollInterval(pollInterval time.Duration) *HealthStrategy
WithPollInterval can be used to override the default polling interval of 100 milliseconds
func (*HealthStrategy) WithStartupTimeout ¶
func (ws *HealthStrategy) WithStartupTimeout(startupTimeout time.Duration) *HealthStrategy
WithStartupTimeout can be used to change the default startup timeout
type HostPortStrategy ¶
func ForListeningPort ¶
func ForListeningPort(port nat.Port) *HostPortStrategy
ForListeningPort is a helper similar to those in Wait.java https://github.com/testcontainers/testcontainers-java/blob/1d85a3834bd937f80aad3a4cec249c027f31aeb4/core/src/main/java/org/testcontainers/containers/wait/strategy/Wait.java
func NewHostPortStrategy ¶
func NewHostPortStrategy(port nat.Port) *HostPortStrategy
NewHostPortStrategy constructs a default host port strategy
func (*HostPortStrategy) WaitUntilReady ¶
func (hp *HostPortStrategy) WaitUntilReady(ctx context.Context, target StrategyTarget) (err error)
WaitUntilReady implements Strategy.WaitUntilReady
func (*HostPortStrategy) WithStartupTimeout ¶
func (hp *HostPortStrategy) WithStartupTimeout(startupTimeout time.Duration) *HostPortStrategy
type LogStrategy ¶
type LogStrategy struct { // additional properties Log string Occurrence int PollInterval time.Duration // contains filtered or unexported fields }
LogStrategy will wait until a given log entry shows up in the docker logs
func ForLog ¶
func ForLog(log string) *LogStrategy
ForLog is the default construction for the fluid interface.
For Example: wait.
ForLog("some text"). WithPollInterval(1 * time.Second)
func NewLogStrategy ¶
func NewLogStrategy(log string) *LogStrategy
NewLogStrategy constructs with polling interval of 100 milliseconds and startup timeout of 60 seconds by default
func (*LogStrategy) WaitUntilReady ¶
func (ws *LogStrategy) WaitUntilReady(ctx context.Context, target StrategyTarget) (err error)
WaitUntilReady implements Strategy.WaitUntilReady
func (*LogStrategy) WithOccurrence ¶
func (ws *LogStrategy) WithOccurrence(o int) *LogStrategy
func (*LogStrategy) WithPollInterval ¶
func (ws *LogStrategy) WithPollInterval(pollInterval time.Duration) *LogStrategy
WithPollInterval can be used to override the default polling interval of 100 milliseconds
func (*LogStrategy) WithStartupTimeout ¶
func (ws *LogStrategy) WithStartupTimeout(startupTimeout time.Duration) *LogStrategy
WithStartupTimeout can be used to change the default startup timeout
type MultiStrategy ¶
type MultiStrategy struct { // additional properties Strategies []Strategy // contains filtered or unexported fields }
func ForAll ¶
func ForAll(strategies ...Strategy) *MultiStrategy
func (*MultiStrategy) WaitUntilReady ¶
func (ms *MultiStrategy) WaitUntilReady(ctx context.Context, target StrategyTarget) (err error)
func (*MultiStrategy) WithStartupTimeout ¶
func (ms *MultiStrategy) WithStartupTimeout(startupTimeout time.Duration) *MultiStrategy