From d696ecdba558806d790fed0087776e43764f03f3 Mon Sep 17 00:00:00 2001 From: Yifan Gu Date: Thu, 9 Apr 2015 18:36:32 -0700 Subject: [PATCH] integration: Randomize the order of the integration tests. --- cmd/integration/integration.go | 36 +++++++++++++++++----------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/cmd/integration/integration.go b/cmd/integration/integration.go index 7d73ef7947..fdff8ee62f 100644 --- a/cmd/integration/integration.go +++ b/cmd/integration/integration.go @@ -999,25 +999,25 @@ func main() { } // Only run at most maxConcurrency tests in parallel. - numFinishedTests := 0 - for numFinishedTests < len(testFuncs) { - numTestsToRun := len(testFuncs) - numFinishedTests - if maxConcurrency > 0 && numTestsToRun > maxConcurrency { - numTestsToRun = maxConcurrency - } - glog.Infof("Running %d tests in parallel.", numTestsToRun) - var wg sync.WaitGroup - wg.Add(numTestsToRun) - for i := 0; i < numTestsToRun; i++ { - f := testFuncs[i+numFinishedTests] - go func() { - f(kubeClient) - wg.Done() - }() - } - wg.Wait() - numFinishedTests += numTestsToRun + if maxConcurrency <= 0 { + maxConcurrency = len(testFuncs) } + glog.Infof("Running %d tests in parallel.", maxConcurrency) + ch := make(chan struct{}, maxConcurrency) + + var wg sync.WaitGroup + wg.Add(len(testFuncs)) + for i := range testFuncs { + f := testFuncs[i] + go func() { + ch <- struct{}{} + f(kubeClient) + <-ch + wg.Done() + }() + } + wg.Wait() + close(ch) // Check that kubelet tried to make the containers. // Using a set to list unique creation attempts. Our fake is