tests: add retry in prometheus config pickup test
We don't know exactly when the prometheus chain will pick up
our config, so let's retry few times before to give up and fail.
@@ -1306,15 +1306,19 @@ spec:
It("[test_id:2936]Should allow Prometheus to scrape KubeVirt endpoints", func() {
coreClient := virtClient.CoreV1()
+ // we don't know when the prometheus toolchain will pick up our config, so we retry plenty of times
+ // before to give up. TODO: there is a smarter way to wait?
+ Eventually(func() string {
By("Obtaining Prometheus' configuration data")
secret, err := coreClient.Secrets("openshift-monitoring").Get("prometheus-k8s", metav1.GetOptions{})
Expect(err).ToNot(HaveOccurred())
+
data := secret.Data["prometheus.yaml"]
Expect(data).ToNot(BeNil())
By("Verifying that Prometheus is watching KubeVirt")
- Expect(string(data)).To(ContainSubstring(tests.KubeVirtInstallNamespace), "Prometheus should be monitoring KubeVirt")
-
+ return string(data)
+ }, 90*time.Second, 3*time.Second).Should(ContainSubstring(tests.KubeVirtInstallNamespace), "Prometheus should be monitoring KubeVirt")
})
})
})
