Browse Source

Add runSleepingContainer in integration-cli

Signed-off-by: Tibor Vass <tibor@docker.com>
Tibor Vass 9 years ago
parent
commit
d6e7dc791f

+ 16 - 0
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...)
+}

+ 6 - 0
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"}

+ 6 - 0
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"}