Skip to content

Commit

Permalink
Fix TestSQSMessagesCollectorErrorsOnReceive flakiness (gravitational#…
Browse files Browse the repository at this point in the history
…28046)

* Fix TestSQSMessagesCollectorErrorsOnReceive flakiness

* Update lib/events/athena/consumer_test.go

Co-authored-by: Tim Buckley <tim@goteleport.com>

---------

Co-authored-by: Tim Buckley <tim@goteleport.com>
  • Loading branch information
tobiaszheller and timothyb89 authored Jun 23, 2023
1 parent 186a277 commit ef123fd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/events/athena/consumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit ef123fd

Please sign in to comment.