docker_cli_logs_bench_test.go 684 B

1234567891011121314151617181920212223242526272829303132
  1. package main
  2. import (
  3. "fmt"
  4. "strings"
  5. "time"
  6. "github.com/go-check/check"
  7. )
  8. func (s *DockerSuite) BenchmarkLogsCLIRotateFollow(c *check.C) {
  9. out, _ := dockerCmd(c, "run", "-d", "--log-opt", "max-size=1b", "--log-opt", "max-file=10", "busybox", "sh", "-c", "while true; do usleep 50000; echo hello; done")
  10. id := strings.TrimSpace(out)
  11. ch := make(chan error, 1)
  12. go func() {
  13. ch <- nil
  14. out, _, _ := dockerCmdWithError("logs", "-f", id)
  15. // if this returns at all, it's an error
  16. ch <- fmt.Errorf(out)
  17. }()
  18. <-ch
  19. select {
  20. case <-time.After(30 * time.Second):
  21. // ran for 30 seconds with no problem
  22. return
  23. case err := <-ch:
  24. if err != nil {
  25. c.Fatal(err)
  26. }
  27. }
  28. }