From 3a74706f0b3b39cdc6841a49b70cc9718cc2f6da Mon Sep 17 00:00:00 2001 From: Stefan Date: Thu, 22 Feb 2024 17:27:08 -0500 Subject: [PATCH] execute up to two tests concurrently --- pkg/coordinator/coordinator.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pkg/coordinator/coordinator.go b/pkg/coordinator/coordinator.go index 94cf8a6..c614ea8 100644 --- a/pkg/coordinator/coordinator.go +++ b/pkg/coordinator/coordinator.go @@ -267,6 +267,9 @@ func (c *Coordinator) createTestRun(descriptor types.TestDescriptor, configOverr } func (c *Coordinator) runTestExecutionLoop(ctx context.Context) { + maxConcurrentTests := 2 + semaphore := make(chan bool, maxConcurrentTests) + for { var nextTest types.Test @@ -279,8 +282,16 @@ func (c *Coordinator) runTestExecutionLoop(ctx context.Context) { c.testRegistryMutex.Unlock() if nextTest != nil { + // run next test - c.runTest(ctx, nextTest) + semaphore <- true + go func(nextTest types.Test) { + c.runTest(ctx, nextTest) + defer func() { + <-semaphore + }() + }(nextTest) + } else { // sleep and wait for queue notification select {