From d6e7dc791ffb78d849923190648b825fc5ff15b7 Mon Sep 17 00:00:00 2001 From: Tibor Vass Date: Wed, 10 Feb 2016 13:05:28 -0500 Subject: [PATCH] Add runSleepingContainer in integration-cli Signed-off-by: Tibor Vass --- integration-cli/docker_utils.go | 16 ++++++++++++++++ integration-cli/test_vars_unix.go | 6 ++++++ integration-cli/test_vars_windows.go | 6 ++++++ 3 files changed, 28 insertions(+) diff --git a/integration-cli/docker_utils.go b/integration-cli/docker_utils.go index 4734c89711..9b768927dd 100644 --- a/integration-cli/docker_utils.go +++ b/integration-cli/docker_utils.go @@ -1704,3 +1704,19 @@ func getInspectBody(c *check.C, version, id string) []byte { c.Assert(status, check.Equals, http.StatusOK) return body } + +// Run a long running idle task in a background container using the +// system-specific default image and command. +func runSleepingContainer(c *check.C, extraArgs ...string) (string, int) { + return runSleepingContainerInImage(c, defaultSleepImage, extraArgs...) +} + +// Run a long running idle task in a background container using the specified +// image and the system-specific command. +func runSleepingContainerInImage(c *check.C, image string, extraArgs ...string) (string, int) { + args := []string{"run", "-d"} + args = append(args, extraArgs...) + args = append(args, image) + args = append(args, defaultSleepCommand...) + return dockerCmd(c, args...) +} diff --git a/integration-cli/test_vars_unix.go b/integration-cli/test_vars_unix.go index 1ab8a5ca48..853889abe7 100644 --- a/integration-cli/test_vars_unix.go +++ b/integration-cli/test_vars_unix.go @@ -7,4 +7,10 @@ const ( isUnixCli = true expectedFileChmod = "-rw-r--r--" + + // On Unix variants, the busybox image comes with the `top` command which + // runs indefinitely while still being interruptible by a signal. + defaultSleepImage = "busybox" ) + +var defaultSleepCommand = []string{"top"} diff --git a/integration-cli/test_vars_windows.go b/integration-cli/test_vars_windows.go index f81ac53cc3..a1b916c181 100644 --- a/integration-cli/test_vars_windows.go +++ b/integration-cli/test_vars_windows.go @@ -8,4 +8,10 @@ const ( // this is the expected file permission set on windows: gh#11395 expectedFileChmod = "-rwxr-xr-x" + + // On Windows, the busybox image doesn't have the `top` command, so we rely + // on `sleep` with a high duration. + defaultSleepImage = "busybox" ) + +var defaultSleepCommand = []string{"sleep", "60"}