mirror of
https://github.com/docker/compose.git
synced 2025-07-28 16:14:06 +02:00
Merge pull request #9794 from laurazard/fix-exitcode-stop-event
Correctly capture exit code when service has dependencies
This commit is contained in:
commit
1a7c1dfe7d
@ -93,11 +93,13 @@ func (p *printer) Run(ctx context.Context, cascadeStop bool, exitCodeFrom string
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if exitCodeFrom == "" {
|
if event.Type == api.ContainerEventExit {
|
||||||
exitCodeFrom = event.Service
|
if exitCodeFrom == "" {
|
||||||
}
|
exitCodeFrom = event.Service
|
||||||
if exitCodeFrom == event.Service {
|
}
|
||||||
exitCode = event.ExitCode
|
if exitCodeFrom == event.Service {
|
||||||
|
exitCode = event.ExitCode
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(containers) == 0 {
|
if len(containers) == 0 {
|
||||||
|
@ -22,6 +22,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
|
"gotest.tools/v3/icmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestUpWait(t *testing.T) {
|
func TestUpWait(t *testing.T) {
|
||||||
@ -45,3 +46,13 @@ func TestUpWait(t *testing.T) {
|
|||||||
|
|
||||||
c.RunDockerComposeCmd(t, "--project-name", projectName, "down")
|
c.RunDockerComposeCmd(t, "--project-name", projectName, "down")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestUpExitCodeFrom(t *testing.T) {
|
||||||
|
c := NewParallelCLI(t)
|
||||||
|
const projectName = "e2e-exit-code-from"
|
||||||
|
|
||||||
|
res := c.RunDockerComposeCmdNoCheck(t, "-f", "fixtures/start-fail/start-depends_on-long-lived.yaml", "--project-name", projectName, "up", "--exit-code-from=test")
|
||||||
|
res.Assert(t, icmd.Expected{ExitCode: 137})
|
||||||
|
|
||||||
|
c.RunDockerComposeCmd(t, "--project-name", projectName, "down", "--remove-orphans")
|
||||||
|
}
|
||||||
|
11
pkg/e2e/fixtures/start-fail/start-depends_on-long-lived.yaml
Normal file
11
pkg/e2e/fixtures/start-fail/start-depends_on-long-lived.yaml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
services:
|
||||||
|
safe:
|
||||||
|
image: 'alpine'
|
||||||
|
command: ['/bin/sh', '-c', 'sleep infinity'] # never exiting
|
||||||
|
failure:
|
||||||
|
image: 'alpine'
|
||||||
|
command: ['/bin/sh', '-c', 'sleep 2 ; echo "exiting" ; exit 42']
|
||||||
|
test:
|
||||||
|
image: 'alpine'
|
||||||
|
command: ['/bin/sh', '-c', 'sleep 99999 ; echo "tests are OK"'] # very long job
|
||||||
|
depends_on: [safe]
|
Loading…
x
Reference in New Issue
Block a user