Skip to content

Commit 31a62d1

Browse files
committed
metrics: Fix Metrics should have the correct labels test
`sriov_kubepoddevice` metric might end up in the Prometheus database after a while, as the default scrape interval is 30s. This leads to failures in the end-to-end lane like: ``` [sriov] Metrics Exporter When Prometheus operator is available [It] Metrics should have the correct labels /root/opr-ocp2-1/data/sriov-network-operator/sriov-network-operator/test/conformance/tests/test_exporter_metrics.go:132 [FAILED] no value for metric sriov_kubepoddevice ``` Put the metric assertion in an `Eventually` statement Signed-off-by: Andrea Panattoni <[email protected]>
1 parent aecf473 commit 31a62d1

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

test/conformance/tests/test_exporter_metrics.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,17 @@ var _ = Describe("[sriov] Metrics Exporter", Ordered, ContinueOnFailure, func()
158158
}, "90s", "1s").Should(Succeed())
159159

160160
// sriov_kubepoddevice has a different sets of label than statistics metrics
161-
samples := runPromQLQuery(fmt.Sprintf(`sriov_kubepoddevice{namespace="%s",pod="%s"}`, pod.Namespace, pod.Name))
162-
Expect(samples).ToNot(BeEmpty(), "no value for metric sriov_kubepoddevice")
163-
Expect(samples[0].Metric).To(And(
164-
HaveKey(model.LabelName("pciAddr")),
165-
HaveKeyWithValue(model.LabelName("node"), model.LabelValue(pod.Spec.NodeName)),
166-
HaveKeyWithValue(model.LabelName("dev_type"), model.LabelValue("openshift.io/metricsResource")),
167-
HaveKeyWithValue(model.LabelName("namespace"), model.LabelValue(pod.Namespace)),
168-
HaveKeyWithValue(model.LabelName("pod"), model.LabelValue(pod.Name)),
169-
))
161+
Eventually(func(g Gomega) {
162+
samples := runPromQLQuery(fmt.Sprintf(`sriov_kubepoddevice{namespace="%s",pod="%s"}`, pod.Namespace, pod.Name))
163+
g.Expect(samples).ToNot(BeEmpty(), "no value for metric sriov_kubepoddevice")
164+
g.Expect(samples[0].Metric).To(And(
165+
HaveKey(model.LabelName("pciAddr")),
166+
HaveKeyWithValue(model.LabelName("node"), model.LabelValue(pod.Spec.NodeName)),
167+
HaveKeyWithValue(model.LabelName("dev_type"), model.LabelValue("openshift.io/metricsResource")),
168+
HaveKeyWithValue(model.LabelName("namespace"), model.LabelValue(pod.Namespace)),
169+
HaveKeyWithValue(model.LabelName("pod"), model.LabelValue(pod.Name)),
170+
))
171+
}, "60s", "1s").Should(Succeed())
170172
})
171173
})
172174
})

0 commit comments

Comments
 (0)