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 an integration test for cursor not found #3768

Closed
wants to merge 19 commits into from
Prev Previous commit
Next Next commit
set small batch size
  • Loading branch information
b1ron committed Nov 28, 2023
commit 7d7359e1eaf4e935430f2ed84fa36ac97b99e6ca
13 changes: 10 additions & 3 deletions integration/cursor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"sync"
"testing"

"github.com/AlekSi/pointer"
"github.com/FerretDB/FerretDB/integration/shareddata"
"github.com/FerretDB/FerretDB/internal/util/iterator"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -59,7 +60,7 @@ func TestCursorStress(t *testing.T) {

t.Cleanup(func() { require.NoError(t, client.Database("test").Drop(context.TODO())) })

N := 200
N := 10

var wg sync.WaitGroup
for i := 0; i < N; i++ {
Expand All @@ -76,10 +77,16 @@ func TestCursorStress(t *testing.T) {

coll := client.Database("test").Collection("foo")

cur, err := coll.Find(context.TODO(), bson.D{}, options.Find().SetSort(bson.D{{"_id", 1}}))
opts := &options.FindOptions{
// set a small batch size to increase the frequency of getMores
BatchSize: pointer.ToInt32(20),
Sort: bson.D{{"_id", 1}},
}

cur, err := coll.Find(context.TODO(), bson.D{}, opts)
require.NoError(t, err)

// Iterate the cursor until the cursor is exhausted or there is an error getting the next document
// iterate the cursor until it is exhausted or there is an error getting the next document
for {
if cur.TryNext(context.TODO()) {
assert.True(t, cur.Next(context.TODO()))
Expand Down
Loading