From 2c1d906cadd5178710864159b0aa984f1d8b8a07 Mon Sep 17 00:00:00 2001 From: Kyle Stang Date: Fri, 4 Dec 2026 18:52:31 +0000 Subject: [PATCH] Ring: fix flaky TestLifecycler_InitRingAdoptsRenewedTimestamp The lifecycler service has no starting function: initRing, which adopts the renewed timestamp from the instance's ring entry, runs at the top of loop() once the service is already running. StartAndAwaitRunning can therefore return before initRing has run, and the test read the zero time. Wait for the timestamp to be adopted instead. Signed-off-by: Kyle Stang --- pkg/ring/lifecycler_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/ring/lifecycler_test.go b/pkg/ring/lifecycler_test.go index b3ec1e1346..622ce444e1 100644 --- a/pkg/ring/lifecycler_test.go +++ b/pkg/ring/lifecycler_test.go @@ -276,7 +276,10 @@ func TestLifecycler_InitRingAdoptsRenewedTimestamp(t *testing.T) { require.NoError(t, services.StartAndAwaitRunning(ctx, l1)) defer services.StopAndAwaitTerminated(ctx, l1) // nolint:errcheck - assert.Equal(t, renewedAt, l1.getRenewedAt()) + // initRing runs once the service is running, so wait for it to adopt the timestamp. + test.Poll(t, 3*time.Second, renewedAt, func() any { + return l1.getRenewedAt() + }) time.Sleep(3 * lifecyclerConfig.HeartbeatPeriod) waitRingInstance(t, 3*time.Second, l1, func(instance InstanceDesc) error { if instance.RenewedTimestamp != renewedAt.Unix() {