From 298af6dca7ffb73a501c01573fb6d1c9dfcc927b Mon Sep 17 00:00:00 2001 From: Paul Banks Date: Thu, 11 Oct 2018 13:12:19 +0100 Subject: [PATCH] Quick fix for cache age flakiness in CI --- agent/cache/cache_test.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/agent/cache/cache_test.go b/agent/cache/cache_test.go index 30fa868178..9f7397e021 100644 --- a/agent/cache/cache_test.go +++ b/agent/cache/cache_test.go @@ -883,8 +883,12 @@ func TestCacheGet_refreshAge(t *testing.T) { // Now fail the next background sync atomic.StoreUint64(&shouldFail, 1) - // Wait until the current request times out and starts failing - time.Sleep(6 * time.Millisecond) + // Wait until the current request times out and starts failing. The request + // should take a maximum of 5ms to return but give it some headroom to allow + // it to finish 5ms sleep, unblock and next background request to be attemoted + // and fail and state updated in noisy CI... We might want to retry if this is + // still flaky but see if a longer wait is sufficient for now. + time.Sleep(50 * time.Millisecond) var lastAge time.Duration { @@ -897,7 +901,7 @@ func TestCacheGet_refreshAge(t *testing.T) { lastAge = meta.Age } // Wait a bit longer - age should increase by at least this much - time.Sleep(1 * time.Millisecond) + time.Sleep(5 * time.Millisecond) { result, meta, err := c.Get("t", TestRequest(t, RequestInfo{Key: "hello"})) require.NoError(err)