mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Parallelize TestEventsLimit
Signed-off-by: Lorenzo Fontana <fontanalorenzo@me.com>
This commit is contained in:
parent
531ec3cac9
commit
40779b28bb
1 changed files with 23 additions and 2 deletions
|
@ -7,6 +7,7 @@ import (
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-check/check"
|
"github.com/go-check/check"
|
||||||
|
@ -65,9 +66,29 @@ func (s *DockerSuite) TestEventsContainerFailStartDie(c *check.C) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *DockerSuite) TestEventsLimit(c *check.C) {
|
func (s *DockerSuite) TestEventsLimit(c *check.C) {
|
||||||
for i := 0; i < 30; i++ {
|
|
||||||
dockerCmd(c, "run", "busybox", "echo", strconv.Itoa(i))
|
var waitGroup sync.WaitGroup
|
||||||
|
errChan := make(chan error, 17)
|
||||||
|
|
||||||
|
args := []string{"run", "--rm", "busybox", "true"}
|
||||||
|
for i := 0; i < 17; i++ {
|
||||||
|
waitGroup.Add(1)
|
||||||
|
go func() {
|
||||||
|
defer waitGroup.Done()
|
||||||
|
err := exec.Command(dockerBinary, args...).Run()
|
||||||
|
errChan <- err
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
waitGroup.Wait()
|
||||||
|
close(errChan)
|
||||||
|
|
||||||
|
for err := range errChan {
|
||||||
|
if err != nil {
|
||||||
|
c.Fatalf("%q failed with error: %v", strings.Join(args, " "), err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
eventsCmd := exec.Command(dockerBinary, "events", "--since=0", fmt.Sprintf("--until=%d", daemonTime(c).Unix()))
|
eventsCmd := exec.Command(dockerBinary, "events", "--since=0", fmt.Sprintf("--until=%d", daemonTime(c).Unix()))
|
||||||
out, _, _ := runCommandWithOutput(eventsCmd)
|
out, _, _ := runCommandWithOutput(eventsCmd)
|
||||||
events := strings.Split(out, "\n")
|
events := strings.Split(out, "\n")
|
||||||
|
|
Loading…
Reference in a new issue