From e535f544c7bc9c32b23e5505110a5513ff36be5a Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Fri, 29 Nov 2013 07:39:51 -0800 Subject: [PATCH] Make sure the container is running before testing against it (TestAttachDetach) --- integration/commands_test.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/integration/commands_test.go b/integration/commands_test.go index 7daebf3cd2..8bc1c99ec7 100644 --- a/integration/commands_test.go +++ b/integration/commands_test.go @@ -481,6 +481,17 @@ func TestAttachDetach(t *testing.T) { 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() { buf := make([]byte, 1024) n, err := stdout.Read(buf) @@ -488,8 +499,6 @@ func TestAttachDetach(t *testing.T) { t.Fatal(err) } - container = globalRuntime.List()[0] - if strings.Trim(string(buf[:n]), " \r\n") != container.ID { t.Fatalf("Wrong ID received. Expect %s, received %s", container.ID, buf[:n]) }