MCPcopy
hub / github.com/docker/compose / TestRestartWithDependencies

Function TestRestartWithDependencies

pkg/e2e/restart_test.go:67–99  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

65}
66
67func TestRestartWithDependencies(t *testing.T) {
68 c := NewCLI(t, WithEnv(
69 "COMPOSE_PROJECT_NAME=e2e-restart-deps",
70 ))
71 baseService := "nginx"
72 depWithRestart := "with-restart"
73 depNoRestart := "no-restart"
74
75 t.Cleanup(func() {
76 c.RunDockerComposeCmd(t, "down", "--remove-orphans")
77 })
78
79 c.RunDockerComposeCmd(t, "-f", "./fixtures/restart-test/compose-depends-on.yaml", "up", "-d")
80
81 res := c.RunDockerComposeCmd(t, "restart", baseService)
82 out := res.Combined()
83 assert.Assert(t, strings.Contains(out, fmt.Sprintf("Container e2e-restart-deps-%s-1 Restarting", baseService)), out)
84 assert.Assert(t, strings.Contains(out, fmt.Sprintf("Container e2e-restart-deps-%s-1 Healthy", baseService)), out)
85 assert.Assert(t, strings.Contains(out, fmt.Sprintf("Container e2e-restart-deps-%s-1 Started", depWithRestart)), out)
86 assert.Assert(t, !strings.Contains(out, depNoRestart), out)
87
88 c = NewParallelCLI(t, WithEnv(
89 "COMPOSE_PROJECT_NAME=e2e-restart-deps",
90 "LABEL=recreate",
91 ))
92 res = c.RunDockerComposeCmd(t, "-f", "./fixtures/restart-test/compose-depends-on.yaml", "up", "-d")
93 out = res.Combined()
94 assert.Assert(t, strings.Contains(out, fmt.Sprintf("Container e2e-restart-deps-%s-1 Stopped", depWithRestart)), out)
95 assert.Assert(t, strings.Contains(out, fmt.Sprintf("Container e2e-restart-deps-%s-1 Recreated", baseService)), out)
96 assert.Assert(t, strings.Contains(out, fmt.Sprintf("Container e2e-restart-deps-%s-1 Healthy", baseService)), out)
97 assert.Assert(t, strings.Contains(out, fmt.Sprintf("Container e2e-restart-deps-%s-1 Started", depWithRestart)), out)
98 assert.Assert(t, strings.Contains(out, fmt.Sprintf("Container e2e-restart-deps-%s-1 Running", depNoRestart)), out)
99}
100
101func TestRestartWithProfiles(t *testing.T) {
102 c := NewParallelCLI(t, WithEnv(

Callers

nothing calls this directly

Calls 4

RunDockerComposeCmdMethod · 0.95
NewCLIFunction · 0.85
WithEnvFunction · 0.85
NewParallelCLIFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…