Skip to content

Commit

Permalink
Merge pull request #2818 from fromanirh/prometheus-servicemon-flaky-test
Browse files Browse the repository at this point in the history
tests: add retry in prometheus config pickup test
  • Loading branch information
rmohr committed Oct 17, 2019
2 parents b07e393 + fa8cf0b commit 61ac912
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions tests/operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1313,15 +1313,19 @@ spec:
It("[test_id:2936]Should allow Prometheus to scrape KubeVirt endpoints", func() {
coreClient := virtClient.CoreV1()

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())
// 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())

By("Verifying that Prometheus is watching KubeVirt")
Expect(string(data)).To(ContainSubstring(tests.KubeVirtInstallNamespace), "Prometheus should be monitoring KubeVirt")
data := secret.Data["prometheus.yaml"]
Expect(data).ToNot(BeNil())

By("Verifying that Prometheus is watching KubeVirt")
return string(data)
}, 90*time.Second, 3*time.Second).Should(ContainSubstring(tests.KubeVirtInstallNamespace), "Prometheus should be monitoring KubeVirt")
})
})
})

0 comments on commit 61ac912

Please sign in to comment.