Limit conccurent container creates in TestEventsLimit to 8
Signed-off-by: Darren Stahl <darst@microsoft.com>
This commit is contained in:
parent
b8265e5550
commit
728a265190
1 changed files with 12 additions and 7 deletions
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue