
The previous approach was based on the observation that some Prow jobs use the
--report-dir parameter instead of the E2E_REPORT_DIR env variable. Parsing the
command line was necessary to use the --json-report and --junit-report
parameters.
But that is complex and can be avoided by triggering the creation of complete
reports in the E2E test suite. The paths are hard-coded and relative to the
report directory to keep the code simple.
There was a report that k8s-triage started processing more data after
6db4b741dd
was merged. It's unclear whether
that was because of the new <report-dir>/ginkgo_report.xml file. To avoid
this potential problem, the reports are now in a "ginkgo" sub-directory.
While at it, error checking gets enhanced:
- Create directories at the start of
the suite and bail out early if that fails.
- *All* e2e suites using the framework do this, not just test/e2e.
- Added missing error checking of truncated JUnit report writing.
43 lines
1.5 KiB
Go
43 lines
1.5 KiB
Go
/*
|
|
Copyright 2022 The Kubernetes Authors.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
package junit
|
|
|
|
import (
|
|
"github.com/onsi/ginkgo/v2"
|
|
"github.com/onsi/ginkgo/v2/reporters"
|
|
"github.com/onsi/ginkgo/v2/types"
|
|
)
|
|
|
|
// WriteJUnitReport generates a JUnit file that is shorter than the one
|
|
// normally written by `ginkgo --junit-report`. This is needed because the full
|
|
// report can become too large for tools like Spyglass
|
|
// (https://github.com/kubernetes/kubernetes/issues/111510).
|
|
func WriteJUnitReport(report ginkgo.Report, filename string) error {
|
|
config := reporters.JunitReportConfig{
|
|
// Remove details for specs where we don't care.
|
|
OmitTimelinesForSpecState: types.SpecStatePassed | types.SpecStateSkipped,
|
|
|
|
// Don't write <failure message="summary">. The same text is
|
|
// also in the full text for the failure. If we were to write
|
|
// both, then tools like kettle and spyglass would concatenate
|
|
// the two strings and thus show duplicated information.
|
|
OmitFailureMessageAttr: true,
|
|
}
|
|
|
|
return reporters.GenerateJUnitReportWithConfig(report, filename, config)
|
|
}
|