Browse code

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 authored on 2022/02/20 21:30:16
Showing 1 changed files
... ...
@@ -4159,25 +4159,27 @@ func (s *DockerSuite) TestRunEmptyEnv(c *testing.T) {
4159 4159
 func (s *DockerSuite) TestSlowStdinClosing(c *testing.T) {
4160 4160
 	const repeat = 3 // regression happened 50% of the time
4161 4161
 	for i := 0; i < repeat; i++ {
4162
-		cmd := icmd.Cmd{
4163
-			Command: []string{dockerBinary, "run", "--rm", "-i", "busybox", "cat"},
4164
-			Stdin:   &delayedReader{},
4165
-		}
4166
-		done := make(chan error, 1)
4167
-		go func() {
4168
-			result := icmd.RunCmd(cmd)
4169
-			if out := result.Combined(); out != "" {
4170
-				c.Log(out)
4162
+		c.Run(strconv.Itoa(i), func(c *testing.T) {
4163
+			cmd := icmd.Cmd{
4164
+				Command: []string{dockerBinary, "run", "--rm", "-i", "busybox", "cat"},
4165
+				Stdin:   &delayedReader{},
4171 4166
 			}
4172
-			done <- result.Error
4173
-		}()
4174
-
4175
-		select {
4176
-		case <-time.After(30 * time.Second):
4177
-			c.Fatal("running container timed out") // cleanup in teardown
4178
-		case err := <-done:
4179
-			assert.NilError(c, err)
4180
-		}
4167
+			done := make(chan error, 1)
4168
+			go func() {
4169
+				result := icmd.RunCmd(cmd)
4170
+				if out := result.Combined(); out != "" {
4171
+					c.Log(out)
4172
+				}
4173
+				done <- result.Error
4174
+			}()
4175
+
4176
+			select {
4177
+			case <-time.After(30 * time.Second):
4178
+				c.Fatal("running container timed out") // cleanup in teardown
4179
+			case err := <-done:
4180
+				assert.NilError(c, err)
4181
+			}
4182
+		})
4181 4183
 	}
4182 4184
 }
4183 4185