Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more cursor tests #3893

Merged
merged 5 commits into from
Dec 21, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
wip
  • Loading branch information
noisersup committed Dec 20, 2023
commit c4611be17a74b1d429a9fd0ca1a8817e1a68984e
56 changes: 56 additions & 0 deletions integration/cursors/getmore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,62 @@ func TestCursorsGetMoreCommandMaxTimeMSErrors(t *testing.T) {
}
}

func TestCursorsGetMoreExhausted(t *testing.T) {
s := setup.SetupWithOpts(t, &setup.SetupOpts{
ExtraOptions: url.Values{
"minPoolSize": []string{"1"},
"maxPoolSize": []string{"1"},
"maxIdleTimeMS": []string{"0"},
},
Providers: []shareddata.Provider{shareddata.Composites},
})

ctx, collection := s.Ctx, s.Collection

// need large amount of documents for time out to trigger
arr, _ := integration.GenerateDocuments(0, 10)

_, err := collection.InsertMany(ctx, arr)
require.NoError(t, err)

var res bson.D
err = collection.Database().RunCommand(ctx, bson.D{
{"find", collection.Name()},
{"batchSize", 1},
{"tailable", true},
}).Decode(&res)

require.NoError(t, err)

firstBatch, cursorID := getFirstBatch(t, res)
require.Equal(t, 1, must.NotFail(firstBatch.Get(0)))
require.NotNil(t, cursorID)

err = collection.Database().RunCommand(ctx, bson.D{
{"getMore", cursorID},
{"collection", collection.Name()},
{"batchSize", 9},
}).Decode(&res)

require.NoError(t, err)

nextBatch, nextID := getNextBatch(t, res)
require.Equal(t, 9, nextBatch.Len())
assert.Equal(t, 0, nextID)

err = collection.Database().RunCommand(ctx, bson.D{
{"getMore", cursorID},
{"collection", collection.Name()},
{"batchSize", 1},
}).Decode(&res)

require.NoError(t, err)

nextBatch, nextID = getNextBatch(t, res)
require.Equal(t, 0, nextBatch.Len())
assert.Equal(t, 0, nextID)
}

func TestCursorsGetMoreCommandMaxTimeMSCursor(t *testing.T) {
// do not run tests in parallel to avoid using too many backend connections

Expand Down
Loading