2015-02-13 19:45:04 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os/exec"
|
|
|
|
"strings"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/go-check/check"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (s *DockerSuite) TestCliStatsNoStream(c *check.C) {
|
2015-07-20 09:44:22 +03:00
|
|
|
out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
|
2015-02-13 19:45:04 +03:00
|
|
|
id := strings.TrimSpace(out)
|
|
|
|
if err := waitRun(id); err != nil {
|
|
|
|
c.Fatalf("error waiting for container to start: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
statsCmd := exec.Command(dockerBinary, "stats", "--no-stream", id)
|
|
|
|
chErr := make(chan error)
|
|
|
|
go func() {
|
|
|
|
chErr <- statsCmd.Run()
|
|
|
|
}()
|
|
|
|
|
|
|
|
select {
|
|
|
|
case err := <-chErr:
|
|
|
|
if err != nil {
|
|
|
|
c.Fatalf("Error running stats: %v", err)
|
|
|
|
}
|
2015-05-30 20:25:51 +03:00
|
|
|
case <-time.After(3 * time.Second):
|
2015-02-13 19:45:04 +03:00
|
|
|
statsCmd.Process.Kill()
|
|
|
|
c.Fatalf("stats did not return immediately when not streaming")
|
|
|
|
}
|
|
|
|
}
|