diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2020-09-15 13:47:05 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2020-09-15 13:56:38 +0300 |
commit | a9ad86db4eda437fe816df1d2f2038185a5e3a8d (patch) | |
tree | 22963b8788e60cdf74ef1b58703a5d4ec13490ec | |
parent | b8e4eb7128808a874cb34bc529330b8cd080ccdc (diff) |
praefect: Add more tolerance in racy error threshold tests
As the error threshold checks function asynchronously, we're sleeping in
the tests which exercises that code. Naturally, CI still manages to be
slow enought to loose the race.
Improve the situation by increasing the amount of time waited from 10ms
to 50ms. To not penalize fast machines, we now sleep in a loop for 1ms
steps until we see the expected error.
-rw-r--r-- | internal/praefect/server_test.go | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/internal/praefect/server_test.go b/internal/praefect/server_test.go index 0dae99082..6e5f7704b 100644 --- a/internal/praefect/server_test.go +++ b/internal/praefect/server_test.go @@ -1012,9 +1012,12 @@ func TestErrorThreshold(t *testing.T) { require.Equal(t, expectedErr, err) } - time.Sleep(10 * time.Millisecond) - - _, err = nodeMgr.GetShard("default") + for i := 0; i < 50; i++ { + if _, err = nodeMgr.GetShard("default"); err != nil { + break + } + time.Sleep(1 * time.Millisecond) + } require.Equal(t, nodes.ErrPrimaryNotHealthy, err) }) } |