-
Notifications
You must be signed in to change notification settings - Fork 53
NO-JIRA: Update e2e diagnostics #488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,7 +36,8 @@ var _ = BeforeSuite(func() { | |
|
|
||
| var _ = ReportAfterEach(func(report SpecReport) { | ||
| if report.Failed() { | ||
| dumpTrackedResources() | ||
| diag := collectTrackedResourceDiagnostics() | ||
| specDiagnostics[report.LeafNodeLocation.String()] = diag | ||
|
Comment on lines
+39
to
+40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # Check Go version in go.mod
head -5 go.mod | grep -i "^go "Repository: openshift/cluster-capi-operator Length of output: 84 🏁 Script executed: # Read the relevant sections of e2e_test.go to understand the context
wc -l e2e/e2e_test.go && echo "---" && sed -n '30,50p' e2e/e2e_test.go && echo "---" && sed -n '60,75p' e2e/e2e_test.goRepository: openshift/cluster-capi-operator Length of output: 1209 🏁 Script executed: # Check if FullText() method is available in the code
rg "FullText" e2e/e2e_test.go -A 2 -B 2Repository: openshift/cluster-capi-operator Length of output: 57 🏁 Script executed: # Find the import of Ginkgo to determine exact version
rg "github.com/onsi/ginkgo" go.modRepository: openshift/cluster-capi-operator Length of output: 143 🌐 Web query:
💡 Result: In Ginkgo v2.2.0, For table-driven tests specifically: each If you need stable uniqueness, prefer deriving a key from the spec’s text (e.g., Sources: Citations:
Use a stronger diagnostics key to prevent collisions across failed specs. Using only A composite key combining 🔧 Suggested fix var _ = ReportAfterEach(func(report SpecReport) {
if report.Failed() {
diag := collectTrackedResourceDiagnostics()
- specDiagnostics[report.LeafNodeLocation.String()] = diag
+ specDiagnostics[diagnosticKey(report)] = diag
}
resourcesUnderTest = nil
})
+
+func diagnosticKey(sr SpecReport) string {
+ return fmt.Sprintf("%s|%s", sr.LeafNodeLocation.String(), sr.FullText())
+}
@@
- if diag, ok := specDiagnostics[sr.LeafNodeLocation.String()]; ok {
+ if diag, ok := specDiagnostics[diagnosticKey(*sr)]; ok {
sr.Failure.Message += "\n\n" + diag
}Also applies to: 68-69 🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| resourcesUnderTest = nil | ||
|
|
@@ -58,20 +59,15 @@ var _ = ReportAfterSuite("junit with diagnostics", func(report Report) { | |
| return | ||
| } | ||
|
|
||
| // Append GinkgoWriter output (which contains our tracked resource dump) | ||
| // to the failure description so it appears in the <failure> element of | ||
| // the JUnit XML, which is what Spyglass renders by default. | ||
| for i := range report.SpecReports { | ||
| sr := &report.SpecReports[i] | ||
| if !sr.Failed() { | ||
| continue | ||
| } | ||
|
|
||
| if sr.CapturedGinkgoWriterOutput == "" { | ||
| continue | ||
| if diag, ok := specDiagnostics[sr.LeafNodeLocation.String()]; ok { | ||
| sr.Failure.Message += "\n\n" + diag | ||
| } | ||
|
|
||
| sr.Failure.Message += "\n\n" + sr.CapturedGinkgoWriterOutput | ||
| } | ||
|
|
||
| dst := filepath.Join(artifactDir, "junit_cluster_capi_operator.xml") | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment/key mismatch for
specDiagnosticscan mislead future changes.Line 71 says the map is keyed by “spec text”, but current usage keys by
LeafNodeLocation.String(). Please align the comment to the implemented key to avoid maintenance mistakes.✏️ Suggested comment fix
📝 Committable suggestion
🤖 Prompt for AI Agents