Skip to content

Commit

Permalink
test(pubsub): fix race condition in ordering integration (#9604)
Browse files Browse the repository at this point in the history
  • Loading branch information
hongalex committed Mar 19, 2024
1 parent 6989196 commit 922f16e
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions pubsub/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,7 @@ func TestIntegration_OrderedKeys_JSON(t *testing.T) {
client := integrationTestClient(ctx, t, option.WithEndpoint("us-west1-pubsub.googleapis.com:443"))
defer client.Close()

testutil.Retry(t, 2, 0, func(r *testutil.R) {
testutil.Retry(t, 2, 1*time.Second, func(r *testutil.R) {
topic, err := createTopicWithRetry(ctx, t, client, topicIDs.New(), nil)
if err != nil {
r.Errorf("createTopicWithRetry err: %v", err)
Expand Down Expand Up @@ -1285,7 +1285,7 @@ func TestIntegration_OrderedKeys_JSON(t *testing.T) {
}

go func() {
if err := sub.Receive(ctx, func(ctx context.Context, msg *Message) {
sub.Receive(ctx, func(ctx context.Context, msg *Message) {
mu.Lock()
defer mu.Unlock()
// Messages are deduped using the data field, since in this case all
Expand All @@ -1298,11 +1298,7 @@ func TestIntegration_OrderedKeys_JSON(t *testing.T) {
receiveData = append(receiveData, testutil2.OrderedKeyMsg{Key: msg.OrderingKey, Data: string(msg.Data)})
wg.Done()
msg.Ack()
}); err != nil {
if c := status.Code(err); c != codes.Canceled {
r.Errorf("status.Code(err) got: %v, want cancelled", err)
}
}
})
}()

done := make(chan struct{})
Expand Down

0 comments on commit 922f16e

Please sign in to comment.