From c6c35a8c7e523ca18d337427a8daaefa2dea740a Mon Sep 17 00:00:00 2001 From: Nahshon Unna-Tsameret Date: Sun, 22 Dec 2024 14:31:43 +0200 Subject: [PATCH] Fix the monitoring test The "KubeVirtCRModified alert should fired when there is a modification on a CR" functional test became flacky. The test changes the KubeVirt CI, and then checks several metrics and alert. When checking the "kubevirt_hyperconverged_operator_health_status" alert, the test sometimes fails, as KubeVirt get into non stable state for a short while for every chenage in the KubeVirt CR, making the health alret to be in "critical" status, instead of "warning". This PR fixes the issue by modifiying the CDI CR instead of the KubeVirt CR, to get the same effect. Signed-off-by: Nahshon Unna-Tsameret --- tests/func-tests/monitoring_test.go | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/tests/func-tests/monitoring_test.go b/tests/func-tests/monitoring_test.go index 803e6f2fb..9c17c0461 100644 --- a/tests/func-tests/monitoring_test.go +++ b/tests/func-tests/monitoring_test.go @@ -5,6 +5,7 @@ import ( "crypto/tls" "flag" "fmt" + cdiv1beta1 "kubevirt.io/containerized-data-importer-api/pkg/apis/core/v1beta1" "net/http" "strconv" "time" @@ -29,8 +30,6 @@ import ( "k8s.io/client-go/rest" "sigs.k8s.io/controller-runtime/pkg/client" - kubevirtcorev1 "kubevirt.io/api/core/v1" - hcoalerts "github.com/kubevirt/hyperconverged-cluster-operator/pkg/monitoring/rules/alerts" "github.com/kubevirt/hyperconverged-cluster-operator/pkg/monitoring/rules/recordingrules" hcoutil "github.com/kubevirt/hyperconverged-cluster-operator/pkg/util" @@ -107,8 +106,8 @@ var _ = Describe("[crit:high][vendor:cnv-qe@redhat.com][level:system]Monitoring" It("KubeVirtCRModified alert should fired when there is a modification on a CR", Serial, func(ctx context.Context) { const ( - query = `kubevirt_hco_out_of_band_modifications_total{component_name="kubevirt/kubevirt-kubevirt-hyperconverged"}` - jsonPatch = `[{"op": "add", "path": "/spec/configuration/developerConfiguration/featureGates/-", "value": "fake-fg-for-testing"}]` + query = `kubevirt_hco_out_of_band_modifications_total{component_name="cdi/cdi-kubevirt-hyperconverged"}` + jsonPatch = `[{"op": "add", "path": "/spec/config/logVerbosity", "value": 5}]` ) By(fmt.Sprintf("Reading the `%s` metric from HCO prometheus endpoint", query)) @@ -120,17 +119,16 @@ var _ = Describe("[crit:high][vendor:cnv-qe@redhat.com][level:system]Monitoring" }).WithTimeout(10 * time.Second).WithPolling(500 * time.Millisecond).WithContext(ctx).Should(Succeed()) GinkgoWriter.Printf("The metric value before the test is: %0.2f\n", valueBefore) - By("Patching kubevirt object") + By("Patching the CDI object") patch := client.RawPatch(types.JSONPatchType, []byte(jsonPatch)) - kv := &kubevirtcorev1.KubeVirt{ + cdi := &cdiv1beta1.CDI{ ObjectMeta: metav1.ObjectMeta{ - Name: "kubevirt-kubevirt-hyperconverged", - Namespace: tests.InstallNamespace, + Name: "cdi-kubevirt-hyperconverged", }, } - Expect(cli.Patch(ctx, kv, patch)).To(Succeed()) + Expect(cli.Patch(ctx, cdi, patch)).To(Succeed()) By("checking that the HCO metric was increased by 1") Eventually(func(g Gomega, ctx context.Context) float64 {