Fix horribly broken TestGetContainerStatsNoStream
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
parent
ae4ee974e8
commit
3434860d54
|
@ -416,22 +416,30 @@ func (s *DockerSuite) TestGetContainerStatsNoStream(c *check.C) {
|
||||||
func (s *DockerSuite) TestGetStoppedContainerStats(c *check.C) {
|
func (s *DockerSuite) TestGetStoppedContainerStats(c *check.C) {
|
||||||
// Problematic on Windows as Windows does not support stats
|
// Problematic on Windows as Windows does not support stats
|
||||||
testRequires(c, DaemonIsLinux)
|
testRequires(c, DaemonIsLinux)
|
||||||
// TODO: this test does nothing because we are c.Assert'ing in goroutine
|
name := "statscontainer"
|
||||||
var (
|
|
||||||
name = "statscontainer"
|
|
||||||
)
|
|
||||||
dockerCmd(c, "create", "--name", name, "busybox", "top")
|
dockerCmd(c, "create", "--name", name, "busybox", "top")
|
||||||
|
|
||||||
|
type stats struct {
|
||||||
|
status int
|
||||||
|
err error
|
||||||
|
}
|
||||||
|
chResp := make(chan stats)
|
||||||
|
|
||||||
|
// We expect an immediate response, but if it's not immediate, the test would hang, so put it in a goroutine
|
||||||
|
// below we'll check this on a timeout.
|
||||||
go func() {
|
go func() {
|
||||||
// We'll never get return for GET stats from sockRequest as of now,
|
resp, body, err := sockRequestRaw("GET", "/containers/"+name+"/stats", nil, "")
|
||||||
// just send request and see if panic or error would happen on daemon side.
|
body.Close()
|
||||||
status, _, err := sockRequest("GET", "/containers/"+name+"/stats", nil)
|
chResp <- stats{resp.StatusCode, err}
|
||||||
c.Assert(err, checker.IsNil)
|
|
||||||
c.Assert(status, checker.Equals, http.StatusOK)
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// allow some time to send request and let daemon deal with it
|
select {
|
||||||
time.Sleep(1 * time.Second)
|
case r := <-chResp:
|
||||||
|
c.Assert(r.err, checker.IsNil)
|
||||||
|
c.Assert(r.status, checker.Equals, http.StatusOK)
|
||||||
|
case <-time.After(10 * time.Second):
|
||||||
|
c.Fatal("timeout waiting for stats reponse for stopped container")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// #9981 - Allow a docker created volume (ie, one in /var/lib/docker/volumes) to be used to overwrite (via passing in Binds on api start) an existing volume
|
// #9981 - Allow a docker created volume (ie, one in /var/lib/docker/volumes) to be used to overwrite (via passing in Binds on api start) an existing volume
|
||||||
|
|
Loading…
Reference in New Issue