Skip to content

Commit

Permalink
test(pubsublite): fix flaky TestIntegration_SeekSubscription (#8479)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmdiep authored Aug 24, 2023
1 parent 236904e commit ee274c7
Showing 1 changed file with 2 additions and 22 deletions.
24 changes: 2 additions & 22 deletions pubsublite/pscompat/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -917,9 +917,6 @@ func TestIntegration_SeekSubscription(t *testing.T) {
createSubscription(ctx, t, admin, subscriptionPath, topicPath)
defer cleanUpSubscription(ctx, t, admin, subscriptionPath)

var msgBatch3 []string
var publishTimes3 *publishTimeRange

// Note: Subtests need to be run sequentially.

t.Run("SeekToBeginning", func(t *testing.T) {
Expand Down Expand Up @@ -996,25 +993,8 @@ func TestIntegration_SeekSubscription(t *testing.T) {

// Publish batch 3 and verify that messages are only received from batch 3
// (batch 2 skipped).
msgBatch3 = publishPrefixedMessages(t, DefaultPublishSettings, topicPath, "seek-batch3", messageCount, 0)
publishTimes3 = receiveAllMessages(t, makeMsgTracker(msgBatch3), recvSettings, subscriptionPath)

if seekOp != nil {
validateCompleteSeekOperation(ctx, t, subscriptionPath, seekOp)
}
})

t.Run("SeekToPublishTime", func(t *testing.T) {
// Seek to min publish time of batch 3.
seekOp, err := admin.SeekSubscription(ctx, subscriptionPath.String(), pubsublite.PublishTime(publishTimes3.Min()))
if err != nil {
t.Errorf("SeekSubscription() got err: %v", err)
} else {
validateNewSeekOperation(t, subscriptionPath, seekOp)
}

// Verify that messages are received from batch 3.
receiveAllMessages(t, makeMsgTracker(msgBatch3), recvSettings, subscriptionPath)
msgBatch := publishPrefixedMessages(t, DefaultPublishSettings, topicPath, "seek-batch3", messageCount, 0)
receiveAllMessages(t, makeMsgTracker(msgBatch), recvSettings, subscriptionPath)

if seekOp != nil {
validateCompleteSeekOperation(ctx, t, subscriptionPath, seekOp)
Expand Down

0 comments on commit ee274c7

Please sign in to comment.