浏览代码

Make race condition more obvious by performing more asserts

Guillaume J. Charmes 11 年之前
父节点
当前提交
ad43d88af5
共有 4 个文件被更改,包括 13 次插入13 次删除
  1. 3 3
      integration/api_test.go
  2. 7 7
      integration/commands_test.go
  3. 1 1
      integration/container_test.go
  4. 2 2
      integration/server_test.go

+ 3 - 3
integration/api_test.go

@@ -454,7 +454,7 @@ func TestGetContainersTop(t *testing.T) {
 	// Make sure sh spawn up cat
 	// Make sure sh spawn up cat
 	setTimeout(t, "read/write assertion timed out", 2*time.Second, func() {
 	setTimeout(t, "read/write assertion timed out", 2*time.Second, func() {
 		in, out := containerAttach(eng, containerID, t)
 		in, out := containerAttach(eng, containerID, t)
-		if err := assertPipe("hello\n", "hello", out, in, 15); err != nil {
+		if err := assertPipe("hello\n", "hello", out, in, 150); err != nil {
 			t.Fatal(err)
 			t.Fatal(err)
 		}
 		}
 	})
 	})
@@ -877,7 +877,7 @@ func TestPostContainersAttach(t *testing.T) {
 	})
 	})
 
 
 	setTimeout(t, "read/write assertion timed out", 2*time.Second, func() {
 	setTimeout(t, "read/write assertion timed out", 2*time.Second, func() {
-		if err := assertPipe("hello\n", string([]byte{1, 0, 0, 0, 0, 0, 0, 6})+"hello", stdout, stdinPipe, 15); err != nil {
+		if err := assertPipe("hello\n", string([]byte{1, 0, 0, 0, 0, 0, 0, 6})+"hello", stdout, stdinPipe, 150); err != nil {
 			t.Fatal(err)
 			t.Fatal(err)
 		}
 		}
 	})
 	})
@@ -956,7 +956,7 @@ func TestPostContainersAttachStderr(t *testing.T) {
 	})
 	})
 
 
 	setTimeout(t, "read/write assertion timed out", 2*time.Second, func() {
 	setTimeout(t, "read/write assertion timed out", 2*time.Second, func() {
-		if err := assertPipe("hello\n", string([]byte{2, 0, 0, 0, 0, 0, 0, 6})+"hello", stdout, stdinPipe, 15); err != nil {
+		if err := assertPipe("hello\n", string([]byte{2, 0, 0, 0, 0, 0, 0, 6})+"hello", stdout, stdinPipe, 150); err != nil {
 			t.Fatal(err)
 			t.Fatal(err)
 		}
 		}
 	})
 	})

+ 7 - 7
integration/commands_test.go

@@ -213,7 +213,7 @@ func TestRunExit(t *testing.T) {
 	}()
 	}()
 
 
 	setTimeout(t, "Read/Write assertion timed out", 2*time.Second, func() {
 	setTimeout(t, "Read/Write assertion timed out", 2*time.Second, func() {
-		if err := assertPipe("hello\n", "hello", stdout, stdinPipe, 15); err != nil {
+		if err := assertPipe("hello\n", "hello", stdout, stdinPipe, 150); err != nil {
 			t.Fatal(err)
 			t.Fatal(err)
 		}
 		}
 	})
 	})
@@ -268,7 +268,7 @@ func TestRunDisconnect(t *testing.T) {
 	}()
 	}()
 
 
 	setTimeout(t, "Read/Write assertion timed out", 2*time.Second, func() {
 	setTimeout(t, "Read/Write assertion timed out", 2*time.Second, func() {
-		if err := assertPipe("hello\n", "hello", stdout, stdinPipe, 15); err != nil {
+		if err := assertPipe("hello\n", "hello", stdout, stdinPipe, 150); err != nil {
 			t.Fatal(err)
 			t.Fatal(err)
 		}
 		}
 	})
 	})
