From b6bada4a1a5e33c3afe581846a8f3e8739d36aa4 Mon Sep 17 00:00:00 2001 From: Daniel Franz Date: Mon, 8 Jun 2026 14:39:57 +0900 Subject: [PATCH] E2E Summary Output Fix The serial e2e tests require pod restarts which causes the metrics to scrape two sets of results, which the summary generator did not allow. Now, the results from the new pod will be aggregated to the final set. Signed-off-by: Daniel Franz --- internal/shared/util/test/utils.go | 23 ------------------- test/e2e/features_test.go | 7 +++--- .../internal/summary}/artifacts.go | 2 +- .../test => test/internal/summary}/summary.go | 12 ++++------ .../internal/summary}/templates/alert.md.tmpl | 0 .../summary}/templates/mermaid_chart.md.tmpl | 0 .../summary}/templates/summary.md.tmpl | 0 7 files changed, 8 insertions(+), 36 deletions(-) delete mode 100644 internal/shared/util/test/utils.go rename {internal/shared/util/test => test/internal/summary}/artifacts.go (99%) rename {internal/shared/util/test => test/internal/summary}/summary.go (93%) rename {internal/shared/util/test => test/internal/summary}/templates/alert.md.tmpl (100%) rename {internal/shared/util/test => test/internal/summary}/templates/mermaid_chart.md.tmpl (100%) rename {internal/shared/util/test => test/internal/summary}/templates/summary.md.tmpl (100%) diff --git a/internal/shared/util/test/utils.go b/internal/shared/util/test/utils.go deleted file mode 100644 index 41128e46f0..0000000000 --- a/internal/shared/util/test/utils.go +++ /dev/null @@ -1,23 +0,0 @@ -package test - -import ( - "os/exec" - "testing" -) - -// FindK8sClient returns the first available Kubernetes CLI client from the system, -// It checks for the existence of each client by running `version --client`. -// If no suitable client is found, the function terminates the test with a failure. -func FindK8sClient(t *testing.T) string { - t.Logf("Finding kubectl client") - clients := []string{"kubectl", "oc"} - for _, c := range clients { - // Would prefer to use `command -v`, but even that may not be installed! - if err := exec.Command(c, "version", "--client").Run(); err == nil { - t.Logf("Using %q as k8s client", c) - return c - } - } - t.Fatal("k8s client not found") - return "" -} diff --git a/test/e2e/features_test.go b/test/e2e/features_test.go index 14d19ac9a3..81f1a09342 100644 --- a/test/e2e/features_test.go +++ b/test/e2e/features_test.go @@ -10,8 +10,8 @@ import ( "github.com/cucumber/godog/colors" "github.com/spf13/pflag" - testutil "github.com/operator-framework/operator-controller/internal/shared/util/test" "github.com/operator-framework/operator-controller/test/e2e/steps" + "github.com/operator-framework/operator-controller/test/internal/summary" ) var opts = godog.Options{ @@ -47,10 +47,9 @@ func TestMain(m *testing.M) { if path == "" { fmt.Println("Note: E2E_SUMMARY_OUTPUT is unset; skipping summary generation") } else { - if err := testutil.PrintSummary(path); err != nil { - // Fail the run if alerts are found + if err := summary.PrintSummary(path); err != nil { + // Alert but do not fail the run if alerts are found fmt.Printf("%v", err) - os.Exit(1) } } return diff --git a/internal/shared/util/test/artifacts.go b/test/internal/summary/artifacts.go similarity index 99% rename from internal/shared/util/test/artifacts.go rename to test/internal/summary/artifacts.go index 727b915e71..850e5bbeec 100644 --- a/internal/shared/util/test/artifacts.go +++ b/test/internal/summary/artifacts.go @@ -1,4 +1,4 @@ -package test +package summary import ( "context" diff --git a/internal/shared/util/test/summary.go b/test/internal/summary/summary.go similarity index 93% rename from internal/shared/util/test/summary.go rename to test/internal/summary/summary.go index e5dc4c195c..4eea7006ea 100644 --- a/internal/shared/util/test/summary.go +++ b/test/internal/summary/summary.go @@ -1,4 +1,4 @@ -package test +package summary import ( "context" @@ -80,8 +80,8 @@ func (s *githubSummary) PerformanceQuery(title, pod, query, yLabel string, scale matrix, ok := result.(model.Matrix) if !ok { return "", fmt.Errorf("typecast for metrics samples failed; aborting") - } else if len(matrix) != 1 { - return "", fmt.Errorf("expected 1 set of results; got: %d", len(matrix)) + } else if len(matrix) == 0 { + return "", fmt.Errorf("expected 1 or more sets of results; got 0") } chart := xychart{ Title: title, @@ -92,10 +92,6 @@ func (s *githubSummary) PerformanceQuery(title, pod, query, yLabel string, scale formattedData := make([]string, 0) // matrix does not allow [] access, so we just do one iteration for the single result for _, metric := range matrix { - if len(metric.Values) < 2 { - // A graph with one data point means something with the collection was wrong - return "", fmt.Errorf("expected at least two data points; got: %d", len(metric.Values)) - } for _, sample := range metric.Values { floatSample := float64(sample.Value) * scaler formattedData = append(formattedData, fmt.Sprintf("%f", floatSample)) @@ -160,7 +156,7 @@ func executeTemplate(templateFile string, obj any) (string, error) { if err != nil { return "", fmt.Errorf("failed to get working directory: %w", err) } - tmpl, err := template.New(templateFile).ParseGlob(filepath.Join(wd, "../../internal/shared/util/test/templates", templateFile)) + tmpl, err := template.New(templateFile).ParseGlob(filepath.Join(wd, "../internal/summary/templates", templateFile)) if err != nil { return "", err } diff --git a/internal/shared/util/test/templates/alert.md.tmpl b/test/internal/summary/templates/alert.md.tmpl similarity index 100% rename from internal/shared/util/test/templates/alert.md.tmpl rename to test/internal/summary/templates/alert.md.tmpl diff --git a/internal/shared/util/test/templates/mermaid_chart.md.tmpl b/test/internal/summary/templates/mermaid_chart.md.tmpl similarity index 100% rename from internal/shared/util/test/templates/mermaid_chart.md.tmpl rename to test/internal/summary/templates/mermaid_chart.md.tmpl diff --git a/internal/shared/util/test/templates/summary.md.tmpl b/test/internal/summary/templates/summary.md.tmpl similarity index 100% rename from internal/shared/util/test/templates/summary.md.tmpl rename to test/internal/summary/templates/summary.md.tmpl