Browse code

cli integration: sync container & image deletion

This makes container and image removal in the tests run synchronously.

Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)

unclejack authored on 2014/04/04 09:22:32
Showing 10 changed files
... ...
@@ -18,7 +18,7 @@ func TestBuildSixtySteps(t *testing.T) {
18 18
 		t.Fatal("failed to build the image")
19 19
 	}
20 20
 
21
-	go deleteImages("foobuildsixtysteps")
21
+	deleteImages("foobuildsixtysteps")
22 22
 
23 23
 	logDone("build - build an image with sixty build steps")
24 24
 }
... ...
@@ -27,8 +27,8 @@ func TestCommitAfterContainerIsDone(t *testing.T) {
27 27
 	out, _, err = runCommandWithOutput(inspectCmd)
28 28
 	errorOut(err, t, fmt.Sprintf("failed to inspect image: %v %v", out, err))
29 29
 
30
-	go deleteContainer(cleanedContainerID)
31
-	go deleteImages(cleanedImageID)
30
+	deleteContainer(cleanedContainerID)
31
+	deleteImages(cleanedImageID)
32 32
 
33 33
 	logDone("commit - echo foo and commit the image")
34 34
 }
... ...
@@ -30,7 +30,7 @@ func TestDiffFilenameShownInOutput(t *testing.T) {
30 30
 	if !found {
31 31
 		t.Errorf("couldn't find the new file in docker diff's output: %v", out)
32 32
 	}
33
-	go deleteContainer(cleanCID)
33
+	deleteContainer(cleanCID)
34 34
 
35 35
 	logDone("diff - check if created file shows up")
36 36
 }
... ...
@@ -53,7 +53,7 @@ func TestDiffEnsureDockerinitFilesAreIgnored(t *testing.T) {
53 53
 		out, _, err := runCommandWithOutput(diffCmd)
54 54
 		errorOut(err, t, fmt.Sprintf("failed to run diff: %v %v", out, err))
55 55
 
56
-		go deleteContainer(cleanCID)
56
+		deleteContainer(cleanCID)
57 57
 
58 58
 		for _, filename := range dockerinitFiles {
59 59
 			if strings.Contains(out, filename) {
... ...
@@ -74,7 +74,7 @@ func TestDiffEnsureOnlyKmsgAndPtmx(t *testing.T) {
74 74
 	diffCmd := exec.Command(dockerBinary, "diff", cleanCID)
75 75
 	out, _, err := runCommandWithOutput(diffCmd)
76 76
 	errorOut(err, t, fmt.Sprintf("failed to run diff: %v %v", out, err))
77
-	go deleteContainer(cleanCID)
77
+	deleteContainer(cleanCID)
78 78
 
79 79
 	expected := map[string]bool{
80 80
 		"C /dev":      true,
... ...
@@ -40,8 +40,8 @@ func TestExportContainerAndImportImage(t *testing.T) {
40 40
 	out, _, err = runCommandWithOutput(inspectCmd)
41 41
 	errorOut(err, t, fmt.Sprintf("output should've been an image id: %v %v", out, err))
42 42
 
43
-	go deleteImages("testexp")
44
-	go deleteContainer(cleanedContainerID)
43
+	deleteContainer(cleanedContainerID)
44
+	deleteImages("testexp")
45 45
 
46 46
 	os.Remove("/tmp/testexp.tar")
47 47
 
... ...
@@ -30,7 +30,7 @@ func TestKillContainer(t *testing.T) {
30 30
 		t.Fatal("killed container is still running")
31 31
 	}
32 32
 
33
-	go deleteContainer(cleanedContainerID)
33
+	deleteContainer(cleanedContainerID)
34 34
 
35 35
 	logDone("kill - kill container running sleep 10")
36 36
 }
... ...
@@ -24,7 +24,7 @@ func TestLogsContainerSmallerThanPage(t *testing.T) {
24 24
 		t.Fatalf("Expected log length of %d, received %d\n", testLen+1, len(out))
25 25
 	}
26 26
 
27
-	go deleteContainer(cleanedContainerID)
27
+	deleteContainer(cleanedContainerID)
28 28
 
29 29
 	logDone("logs - logs container running echo smaller than page size")
30 30
 }
... ...
@@ -47,7 +47,7 @@ func TestLogsContainerBiggerThanPage(t *testing.T) {
47 47
 		t.Fatalf("Expected log length of %d, received %d\n", testLen+1, len(out))
48 48
 	}
49 49
 
50
-	go deleteContainer(cleanedContainerID)
50
+	deleteContainer(cleanedContainerID)
51 51
 
52 52
 	logDone("logs - logs container running echo bigger than page size")
53 53
 }
... ...
@@ -70,7 +70,7 @@ func TestLogsContainerMuchBiggerThanPage(t *testing.T) {
70 70
 		t.Fatalf("Expected log length of %d, received %d\n", testLen+1, len(out))
71 71
 	}
72 72
 
73
-	go deleteContainer(cleanedContainerID)
73
+	deleteContainer(cleanedContainerID)
74 74
 
75 75
 	logDone("logs - logs container running echo much bigger than page size")
76 76
 }
... ...
@@ -26,7 +26,7 @@ func TestPushBusyboxImage(t *testing.T) {
26 26
 	out, exitCode, err = runCommandWithOutput(pushCmd)
27 27
 	errorOut(err, t, fmt.Sprintf("%v %v", out, err))
28 28
 
29
-	go deleteImages(repoName)
29
+	deleteImages(repoName)
30 30
 
31 31
 	if err != nil || exitCode != 0 {
32 32
 		t.Fatal("pushing the image to the private registry has failed")
... ...
@@ -42,8 +42,8 @@ func TestSaveAndLoadRepo(t *testing.T) {
42 42
 	out, _, err = runCommandWithOutput(inspectCmd)
43 43
 	errorOut(err, t, fmt.Sprintf("the repo should exist after loading it: %v %v", out, err))
44 44
 
45
-	go deleteImages(repoName)
46
-	go deleteContainer(cleanedContainerID)
45
+	deleteContainer(cleanedContainerID)
46
+	deleteImages(repoName)
47 47
 
48 48
 	os.Remove("/tmp/foobar-save-load-test.tar")
49 49
 
... ...
@@ -79,7 +79,7 @@ func TestTagValidPrefixedRepo(t *testing.T) {
79 79
 			t.Errorf("tag busybox %v should have worked: %s", repo, err)
80 80
 			continue
81 81
 		}
82
-		go deleteImages(repo)
82
+		deleteImages(repo)
83 83
 		logMessage := fmt.Sprintf("tag - busybox %v", repo)
84 84
 		logDone(logMessage)
85 85
 	}
... ...
@@ -22,7 +22,7 @@ func TestTop(t *testing.T) {
22 22
 	_, err = runCommand(killCmd)
23 23
 	errorOut(err, t, fmt.Sprintf("failed to kill container: %v", err))
24 24
 
25
-	go deleteContainer(cleanedContainerID)
25
+	deleteContainer(cleanedContainerID)
26 26
 
27 27
 	if !strings.Contains(out, "sleep 20") {
28 28
 		t.Fatal("top should've listed sleep 20 in the process list")