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

GODRIVER-2388 Improved Bulk Write API. #1884

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
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
1 change: 1 addition & 0 deletions internal/driverutil/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ const (
ListIndexesOp = "listIndexes" // ListIndexesOp is the name for listing indexes
ListDatabasesOp = "listDatabases" // ListDatabasesOp is the name for listing databases
UpdateOp = "update" // UpdateOp is the name for updating
BulkWriteOp = "bulkWrite" // BulkWriteOp is the name for client-level bulk write
)
2 changes: 1 addition & 1 deletion internal/integration/client_side_encryption_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ func TestClientSideEncryptionCustomCrypt(t *testing.T) {
"expected 0 calls to DecryptExplicit, got %v", cc.numDecryptExplicitCalls)
assert.Equal(mt, cc.numCloseCalls, 0,
"expected 0 calls to Close, got %v", cc.numCloseCalls)
assert.Equal(mt, cc.numBypassAutoEncryptionCalls, 2,
assert.Equal(mt, cc.numBypassAutoEncryptionCalls, 1,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only call it once after the operation.go refactoring.

"expected 2 calls to BypassAutoEncryption, got %v", cc.numBypassAutoEncryptionCalls)
})
}
Expand Down
553 changes: 553 additions & 0 deletions internal/integration/crud_prose_test.go

Large diffs are not rendered by default.

54 changes: 54 additions & 0 deletions internal/integration/csot_prose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,60 @@ func TestCSOTProse(t *testing.T) {
"expected ping to fail within 150ms")
})
})

mt.RunOpts("11. multi-batch bulkWrites", mtest.NewOptions().MinServerVersion("8.0").
AtlasDataLake(false).Topologies(mtest.Single), func(mt *mtest.T) {
coll := mt.CreateCollection(mtest.Collection{DB: "db", Name: "coll"}, false)
err := coll.Drop(context.Background())
require.NoError(mt, err, "Drop error: %v", err)

mt.SetFailPoint(failpoint.FailPoint{
ConfigureFailPoint: "failCommand",
Mode: failpoint.Mode{
Times: 2,
},
Data: failpoint.Data{
FailCommands: []string{"bulkWrite"},
BlockConnection: true,
BlockTimeMS: 1010,
},
})

var hello struct {
MaxBsonObjectSize int
MaxMessageSizeBytes int
}
err = mt.DB.RunCommand(context.Background(), bson.D{{"hello", 1}}).Decode(&hello)
require.NoError(mt, err, "Hello error: %v", err)

models := &mongo.ClientWriteModels{}
n := hello.MaxMessageSizeBytes/hello.MaxBsonObjectSize + 1
for i := 0; i < n; i++ {
models.
AppendInsertOne("db", "coll", &mongo.ClientInsertOneModel{
Document: bson.D{{"a", strings.Repeat("b", hello.MaxBsonObjectSize-500)}},
})
}

var cnt int
cm := &event.CommandMonitor{
Started: func(_ context.Context, evt *event.CommandStartedEvent) {
if evt.CommandName == "bulkWrite" {
cnt++
}
},
}
cliOptions := options.Client().
SetTimeout(2 * time.Second).
SetMonitor(cm).
ApplyURI(mtest.ClusterURI())
integtest.AddTestServerAPIVersion(cliOptions)
cli, err := mongo.Connect(cliOptions)
require.NoError(mt, err, "Connect error: %v", err)
_, err = cli.BulkWrite(context.Background(), models)
assert.ErrorContains(mt, err, "context deadline exceeded", "expected a timeout error, got: %v", err)
assert.Equal(mt, 2, cnt, "expected bulkWrite calls: %d, got: %d", 2, cnt)
})
}

func TestCSOTProse_GridFS(t *testing.T) {
Expand Down
Loading
Loading