Sfoglia il codice sorgente

integration-cli: TestSlowStdinClosing: use sub-tests

Use sub-tests so that the iterations can run in parallel (instead of
sequential), and to make failures show up for the iteration that they're
part of.

Note that changing to subtests means that we'll always run 3 iterations of
the test, and no longer fail early (but the test still fails if any of
those iterations fails.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 3 anni fa
parent
commit
3f0abde50d
1 ha cambiato i file con 20 aggiunte e 18 eliminazioni
  1. 20 18
      integration-cli/docker_cli_run_test.go

+ 20 - 18
integration-cli/docker_cli_run_test.go

@@ -4159,25 +4159,27 @@ func (s *DockerSuite) TestRunEmptyEnv(c *testing.T) {
 func (s *DockerSuite) TestSlowStdinClosing(c *testing.T) {
 	const repeat = 3 // regression happened 50% of the time
 	for i := 0; i < repeat; i++ {
-		cmd := icmd.Cmd{
-			Command: []string{dockerBinary, "run", "--rm", "-i", "busybox", "cat"},
-			Stdin:   &delayedReader{},
-		}
-		done := make(chan error, 1)
-		go func() {
-			result := icmd.RunCmd(cmd)
-			if out := result.Combined(); out != "" {
-				c.Log(out)
+		c.Run(strconv.Itoa(i), func(c *testing.T) {
+			cmd := icmd.Cmd{
+				Command: []string{dockerBinary, "run", "--rm", "-i", "busybox", "cat"},
+				Stdin:   &delayedReader{},
 			}
-			done <- result.Error
-		}()
-
-		select {
-		case <-time.After(30 * time.Second):
-			c.Fatal("running container timed out") // cleanup in teardown
-		case err := <-done:
-			assert.NilError(c, err)
-		}
+			done := make(chan error, 1)
+			go func() {
+				result := icmd.RunCmd(cmd)
+				if out := result.Combined(); out != "" {
+					c.Log(out)
+				}
+				done <- result.Error
+			}()
+
+			select {
+			case <-time.After(30 * time.Second):
+				c.Fatal("running container timed out") // cleanup in teardown
+			case err := <-done:
+				assert.NilError(c, err)
+			}
+		})
 	}
 }