@@ -330,7 +330,7 @@ func TestRunDisconnectTty(t *testing.T) {
 	container := globalRuntime.List()[0]
 	container := globalRuntime.List()[0]
 
 
 	setTimeout(t, "Read/Write assertion timed out", 2*time.Second, func() {
 	setTimeout(t, "Read/Write assertion timed out", 2*time.Second, func() {
-		if err := assertPipe("hello\n", "hello", stdout, stdinPipe, 15); err != nil {
+		if err := assertPipe("hello\n", "hello", stdout, stdinPipe, 150); err != nil {
 			t.Fatal(err)
 			t.Fatal(err)
 		}
 		}
 	})
 	})
@@ -432,7 +432,7 @@ func TestRunDetach(t *testing.T) {
 	}()
 	}()
 
 
 	setTimeout(t, "First read/write assertion timed out", 2*time.Second, func() {
 	setTimeout(t, "First read/write assertion timed out", 2*time.Second, func() {
-		if err := assertPipe("hello\n", "hello", stdout, stdinPipe, 15); err != nil {
+		if err := assertPipe("hello\n", "hello", stdout, stdinPipe, 150); err != nil {
 			t.Fatal(err)
 			t.Fatal(err)
 		}
 		}
 	})
 	})
@@ -513,7 +513,7 @@ func TestAttachDetach(t *testing.T) {
 	}()
 	}()
 
 
 	setTimeout(t, "First read/write assertion timed out", 2*time.Second, func() {
 	setTimeout(t, "First read/write assertion timed out", 2*time.Second, func() {
-		if err := assertPipe("hello\n", "hello", stdout, stdinPipe, 15); err != nil {
+		if err := assertPipe("hello\n", "hello", stdout, stdinPipe, 150); err != nil {
 			if err != io.ErrClosedPipe {
 			if err != io.ErrClosedPipe {
 				t.Fatal(err)
 				t.Fatal(err)
 			}
 			}
@@ -575,7 +575,7 @@ func TestAttachDetachTruncatedID(t *testing.T) {
 	}()
 	}()
 
 
 	setTimeout(t, "First read/write assertion timed out", 2*time.Second, func() {
 	setTimeout(t, "First read/write assertion timed out", 2*time.Second, func() {
-		if err := assertPipe("hello\n", "hello", stdout, stdinPipe, 15); err != nil {
+		if err := assertPipe("hello\n", "hello", stdout, stdinPipe, 150); err != nil {
 			if err != io.ErrClosedPipe {
 			if err != io.ErrClosedPipe {
 				t.Fatal(err)
 				t.Fatal(err)
 			}
 			}
@@ -648,7 +648,7 @@ func TestAttachDisconnect(t *testing.T) {
 	}()
 	}()
 
 
 	setTimeout(t, "First read/write assertion timed out", 2*time.Second, func() {
 	setTimeout(t, "First read/write assertion timed out", 2*time.Second, func() {
-		if err := assertPipe("hello\n", "hello", stdout, stdinPipe, 15); err != nil {
+		if err := assertPipe("hello\n", "hello", stdout, stdinPipe, 150); err != nil {
 			t.Fatal(err)
 			t.Fatal(err)
 		}
 		}
 	})
 	})

+ 1 - 1
integration/container_test.go

@@ -462,7 +462,7 @@ func TestKillDifferentUser(t *testing.T) {
 	setTimeout(t, "read/write assertion timed out", 2*time.Second, func() {
 	setTimeout(t, "read/write assertion timed out", 2*time.Second, func() {
 		out, _ := container.StdoutPipe()
 		out, _ := container.StdoutPipe()
 		in, _ := container.StdinPipe()
 		in, _ := container.StdinPipe()
-		if err := assertPipe("hello\n", "hello", out, in, 15); err != nil {
+		if err := assertPipe("hello\n", "hello", out, in, 150); err != nil {
 			t.Fatal(err)
 			t.Fatal(err)
 		}
 		}
 	})
 	})

+ 2 - 2
integration/server_test.go

@@ -183,11 +183,11 @@ func TestCreateStartRestartStopStartKillRm(t *testing.T) {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
 
 
-	if err := srv.ContainerRestart(id, 15); err != nil {
+	if err := srv.ContainerRestart(id, 150); err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
 
 
-	if err := srv.ContainerStop(id, 15); err != nil {
+	if err := srv.ContainerStop(id, 150); err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}