From 7f2155dea57d4a1247df84635e58b40fcc544dfb Mon Sep 17 00:00:00 2001 From: Matej Kralik Date: Tue, 23 Apr 2024 10:19:54 +0200 Subject: [PATCH] Use common WaitForOperatorReady function in custom prometheus test (#680) --- .../observability/custom_prometheus_test.go | 21 +++---------------- 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/pkg/tests/tasks/observability/custom_prometheus_test.go b/pkg/tests/tasks/observability/custom_prometheus_test.go index d113ff3b..f2c9cad5 100644 --- a/pkg/tests/tasks/observability/custom_prometheus_test.go +++ b/pkg/tests/tasks/observability/custom_prometheus_test.go @@ -8,11 +8,11 @@ import ( "github.com/maistra/maistra-test-tool/pkg/app" "github.com/maistra/maistra-test-tool/pkg/util/check/assert" - "github.com/maistra/maistra-test-tool/pkg/util/check/common" "github.com/maistra/maistra-test-tool/pkg/util/curl" "github.com/maistra/maistra-test-tool/pkg/util/env" "github.com/maistra/maistra-test-tool/pkg/util/ns" "github.com/maistra/maistra-test-tool/pkg/util/oc" + "github.com/maistra/maistra-test-tool/pkg/util/operator" "github.com/maistra/maistra-test-tool/pkg/util/pod" "github.com/maistra/maistra-test-tool/pkg/util/prometheus" "github.com/maistra/maistra-test-tool/pkg/util/retry" @@ -68,7 +68,8 @@ func TestCustomPrometheus(t *testing.T) { enableAppMtlsMonitoring(t, customPrometheusNs, ns.Bookinfo) t.LogStep("Waiting for installs to complete") - ocWaitOperatorInstall(t, customPrometheusNs, "rhods-prometheus-operator") + fullCsvName := operator.GetCsvName(t, customPrometheusNs, "rhods-prometheus") + operator.WaitForOperatorReady(t, customPrometheusNs, "k8s-app=prometheus-operator", fullCsvName) oc.WaitPodReady(t, pod.MatchingSelector("prometheus=prometheus", customPrometheusNs)) bookinfoApp.WaitReady(t) @@ -102,13 +103,6 @@ func shellArgf(format string, a ...any) string { return shellArg(fmt.Sprintf(format, a...)) } -func ocGetJsonpath(t test.TestHelper, ns, kind, name, jsonpath string, checks ...common.CheckFunc) string { - t.T().Helper() - cmd := fmt.Sprintf(`oc -n %s get %s -o %s`, - shellArg(ns), shellArgf("%s/%s", kind, name), shellArgf("jsonpath=%s", jsonpath)) - return oc.DefaultOC.Invoke(t, cmd, checks...) -} - func ocWaitJsonpath(t test.TestHelper, ns, kind, name, jsonpath, expected, successMessage, failureMsg string) { t.T().Helper() timeout := "1s" @@ -119,15 +113,6 @@ func ocWaitJsonpath(t test.TestHelper, ns, kind, name, jsonpath, expected, succe }) } -func ocWaitOperatorInstall(t test.TestHelper, ns, subscriptionName string) { - t.T().Helper() - ocWaitJsonpath(t, ns, "subscription", subscriptionName, - "{.status.installPlanRef.kind}", "InstallPlan", - "Install plan was created.", "Wait for install plan failed.") - installPlanName := ocGetJsonpath(t, ns, "subscription", subscriptionName, "{.status.installPlanRef.name}") - oc.WaitCondition(t, ns, "installplan", installPlanName, "Installed") -} - func installPrometheusOperator(t test.TestHelper, ns string) { t.T().Helper() oc.ApplyString(t, ns,