From b047c92e1cdb76635ff19d80b97c3d40e1901bdf Mon Sep 17 00:00:00 2001 From: Stephen J Day Date: Tue, 2 Dec 2014 20:43:31 -0800 Subject: [PATCH] Use sync.WaitGroup to control concurrent tests --- storagedriver/testsuites/testsuites.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/storagedriver/testsuites/testsuites.go b/storagedriver/testsuites/testsuites.go index c2604f4f..92f7454d 100644 --- a/storagedriver/testsuites/testsuites.go +++ b/storagedriver/testsuites/testsuites.go @@ -7,6 +7,7 @@ import ( "os" "path" "sort" + "sync" "testing" "github.com/docker/docker-registry/storagedriver" @@ -386,13 +387,14 @@ func (suite *DriverSuite) TestConcurrentFileStreams(c *check.C) { c.Skip("Need to fix out-of-process concurrency") } - doneChan := make(chan struct{}) + var wg sync.WaitGroup testStream := func(size int64) { + defer wg.Done() suite.testFileStreams(c, size) - doneChan <- struct{}{} } + wg.Add(6) go testStream(8 * 1024 * 1024) go testStream(4 * 1024 * 1024) go testStream(2 * 1024 * 1024) @@ -400,10 +402,7 @@ func (suite *DriverSuite) TestConcurrentFileStreams(c *check.C) { go testStream(1024) go testStream(64) - for i := 0; i < 6; i++ { - <-doneChan - } - + wg.Wait() } func (suite *DriverSuite) testFileStreams(c *check.C, size int64) {