diff --git a/integration-cli/docker_cli_events_test.go b/integration-cli/docker_cli_events_test.go index 9fd4318245..69175eb1f8 100644 --- a/integration-cli/docker_cli_events_test.go +++ b/integration-cli/docker_cli_events_test.go @@ -10,7 +10,6 @@ import ( "os" "os/exec" "strings" - "sync" "time" eventtypes "github.com/docker/docker/api/types/events" @@ -79,14 +78,17 @@ func (s *DockerSuite) TestEventsUntag(c *check.C) { } func (s *DockerSuite) TestEventsLimit(c *check.C) { - var waitGroup sync.WaitGroup - errChan := make(chan error, 17) + // Limit to 8 goroutines creating containers in order to prevent timeouts + // creating so many containers simultaneously on Windows + sem := make(chan bool, 8) + numContainers := 17 + errChan := make(chan error, numContainers) args := []string{"run", "--rm", "busybox", "true"} - for i := 0; i < 17; i++ { - waitGroup.Add(1) + for i := 0; i < numContainers; i++ { + sem <- true go func() { - defer waitGroup.Done() + defer func() { <-sem }() out, err := exec.Command(dockerBinary, args...).CombinedOutput() if err != nil { err = fmt.Errorf("%v: %s", err, string(out)) @@ -95,7 +97,10 @@ func (s *DockerSuite) TestEventsLimit(c *check.C) { }() } - waitGroup.Wait() + // Wait for all goroutines to finish + for i := 0; i < cap(sem); i++ { + sem <- true + } close(errChan) for err := range errChan {