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>
This commit is contained in:
Sebastiaan van Stijn 2022-02-20 13:30:16 +01:00
parent 496a4bd15e
commit 3f0abde50d
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -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
}()
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)
}
select {
case <-time.After(30 * time.Second):
c.Fatal("running container timed out") // cleanup in teardown
case err := <-done:
assert.NilError(c, err)
}
})
}
}