|
@@ -481,6 +481,17 @@ func TestAttachDetach(t *testing.T) {
|
|
|
|
|
|
var container *docker.Container
|
|
var container *docker.Container
|
|
|
|
|
|
|
|
+ setTimeout(t, "Waiting for the container to be started timed out", 10*time.Second, func() {
|
|
|
|
+ for {
|
|
|
|
+ l := globalRuntime.List()
|
|
|
|
+ if len(l) == 1 && l[0].State.IsRunning() {
|
|
|
|
+ container = l[0]
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ time.Sleep(10 * time.Millisecond)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+
|
|
setTimeout(t, "Reading container's id timed out", 10*time.Second, func() {
|
|
setTimeout(t, "Reading container's id timed out", 10*time.Second, func() {
|
|
buf := make([]byte, 1024)
|
|
buf := make([]byte, 1024)
|
|
n, err := stdout.Read(buf)
|
|
n, err := stdout.Read(buf)
|
|
@@ -488,8 +499,6 @@ func TestAttachDetach(t *testing.T) {
|
|
t.Fatal(err)
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
|
|
|
|
- container = globalRuntime.List()[0]
|
|
|
|
-
|
|
|
|
if strings.Trim(string(buf[:n]), " \r\n") != container.ID {
|
|
if strings.Trim(string(buf[:n]), " \r\n") != container.ID {
|
|
t.Fatalf("Wrong ID received. Expect %s, received %s", container.ID, buf[:n])
|
|
t.Fatalf("Wrong ID received. Expect %s, received %s", container.ID, buf[:n])
|
|
}
|
|
}
|