mirror of https://github.com/docker/compose.git
chore(e2e): fix flaky cascade failure test
This was racy with the sleep, so the Compose file has been tweaked to make it pass reliably. Now, there's 3 services: * `running` - sleeps forever * `exit` - exits _successfully_ immediately * depends on `running` started * `fail` - exits _with error_ immediately * depends on `exit` succeeding Now, the test can ensure that the containers are all run/ started in the expected order the assertions will be reliable. Before, it was possible for `fail` to run & exit before `exit`, for example. The `running` service also ensures there's always at least one other "running" container when we do an abort. Signed-off-by: Milas Bowman <milas.bowman@docker.com>
This commit is contained in:
parent
299fcd57fd
commit
36bf0c458b
|
@ -36,6 +36,8 @@ func TestCascadeStop(t *testing.T) {
|
||||||
res := c.RunDockerComposeCmd(t, "-f", "./fixtures/cascade/compose.yaml", "--project-name", projectName,
|
res := c.RunDockerComposeCmd(t, "-f", "./fixtures/cascade/compose.yaml", "--project-name", projectName,
|
||||||
"up", "--abort-on-container-exit")
|
"up", "--abort-on-container-exit")
|
||||||
assert.Assert(t, strings.Contains(res.Combined(), "exit-1 exited with code 0"), res.Combined())
|
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) {
|
func TestCascadeFail(t *testing.T) {
|
||||||
|
@ -48,6 +50,7 @@ func TestCascadeFail(t *testing.T) {
|
||||||
res := c.RunDockerComposeCmdNoCheck(t, "-f", "./fixtures/cascade/compose.yaml", "--project-name", projectName,
|
res := c.RunDockerComposeCmdNoCheck(t, "-f", "./fixtures/cascade/compose.yaml", "--project-name", projectName,
|
||||||
"up", "--abort-on-container-failure")
|
"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(), "exit-1 exited with code 0"), res.Combined())
|
||||||
assert.Assert(t, strings.Contains(res.Combined(), "fail-1 exited with code 1"), res.Combined())
|
assert.Assert(t, strings.Contains(res.Combined(), "fail-1 exited with code 111"), res.Combined())
|
||||||
assert.Equal(t, res.ExitCode, 1)
|
// failing exit code should be propagated
|
||||||
|
assert.Equal(t, res.ExitCode, 111)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,19 @@
|
||||||
services:
|
services:
|
||||||
|
running:
|
||||||
|
image: alpine
|
||||||
|
command: sleep infinity
|
||||||
|
init: true
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
image: alpine
|
image: alpine
|
||||||
command: /bin/true
|
command: /bin/true
|
||||||
|
depends_on:
|
||||||
|
running:
|
||||||
|
condition: service_started
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
image: alpine
|
image: alpine
|
||||||
command: sh -c "sleep 0.1 && /bin/false"
|
command: sh -c "return 111"
|
||||||
|
depends_on:
|
||||||
|
exit:
|
||||||
|
condition: service_completed_successfully
|
||||||
|
|
Loading…
Reference in New Issue