Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,10 +604,10 @@ func TestContainerCreationWaitsForLogAndPortContextTimeout(t *testing.T) {
"MYSQL_ROOT_PASSWORD": "password",
"MYSQL_DATABASE": "database",
}),
WithWaitStrategy(wait.ForAll(
WithWaitStrategy(
wait.ForLog("I love testcontainers-go"),
wait.ForListeningPort("3306/tcp"),
)),
),
)
CleanupContainer(t, c)
require.Errorf(t, err, "Expected timeout")
Expand Down Expand Up @@ -646,9 +646,9 @@ func TestCMD(t *testing.T) {

c, err := Run(ctx, alpineImage,
WithCmd("echo", "command override!"),
WithWaitStrategy(wait.ForAll(
WithWaitStrategy(
wait.ForLog("command override!"),
)),
),
)
CleanupContainer(t, c)
require.NoError(t, err)
Expand All @@ -665,9 +665,9 @@ func TestEntrypoint(t *testing.T) {

c, err := Run(ctx, alpineImage,
WithEntrypoint("echo", "entrypoint override!"),
WithWaitStrategy(wait.ForAll(
WithWaitStrategy(
wait.ForLog("entrypoint override!"),
)),
),
)
CleanupContainer(t, c)
require.NoError(t, err)
Expand All @@ -684,9 +684,9 @@ func TestWorkingDir(t *testing.T) {

c, err := Run(ctx, alpineImage,
WithEntrypoint("pwd"),
WithWaitStrategy(wait.ForAll(
WithWaitStrategy(
wait.ForLog("/var/tmp/test"),
)),
),
WithConfigModifier(func(c *container.Config) {
c.WorkingDir = "/var/tmp/test"
}),
Expand Down Expand Up @@ -1431,13 +1431,13 @@ func TestContainerRunningCheckingStatusCode(t *testing.T) {
influx, err := Run(ctx, "influxdb:1.8.10-alpine",
WithExposedPorts("8086/tcp"),
WithImagePlatform("linux/amd64"), // influxdb doesn't provide an alpine+arm build (https://github.com/influxdata/influxdata-docker/issues/335)
WithWaitStrategy(wait.ForAll(
WithWaitStrategy(
wait.ForHTTP("/ping").WithPort("8086/tcp").WithStatusCodeMatcher(
func(status int) bool {
return status == http.StatusNoContent
},
),
)),
),
)
CleanupContainer(t, influx)
require.NoError(t, err)
Expand Down
4 changes: 2 additions & 2 deletions modules/aerospike/aerospike.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustom
testcontainers.WithEnv(map[string]string{
"AEROSPIKE_CONFIG_FILE": "/etc/aerospike/aerospike.conf",
}),
testcontainers.WithWaitStrategy(wait.ForAll(
testcontainers.WithWaitStrategy(
wait.ForLog("migrations: complete"),
wait.ForListeningPort(port).WithStartupTimeout(10*time.Second),
wait.ForListeningPort(fabricPort).WithStartupTimeout(10*time.Second),
wait.ForListeningPort(heartbeatPort).WithStartupTimeout(10*time.Second),
)),
),
}

moduleOpts = append(moduleOpts, opts...)
Expand Down
4 changes: 2 additions & 2 deletions modules/artemis/artemis.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustom
"ARTEMIS_USER": defaultUser,
"ARTEMIS_PASSWORD": defaultPassword,
}),
testcontainers.WithWaitStrategy(wait.ForAll(
testcontainers.WithWaitStrategy(
wait.ForListeningPort(defaultBrokerPort),
wait.ForListeningPort(defaultHTTPPort),
wait.ForLog("Server is now live"),
wait.ForLog("REST API available"),
)),
),
}

moduleOpts = append(moduleOpts, opts...)
Expand Down
2 changes: 1 addition & 1 deletion modules/azure/azurite/azurite.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustom
}

moduleOpts = append(moduleOpts, testcontainers.WithCmd(moduleCmd...))
moduleOpts = append(moduleOpts, testcontainers.WithWaitStrategy(wait.ForAll(waitingFor...)))
moduleOpts = append(moduleOpts, testcontainers.WithWaitStrategy(waitingFor...))
}

