e2e: bring back total test spec for Ginkgo v2

Bring back the number of test spec which was dropped earlier.
It's now available in the reporting node of `ReportBeforeSuite` by extracting
the number from report.PreRunStats.SpecsThatWillBeRun.

Signed-off-by: Dave Chen <dave.chen@arm.com>
This commit is contained in:
Dave Chen 2022-12-22 10:39:55 +08:00
parent d2504c94a0
commit 8fe3e8df46
2 changed files with 10 additions and 2 deletions

View File

@ -151,6 +151,10 @@ var _ = ginkgo.ReportAfterEach(func(report ginkgo.SpecReport) {
progressReporter.ProcessSpecReport(report)
})
var _ = ginkgo.ReportBeforeSuite(func(report ginkgo.Report) {
progressReporter.SetTestsTotal(report.PreRunStats.SpecsThatWillRun)
})
var _ = ginkgo.ReportAfterSuite("Kubernetes e2e suite report", func(report ginkgo.Report) {
var err error
// The DetailsRepoerter will output details about every test (name, files, lines, etc) which helps

View File

@ -33,11 +33,10 @@ import (
// ProgressReporter is a ginkgo reporter which tracks the total number of tests to be run/passed/failed/skipped.
// As new tests are completed it updates the values and prints them to stdout and optionally, sends the updates
// to the configured URL.
// TODO: Number of test specs is not available now, we can add it back when this is fixed in the Ginkgo V2.
// pls see: https://github.com/kubernetes/kubernetes/issues/109744
type ProgressReporter struct {
LastMsg string `json:"msg"`
TestsTotal int `json:"total"`
TestsCompleted int `json:"completed"`
TestsSkipped int `json:"skipped"`
TestsFailed int `json:"failed"`
@ -109,6 +108,11 @@ func (reporter *ProgressReporter) SetStartMsg() {
reporter.SendUpdates()
}
func (reporter *ProgressReporter) SetTestsTotal(totalSpec int) {
reporter.TestsTotal = totalSpec
reporter.SendUpdates()
}
// ProcessSpecReport summarizes the report state and sends the state to the configured endpoint if set.
func (reporter *ProgressReporter) ProcessSpecReport(report ginkgo.SpecReport) {
testName := strings.Join(report.ContainerHierarchyTexts, " ")