cleanup/fix integration-cli for overlay in overlay

Signed-off-by: Jessica Frazelle <jess@docker.com>
This commit is contained in:
Jessica Frazelle 2015-04-08 16:20:42 -07:00
parent 7233bd223d
commit 255b84444a
4 changed files with 37 additions and 30 deletions

View File

@ -472,7 +472,7 @@ func TestCpVolumePath(t *testing.T) {
}
cleanedContainerID := strings.TrimSpace(out)
defer deleteContainer(cleanedContainerID)
defer dockerCmd(t, "rm", "-fv", cleanedContainerID)
out, _, err = dockerCmd(t, "wait", cleanedContainerID)
if err != nil || strings.TrimSpace(out) != "0" {

View File

@ -42,12 +42,22 @@ func TestPsListContainers(t *testing.T) {
}
fourthID := strings.TrimSpace(out)
// make sure the second is running
if err := waitRun(secondID); err != nil {
t.Fatalf("waiting for container failed: %v", err)
}
// make sure third one is not running
runCmd = exec.Command(dockerBinary, "wait", thirdID)
if out, _, err = runCommandWithOutput(runCmd); err != nil {
t.Fatal(out, err)
}
// make sure the forth is running
if err := waitRun(fourthID); err != nil {
t.Fatalf("waiting for container failed: %v", err)
}
// all
runCmd = exec.Command(dockerBinary, "ps", "-a")
out, _, err = runCommandWithOutput(runCmd)
@ -56,7 +66,7 @@ func TestPsListContainers(t *testing.T) {
}
if !assertContainerList(out, []string{fourthID, thirdID, secondID, firstID}) {
t.Error("Container list is not in the correct order")
t.Errorf("Container list is not in the correct order: %s", out)
}
// running
@ -67,7 +77,7 @@ func TestPsListContainers(t *testing.T) {
}
if !assertContainerList(out, []string{fourthID, secondID, firstID}) {
t.Error("Container list is not in the correct order")
t.Errorf("Container list is not in the correct order: %s", out)
}
// from here all flag '-a' is ignored
@ -81,7 +91,7 @@ func TestPsListContainers(t *testing.T) {
expected := []string{fourthID, thirdID}
if !assertContainerList(out, expected) {
t.Error("Container list is not in the correct order")
t.Errorf("Container list is not in the correct order: %s", out)
}
runCmd = exec.Command(dockerBinary, "ps", "-n=2")
@ -91,7 +101,7 @@ func TestPsListContainers(t *testing.T) {
}
if !assertContainerList(out, expected) {
t.Error("Container list is not in the correct order")
t.Errorf("Container list is not in the correct order: %s", out)
}
// since
@ -103,7 +113,7 @@ func TestPsListContainers(t *testing.T) {
expected = []string{fourthID, thirdID, secondID}
if !assertContainerList(out, expected) {
t.Error("Container list is not in the correct order")
t.Errorf("Container list is not in the correct order: %s", out)
}
runCmd = exec.Command(dockerBinary, "ps", "--since", firstID)
@ -113,7 +123,7 @@ func TestPsListContainers(t *testing.T) {
}
if !assertContainerList(out, expected) {
t.Error("Container list is not in the correct order")
t.Errorf("Container list is not in the correct order: %s", out)
}
// before
@ -125,7 +135,7 @@ func TestPsListContainers(t *testing.T) {
expected = []string{secondID, firstID}
if !assertContainerList(out, expected) {
t.Error("Container list is not in the correct order")
t.Errorf("Container list is not in the correct order: %s", out)
}
runCmd = exec.Command(dockerBinary, "ps", "--before", thirdID)
@ -135,7 +145,7 @@ func TestPsListContainers(t *testing.T) {
}
if !assertContainerList(out, expected) {
t.Error("Container list is not in the correct order")
t.Errorf("Container list is not in the correct order: %s", out)
}
// since & before
@ -147,7 +157,7 @@ func TestPsListContainers(t *testing.T) {
expected = []string{thirdID, secondID}
if !assertContainerList(out, expected) {
t.Error("Container list is not in the correct order")
t.Errorf("Container list is not in the correct order: %s", out)
}
runCmd = exec.Command(dockerBinary, "ps", "--since", firstID, "--before", fourthID)
@ -156,7 +166,7 @@ func TestPsListContainers(t *testing.T) {
t.Fatal(out, err)
}
if !assertContainerList(out, expected) {
t.Error("Container list is not in the correct order")
t.Errorf("Container list is not in the correct order: %s", out)
}
// since & limit
@ -168,7 +178,7 @@ func TestPsListContainers(t *testing.T) {
expected = []string{fourthID, thirdID}
if !assertContainerList(out, expected) {
t.Error("Container list is not in the correct order")
t.Errorf("Container list is not in the correct order: %s", out)
}
runCmd = exec.Command(dockerBinary, "ps", "--since", firstID, "-n=2")
@ -178,7 +188,7 @@ func TestPsListContainers(t *testing.T) {
}
if !assertContainerList(out, expected) {
t.Error("Container list is not in the correct order")
t.Errorf("Container list is not in the correct order: %s", out)
}
// before & limit
@ -190,7 +200,7 @@ func TestPsListContainers(t *testing.T) {
expected = []string{thirdID}
if !assertContainerList(out, expected) {
t.Error("Container list is not in the correct order")
t.Errorf("Container list is not in the correct order: %s", out)
}
runCmd = exec.Command(dockerBinary, "ps", "--before", fourthID, "-n=1")
@ -200,7 +210,7 @@ func TestPsListContainers(t *testing.T) {
}
if !assertContainerList(out, expected) {
t.Error("Container list is not in the correct order")
t.Errorf("Container list is not in the correct order: %s", out)
}
// since & before & limit
@ -212,7 +222,7 @@ func TestPsListContainers(t *testing.T) {
expected = []string{thirdID}
if !assertContainerList(out, expected) {
t.Error("Container list is not in the correct order")
t.Errorf("Container list is not in the correct order: %s", out)
}
runCmd = exec.Command(dockerBinary, "ps", "--since", firstID, "--before", fourthID, "-n=1")
@ -222,7 +232,7 @@ func TestPsListContainers(t *testing.T) {
}
if !assertContainerList(out, expected) {
t.Error("Container list is not in the correct order")
t.Errorf("Container list is not in the correct order: %s", out)
}
logDone("ps - test ps options")
@ -535,7 +545,7 @@ func TestPsListContainersFilterExited(t *testing.T) {
}
ids := strings.Split(strings.TrimSpace(out), "\n")
if len(ids) != 2 {
t.Fatalf("Should be 2 zero exited containerst got %d", len(ids))
t.Fatalf("Should be 2 zero exited containers got %d: %s", len(ids), out)
}
if ids[0] != secondZero {
t.Fatalf("First in list should be %q, got %q", secondZero, ids[0])

View File

@ -3428,7 +3428,8 @@ func TestRunVolumesFromRestartAfterRemoved(t *testing.T) {
func TestRunContainerWithRmFlagExitCodeNotEqualToZero(t *testing.T) {
defer deleteAllContainers()
runCmd := exec.Command(dockerBinary, "run", "--rm", "busybox", "ls", "/notexists")
name := "flowers"
runCmd := exec.Command(dockerBinary, "run", "--name", name, "--rm", "busybox", "ls", "/notexists")
out, _, err := runCommandWithOutput(runCmd)
if err == nil {
t.Fatal("Expected docker run to fail", out, err)
@ -3449,7 +3450,8 @@ func TestRunContainerWithRmFlagExitCodeNotEqualToZero(t *testing.T) {
func TestRunContainerWithRmFlagCannotStartContainer(t *testing.T) {
defer deleteAllContainers()
runCmd := exec.Command(dockerBinary, "run", "--rm", "busybox", "commandNotFound")
name := "sparkles"
runCmd := exec.Command(dockerBinary, "run", "--name", name, "--rm", "busybox", "commandNotFound")
out, _, err := runCommandWithOutput(runCmd)
if err == nil {
t.Fatal("Expected docker run to fail", out, err)

View File

@ -340,16 +340,11 @@ func sockRequestRaw(method, endpoint string, data io.Reader, ct string) ([]byte,
}
func deleteContainer(container string) error {
container = strings.Replace(container, "\n", " ", -1)
container = strings.Trim(container, " ")
killArgs := fmt.Sprintf("kill %v", container)
killSplitArgs := strings.Split(killArgs, " ")
killCmd := exec.Command(dockerBinary, killSplitArgs...)
runCommand(killCmd)
rmArgs := fmt.Sprintf("rm -v %v", container)
rmSplitArgs := strings.Split(rmArgs, " ")
rmCmd := exec.Command(dockerBinary, rmSplitArgs...)
exitCode, err := runCommand(rmCmd)
container = strings.TrimSpace(strings.Replace(container, "\n", " ", -1))
killArgs := strings.Split(fmt.Sprintf("kill %v", container), " ")
runCommand(exec.Command(dockerBinary, killArgs...))
rmArgs := strings.Split(fmt.Sprintf("rm -v %v", container), " ")
exitCode, err := runCommand(exec.Command(dockerBinary, rmArgs...))
// set error manually if not set
if exitCode != 0 && err == nil {
err = fmt.Errorf("failed to remove container: `docker rm` exit is non-zero")