Skip to content

Commit

Permalink
Merge pull request #11739 from milas/fix-e2e-cascade-flaky
Browse files Browse the repository at this point in the history
chore(e2e): fix flaky cascade failure test
  • Loading branch information
glours authored Apr 24, 2024
2 parents 299fcd5 + 36bf0c4 commit b53b8b2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
7 changes: 5 additions & 2 deletions pkg/e2e/cascade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ func TestCascadeStop(t *testing.T) {
res := c.RunDockerComposeCmd(t, "-f", "./fixtures/cascade/compose.yaml", "--project-name", projectName,
"up", "--abort-on-container-exit")
assert.Assert(t, strings.Contains(res.Combined(), "exit-1 exited with code 0"), res.Combined())
// no --exit-code-from, so this is not an error
assert.Equal(t, res.ExitCode, 0)
}

func TestCascadeFail(t *testing.T) {
Expand All @@ -48,6 +50,7 @@ func TestCascadeFail(t *testing.T) {
res := c.RunDockerComposeCmdNoCheck(t, "-f", "./fixtures/cascade/compose.yaml", "--project-name", projectName,
"up", "--abort-on-container-failure")
assert.Assert(t, strings.Contains(res.Combined(), "exit-1 exited with code 0"), res.Combined())
assert.Assert(t, strings.Contains(res.Combined(), "fail-1 exited with code 1"), res.Combined())
assert.Equal(t, res.ExitCode, 1)
assert.Assert(t, strings.Contains(res.Combined(), "fail-1 exited with code 111"), res.Combined())
// failing exit code should be propagated
assert.Equal(t, res.ExitCode, 111)
}
13 changes: 12 additions & 1 deletion pkg/e2e/fixtures/cascade/compose.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
services:
running:
image: alpine
command: sleep infinity
init: true

exit:
image: alpine
command: /bin/true
depends_on:
running:
condition: service_started

fail:
image: alpine
command: sh -c "sleep 0.1 && /bin/false"
command: sh -c "return 111"
depends_on:
exit:
condition: service_completed_successfully

0 comments on commit b53b8b2

Please sign in to comment.