From ed679ce75550a8653103806ddbaf2c0a7e0c3be7 Mon Sep 17 00:00:00 2001 From: Ayoub Mrini Date: Tue, 25 Jun 2024 16:24:43 +0200 Subject: [PATCH] MON-3934: Parallelize some readonly/non disruptive e2e tests for faster runs --- test/e2e/alertmanager_test.go | 4 ++++ test/e2e/image_registry_test.go | 1 + test/e2e/kube_state_metrics_test.go | 4 ++++ test/e2e/main_test.go | 2 ++ test/e2e/metrics_adapter_test.go | 10 ++++++++++ test/e2e/multi_namespace_test.go | 3 ++- test/e2e/priority_class_test.go | 2 ++ test/e2e/prometheus_test.go | 6 ++++++ test/e2e/security_headers_test.go | 4 ++++ test/e2e/telemeter_test.go | 2 ++ test/e2e/thanos_querier_test.go | 4 ++++ test/e2e/validatingwebhook_test.go | 4 ++++ 12 files changed, 45 insertions(+), 1 deletion(-) diff --git a/test/e2e/alertmanager_test.go b/test/e2e/alertmanager_test.go index 70cce021e8..45199ec91e 100644 --- a/test/e2e/alertmanager_test.go +++ b/test/e2e/alertmanager_test.go @@ -465,6 +465,8 @@ func TestAlertmanagerDataReplication(t *testing.T) { // The Alertmanager API should be protected by authentication/authorization. func TestAlertmanagerAPI(t *testing.T) { + // The test shouldn't be disruptive, safe to run in parallel with others. + t.Parallel() err := framework.Poll(5*time.Second, 5*time.Minute, func() error { body, err := f.AlertmanagerClient.GetAlertmanagerAlerts( "filter", `alertname="Watchdog"`, @@ -748,6 +750,8 @@ func TestAlertmanagerDisabling(t *testing.T) { } func TestAlertManagerHasAdditionalAlertRelabelConfigs(t *testing.T) { + // The test is "read-only", safe to run in parallel with others. + t.Parallel() const ( expectPlatformLabel = "openshift_io_alert_source" expectPlatformLabelValue = "platform" diff --git a/test/e2e/image_registry_test.go b/test/e2e/image_registry_test.go index d74fece1dd..5cac415635 100644 --- a/test/e2e/image_registry_test.go +++ b/test/e2e/image_registry_test.go @@ -8,6 +8,7 @@ import ( v1 "k8s.io/api/core/v1" ) + func TestImageRegistryPods(t *testing.T) { var pods *v1.PodList diff --git a/test/e2e/kube_state_metrics_test.go b/test/e2e/kube_state_metrics_test.go index e8c19bfccc..a00773d189 100644 --- a/test/e2e/kube_state_metrics_test.go +++ b/test/e2e/kube_state_metrics_test.go @@ -32,6 +32,8 @@ import ( ) func TestKSMMetricsSuppression(t *testing.T) { + // The test is "read-only", safe to run in parallel with others. + t.Parallel() suppressedPattern, _ := regexp.Compile("kube_.*_annotations") @@ -74,6 +76,8 @@ func TestKSMMetricsSuppression(t *testing.T) { } func TestKSMCRSMetrics(t *testing.T) { + // The test shouldn't be disruptive, safe to run in parallel with others. + t.Parallel() const timeout = 5 * time.Minute assetsDir := "./assets" ksmCRSMetricPrefix := "kube_customresource" diff --git a/test/e2e/main_test.go b/test/e2e/main_test.go index 2aebbb254c..6adad336a6 100644 --- a/test/e2e/main_test.go +++ b/test/e2e/main_test.go @@ -182,6 +182,8 @@ func testTargetsUp(t *testing.T) { // Once we have the need to test multiple recording rules, we can unite them in // a single test function. func TestMemoryUsageRecordingRule(t *testing.T) { + // The test is "read-only", safe to run in parallel with others. + t.Parallel() f.ThanosQuerierClient.WaitForQueryReturnGreaterEqualOne( t, time.Minute, diff --git a/test/e2e/metrics_adapter_test.go b/test/e2e/metrics_adapter_test.go index 505dbeca82..208af91958 100644 --- a/test/e2e/metrics_adapter_test.go +++ b/test/e2e/metrics_adapter_test.go @@ -79,6 +79,8 @@ func isAPIServiceAvailable(conditions []apiservicesv1.APIServiceCondition) bool } func TestMetricsAPIAvailability(t *testing.T) { + // The test is "read-only", safe to run in parallel with others. + t.Parallel() ctx := context.Background() var lastErr error err := wait.Poll(time.Second, 5*time.Minute, func() (bool, error) { @@ -106,6 +108,8 @@ func TestMetricsAPIAvailability(t *testing.T) { } func TestNodeMetricsPresence(t *testing.T) { + // The test is "read-only", safe to run in parallel with others. + t.Parallel() ctx := context.Background() var lastErr error err := wait.Poll(time.Second, 5*time.Minute, func() (bool, error) { @@ -144,6 +148,8 @@ func TestNodeMetricsPresence(t *testing.T) { } func TestPodMetricsPresence(t *testing.T) { + // The test is "read-only", safe to run in parallel with others. + t.Parallel() var lastErr error ctx := context.Background() err := wait.Poll(time.Second, 5*time.Minute, func() (bool, error) { @@ -185,6 +191,8 @@ func TestPodMetricsPresence(t *testing.T) { } func TestAggregatedMetricPermissions(t *testing.T) { + // The test is "read-only", safe to run in parallel with others. + t.Parallel() ctx := context.Background() present := func(where []string, what string) bool { sort.Strings(where) @@ -340,6 +348,8 @@ func TestPrometheusAdapterCARotation(t *testing.T) { } func TestMetricsServerRollout(t *testing.T) { + // The test is "read-only", safe to run in parallel with others. + t.Parallel() skipMetricsServerTests(t) for _, test := range []scenario{ { diff --git a/test/e2e/multi_namespace_test.go b/test/e2e/multi_namespace_test.go index 997cdad97a..ca428915e9 100644 --- a/test/e2e/multi_namespace_test.go +++ b/test/e2e/multi_namespace_test.go @@ -31,9 +31,10 @@ import ( ) func TestMultinamespacePrometheusRule(t *testing.T) { + // The test shouldn't be disruptive, safe to run in parallel with others. + t.Parallel() ctx := context.Background() nsName := "openshift-test-prometheus-rules" + strconv.FormatInt(time.Now().Unix(), 36) - t.Parallel() t.Cleanup(func() { f.OperatorClient.DeleteIfExists(ctx, nsName) diff --git a/test/e2e/priority_class_test.go b/test/e2e/priority_class_test.go index 2473475176..28a954ca44 100644 --- a/test/e2e/priority_class_test.go +++ b/test/e2e/priority_class_test.go @@ -27,6 +27,8 @@ import ( // system-cluster-critical 2000000000 false 114m // system-node-critical 2000001000 false 114m func TestToEnsureUserPriorityClassIsPresentAndLower(t *testing.T) { + // The test is "read-only", safe to run in parallel with others. + t.Parallel() ctx := context.Background() // Get system priority class values. diff --git a/test/e2e/prometheus_test.go b/test/e2e/prometheus_test.go index 1a05da16d2..c7f70c4bb8 100644 --- a/test/e2e/prometheus_test.go +++ b/test/e2e/prometheus_test.go @@ -30,6 +30,8 @@ import ( ) func TestPrometheusMetrics(t *testing.T) { + // The test is "read-only", safe to run in parallel with others. + t.Parallel() expected := map[string]int{ "prometheus-operator": 1, "prometheus-k8s": 2, @@ -69,6 +71,8 @@ func TestPrometheusMetrics(t *testing.T) { // consider whether the new default value is still suitable. // Refer to this link for some points that may need to be examined https://github.com/openshift/prometheus/pull/206#issuecomment-2182168575. func TestPrometheusGOGC(t *testing.T) { + // The test is "read-only", safe to run in parallel with others. + t.Parallel() gogc := 75 f.ThanosQuerierClient.WaitForQueryReturn( t, 5*time.Minute, `min(go_gc_gogc_percent{namespace="openshift-monitoring", service="prometheus-k8s", container="kube-rbac-proxy"})`, // kube-rbac-proxy exposes prometheus container's metrics. @@ -83,6 +87,8 @@ func TestPrometheusGOGC(t *testing.T) { } func TestAntiAffinity(t *testing.T) { + // The test is "read-only", safe to run in parallel with others. + t.Parallel() for _, tc := range []struct { name string instance string diff --git a/test/e2e/security_headers_test.go b/test/e2e/security_headers_test.go index d147054b59..cd7eed3683 100644 --- a/test/e2e/security_headers_test.go +++ b/test/e2e/security_headers_test.go @@ -24,6 +24,8 @@ import ( ) func TestAlertmanagerPolicyHeaders(t *testing.T) { + // The test shouldn't be disruptive, safe to run in parallel with others. + t.Parallel() // The tenancy port (9092) is only exposed in-cluster, so we need to use // port forwarding to access kube-rbac-proxy. host, cleanUp, err := f.ForwardPort(t, f.Ns, "alertmanager-main", 9092) @@ -36,6 +38,8 @@ func TestAlertmanagerPolicyHeaders(t *testing.T) { } func TestPrometheusPolicyHeaders(t *testing.T) { + // The test shouldn't be disruptive, safe to run in parallel with others. + t.Parallel() host, cleanUp, err := f.ForwardPort(t, f.Ns, "prometheus-k8s", 9091) if err != nil { t.Fatal(err) diff --git a/test/e2e/telemeter_test.go b/test/e2e/telemeter_test.go index 72c3de388f..81cb9ce371 100644 --- a/test/e2e/telemeter_test.go +++ b/test/e2e/telemeter_test.go @@ -90,6 +90,8 @@ func TestTelemeterRemoteWrite(t *testing.T) { // TestTelemeterClient verifies that the telemeter client can collect metrics from the monitoring stack and forward them to the telemeter server. func TestTelemeterClient(t *testing.T) { + // The test is "read-only", safe to run in parallel with others. + t.Parallel() { f.PrometheusK8sClient.WaitForQueryReturn( t, diff --git a/test/e2e/thanos_querier_test.go b/test/e2e/thanos_querier_test.go index 4e2ce547bc..352b0da1eb 100644 --- a/test/e2e/thanos_querier_test.go +++ b/test/e2e/thanos_querier_test.go @@ -24,6 +24,8 @@ import ( ) func TestThanosQueryCanQueryWatchdogAlert(t *testing.T) { + // The test is "read-only", safe to run in parallel with others. + t.Parallel() // The 2-minute timeout is what console CI tests set. // If this test is flaky, we should increase until // we can fix the possible DNS resolve issues. @@ -43,6 +45,8 @@ const ( ) func TestMonitoringApiRoles(t *testing.T) { + // The test shouldn't be disruptive, safe to run in parallel with others. + t.Parallel() cf, err := f.CreateNamespace(testNamespaceTQ) if err != nil { diff --git a/test/e2e/validatingwebhook_test.go b/test/e2e/validatingwebhook_test.go index 36106fbb2e..338cfd712f 100644 --- a/test/e2e/validatingwebhook_test.go +++ b/test/e2e/validatingwebhook_test.go @@ -104,6 +104,8 @@ spec: ) func TestPrometheusRuleValidatingWebhook(t *testing.T) { + // The test shouldn't be disruptive, safe to run in parallel with others. + t.Parallel() ctx := context.Background() _, err := f.AdmissionClient.ValidatingWebhookConfigurations().Get(ctx, prometheusRuleWebhookName, metav1.GetOptions{}) @@ -134,6 +136,8 @@ func TestPrometheusRuleValidatingWebhook(t *testing.T) { } func TestAlertManagerConfigValidatingWebhook(t *testing.T) { + // The test shouldn't be disruptive, safe to run in parallel with others. + t.Parallel() ctx := context.Background() _, err := f.AdmissionClient.ValidatingWebhookConfigurations().Get(ctx, alertmanagerConfigWebhookName, metav1.GetOptions{})