Skip to content

Commit a01a139

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 a01a139

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

test/conformance/tests/test_exporter_metrics.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ var _ = Describe("[sriov] Metrics Exporter", Ordered, ContinueOnFailure, func()
6666
Expect(err).ToNot(HaveOccurred())
6767
waitForNetAttachDef("test-me-network", namespaces.Test)
6868

69+
WaitForSRIOVStable()
70+
6971
DeferCleanup(namespaces.Clean, operatorNamespace, namespaces.Test, clients, discovery.Enabled())
7072
})
7173

@@ -158,15 +160,17 @@ var _ = Describe("[sriov] Metrics Exporter", Ordered, ContinueOnFailure, func()
158160
}, "90s", "1s").Should(Succeed())
159161

160162
// 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-
))
163+
Eventually(func(g Gomega) {
164+
samples := runPromQLQuery(fmt.Sprintf(`sriov_kubepoddevice{namespace="%s",pod="%s"}`, pod.Namespace, pod.Name))
165+
g.Expect(samples).ToNot(BeEmpty(), "no value for metric sriov_kubepoddevice")
166+
g.Expect(samples[0].Metric).To(And(
167+
HaveKey(model.LabelName("pciAddr")),
168+
HaveKeyWithValue(model.LabelName("node"), model.LabelValue(pod.Spec.NodeName)),
169+
HaveKeyWithValue(model.LabelName("dev_type"), model.LabelValue("openshift.io/metricsResource")),
170+
HaveKeyWithValue(model.LabelName("namespace"), model.LabelValue(pod.Namespace)),
171+
HaveKeyWithValue(model.LabelName("pod"), model.LabelValue(pod.Name)),
172+
))
173+
}, "60s", "1s").Should(Succeed())
170174
})
171175
})
172176
})

0 commit comments

Comments
 (0)