Skip to content

Commit 8f85b40

Browse files
committed
wait in test until metrics are available before running tests that rely on the values.
up until now, the metrics go routine ran in tests with time.Sleep(0), which means metrics were avaiable immediately. while in tests in might be acceptable to wait few seconds using sleep, in the actual code (not tests) it's a bad practice to use sleep which was replaced with a ticker (to perform periodic task in an endless loop). Signed-off-by: Nir Rozenbaum <[email protected]>
1 parent a0082b6 commit 8f85b40

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

test/integration/epp/hermetic_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -1496,6 +1496,7 @@ func TestFullDuplexStreamed_KubeInferenceModelRequest(t *testing.T) {
14961496
if len(test.wantMetrics) != 0 {
14971497
for metricName, value := range test.wantMetrics {
14981498
if err := metricsutils.GatherAndCompare(legacyregistry.DefaultGatherer, strings.NewReader(value), metricName); err != nil {
1499+
t.Log(metricName, value)
14991500
t.Error(err)
15001501
}
15011502
}
@@ -1548,6 +1549,8 @@ func setUpHermeticServer(t *testing.T, podAndMetrics map[backendmetrics.Pod]*bac
15481549
}
15491550
}()
15501551

1552+
time.Sleep(serverRunner.RefreshPrometheusMetricsInterval) // wait for metrics to get published before running tests that rely on these metrics
1553+
15511554
// check if all pods are synced to datastore
15521555
assert.EventuallyWithT(t, func(t *assert.CollectT) {
15531556
assert.Len(t, serverRunner.Datastore.PodGetAll(), len(podAndMetrics), "Datastore not synced")

0 commit comments

Comments
 (0)