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:
parent
496a4bd15e
commit
3f0abde50d
1 changed files with 19 additions and 17 deletions
|
@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue