Browse code

Increase time before exit in TestMultipleAttachRestart

Sometimes third attacher attaching to already stopped container.
Also I've changed prefix to attach and fixed cleanup on Fatal.
Docker-DCO-1.1-Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com> (github: LK4D4)

LK4D4 authored on 2014/06/14 02:32:25
Showing 1 changed files
... ...
@@ -10,11 +10,19 @@ import (
10 10
 
11 11
 func TestMultipleAttachRestart(t *testing.T) {
12 12
 	cmd := exec.Command(dockerBinary, "run", "--name", "attacher", "-d", "busybox",
13
-		"/bin/sh", "-c", "sleep 1 && echo hello")
13
+		"/bin/sh", "-c", "sleep 2 && echo hello")
14 14
 
15 15
 	group := sync.WaitGroup{}
16 16
 	group.Add(4)
17 17
 
18
+	defer func() {
19
+		cmd = exec.Command(dockerBinary, "kill", "attacher")
20
+		if _, err := runCommand(cmd); err != nil {
21
+			t.Fatal(err)
22
+		}
23
+		deleteAllContainers()
24
+	}()
25
+
18 26
 	go func() {
19 27
 		defer group.Done()
20 28
 		out, _, err := runCommandWithOutput(cmd)
... ...
@@ -41,11 +49,5 @@ func TestMultipleAttachRestart(t *testing.T) {
41 41
 
42 42
 	group.Wait()
43 43
 
44
-	cmd = exec.Command(dockerBinary, "kill", "attacher")
45
-	if _, err := runCommand(cmd); err != nil {
46
-		t.Fatal(err)
47
-	}
48
-	deleteAllContainers()
49
-
50
-	logDone("run - multiple attach")
44
+	logDone("attach - multiple attach")
51 45
 }