Browse code

Flaky test: TestRunAttachFailedNoLeak (#21247)

This pull request tries to diagnosis and fix the flaky test of
TestRunAttachFailedNoLeak. The test failed several times in
Docker CI but is very difficult to repeat even in CI.

This pull request first try to repeat the issue at the Jenkins
server with some diagnosis message added to the output in case
the test fails again.

Since the added ouputs will only be invoked when test fails,
it will not add any unnecessary content in normal situations.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

Yong Tang authored on 2016/03/19 12:24:57
Showing 1 changed files
... ...
@@ -4230,8 +4230,11 @@ func (s *DockerSuite) TestRunAttachFailedNoLeak(c *check.C) {
4230 4230
 	// Wait until container is fully up and running
4231 4231
 	c.Assert(waitRun("test"), check.IsNil)
4232 4232
 
4233
-	out, _, err := dockerCmdWithError("run", "-p", "8000:8000", "busybox", "true")
4234
-	c.Assert(err, checker.NotNil)
4233
+	out, _, err := dockerCmdWithError("run", "--name=fail", "-p", "8000:8000", "busybox", "true")
4234
+	// We will need the following `inspect` to diagnose the issue if test fails (#21247)
4235
+	out1, err1 := dockerCmd(c, "inspect", "--format", "{{json .State}}", "test")
4236
+	out2, err2 := dockerCmd(c, "inspect", "--format", "{{json .State}}", "fail")
4237
+	c.Assert(err, checker.NotNil, check.Commentf("Command should have failed but succeeded with: %s\nContainer 'test' [%+v]: %s\nContainer 'fail' [%+v]: %s", out, err1, out1, err2, out2))
4235 4238
 	// check for windows error as well
4236 4239
 	// TODO Windows Post TP5. Fix the error message string
4237 4240
 	c.Assert(strings.Contains(string(out), "port is already allocated") ||