Merge pull request #43264 from thaJeztah/fix_TestSlowStdinClosing

integration-cli: TestSlowStdinClosing: add logs, and potential naming conflict
This commit is contained in:
Sebastiaan van Stijn 2022-03-03 21:22:41 +01:00 committed by GitHub
commit eac029c868
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 17 deletions

View File

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