Fix two test issues:
- pidof is not available in PATH on some Jenkins systems (rhel, centos)
Use kill -0 instead.
- Cleanup after plugin test. This is a stop gap fix. The right way to
fix this, is to shutdown the plugin on daemon shutdown path (except
for the live-restore case). This will be done in a follow up PR.
Signed-off-by: Anusha Ragunathan <anusha@docker.com>
... | ... |
@@ -19,6 +19,15 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithPluginEnabled(c *check.C) { |
19 | 19 |
c.Fatalf("Could not install plugin: %v %s", err, out) |
20 | 20 |
} |
21 | 21 |
|
22 |
+ defer func() { |
|
23 |
+ if out, err := s.d.Cmd("plugin", "disable", pluginName); err != nil { |
|
24 |
+ c.Fatalf("Could not disable plugin: %v %s", err, out) |
|
25 |
+ } |
|
26 |
+ if out, err := s.d.Cmd("plugin", "remove", pluginName); err != nil { |
|
27 |
+ c.Fatalf("Could not remove plugin: %v %s", err, out) |
|
28 |
+ } |
|
29 |
+ }() |
|
30 |
+ |
|
22 | 31 |
if err := s.d.Restart(); err != nil { |
23 | 32 |
c.Fatalf("Could not restart daemon: %v", err) |
24 | 33 |
} |
... | ... |
@@ -41,6 +50,12 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithPluginDisabled(c *check.C) { |
41 | 41 |
c.Fatalf("Could not install plugin: %v %s", err, out) |
42 | 42 |
} |
43 | 43 |
|
44 |
+ defer func() { |
|
45 |
+ if out, err := s.d.Cmd("plugin", "remove", pluginName); err != nil { |
|
46 |
+ c.Fatalf("Could not remove plugin: %v %s", err, out) |
|
47 |
+ } |
|
48 |
+ }() |
|
49 |
+ |
|
44 | 50 |
if err := s.d.Restart(); err != nil { |
45 | 51 |
c.Fatalf("Could not restart daemon: %v", err) |
46 | 52 |
} |
... | ... |
@@ -2106,6 +2106,10 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithKilledRunningContainer(t *check |
2106 | 2106 |
} |
2107 | 2107 |
cid = strings.TrimSpace(cid) |
2108 | 2108 |
|
2109 |
+ pid, err := s.d.Cmd("inspect", "-f", "{{.State.Pid}}", cid) |
|
2110 |
+ t.Assert(err, check.IsNil) |
|
2111 |
+ pid = strings.TrimSpace(pid) |
|
2112 |
+ |
|
2109 | 2113 |
// Kill the daemon |
2110 | 2114 |
if err := s.d.Kill(); err != nil { |
2111 | 2115 |
t.Fatal(err) |
... | ... |
@@ -2119,10 +2123,10 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithKilledRunningContainer(t *check |
2119 | 2119 |
|
2120 | 2120 |
// Give time to containerd to process the command if we don't |
2121 | 2121 |
// the exit event might be received after we do the inspect |
2122 |
- pidCmd := exec.Command("pidof", "top") |
|
2122 |
+ pidCmd := exec.Command("kill", "-0", pid) |
|
2123 | 2123 |
_, ec, _ := runCommandWithOutput(pidCmd) |
2124 | 2124 |
for ec == 0 { |
2125 |
- time.Sleep(3 * time.Second) |
|
2125 |
+ time.Sleep(1 * time.Second) |
|
2126 | 2126 |
_, ec, _ = runCommandWithOutput(pidCmd) |
2127 | 2127 |
} |
2128 | 2128 |
|
... | ... |
@@ -2200,6 +2204,10 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithUnpausedRunningContainer(t *che |
2200 | 2200 |
} |
2201 | 2201 |
cid = strings.TrimSpace(cid) |
2202 | 2202 |
|
2203 |
+ pid, err := s.d.Cmd("inspect", "-f", "{{.State.Pid}}", cid) |
|
2204 |
+ t.Assert(err, check.IsNil) |
|
2205 |
+ pid = strings.TrimSpace(pid) |
|
2206 |
+ |
|
2203 | 2207 |
// pause the container |
2204 | 2208 |
if _, err := s.d.Cmd("pause", cid); err != nil { |
2205 | 2209 |
t.Fatal(cid, err) |
... | ... |
@@ -2218,10 +2226,10 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithUnpausedRunningContainer(t *che |
2218 | 2218 |
|
2219 | 2219 |
// Give time to containerd to process the command if we don't |
2220 | 2220 |
// the resume event might be received after we do the inspect |
2221 |
- pidCmd := exec.Command("pidof", "top") |
|
2221 |
+ pidCmd := exec.Command("kill", "-0", pid) |
|
2222 | 2222 |
_, ec, _ := runCommandWithOutput(pidCmd) |
2223 | 2223 |
for ec == 0 { |
2224 |
- time.Sleep(3 * time.Second) |
|
2224 |
+ time.Sleep(1 * time.Second) |
|
2225 | 2225 |
_, ec, _ = runCommandWithOutput(pidCmd) |
2226 | 2226 |
} |
2227 | 2227 |
|