From 81073ff88ed84841c2825502063cdeb6a496a331 Mon Sep 17 00:00:00 2001 From: Mahmood Ali Date: Sun, 29 Mar 2020 21:33:31 -0400 Subject: [PATCH] tests: deflake TestAllocGarbageCollector_MakeRoomFor_MaxAllocs The test inserts an alloc in the server state, but expect the client to start the alloc runner for it almost immediately. Here, we add a retry loop to check that the client start all expected alloc runners eventually. --- client/gc_test.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/client/gc_test.go b/client/gc_test.go index e1f12a689..86cb6b90f 100644 --- a/client/gc_test.go +++ b/client/gc_test.go @@ -481,7 +481,16 @@ func TestAllocGarbageCollector_MakeRoomFor_MaxAllocs(t *testing.T) { t.Fatalf("Allocs did not get GC'd: %v", err) }) - require.Len(client.getAllocRunners(), 8) + // check that all 8 get run eventually + testutil.WaitForResult(func() (bool, error) { + ar := client.getAllocRunners() + if len(ar) != 8 { + return false, fmt.Errorf("expected 8 ARs, found %d: %v", len(ar), ar) + } + return true, nil + }, func(err error) { + require.NoError(err) + }) } func TestAllocGarbageCollector_UsageBelowThreshold(t *testing.T) {