Skip to content

Commit

Permalink
Func Test: Don't verify Operator Health Metric (#3262)
Browse files Browse the repository at this point in the history
This check is flaky. Temporary remove this check to make the test more
stable, while looking for alternative check in order to verify the
operator health metric.

Signed-off-by: Nahshon Unna-Tsameret <[email protected]>
  • Loading branch information
nunnatsa authored Jan 7, 2025
1 parent 17131a5 commit e26cc2e
Showing 1 changed file with 6 additions and 25 deletions.
31 changes: 6 additions & 25 deletions tests/func-tests/monitoring_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (
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"
tests "github.com/kubevirt/hyperconverged-cluster-operator/tests/func-tests"
)
Expand All @@ -43,13 +42,12 @@ var _ = Describe("[crit:high][vendor:[email protected]][level:system]Monitoring"
flag.Parse()

var (
cli client.Client
cliSet *kubernetes.Clientset
restClient rest.Interface
promClient promApiv1.API
prometheusRule monitoringv1.PrometheusRule
initialOperatorHealthMetricValue float64
hcoClient *tests.HCOPrometheusClient
cli client.Client
cliSet *kubernetes.Clientset
restClient rest.Interface
promClient promApiv1.API
prometheusRule monitoringv1.PrometheusRule
hcoClient *tests.HCOPrometheusClient
)

runbookClient.Timeout = time.Second * 3
Expand All @@ -67,7 +65,6 @@ var _ = Describe("[crit:high][vendor:[email protected]][level:system]Monitoring"
hcoClient, err = tests.GetHCOPrometheusClient(ctx, cli)
Expect(err).NotTo(HaveOccurred())

initialOperatorHealthMetricValue = getMetricValue(ctx, promClient, "kubevirt_hyperconverged_operator_health_status")
Expect(err).NotTo(HaveOccurred())
})

Expand Down Expand Up @@ -165,8 +162,6 @@ var _ = Describe("[crit:high][vendor:[email protected]][level:system]Monitoring"
alert := getAlertByName(alerts, "KubeVirtCRModified")
return alert
}).WithTimeout(60 * time.Second).WithPolling(time.Second).WithContext(ctx).ShouldNot(BeNil())

verifyOperatorHealthMetricValue(ctx, promClient, initialOperatorHealthMetricValue, recordingrules.WarningImpact)
})

It("UnsupportedHCOModification alert should fired when there is an jsonpatch annotation to modify an operand CRs", func(ctx context.Context) {
Expand All @@ -184,7 +179,6 @@ var _ = Describe("[crit:high][vendor:[email protected]][level:system]Monitoring"
alert := getAlertByName(alerts, "UnsupportedHCOModification")
return alert
}).WithTimeout(60 * time.Second).WithPolling(time.Second).WithContext(ctx).ShouldNot(BeNil())
verifyOperatorHealthMetricValue(ctx, promClient, initialOperatorHealthMetricValue, recordingrules.WarningImpact)
})

Describe("KubeDescheduler", Serial, Ordered, Label(tests.OpenshiftLabel, "monitoring"), func() {
Expand Down Expand Up @@ -288,8 +282,6 @@ var _ = Describe("[crit:high][vendor:[email protected]][level:system]Monitoring"
return alert
}).WithTimeout(60 * time.Second).WithPolling(time.Second).WithContext(ctx).ShouldNot(BeNil())

verifyOperatorHealthMetricValue(ctx, promClient, initialOperatorHealthMetricValue, recordingrules.CriticalImpact)

By("Correctly configuring the descheduler for KubeVirt")
Expect(cli.Patch(ctx, descheduler, patchConfigure)).To(Succeed())
By("checking that the metric doesn't report it as misconfigured (0.0)")
Expand Down Expand Up @@ -361,8 +353,6 @@ var _ = Describe("[crit:high][vendor:[email protected]][level:system]Monitoring"
alert := getAlertByName(alerts, hcoalerts.MisconfiguredDeschedulerAlert)
return alert
}).WithTimeout(60 * time.Second).WithPolling(time.Second).WithContext(ctx).ShouldNot(BeNil())

verifyOperatorHealthMetricValue(ctx, promClient, initialOperatorHealthMetricValue, recordingrules.CriticalImpact)
})
})

Expand All @@ -377,15 +367,6 @@ func getAlertByName(alerts promApiv1.AlertsResult, alertName string) *promApiv1.
return nil
}

func verifyOperatorHealthMetricValue(ctx context.Context, promClient promApiv1.API, initialOperatorHealthMetricValue, alertImpact float64) {
Eventually(func(g Gomega, ctx context.Context) {
if alertImpact >= initialOperatorHealthMetricValue {
operatorHealthMetricValue := getMetricValue(ctx, promClient, "kubevirt_hyperconverged_operator_health_status")
g.Expect(operatorHealthMetricValue).To(Equal(alertImpact))
}
}).WithTimeout(60 * time.Second).WithPolling(5 * time.Second).WithContext(ctx).Should(Succeed())
}

func getMetricValue(ctx context.Context, promClient promApiv1.API, metricName string) float64 {
queryResult, _, err := promClient.Query(ctx, metricName, time.Now())
ExpectWithOffset(1, err).ToNot(HaveOccurred())
Expand Down

0 comments on commit e26cc2e

Please sign in to comment.