mirror of
https://github.com/containers/podman.git
synced 2025-06-20 09:03:43 +08:00
test/e2e: write timings directly to file
There is no need to buffer them all into an array then write them once at the end. Just write directly to the file. Fixes #19104 Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
@ -56,7 +56,6 @@ type PodmanTestIntegration struct {
|
|||||||
SignaturePolicyPath string
|
SignaturePolicyPath string
|
||||||
CgroupManager string
|
CgroupManager string
|
||||||
Host HostOS
|
Host HostOS
|
||||||
Timings []string
|
|
||||||
TmpDir string
|
TmpDir string
|
||||||
RemoteStartErr error
|
RemoteStartErr error
|
||||||
}
|
}
|
||||||
@ -82,9 +81,6 @@ 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 testResultsMutex sync.Mutex
|
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
if reexec.Init() {
|
if reexec.Init() {
|
||||||
return
|
return
|
||||||
@ -107,6 +103,7 @@ var (
|
|||||||
err error
|
err error
|
||||||
podmanTest *PodmanTestIntegration
|
podmanTest *PodmanTestIntegration
|
||||||
safeIPOctets [2]uint8
|
safeIPOctets [2]uint8
|
||||||
|
timingsFile *os.File
|
||||||
|
|
||||||
_ = BeforeEach(func() {
|
_ = BeforeEach(func() {
|
||||||
tempdir, err = CreateTempDirInTempDir()
|
tempdir, err = CreateTempDirInTempDir()
|
||||||
@ -188,6 +185,9 @@ var _ = SynchronizedBeforeSuite(func() []byte {
|
|||||||
cwd, _ := os.Getwd()
|
cwd, _ := os.Getwd()
|
||||||
INTEGRATION_ROOT = filepath.Join(cwd, "../../")
|
INTEGRATION_ROOT = filepath.Join(cwd, "../../")
|
||||||
LockTmpDir = string(data)
|
LockTmpDir = string(data)
|
||||||
|
|
||||||
|
timingsFile, err = os.Create(fmt.Sprintf("%s/timings-%d", LockTmpDir, GinkgoParallelProcess()))
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
})
|
})
|
||||||
|
|
||||||
func (p *PodmanTestIntegration) Setup() {
|
func (p *PodmanTestIntegration) Setup() {
|
||||||
@ -196,13 +196,8 @@ func (p *PodmanTestIntegration) Setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var _ = SynchronizedAfterSuite(func() {
|
var _ = SynchronizedAfterSuite(func() {
|
||||||
f, err := os.Create(fmt.Sprintf("%s/timings-%d", LockTmpDir, GinkgoParallelProcess()))
|
timingsFile.Close()
|
||||||
Expect(err).ToNot(HaveOccurred())
|
timingsFile = nil
|
||||||
defer f.Close()
|
|
||||||
for _, result := range testResults {
|
|
||||||
_, err := f.WriteString(fmt.Sprintf("%s\t\t%f\n", result.name, result.length))
|
|
||||||
Expect(err).ToNot(HaveOccurred(), "write timings")
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
func() {
|
func() {
|
||||||
testTimings := make(testResultsSorted, 0, 2000)
|
testTimings := make(testResultsSorted, 0, 2000)
|
||||||
@ -467,9 +462,8 @@ func (p *PodmanTestIntegration) InspectContainer(name string) []define.InspectCo
|
|||||||
|
|
||||||
func processTestResult(r SpecReport) {
|
func processTestResult(r SpecReport) {
|
||||||
tr := testResult{length: r.RunTime.Seconds(), name: r.FullText()}
|
tr := testResult{length: r.RunTime.Seconds(), name: r.FullText()}
|
||||||
testResultsMutex.Lock()
|
_, err := timingsFile.WriteString(fmt.Sprintf("%s\t\t%f\n", tr.name, tr.length))
|
||||||
testResults = append(testResults, tr)
|
Expect(err).ToNot(HaveOccurred(), "write timings")
|
||||||
testResultsMutex.Unlock()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetPortLock(port string) *lockfile.LockFile {
|
func GetPortLock(port string) *lockfile.LockFile {
|
||||||
|
Reference in New Issue
Block a user