Skip to content

Commit 6afa145

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 6afa145

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

test/integration/epp/hermetic_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -1548,6 +1548,8 @@ func setUpHermeticServer(t *testing.T, podAndMetrics map[backendmetrics.Pod]*bac
15481548
}
15491549
}()
15501550

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

0 commit comments

Comments
 (0)