mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 12:15:52 +00:00
e2e framework: avoid storing redundant failure message string
All information that we want will be written into the failure XML element's data. We don't need the message tag and don't want it because our tools (kettle, testgrid, spyglass) would then just concatenate the two strings. This gets implemented for us by Ginkgo. However, truncating the failure message is not supported there at the moment. It's unclear how important that is, therefore this (recently added feature) gets removed.
This commit is contained in:
parent
6db4b741dd
commit
f4a837affb
@ -530,14 +530,6 @@ func AfterReadingAllFlags(t *TestContextType) {
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
// This is the traditional gomega.Format default of 4000 for an object
|
||||
// dump plus some extra room for the message.
|
||||
maxFailureMessageSize = 5000
|
||||
|
||||
truncatedMsg = "\n[... see output for full dump ...]\n"
|
||||
)
|
||||
|
||||
// writeJUnitReport generates a JUnit file in the e2e report directory 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
|
||||
@ -545,47 +537,15 @@ const (
|
||||
//
|
||||
// Users who want the full report can use `--junit-report`.
|
||||
func writeJUnitReport(report ginkgo.Report) {
|
||||
trimmedReport := report
|
||||
trimmedReport.SpecReports = nil
|
||||
for _, specReport := range report.SpecReports {
|
||||
// Remove details for any spec that hasn't failed. In Prow,
|
||||
// jobs that use ginkgo-e2e.sh will dump the full
|
||||
// information into ginkgo_report.xml/json.
|
||||
if specReport.State != types.SpecStateFailed {
|
||||
specReport.CapturedGinkgoWriterOutput = ""
|
||||
specReport.CapturedStdOutErr = ""
|
||||
} else {
|
||||
// Truncate the failure message if it is too large.
|
||||
msgLen := len(specReport.Failure.Message)
|
||||
if msgLen > maxFailureMessageSize {
|
||||
// Insert full message at the beginning where it is easy to find.
|
||||
specReport.CapturedGinkgoWriterOutput =
|
||||
"Full failure message:\n" +
|
||||
specReport.Failure.Message + "\n\n" +
|
||||
strings.Repeat("=", 70) + "\n\n" +
|
||||
specReport.CapturedGinkgoWriterOutput
|
||||
specReport.Failure.Message = specReport.Failure.Message[0:maxFailureMessageSize/2] + truncatedMsg + specReport.Failure.Message[msgLen-maxFailureMessageSize/2:msgLen]
|
||||
}
|
||||
}
|
||||
config := reporters.JunitReportConfig{
|
||||
// Remove details for specs where we don't care.
|
||||
OmitTimelinesForSpecState: types.SpecStatePassed | types.SpecStateSkipped,
|
||||
|
||||
// Remove report entries generated by ginkgo.By("doing
|
||||
// something") because those are not useful (just have the
|
||||
// start time) and cause Spyglass to show an additional "open
|
||||
// stdout" button with a summary of the steps, which usually
|
||||
// doesn't help. We don't remove all entries because other
|
||||
// measurements also get reported this way.
|
||||
//
|
||||
// Removing the report entries is okay because message text was
|
||||
// already added to the test output when ginkgo.By was called.
|
||||
reportEntries := specReport.ReportEntries
|
||||
specReport.ReportEntries = nil
|
||||
for _, reportEntry := range reportEntries {
|
||||
if reportEntry.Name != "By Step" {
|
||||
specReport.ReportEntries = append(specReport.ReportEntries, reportEntry)
|
||||
}
|
||||
}
|
||||
|
||||
trimmedReport.SpecReports = append(trimmedReport.SpecReports, specReport)
|
||||
// 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,
|
||||
}
|
||||
|
||||
// With Ginkgo v1, we used to write one file per parallel node. Now
|
||||
@ -593,5 +553,5 @@ func writeJUnitReport(report ginkgo.Report) {
|
||||
// 01 suffix is kept in case that users expect files to be called
|
||||
// "junit_<prefix><number>.xml".
|
||||
junitReport := path.Join(TestContext.ReportDir, "junit_"+TestContext.ReportPrefix+"01.xml")
|
||||
reporters.GenerateJUnitReport(trimmedReport, junitReport)
|
||||
reporters.GenerateJUnitReportWithConfig(report, junitReport, config)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user