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