mirror of
https://github.com/docker/compose.git
synced 2025-07-27 15:44:08 +02:00
e2e test
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
d9fe745cc0
commit
8b90814de6
@ -65,7 +65,7 @@ type CreateOptions struct {
|
|||||||
|
|
||||||
// StartOptions group options of the Start API
|
// StartOptions group options of the Start API
|
||||||
type StartOptions struct {
|
type StartOptions struct {
|
||||||
// Attach will attach to service containers and pipe stdout/stderr to channel
|
// Attach will attach to service containers and send container logs and events
|
||||||
Attach ContainerEventListener
|
Attach ContainerEventListener
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,6 +133,13 @@ func runCreateStart(ctx context.Context, opts upOptions, services []string) erro
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if opts.exitCodeFrom != "" {
|
||||||
|
_, err := project.GetService(opts.exitCodeFrom)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_, err = progress.Run(ctx, func(ctx context.Context) (string, error) {
|
_, err = progress.Run(ctx, func(ctx context.Context) (string, error) {
|
||||||
err := c.ComposeService().Create(ctx, project, compose.CreateOptions{
|
err := c.ComposeService().Create(ctx, project, compose.CreateOptions{
|
||||||
RemoveOrphans: opts.removeOrphans,
|
RemoveOrphans: opts.removeOrphans,
|
||||||
|
@ -30,20 +30,19 @@ func TestCascadeStop(t *testing.T) {
|
|||||||
const projectName = "compose-e2e-logs"
|
const projectName = "compose-e2e-logs"
|
||||||
|
|
||||||
t.Run("abort-on-container-exit", func(t *testing.T) {
|
t.Run("abort-on-container-exit", func(t *testing.T) {
|
||||||
res := c.RunDockerCmd("compose", "-f", "./fixtures/cascade-stop-test/compose.yaml", "--project-name", projectName, "up", "--abort-on-container-exit")
|
res := c.RunDockerOrExitError("compose", "-f", "./fixtures/cascade-stop-test/compose.yaml", "--project-name", projectName, "up", "--abort-on-container-exit")
|
||||||
res.Assert(t, icmd.Expected{Out: `/does_not_exist: No such file or directory`})
|
res.Assert(t, icmd.Expected{ExitCode: 1, Out: `should_fail_1 exited with code 1`})
|
||||||
res.Assert(t, icmd.Expected{Out: `should_fail_1 exited with code 1`})
|
res.Assert(t, icmd.Expected{ExitCode: 1, Out: `Aborting on container exit...`})
|
||||||
res.Assert(t, icmd.Expected{Out: `Aborting on container exit...`})
|
|
||||||
res.Assert(t, icmd.Expected{Out: `ERROR 1`})
|
|
||||||
res.Assert(t, icmd.Expected{ExitCode: 1})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("exit-code-from", func(t *testing.T) {
|
t.Run("exit-code-from", func(t *testing.T) {
|
||||||
res := c.RunDockerCmd("compose", "-f", "./fixtures/cascade-stop-test/compose.yaml", "--project-name", projectName, "up", "--exit-code-from=sleep")
|
res := c.RunDockerOrExitError("compose", "-f", "./fixtures/cascade-stop-test/compose.yaml", "--project-name", projectName, "up", "--exit-code-from=sleep")
|
||||||
res.Assert(t, icmd.Expected{Out: `/does_not_exist: No such file or directory`})
|
res.Assert(t, icmd.Expected{ExitCode: 137, Out: `should_fail_1 exited with code 1`})
|
||||||
res.Assert(t, icmd.Expected{Out: `should_fail_1 exited with code 1`})
|
res.Assert(t, icmd.Expected{ExitCode: 137, Out: `Aborting on container exit...`})
|
||||||
res.Assert(t, icmd.Expected{Out: `Aborting on container exit...`})
|
})
|
||||||
res.Assert(t, icmd.Expected{Out: `ERROR 143`})
|
|
||||||
res.Assert(t, icmd.Expected{ExitCode: 143})
|
t.Run("exit-code-from unknown", func(t *testing.T) {
|
||||||
|
res := c.RunDockerOrExitError("compose", "-f", "./fixtures/cascade-stop-test/compose.yaml", "--project-name", projectName, "up", "--exit-code-from=unknown")
|
||||||
|
res.Assert(t, icmd.Expected{ExitCode: 1, Err: `no such service: unknown`})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -4,4 +4,4 @@ services:
|
|||||||
command: ls /does_not_exist
|
command: ls /does_not_exist
|
||||||
sleep: # will be killed
|
sleep: # will be killed
|
||||||
image: busybox:1.27.2
|
image: busybox:1.27.2
|
||||||
command: sleep 10
|
command: ping localhost
|
||||||
|
Loading…
x
Reference in New Issue
Block a user