diff --git a/local/e2e/compose/compose_test.go b/local/e2e/compose/compose_test.go index d1d58fd39..459e96c41 100644 --- a/local/e2e/compose/compose_test.go +++ b/local/e2e/compose/compose_test.go @@ -22,7 +22,6 @@ import ( "net/http" "os" "path/filepath" - "regexp" "runtime" "strings" "testing" @@ -192,15 +191,16 @@ func TestDownComposefileInParentFolder(t *testing.T) { func TestAttachRestart(t *testing.T) { c := NewParallelE2eCLI(t, binDir) - res := c.RunDockerOrExitError("compose", "--ansi=never", "--project-directory", "./fixtures/attach-restart", "up") + cmd := c.NewDockerCmd("compose", "--ansi=never", "--project-directory", "./fixtures/attach-restart", "up") + res := icmd.StartCmd(cmd) defer c.RunDockerOrExitError("compose", "-p", "attach-restart", "down") - output := res.Stdout() - exitRegex := regexp.MustCompile("another_1 exited with code 1") - assert.Equal(t, len(exitRegex.FindAllStringIndex(output, -1)), 3, res.Combined()) + c.WaitForCondition(func() (bool, string) { + debug := res.Combined() + return strings.Count(res.Stdout(), "another_1 exited with code 1") == 3, fmt.Sprintf("'another_1 exited with code 1' not found 3 times in : \n%s\n", debug) + }, 2*time.Minute, 2*time.Second) - execRegex := regexp.MustCompile(`another_1 \| world`) - assert.Equal(t, len(execRegex.FindAllStringIndex(output, -1)), 3, res.Combined()) + assert.Equal(t, strings.Count(res.Stdout(), "another_1 | world"), 3, res.Combined()) } func TestInitContainer(t *testing.T) { diff --git a/local/e2e/compose/fixtures/attach-restart/compose.yaml b/local/e2e/compose/fixtures/attach-restart/compose.yaml index d628e6930..eb364bda7 100644 --- a/local/e2e/compose/fixtures/attach-restart/compose.yaml +++ b/local/e2e/compose/fixtures/attach-restart/compose.yaml @@ -1,7 +1,7 @@ services: simple: image: alpine - command: sh -c "sleep 5" + command: sh -c "sleep infinity" another: image: alpine command: sh -c "sleep 0.1 && echo world && /bin/false"