Skip to content

Commit

Permalink
execute up to two tests concurrently
Browse files Browse the repository at this point in the history
  • Loading branch information
qu0b committed Feb 22, 2024
1 parent f1a2c8a commit 3a74706
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkg/coordinator/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 {
Expand Down

0 comments on commit 3a74706

Please sign in to comment.