From 43186c4304c8f35d3d3f0b579bdd9bd8df987374 Mon Sep 17 00:00:00 2001 From: Anusha Ragunathan Date: Mon, 27 Jun 2016 20:32:03 -0700 Subject: [PATCH] Fix daemon tests. 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 (cherry picked from commit 6d36431e2395867d7bb101dbfd4340e132fd5438) --- .../docker_cli_daemon_experimental_test.go | 15 +++++++++++++++ integration-cli/docker_cli_daemon_test.go | 16 ++++++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/integration-cli/docker_cli_daemon_experimental_test.go b/integration-cli/docker_cli_daemon_experimental_test.go index 46ce156a48..7230dbb67d 100644 --- a/integration-cli/docker_cli_daemon_experimental_test.go +++ b/integration-cli/docker_cli_daemon_experimental_test.go @@ -19,6 +19,15 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithPluginEnabled(c *check.C) { c.Fatalf("Could not install plugin: %v %s", err, out) } + defer func() { + if out, err := s.d.Cmd("plugin", "disable", pluginName); err != nil { + c.Fatalf("Could not disable plugin: %v %s", err, out) + } + if out, err := s.d.Cmd("plugin", "remove", pluginName); err != nil { + c.Fatalf("Could not remove plugin: %v %s", err, out) + } + }() + if err := s.d.Restart(); err != nil { c.Fatalf("Could not restart daemon: %v", err) } @@ -41,6 +50,12 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithPluginDisabled(c *check.C) { c.Fatalf("Could not install plugin: %v %s", err, out) } + defer func() { + if out, err := s.d.Cmd("plugin", "remove", pluginName); err != nil { + c.Fatalf("Could not remove plugin: %v %s", err, out) + } + }() + if err := s.d.Restart(); err != nil { c.Fatalf("Could not restart daemon: %v", err) } diff --git a/integration-cli/docker_cli_daemon_test.go b/integration-cli/docker_cli_daemon_test.go index 0567f15c74..7508f9fc67 100644 --- a/integration-cli/docker_cli_daemon_test.go +++ b/integration-cli/docker_cli_daemon_test.go @@ -2106,6 +2106,10 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithKilledRunningContainer(t *check } cid = strings.TrimSpace(cid) + pid, err := s.d.Cmd("inspect", "-f", "{{.State.Pid}}", cid) + t.Assert(err, check.IsNil) + pid = strings.TrimSpace(pid) + // Kill the daemon if err := s.d.Kill(); err != nil { t.Fatal(err) @@ -2119,10 +2123,10 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithKilledRunningContainer(t *check // Give time to containerd to process the command if we don't // the exit event might be received after we do the inspect - pidCmd := exec.Command("pidof", "top") + pidCmd := exec.Command("kill", "-0", pid) _, ec, _ := runCommandWithOutput(pidCmd) for ec == 0 { - time.Sleep(3 * time.Second) + time.Sleep(1 * time.Second) _, ec, _ = runCommandWithOutput(pidCmd) } @@ -2200,6 +2204,10 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithUnpausedRunningContainer(t *che } cid = strings.TrimSpace(cid) + pid, err := s.d.Cmd("inspect", "-f", "{{.State.Pid}}", cid) + t.Assert(err, check.IsNil) + pid = strings.TrimSpace(pid) + // pause the container if _, err := s.d.Cmd("pause", cid); err != nil { t.Fatal(cid, err) @@ -2218,10 +2226,10 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithUnpausedRunningContainer(t *che // Give time to containerd to process the command if we don't // the resume event might be received after we do the inspect - pidCmd := exec.Command("pidof", "top") + pidCmd := exec.Command("kill", "-0", pid) _, ec, _ := runCommandWithOutput(pidCmd) for ec == 0 { - time.Sleep(3 * time.Second) + time.Sleep(1 * time.Second) _, ec, _ = runCommandWithOutput(pidCmd) }