Skip to content

Commit

Permalink
e2e tests: synchronize test results
Browse files Browse the repository at this point in the history
Use a mutex to synchronize the slice for storing tests results.
Running the e2e tests in parallel is otherwise subject to race
conditions surfacing in lost entries.

Fixes: containers#8358
Signed-off-by: Valentin Rothberg <[email protected]>
  • Loading branch information
vrothberg committed Jan 27, 2021
1 parent 6ba8819 commit fee2fad
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/e2e/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"sort"
"strconv"
"strings"
"sync"
"testing"
"time"

Expand Down Expand Up @@ -84,6 +85,7 @@ type testResultsSortedLength struct{ testResultsSorted }
func (a testResultsSorted) Less(i, j int) bool { return a[i].length < a[j].length }

var testResults []testResult
var testResultsMutex sync.Mutex

func TestMain(m *testing.M) {
if reexec.Init() {
Expand Down Expand Up @@ -349,7 +351,9 @@ func (p *PodmanTestIntegration) InspectContainer(name string) []define.InspectCo

func processTestResult(f GinkgoTestDescription) {
tr := testResult{length: f.Duration.Seconds(), name: f.TestText}
testResultsMutex.Lock()
testResults = append(testResults, tr)
testResultsMutex.Unlock()
}

func GetPortLock(port string) storage.Locker {
Expand Down

0 comments on commit fee2fad

Please sign in to comment.