moduleOpts = append(moduleOpts, opts...)
Expand Down
4 changes: 2 additions & 2 deletions modules/azure/eventhubs/eventhubs.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustom
// Build moduleOpts with defaults
moduleOpts := []testcontainers.ContainerCustomizer{
testcontainers.WithExposedPorts(defaultAMPQPort, defaultHTTPPort),
testcontainers.WithWaitStrategy(wait.ForAll(
testcontainers.WithWaitStrategy(
wait.ForListeningPort(defaultAMPQPort),
wait.ForListeningPort(defaultHTTPPort),
wait.ForHTTP("/health").WithPort(defaultHTTPPort).WithStatusCodeMatcher(func(status int) bool {
return status == http.StatusOK
}),
)),
),
}

if defaultOptions.azuriteContainer == nil {
Expand Down
4 changes: 2 additions & 2 deletions modules/azure/servicebus/servicebus.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustom
testcontainers.WithEnv(map[string]string{
"SQL_WAIT_INTERVAL": "0", // default is zero because the MSSQL container is started first
}),
testcontainers.WithWaitStrategy(wait.ForAll(
testcontainers.WithWaitStrategy(
wait.ForListeningPort(defaultPort),
wait.ForListeningPort(defaultHTTPPort),
wait.ForHTTP("/health").WithPort(defaultHTTPPort).WithStatusCodeMatcher(func(status int) bool {
return status == http.StatusOK
}),
)),
),
}

if defaultOptions.mssqlContainer == nil {
Expand Down
4 changes: 2 additions & 2 deletions modules/cassandra/cassandra.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustom
"CASSANDRA_ENDPOINT_SNITCH": "GossipingPropertyFileSnitch",
"CASSANDRA_DC": "datacenter1",
}),
testcontainers.WithWaitStrategy(wait.ForAll(
testcontainers.WithWaitStrategy(
wait.ForListeningPort(port),
wait.ForExec([]string{"cqlsh", "-e", "SELECT bootstrapped FROM system.local"}).WithResponseMatcher(func(body io.Reader) bool {
data, _ := io.ReadAll(body)
return strings.Contains(string(data), "COMPLETED")
}),
)),
),
}

moduleOpts = append(moduleOpts, opts...)
Expand Down
4 changes: 2 additions & 2 deletions modules/chroma/chroma.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomize
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*ChromaContainer, error) {
moduleOpts := []testcontainers.ContainerCustomizer{
testcontainers.WithExposedPorts("8000/tcp"),
testcontainers.WithWaitStrategy(wait.ForAll(
testcontainers.WithWaitStrategy(
wait.ForListeningPort("8000/tcp"),
wait.ForLog("Application startup complete"),
wait.ForHTTP("/api/v1/heartbeat").WithStatusCodeMatcher(func(status int) bool {
return status == 200
}),
)),
),
}

moduleOpts = append(moduleOpts, opts...)
Expand Down
4 changes: 2 additions & 2 deletions modules/cockroachdb/cockroachdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustom
ContainerFilePath: clusterDefaultsContainerFile,
FileMode: 0o644,
}),
testcontainers.WithWaitStrategy(wait.ForAll(
testcontainers.WithWaitStrategy(
wait.ForFile(cockroachDir+"/init_success"),
wait.ForHTTP("/health").WithPort(defaultAdminPort),
wait.ForTLSCert(
Expand All @@ -205,7 +205,7 @@ func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustom
}
return connStr
}),
)),
),
}

moduleOpts = append(moduleOpts, opts...)
Expand Down
4 changes: 2 additions & 2 deletions modules/consul/consul.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomize
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*ConsulContainer, error) {
moduleOpts := []testcontainers.ContainerCustomizer{
testcontainers.WithExposedPorts(defaultHTTPAPIPort+"/tcp", defaultBrokerPort+"/tcp", defaultBrokerPort+"/udp"),
testcontainers.WithWaitStrategy(wait.ForAll(
testcontainers.WithWaitStrategy(
wait.ForLog("Consul agent running!"),
wait.ForListeningPort(defaultHTTPAPIPort+"/tcp"),
)),
),
}

moduleOpts = append(moduleOpts, opts...)
Expand Down
4 changes: 2 additions & 2 deletions modules/dockermcpgateway/dockermcpgateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustom
dockerHostMount + ":/var/run/docker.sock",
}
}),
testcontainers.WithWaitStrategy(wait.ForAll(
testcontainers.WithWaitStrategy(
wait.ForListeningPort(defaultPort),
wait.ForLog(".*Start sse server on port.*").AsRegexp(),
)),
),
}

