From 5a02c9ba0a8e4dc19001a11d00049ec2c76511f0 Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Tue, 23 Apr 2013 10:28:40 -0700 Subject: [PATCH] Make sure the container is well started prior to perform the test --- runtime_test.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/runtime_test.go b/runtime_test.go index 3964549412..1c2634f1d8 100644 --- a/runtime_test.go +++ b/runtime_test.go @@ -273,7 +273,16 @@ func TestAllocatePortLocalhost(t *testing.T) { t.Fatal(err) } defer container.Kill() - time.Sleep(600 * time.Millisecond) // Wait for the container to run + + setTimeout(t, "Waiting for the container to be started timed out", 2*time.Second, func() { + for { + if container.State.Running { + break + } + time.Sleep(10 * time.Millisecond) + } + }) + conn, err := net.Dial("tcp", fmt.Sprintf( "localhost:%s", container.NetworkSettings.PortMapping["5555"], @@ -293,6 +302,7 @@ func TestAllocatePortLocalhost(t *testing.T) { string(output), ) } + container.Wait() } func TestRestore(t *testing.T) {