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"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
eventtypes "github.com/docker/docker/api/types/events"
|
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) {
|
func (s *DockerSuite) TestEventsLimit(c *check.C) {
|
||||||
var waitGroup sync.WaitGroup
|
// Limit to 8 goroutines creating containers in order to prevent timeouts
|
||||||
errChan := make(chan error, 17)
|
// 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"}
|
args := []string{"run", "--rm", "busybox", "true"}
|
||||||
for i := 0; i < 17; i++ {
|
for i := 0; i < numContainers; i++ {
|
||||||
waitGroup.Add(1)
|
sem <- true
|
||||||
go func() {
|
go func() {
|
||||||
defer waitGroup.Done()
|
defer func() { <-sem }()
|
||||||
out, err := exec.Command(dockerBinary, args...).CombinedOutput()
|
out, err := exec.Command(dockerBinary, args...).CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("%v: %s", err, string(out))
|
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)
|
close(errChan)
|
||||||
|
|
||||||
for err := range errChan {
|
for err := range errChan {
|
||||||
|
|
Loading…
Reference in a new issue