mirror of
https://github.com/containers/podman.git
synced 2025-06-19 00:06:43 +08:00
e2e tests: synchronize test results
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: #8358 Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
This commit is contained in:
@ -10,6 +10,7 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -84,6 +85,7 @@ type testResultsSortedLength struct{ testResultsSorted }
|
|||||||
func (a testResultsSorted) Less(i, j int) bool { return a[i].length < a[j].length }
|
func (a testResultsSorted) Less(i, j int) bool { return a[i].length < a[j].length }
|
||||||
|
|
||||||
var testResults []testResult
|
var testResults []testResult
|
||||||
|
var testResultsMutex sync.Mutex
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
if reexec.Init() {
|
if reexec.Init() {
|
||||||
@ -349,7 +351,9 @@ func (p *PodmanTestIntegration) InspectContainer(name string) []define.InspectCo
|
|||||||
|
|
||||||
func processTestResult(f GinkgoTestDescription) {
|
func processTestResult(f GinkgoTestDescription) {
|
||||||
tr := testResult{length: f.Duration.Seconds(), name: f.TestText}
|
tr := testResult{length: f.Duration.Seconds(), name: f.TestText}
|
||||||
|
testResultsMutex.Lock()
|
||||||
testResults = append(testResults, tr)
|
testResults = append(testResults, tr)
|
||||||
|
testResultsMutex.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetPortLock(port string) storage.Locker {
|
func GetPortLock(port string) storage.Locker {
|
||||||
|
Reference in New Issue
Block a user