Skip to content

Commit

Permalink
Merge pull request #455 from funvit/fix/flaky-test
Browse files Browse the repository at this point in the history
fix: temp fix of flaky test
  • Loading branch information
mdelapenya committed Jun 13, 2022
2 parents 82b7734 + 25da222 commit 28706cb
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions logconsumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package testcontainers

import (
"context"
"errors"
"fmt"
"net/http"
"testing"
Expand Down Expand Up @@ -201,13 +202,29 @@ func TestContainerLogWithErrClosed(t *testing.T) {
},
})
if err != nil {
t.Fatal(err)
t.Fatal("create generic container:", err)
}
defer dind.Terminate(ctx)

remoteDocker, err := dind.Endpoint(ctx, "2375/tcp")
var remoteDocker string

ctxEndpoint, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()

// todo: remove this temporary fix (test is flaky).
for {
remoteDocker, err = dind.Endpoint(ctxEndpoint, "2375/tcp")
if err == nil {
break
}
if errors.Is(err, context.DeadlineExceeded) {
break
}
time.Sleep(100 * time.Microsecond)
t.Log("retrying get endpoint")
}
if err != nil {
t.Fatal(err)
t.Fatal("get endpoint:", err)
}

client, err := client.NewClientWithOpts(client.WithHost(remoteDocker))
Expand Down

0 comments on commit 28706cb

Please sign in to comment.