mirror of
https://github.com/containers/podman.git
synced 2025-06-24 19:42:56 +08:00
test/e2e: fix custom timing reporting
This never worked when ginkgo runs with more than one thread, we use 3 in CI. The problem is that the SynchronizedAfterSuite() function accepts two functions. The first one is run for each ginkgo node while the second one is only run once for the whole suite. Because the timings are stored as slice thus in memory we loose all timings from the other nodes as they were only reported on node 1. Moving the printing in the first function solves this but causes the problem that the result is now no longer sorted. To fix this we let each node write the result to a tmp file and only then let the final after suite function collect the timings from all these files, then sort them and print the output like we did before. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package integration
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
@ -167,11 +168,40 @@ func (p *PodmanTestIntegration) Setup() {
|
||||
INTEGRATION_ROOT = filepath.Join(cwd, "../../")
|
||||
}
|
||||
|
||||
var _ = SynchronizedAfterSuite(func() {},
|
||||
var _ = SynchronizedAfterSuite(func() {
|
||||
f, err := os.Create(fmt.Sprintf("%s/timings-%d", LockTmpDir, GinkgoParallelProcess()))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
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() {
|
||||
sort.Sort(testResultsSortedLength{testResults})
|
||||
testTimings := make(testResultsSorted, 0, 2000)
|
||||
for i := 1; i <= GinkgoT().ParallelTotal(); i++ {
|
||||
f, err := os.Open(fmt.Sprintf("%s/timings-%d", LockTmpDir, i))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
defer f.Close()
|
||||
scanner := bufio.NewScanner(f)
|
||||
for scanner.Scan() {
|
||||
text := scanner.Text()
|
||||
timing := strings.SplitN(text, "\t\t", 2)
|
||||
if len(timing) != 2 {
|
||||
Fail(fmt.Sprintf("incorrect timing line: %q", text))
|
||||
}
|
||||
name := timing[0]
|
||||
duration, err := strconv.ParseFloat(timing[1], 64)
|
||||
Expect(err).ToNot(HaveOccurred(), "failed to parse float from timings file")
|
||||
testTimings = append(testTimings, testResult{name: name, length: duration})
|
||||
}
|
||||
if err := scanner.Err(); err != nil {
|
||||
Expect(err).ToNot(HaveOccurred(), "read timings %d", i)
|
||||
}
|
||||
}
|
||||
sort.Sort(testResultsSortedLength{testTimings})
|
||||
GinkgoWriter.Println("integration timing results")
|
||||
for _, result := range testResults {
|
||||
for _, result := range testTimings {
|
||||
GinkgoWriter.Printf("%s\t\t%f\n", result.name, result.length)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user