[19.03 backport] do not stop health check before sending signal
Sebastiaan van Stijn authored on 2019/08/15 23:16:58... | ... |
@@ -9,6 +9,7 @@ import ( |
9 | 9 |
containertypes "github.com/docker/docker/api/types/container" |
10 | 10 |
"github.com/docker/docker/client" |
11 | 11 |
"github.com/docker/docker/integration/internal/container" |
12 |
+ "gotest.tools/assert" |
|
12 | 13 |
"gotest.tools/poll" |
13 | 14 |
"gotest.tools/skip" |
14 | 15 |
) |
... | ... |
@@ -32,6 +33,35 @@ func TestHealthCheckWorkdir(t *testing.T) { |
32 | 32 |
poll.WaitOn(t, pollForHealthStatus(ctx, client, cID, types.Healthy), poll.WithDelay(100*time.Millisecond)) |
33 | 33 |
} |
34 | 34 |
|
35 |
+// GitHub #37263 |
|
36 |
+// Do not stop healthchecks just because we sent a signal to the container |
|
37 |
+func TestHealthKillContainer(t *testing.T) { |
|
38 |
+ skip.If(t, testEnv.OSType == "windows", "Windows only supports SIGKILL and SIGTERM? See https://github.com/moby/moby/issues/39574") |
|
39 |
+ defer setupTest(t)() |
|
40 |
+ |
|
41 |
+ ctx := context.Background() |
|
42 |
+ client := testEnv.APIClient() |
|
43 |
+ |
|
44 |
+ id := container.Run(t, ctx, client, func(c *container.TestContainerConfig) { |
|
45 |
+ c.Config.Healthcheck = &containertypes.HealthConfig{ |
|
46 |
+ Test: []string{"CMD-SHELL", "sleep 1"}, |
|
47 |
+ Interval: time.Second, |
|
48 |
+ Retries: 5, |
|
49 |
+ } |
|
50 |
+ }) |
|
51 |
+ |
|
52 |
+ ctxPoll, cancel := context.WithTimeout(ctx, 30*time.Second) |
|
53 |
+ defer cancel() |
|
54 |
+ poll.WaitOn(t, pollForHealthStatus(ctxPoll, client, id, "healthy"), poll.WithDelay(100*time.Millisecond)) |
|
55 |
+ |
|
56 |
+ err := client.ContainerKill(ctx, id, "SIGUSR1") |
|
57 |
+ assert.NilError(t, err) |
|
58 |
+ |
|
59 |
+ ctxPoll, cancel = context.WithTimeout(ctx, 30*time.Second) |
|
60 |
+ defer cancel() |
|
61 |
+ poll.WaitOn(t, pollForHealthStatus(ctxPoll, client, id, "healthy"), poll.WithDelay(100*time.Millisecond)) |
|
62 |
+} |
|
63 |
+ |
|
35 | 64 |
func pollForHealthStatus(ctx context.Context, client client.APIClient, containerID string, healthStatus string) func(log poll.LogT) poll.Result { |
36 | 65 |
return func(log poll.LogT) poll.Result { |
37 | 66 |
inspect, err := client.ContainerInspect(ctx, containerID) |