From ef123fd593c1619fd07146c292b74b39b3c85a0e Mon Sep 17 00:00:00 2001 From: Tobiasz Heller <14020794+tobiaszheller@users.noreply.github.com> Date: Fri, 23 Jun 2023 10:21:21 +0200 Subject: [PATCH] Fix TestSQSMessagesCollectorErrorsOnReceive flakiness (#28046) * Fix TestSQSMessagesCollectorErrorsOnReceive flakiness * Update lib/events/athena/consumer_test.go Co-authored-by: Tim Buckley --------- Co-authored-by: Tim Buckley --- lib/events/athena/consumer_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/events/athena/consumer_test.go b/lib/events/athena/consumer_test.go index 514e04d718393..e6e6360e542fd 100644 --- a/lib/events/athena/consumer_test.go +++ b/lib/events/athena/consumer_test.go @@ -33,7 +33,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/sqs" sqsTypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" "github.com/gravitational/trace" "github.com/jonboulle/clockwork" @@ -338,8 +337,9 @@ func TestSQSMessagesCollectorErrorsOnReceive(t *testing.T) { gotNoOfCalls := mockReceiver.getNoOfCalls() // We can't be sure that there will be equaly noOfCalls as expected, - // because they are process in async way, that's why margin in EquateApprox is used. - require.Empty(t, cmp.Diff(float32(gotNoOfCalls), float32(expectedNoOfCalls), cmpopts.EquateApprox(0, 4))) + // because they are process in async way, but anything within range x>= 0 && x< 1.5*expected is valid. + require.LessOrEqual(t, float64(gotNoOfCalls), 1.5*float64(expectedNoOfCalls), "receiveMessage got too many calls") + require.Greater(t, gotNoOfCalls, 0, "receiveMessage was not called at all") } type mockReceiver struct {