Merge pull request #26968 from darrenstahlmsft/TestEventsFix

Limit conccurent container creates in TestEventsLimit to 8
This commit is contained in:
Michael Crosby 2016-09-30 16:29:01 -07:00 committed by GitHub
commit 18338427ed

View file

@ -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 {