Merge pull request #19570 from WeiZhang555/18679-flaky-test
Fix flaky test `TestGetContainerStatsRmRunning`
This commit is contained in:
commit
a898478a79
|
@ -303,7 +303,7 @@ func (s *DockerSuite) TestGetContainerStatsRmRunning(c *check.C) {
|
||||||
|
|
||||||
buf := &integration.ChannelBuffer{make(chan []byte, 1)}
|
buf := &integration.ChannelBuffer{make(chan []byte, 1)}
|
||||||
defer buf.Close()
|
defer buf.Close()
|
||||||
chErr := make(chan error)
|
chErr := make(chan error, 1)
|
||||||
go func() {
|
go func() {
|
||||||
_, body, err := sockRequestRaw("GET", "/containers/"+id+"/stats?stream=1", nil, "application/json")
|
_, body, err := sockRequestRaw("GET", "/containers/"+id+"/stats?stream=1", nil, "application/json")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -314,7 +314,12 @@ func (s *DockerSuite) TestGetContainerStatsRmRunning(c *check.C) {
|
||||||
chErr <- err
|
chErr <- err
|
||||||
}()
|
}()
|
||||||
defer func() {
|
defer func() {
|
||||||
c.Assert(<-chErr, checker.IsNil)
|
select {
|
||||||
|
case err := <-chErr:
|
||||||
|
c.Assert(err, checker.IsNil)
|
||||||
|
default:
|
||||||
|
return
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
b := make([]byte, 32)
|
b := make([]byte, 32)
|
||||||
|
@ -327,10 +332,8 @@ func (s *DockerSuite) TestGetContainerStatsRmRunning(c *check.C) {
|
||||||
c.Assert(err, checker.Not(checker.IsNil), check.Commentf("rm should have failed but didn't"))
|
c.Assert(err, checker.Not(checker.IsNil), check.Commentf("rm should have failed but didn't"))
|
||||||
_, err = buf.ReadTimeout(b, 2*time.Second)
|
_, err = buf.ReadTimeout(b, 2*time.Second)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
dockerCmd(c, "rm", "-f", id)
|
|
||||||
|
|
||||||
_, err = buf.ReadTimeout(b, 2*time.Second)
|
dockerCmd(c, "kill", id)
|
||||||
c.Assert(err, checker.Not(checker.IsNil))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// regression test for gh13421
|
// regression test for gh13421
|
||||||
|
|
Loading…
Reference in New Issue