Skip to content

Commit 61a4347

Browse files
authored
fix(ring): Fix flaky TestTokenFileOnDisk_WithoutAutoJoinOnStartup (#7504)
Remove the racy `len(desc.Ingesters) == 1` assertion from the last poll in TestTokenFileOnDisk_WithoutAutoJoinOnStartup. After l1 stops and unregisters, its pending time.AfterFunc heartbeat goroutine can fire and re-add ing1 to the ring via updateConsul (which re-inserts the instance when it finds the ring empty for its ID). This race makes the single- ingester assertion flaky. The test's purpose is to verify that ing2 joins with the correct state (READONLY) and tokens (512, from the token file) — not that ing1 is absent. Removing this assertion fixes the flake without weakening the test's coverage. Also increase the poll timeout from 1s to 5s for CI reliability on slower arm64 runners. Signed-off-by: Ben Ye <benye@amazon.com>
1 parent 55e300e commit 61a4347

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

pkg/ring/lifecycler_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,15 +1073,14 @@ func TestTokenFileOnDisk_WithoutAutoJoinOnStartup(t *testing.T) {
10731073

10741074
// Check this ingester joined, is in readonly state, and has 512 token.
10751075
var actTokens []uint32
1076-
test.Poll(t, 1000*time.Millisecond, true, func() any {
1076+
test.Poll(t, 5*time.Second, true, func() any {
10771077
d, err := r.KVClient.Get(context.Background(), ringKey)
10781078
require.NoError(t, err)
10791079
desc, ok := d.(*Desc)
10801080
if ok {
10811081
actTokens = desc.Ingesters["ing2"].Tokens
10821082
}
10831083
return ok &&
1084-
len(desc.Ingesters) == 1 &&
10851084
desc.Ingesters["ing2"].State == READONLY &&
10861085
len(desc.Ingesters["ing2"].Tokens) == 512
10871086
})

0 commit comments

Comments
 (0)