if len(settings.secrets) > 0 {
Expand Down
4 changes: 2 additions & 2 deletions modules/gcloud/bigquery/bigquery.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ func (c *Container) URI() string {
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*Container, error) {
moduleOpts := []testcontainers.ContainerCustomizer{
testcontainers.WithExposedPorts(defaultPort9050, defaultPort9060),
testcontainers.WithWaitStrategy(wait.ForAll(
testcontainers.WithWaitStrategy(
wait.ForListeningPort(defaultPort9050),
wait.ForHTTP("/discovery/v1/apis/bigquery/v2/rest").WithPort(defaultPort9050).WithStatusCodeMatcher(func(status int) bool {
return status == 200
}).WithStartupTimeout(time.Second*5),
)),
),
}

settings := defaultOptions()
Expand Down
4 changes: 2 additions & 2 deletions modules/gcloud/bigtable.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ func RunBigTableContainer(ctx context.Context, opts ...testcontainers.ContainerC
func RunBigTable(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*GCloudContainer, error) {
moduleOpts := []testcontainers.ContainerCustomizer{
testcontainers.WithExposedPorts("9000/tcp"),
testcontainers.WithWaitStrategy(wait.ForAll(
testcontainers.WithWaitStrategy(
wait.ForListeningPort("9000/tcp"),
wait.ForLog("running")),
wait.ForLog("running"),
),
}

Expand Down
4 changes: 2 additions & 2 deletions modules/gcloud/bigtable/bigtable.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ func (c *Container) URI() string {
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*Container, error) {
moduleOpts := []testcontainers.ContainerCustomizer{
testcontainers.WithExposedPorts(defaultPort),
testcontainers.WithWaitStrategy(wait.ForAll(
testcontainers.WithWaitStrategy(
wait.ForListeningPort(defaultPort),
wait.ForLog("running"),
)),
),
}

settings := defaultOptions()
Expand Down
4 changes: 2 additions & 2 deletions modules/gcloud/datastore/datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ func (c *Container) URI() string {
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*Container, error) {
moduleOpts := []testcontainers.ContainerCustomizer{
testcontainers.WithExposedPorts(defaultPort),
testcontainers.WithWaitStrategy(wait.ForAll(
testcontainers.WithWaitStrategy(
wait.ForListeningPort(defaultPort),
wait.ForHTTP("/").WithPort(defaultPort),
)),
),
}

settings := defaultOptions()
Expand Down
4 changes: 2 additions & 2 deletions modules/gcloud/firestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ func RunFirestoreContainer(ctx context.Context, opts ...testcontainers.Container
func RunFirestore(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*GCloudContainer, error) {
moduleOpts := []testcontainers.ContainerCustomizer{
testcontainers.WithExposedPorts("8080/tcp"),
testcontainers.WithWaitStrategy(wait.ForAll(
testcontainers.WithWaitStrategy(
wait.ForListeningPort("8080/tcp"),
wait.ForLog("running"),
)),
),
}

moduleOpts = append(moduleOpts, opts...)
Expand Down
4 changes: 2 additions & 2 deletions modules/gcloud/firestore/firestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustom
// Build moduleOpts with defaults
moduleOpts := []testcontainers.ContainerCustomizer{
testcontainers.WithExposedPorts(defaultPort),
testcontainers.WithWaitStrategy(wait.ForAll(
testcontainers.WithWaitStrategy(
wait.ForListeningPort(defaultPort),
wait.ForLog("running"),
)),
),
testcontainers.WithCmd(
"/bin/sh",
"-c",
Expand Down
4 changes: 2 additions & 2 deletions modules/gcloud/pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ func RunPubsubContainer(ctx context.Context, opts ...testcontainers.ContainerCus
func RunPubsub(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*GCloudContainer, error) {
moduleOpts := []testcontainers.ContainerCustomizer{
testcontainers.WithExposedPorts("8085/tcp"),
testcontainers.WithWaitStrategy(wait.ForAll(
testcontainers.WithWaitStrategy(
wait.ForListeningPort("8085/tcp"),
wait.ForLog("started"),
)),
),
}

moduleOpts = append(moduleOpts, opts...)
Expand Down
4 changes: 2 additions & 2 deletions modules/gcloud/pubsub/pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ func (c *Container) URI() string {
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*Container, error) {
moduleOpts := []testcontainers.ContainerCustomizer{
testcontainers.WithExposedPorts(defaultPort),
testcontainers.WithWaitStrategy(wait.ForAll(
testcontainers.WithWaitStrategy(
wait.ForListeningPort(defaultPort),
wait.ForLog("started"),
)),
),
}

settings := defaultOptions()
Expand Down
4 changes: 2 additions & 2 deletions modules/gcloud/spanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ func RunSpannerContainer(ctx context.Context, opts ...testcontainers.ContainerCu
func RunSpanner(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*GCloudContainer, error) {
moduleOpts := []testcontainers.ContainerCustomizer{
testcontainers.WithExposedPorts("9010/tcp"),
testcontainers.WithWaitStrategy(wait.ForAll(
testcontainers.WithWaitStrategy(
wait.ForListeningPort("9010/tcp"),
wait.ForLog("Cloud Spanner emulator running"),
)),
),
}

moduleOpts = append(moduleOpts, opts...)
Expand Down
4 changes: 2 additions & 2 deletions modules/gcloud/spanner/spanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ func (c *Container) URI() string {
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*Container, error) {
moduleOpts := []testcontainers.ContainerCustomizer{
testcontainers.WithExposedPorts(defaultPort),
testcontainers.WithWaitStrategy(wait.ForAll(
testcontainers.WithWaitStrategy(
wait.ForListeningPort(defaultPort),
wait.ForLog("Cloud Spanner emulator running"),
)),
),
}

settings := defaultOptions()
Expand Down
4 changes: 2 additions & 2 deletions modules/milvus/milvus.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustom
"DEPLOY_MODE": "STANDALONE",
}),
testcontainers.WithCmd("milvus", "run", "standalone"),
testcontainers.WithWaitStrategy(wait.ForAll(
testcontainers.WithWaitStrategy(
wait.ForHTTP("/healthz").
WithPort(httpPort).
WithStartupTimeout(time.Minute).
Expand All @@ -68,7 +68,7 @@ func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustom
WithStartupTimeout(time.Minute),
wait.ForListeningPort(grpcPort).
WithStartupTimeout(time.Minute),
)),
),
testcontainers.WithFiles(testcontainers.ContainerFile{
ContainerFilePath: embedEtcdContainerPath,
Reader: config,
Expand Down
4 changes: 2 additions & 2 deletions modules/mockserver/mockserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomize
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*MockServerContainer, error) {
moduleOpts := []testcontainers.ContainerCustomizer{
testcontainers.WithExposedPorts("1080/tcp"),
testcontainers.WithWaitStrategy(wait.ForAll(
testcontainers.WithWaitStrategy(
wait.ForLog("started on port: 1080"),
wait.ForListeningPort("1080/tcp").SkipInternalCheck(),
)),
),
}

moduleOpts = append(moduleOpts, opts...)
Expand Down
2 changes: 1 addition & 1 deletion modules/mongodb/atlaslocal/atlaslocal.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustom

moduleOpts := []testcontainers.ContainerCustomizer{ // Set the defaults
testcontainers.WithExposedPorts(defaultPort),
testcontainers.WithWaitStrategy(wait.ForAll(wait.ForListeningPort(defaultPort), wait.ForHealthCheck())),
testcontainers.WithWaitStrategy(wait.ForListeningPort(defaultPort), wait.ForHealthCheck()),
testcontainers.WithEnv(userOpts.env()),
testcontainers.WithFiles(userOpts.files...),
}
Expand Down
4 changes: 2 additions & 2 deletions modules/mssql/mssql.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustom
testcontainers.WithEnv(map[string]string{
"MSSQL_SA_PASSWORD": defaultPassword,
}),
testcontainers.WithWaitStrategy(wait.ForAll(
testcontainers.WithWaitStrategy(
wait.ForListeningPort(defaultPort).WithStartupTimeout(time.Minute),
wait.ForLog("Recovery is complete."),
)),
),
}

moduleOpts = append(moduleOpts, opts...)
Expand Down
Loading
Loading