瀏覽代碼

Merge pull request #21035 from LK4D4/exec_ids

make TestExecInspectIDs less racy
David Calavera 9 年之前
父節點
當前提交
76a5ab3b43
共有 1 個文件被更改,包括 12 次插入7 次删除
  1. 12 7
      integration-cli/docker_cli_exec_test.go

+ 12 - 7
integration-cli/docker_cli_exec_test.go

@@ -313,13 +313,12 @@ func (s *DockerSuite) TestExecInspectID(c *check.C) {
 	tries := 10
 	tries := 10
 	for i := 0; i < tries; i++ {
 	for i := 0; i < tries; i++ {
 		// Since its still running we should see exec as part of the container
 		// Since its still running we should see exec as part of the container
-		out = inspectField(c, id, "ExecIDs")
+		out = strings.TrimSpace(inspectField(c, id, "ExecIDs"))
 
 
-		out = strings.TrimSuffix(out, "\n")
 		if out != "[]" && out != "<no value>" {
 		if out != "[]" && out != "<no value>" {
 			break
 			break
 		}
 		}
-		c.Assert(i+1, checker.Not(checker.Equals), tries, check.Commentf("ExecIDs should be empty, got: %s", out))
+		c.Assert(i+1, checker.Not(checker.Equals), tries, check.Commentf("ExecIDs still empty after 10 second"))
 		time.Sleep(1 * time.Second)
 		time.Sleep(1 * time.Second)
 	}
 	}
 
 
@@ -336,11 +335,17 @@ func (s *DockerSuite) TestExecInspectID(c *check.C) {
 	// Wait for 1st exec to complete
 	// Wait for 1st exec to complete
 	cmd.Wait()
 	cmd.Wait()
 
 
-	// All execs for the container should be gone now
-	out = inspectField(c, id, "ExecIDs")
+	// Give the exec 10 chances/seconds to stop then give up and stop the test
+	for i := 0; i < tries; i++ {
+		// Since its still running we should see exec as part of the container
+		out = strings.TrimSpace(inspectField(c, id, "ExecIDs"))
 
 
-	out = strings.TrimSuffix(out, "\n")
-	c.Assert(out == "[]" || out == "<no value>", checker.True)
+		if out == "[]" {
+			break
+		}
+		c.Assert(i+1, checker.Not(checker.Equals), tries, check.Commentf("ExecIDs still not empty after 10 second"))
+		time.Sleep(1 * time.Second)
+	}
 
 
 	// But we should still be able to query the execID
 	// But we should still be able to query the execID
 	sc, body, err := sockRequest("GET", "/exec/"+execID+"/json", nil)
 	sc, body, err := sockRequest("GET", "/exec/"+execID+"/json", nil)