Browse Source

fix #12188 integration-cli: tests using "sleep" can timeout too early - change to "top" instead

Signed-off-by: Todd Whiteman <todd.whiteman@joyent.com>
Todd Whiteman 10 years ago
parent
commit
42d47c3136

+ 4 - 4
integration-cli/docker_cli_exec_test.go

@@ -19,7 +19,7 @@ import (
 func TestExec(t *testing.T) {
 func TestExec(t *testing.T) {
 	defer deleteAllContainers()
 	defer deleteAllContainers()
 
 
-	runCmd := exec.Command(dockerBinary, "run", "-d", "--name", "testing", "busybox", "sh", "-c", "echo test > /tmp/file && sleep 100")
+	runCmd := exec.Command(dockerBinary, "run", "-d", "--name", "testing", "busybox", "sh", "-c", "echo test > /tmp/file && top")
 	if out, _, _, err := runCommandWithStdoutStderr(runCmd); err != nil {
 	if out, _, _, err := runCommandWithStdoutStderr(runCmd); err != nil {
 		t.Fatal(out, err)
 		t.Fatal(out, err)
 	}
 	}
@@ -82,7 +82,7 @@ func TestExecInteractiveStdinClose(t *testing.T) {
 func TestExecInteractive(t *testing.T) {
 func TestExecInteractive(t *testing.T) {
 	defer deleteAllContainers()
 	defer deleteAllContainers()
 
 
-	runCmd := exec.Command(dockerBinary, "run", "-d", "--name", "testing", "busybox", "sh", "-c", "echo test > /tmp/file && sleep 100")
+	runCmd := exec.Command(dockerBinary, "run", "-d", "--name", "testing", "busybox", "sh", "-c", "echo test > /tmp/file && top")
 	if out, _, _, err := runCommandWithStdoutStderr(runCmd); err != nil {
 	if out, _, _, err := runCommandWithStdoutStderr(runCmd); err != nil {
 		t.Fatal(out, err)
 		t.Fatal(out, err)
 	}
 	}
@@ -500,12 +500,12 @@ func TestLinksPingLinkedContainersOnRename(t *testing.T) {
 	defer deleteAllContainers()
 	defer deleteAllContainers()
 
 
 	var out string
 	var out string
-	out, _, _ = dockerCmd(t, "run", "-d", "--name", "container1", "busybox", "sleep", "10")
+	out, _, _ = dockerCmd(t, "run", "-d", "--name", "container1", "busybox", "top")
 	idA := strings.TrimSpace(out)
 	idA := strings.TrimSpace(out)
 	if idA == "" {
 	if idA == "" {
 		t.Fatal(out, "id should not be nil")
 		t.Fatal(out, "id should not be nil")
 	}
 	}
-	out, _, _ = dockerCmd(t, "run", "-d", "--link", "container1:alias1", "--name", "container2", "busybox", "sleep", "10")
+	out, _, _ = dockerCmd(t, "run", "-d", "--link", "container1:alias1", "--name", "container2", "busybox", "top")
 	idB := strings.TrimSpace(out)
 	idB := strings.TrimSpace(out)
 	if idB == "" {
 	if idB == "" {
 		t.Fatal(out, "id should not be nil")
 		t.Fatal(out, "id should not be nil")

+ 4 - 4
integration-cli/docker_cli_kill_test.go

@@ -7,7 +7,7 @@ import (
 )
 )
 
 
 func TestKillContainer(t *testing.T) {
 func TestKillContainer(t *testing.T) {
-	runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sh", "-c", "sleep 10")
+	runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "top")
 	out, _, err := runCommandWithOutput(runCmd)
 	out, _, err := runCommandWithOutput(runCmd)
 	if err != nil {
 	if err != nil {
 		t.Fatal(out, err)
 		t.Fatal(out, err)
@@ -37,11 +37,11 @@ func TestKillContainer(t *testing.T) {
 
 
 	deleteContainer(cleanedContainerID)
 	deleteContainer(cleanedContainerID)
 
 
-	logDone("kill - kill container running sleep 10")
+	logDone("kill - kill container running top")
 }
 }
 
 
 func TestKillDifferentUserContainer(t *testing.T) {
 func TestKillDifferentUserContainer(t *testing.T) {
-	runCmd := exec.Command(dockerBinary, "run", "-u", "daemon", "-d", "busybox", "sh", "-c", "sleep 10")
+	runCmd := exec.Command(dockerBinary, "run", "-u", "daemon", "-d", "busybox", "top")
 	out, _, err := runCommandWithOutput(runCmd)
 	out, _, err := runCommandWithOutput(runCmd)
 	if err != nil {
 	if err != nil {
 		t.Fatal(out, err)
 		t.Fatal(out, err)
@@ -71,5 +71,5 @@ func TestKillDifferentUserContainer(t *testing.T) {
 
 
 	deleteContainer(cleanedContainerID)
 	deleteContainer(cleanedContainerID)
 
 
-	logDone("kill - kill container running sleep 10 from a different user")
+	logDone("kill - kill container running top from a different user")
 }
 }

+ 9 - 9
integration-cli/docker_cli_links_test.go

@@ -110,9 +110,9 @@ func TestLinksPingLinkedContainers(t *testing.T) {
 func TestLinksPingLinkedContainersAfterRename(t *testing.T) {
 func TestLinksPingLinkedContainersAfterRename(t *testing.T) {
 	defer deleteAllContainers()
 	defer deleteAllContainers()
 
 
-	out, _, _ := dockerCmd(t, "run", "-d", "--name", "container1", "busybox", "sleep", "10")
+	out, _, _ := dockerCmd(t, "run", "-d", "--name", "container1", "busybox", "top")
 	idA := strings.TrimSpace(out)
 	idA := strings.TrimSpace(out)
-	out, _, _ = dockerCmd(t, "run", "-d", "--name", "container2", "busybox", "sleep", "10")
+	out, _, _ = dockerCmd(t, "run", "-d", "--name", "container2", "busybox", "top")
 	idB := strings.TrimSpace(out)
 	idB := strings.TrimSpace(out)
 	dockerCmd(t, "rename", "container1", "container_new")
 	dockerCmd(t, "rename", "container1", "container_new")
 	dockerCmd(t, "run", "--rm", "--link", "container_new:alias1", "--link", "container2:alias2", "busybox", "sh", "-c", "ping -c 1 alias1 -W 1 && ping -c 1 alias2 -W 1")
 	dockerCmd(t, "run", "--rm", "--link", "container_new:alias1", "--link", "container2:alias2", "busybox", "sh", "-c", "ping -c 1 alias1 -W 1 && ping -c 1 alias2 -W 1")
@@ -126,8 +126,8 @@ func TestLinksIpTablesRulesWhenLinkAndUnlink(t *testing.T) {
 	testRequires(t, SameHostDaemon)
 	testRequires(t, SameHostDaemon)
 	defer deleteAllContainers()
 	defer deleteAllContainers()
 
 
-	dockerCmd(t, "run", "-d", "--name", "child", "--publish", "8080:80", "busybox", "sleep", "10")
-	dockerCmd(t, "run", "-d", "--name", "parent", "--link", "child:http", "busybox", "sleep", "10")
+	dockerCmd(t, "run", "-d", "--name", "child", "--publish", "8080:80", "busybox", "top")
+	dockerCmd(t, "run", "-d", "--name", "parent", "--link", "child:http", "busybox", "top")
 
 
 	childIP := findContainerIP(t, "child")
 	childIP := findContainerIP(t, "child")
 	parentIP := findContainerIP(t, "parent")
 	parentIP := findContainerIP(t, "parent")
@@ -155,9 +155,9 @@ func TestLinksInspectLinksStarted(t *testing.T) {
 		result   []string
 		result   []string
 	)
 	)
 	defer deleteAllContainers()
 	defer deleteAllContainers()
-	dockerCmd(t, "run", "-d", "--name", "container1", "busybox", "sleep", "10")
-	dockerCmd(t, "run", "-d", "--name", "container2", "busybox", "sleep", "10")
-	dockerCmd(t, "run", "-d", "--name", "testinspectlink", "--link", "container1:alias1", "--link", "container2:alias2", "busybox", "sleep", "10")
+	dockerCmd(t, "run", "-d", "--name", "container1", "busybox", "top")
+	dockerCmd(t, "run", "-d", "--name", "container2", "busybox", "top")
+	dockerCmd(t, "run", "-d", "--name", "testinspectlink", "--link", "container1:alias1", "--link", "container2:alias2", "busybox", "top")
 	links, err := inspectFieldJSON("testinspectlink", "HostConfig.Links")
 	links, err := inspectFieldJSON("testinspectlink", "HostConfig.Links")
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
@@ -184,8 +184,8 @@ func TestLinksInspectLinksStopped(t *testing.T) {
 		result   []string
 		result   []string
 	)
 	)
 	defer deleteAllContainers()
 	defer deleteAllContainers()
-	dockerCmd(t, "run", "-d", "--name", "container1", "busybox", "sleep", "10")
-	dockerCmd(t, "run", "-d", "--name", "container2", "busybox", "sleep", "10")
+	dockerCmd(t, "run", "-d", "--name", "container1", "busybox", "top")
+	dockerCmd(t, "run", "-d", "--name", "container2", "busybox", "top")
 	dockerCmd(t, "run", "-d", "--name", "testinspectlink", "--link", "container1:alias1", "--link", "container2:alias2", "busybox", "true")
 	dockerCmd(t, "run", "-d", "--name", "testinspectlink", "--link", "container1:alias1", "--link", "container2:alias2", "busybox", "true")
 	links, err := inspectFieldJSON("testinspectlink", "HostConfig.Links")
 	links, err := inspectFieldJSON("testinspectlink", "HostConfig.Links")
 	if err != nil {
 	if err != nil {

+ 2 - 14
integration-cli/docker_cli_pause_test.go

@@ -14,7 +14,7 @@ func TestPause(t *testing.T) {
 	name := "testeventpause"
 	name := "testeventpause"
 	out, _, _ := dockerCmd(t, "images", "-q")
 	out, _, _ := dockerCmd(t, "images", "-q")
 	image := strings.Split(out, "\n")[0]
 	image := strings.Split(out, "\n")[0]
-	dockerCmd(t, "run", "-d", "--name", name, image, "sleep", "2")
+	dockerCmd(t, "run", "-d", "--name", name, image, "top")
 
 
 	dockerCmd(t, "pause", name)
 	dockerCmd(t, "pause", name)
 	pausedContainers, err := getSliceOfPausedContainers()
 	pausedContainers, err := getSliceOfPausedContainers()
@@ -44,11 +44,6 @@ func TestPause(t *testing.T) {
 		t.Fatalf("event should be unpause, not %#v", unpauseEvent)
 		t.Fatalf("event should be unpause, not %#v", unpauseEvent)
 	}
 	}
 
 
-	waitCmd := exec.Command(dockerBinary, "wait", name)
-	if waitOut, _, err := runCommandWithOutput(waitCmd); err != nil {
-		t.Fatalf("error thrown while waiting for container: %s, %v", waitOut, err)
-	}
-
 	logDone("pause - pause/unpause is logged")
 	logDone("pause - pause/unpause is logged")
 }
 }
 
 
@@ -63,7 +58,7 @@ func TestPauseMultipleContainers(t *testing.T) {
 	out, _, _ := dockerCmd(t, "images", "-q")
 	out, _, _ := dockerCmd(t, "images", "-q")
 	image := strings.Split(out, "\n")[0]
 	image := strings.Split(out, "\n")[0]
 	for _, name := range containers {
 	for _, name := range containers {
-		dockerCmd(t, "run", "-d", "--name", name, image, "sleep", "2")
+		dockerCmd(t, "run", "-d", "--name", name, image, "top")
 	}
 	}
 	dockerCmd(t, append([]string{"pause"}, containers...)...)
 	dockerCmd(t, append([]string{"pause"}, containers...)...)
 	pausedContainers, err := getSliceOfPausedContainers()
 	pausedContainers, err := getSliceOfPausedContainers()
@@ -101,12 +96,5 @@ func TestPauseMultipleContainers(t *testing.T) {
 		}
 		}
 	}
 	}
 
 
-	for _, name := range containers {
-		waitCmd := exec.Command(dockerBinary, "wait", name)
-		if waitOut, _, err := runCommandWithOutput(waitCmd); err != nil {
-			t.Fatalf("error thrown while waiting for container: %s, %v", waitOut, err)
-		}
-	}
-
 	logDone("pause - multi pause/unpause is logged")
 	logDone("pause - multi pause/unpause is logged")
 }
 }

+ 2 - 2
integration-cli/docker_cli_ps_test.go

@@ -377,7 +377,7 @@ func TestPsListContainersFilterID(t *testing.T) {
 	firstID := strings.TrimSpace(out)
 	firstID := strings.TrimSpace(out)
 
 
 	// start another container
 	// start another container
-	runCmd = exec.Command(dockerBinary, "run", "-d", "busybox", "sh", "-c", "sleep 360")
+	runCmd = exec.Command(dockerBinary, "run", "-d", "busybox", "top")
 	if out, _, err = runCommandWithOutput(runCmd); err != nil {
 	if out, _, err = runCommandWithOutput(runCmd); err != nil {
 		t.Fatal(out, err)
 		t.Fatal(out, err)
 	}
 	}
@@ -407,7 +407,7 @@ func TestPsListContainersFilterName(t *testing.T) {
 	firstID := strings.TrimSpace(out)
 	firstID := strings.TrimSpace(out)
 
 
 	// start another container
 	// start another container
-	runCmd = exec.Command(dockerBinary, "run", "-d", "--name=b_name_to_match", "busybox", "sh", "-c", "sleep 360")
+	runCmd = exec.Command(dockerBinary, "run", "-d", "--name=b_name_to_match", "busybox", "top")
 	if out, _, err = runCommandWithOutput(runCmd); err != nil {
 	if out, _, err = runCommandWithOutput(runCmd); err != nil {
 		t.Fatal(out, err)
 		t.Fatal(out, err)
 	}
 	}

+ 17 - 17
integration-cli/docker_cli_top_test.go

@@ -7,7 +7,7 @@ import (
 )
 )
 
 
 func TestTopMultipleArgs(t *testing.T) {
 func TestTopMultipleArgs(t *testing.T) {
-	runCmd := exec.Command(dockerBinary, "run", "-i", "-d", "busybox", "sleep", "20")
+	runCmd := exec.Command(dockerBinary, "run", "-i", "-d", "busybox", "top")
 	out, _, err := runCommandWithOutput(runCmd)
 	out, _, err := runCommandWithOutput(runCmd)
 	if err != nil {
 	if err != nil {
 		t.Fatalf("failed to start the container: %s, %v", out, err)
 		t.Fatalf("failed to start the container: %s, %v", out, err)
@@ -30,7 +30,7 @@ func TestTopMultipleArgs(t *testing.T) {
 }
 }
 
 
 func TestTopNonPrivileged(t *testing.T) {
 func TestTopNonPrivileged(t *testing.T) {
-	runCmd := exec.Command(dockerBinary, "run", "-i", "-d", "busybox", "sleep", "20")
+	runCmd := exec.Command(dockerBinary, "run", "-i", "-d", "busybox", "top")
 	out, _, err := runCommandWithOutput(runCmd)
 	out, _, err := runCommandWithOutput(runCmd)
 	if err != nil {
 	if err != nil {
 		t.Fatalf("failed to start the container: %s, %v", out, err)
 		t.Fatalf("failed to start the container: %s, %v", out, err)
@@ -57,19 +57,19 @@ func TestTopNonPrivileged(t *testing.T) {
 
 
 	deleteContainer(cleanedContainerID)
 	deleteContainer(cleanedContainerID)
 
 
-	if !strings.Contains(out1, "sleep 20") && !strings.Contains(out2, "sleep 20") {
-		t.Fatal("top should've listed `sleep 20` in the process list, but failed twice")
-	} else if !strings.Contains(out1, "sleep 20") {
-		t.Fatal("top should've listed `sleep 20` in the process list, but failed the first time")
-	} else if !strings.Contains(out2, "sleep 20") {
-		t.Fatal("top should've listed `sleep 20` in the process list, but failed the second itime")
+	if !strings.Contains(out1, "top") && !strings.Contains(out2, "top") {
+		t.Fatal("top should've listed `top` in the process list, but failed twice")
+	} else if !strings.Contains(out1, "top") {
+		t.Fatal("top should've listed `top` in the process list, but failed the first time")
+	} else if !strings.Contains(out2, "top") {
+		t.Fatal("top should've listed `top` in the process list, but failed the second itime")
 	}
 	}
 
 
-	logDone("top - sleep process should be listed in non privileged mode")
+	logDone("top - top process should be listed in non privileged mode")
 }
 }
 
 
 func TestTopPrivileged(t *testing.T) {
 func TestTopPrivileged(t *testing.T) {
-	runCmd := exec.Command(dockerBinary, "run", "--privileged", "-i", "-d", "busybox", "sleep", "20")
+	runCmd := exec.Command(dockerBinary, "run", "--privileged", "-i", "-d", "busybox", "top")
 	out, _, err := runCommandWithOutput(runCmd)
 	out, _, err := runCommandWithOutput(runCmd)
 	if err != nil {
 	if err != nil {
 		t.Fatalf("failed to start the container: %s, %v", out, err)
 		t.Fatalf("failed to start the container: %s, %v", out, err)
@@ -96,13 +96,13 @@ func TestTopPrivileged(t *testing.T) {
 
 
 	deleteContainer(cleanedContainerID)
 	deleteContainer(cleanedContainerID)
 
 
-	if !strings.Contains(out1, "sleep 20") && !strings.Contains(out2, "sleep 20") {
-		t.Fatal("top should've listed `sleep 20` in the process list, but failed twice")
-	} else if !strings.Contains(out1, "sleep 20") {
-		t.Fatal("top should've listed `sleep 20` in the process list, but failed the first time")
-	} else if !strings.Contains(out2, "sleep 20") {
-		t.Fatal("top should've listed `sleep 20` in the process list, but failed the second itime")
+	if !strings.Contains(out1, "top") && !strings.Contains(out2, "top") {
+		t.Fatal("top should've listed `top` in the process list, but failed twice")
+	} else if !strings.Contains(out1, "top") {
+		t.Fatal("top should've listed `top` in the process list, but failed the first time")
+	} else if !strings.Contains(out2, "top") {
+		t.Fatal("top should've listed `top` in the process list, but failed the second itime")
 	}
 	}
 
 
-	logDone("top - sleep process should be listed in privileged mode")
+	logDone("top - top process should be listed in privileged mode")
 }
 }