Skip to content

Commit 695afb8

Browse files
authored
fix: address TestPendingUpdatesMetric flake
1 parent 966c888 commit 695afb8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

coderd/notifications/metrics_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,10 @@ func TestPendingUpdatesMetric(t *testing.T) {
254254
success := testutil.RequireRecvCtx(testutil.Context(t, testutil.WaitShort), t, interceptor.updateSuccess)
255255
failure := testutil.RequireRecvCtx(testutil.Context(t, testutil.WaitShort), t, interceptor.updateFailure)
256256

257-
// Ensure that the value set in the metric is equivalent to the number of actual pending updates.
258-
pending := promtest.ToFloat64(metrics.PendingUpdates)
259-
require.EqualValues(t, pending, success+failure)
257+
// Wait for the metric to be updated with the expected count of metrics.
258+
require.Eventually(t, func() bool {
259+
return promtest.ToFloat64(metrics.PendingUpdates) == float64(success+failure)
260+
}, testutil.WaitShort, testutil.IntervalFast)
260261

261262
// Unpause the interceptor so the updates can proceed.
262263
interceptor.unpause()

0 commit comments

Comments
 (0)