Skip to content

Commit 4d88edf

Browse files
committed
GODRIVER-2388 implementation
1 parent 1309416 commit 4d88edf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2982
-440
lines changed

internal/driverutil/operation.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ const (
2828
ListIndexesOp = "listIndexes" // ListIndexesOp is the name for listing indexes
2929
ListDatabasesOp = "listDatabases" // ListDatabasesOp is the name for listing databases
3030
UpdateOp = "update" // UpdateOp is the name for updating
31+
BulkWriteOp = "bulkWrite" // BulkWriteOp is the name for client-level bulk write
3132
)

internal/integration/client_side_encryption_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ func TestClientSideEncryptionCustomCrypt(t *testing.T) {
398398
"expected 0 calls to DecryptExplicit, got %v", cc.numDecryptExplicitCalls)
399399
assert.Equal(mt, cc.numCloseCalls, 0,
400400
"expected 0 calls to Close, got %v", cc.numCloseCalls)
401-
assert.Equal(mt, cc.numBypassAutoEncryptionCalls, 2,
401+
assert.Equal(mt, cc.numBypassAutoEncryptionCalls, 1,
402402
"expected 2 calls to BypassAutoEncryption, got %v", cc.numBypassAutoEncryptionCalls)
403403
})
404404
}

internal/integration/crud_prose_test.go

Lines changed: 553 additions & 0 deletions
Large diffs are not rendered by default.

internal/integration/csot_prose_test.go

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,60 @@ func TestCSOTProse(t *testing.T) {
177177
"expected ping to fail within 150ms")
178178
})
179179
})
180+
181+
mt.RunOpts("11. multi-batch bulkWrites", mtest.NewOptions().MinServerVersion("8.0").
182+
AtlasDataLake(false).Topologies(mtest.Single), func(mt *mtest.T) {
183+
coll := mt.CreateCollection(mtest.Collection{DB: "db", Name: "coll"}, false)
184+
err := coll.Drop(context.Background())
185+
require.NoError(mt, err, "Drop error: %v", err)
186+
187+
mt.SetFailPoint(failpoint.FailPoint{
188+
ConfigureFailPoint: "failCommand",
189+
Mode: failpoint.Mode{
190+
Times: 2,
191+
},
192+
Data: failpoint.Data{
193+
FailCommands: []string{"bulkWrite"},
194+
BlockConnection: true,
195+
BlockTimeMS: 1010,
196+
},
197+
})
198+
199+
var hello struct {
200+
MaxBsonObjectSize int
201+
MaxMessageSizeBytes int
202+
}
203+
err = mt.DB.RunCommand(context.Background(), bson.D{{"hello", 1}}).Decode(&hello)
204+
require.NoError(mt, err, "Hello error: %v", err)
205+
206+
models := &mongo.ClientWriteModels{}
207+
n := hello.MaxMessageSizeBytes/hello.MaxBsonObjectSize + 1
208+
for i := 0; i < n; i++ {
209+
models.
210+
AppendInsertOne("db", "coll", &mongo.ClientInsertOneModel{
211+
Document: bson.D{{"a", strings.Repeat("b", hello.MaxBsonObjectSize-500)}},
212+
})
213+
}
214+
215+
var cnt int
216+
cm := &event.CommandMonitor{
217+
Started: func(_ context.Context, evt *event.CommandStartedEvent) {
218+
if evt.CommandName == "bulkWrite" {
219+
cnt++
220+
}
221+
},
222+
}
223+
cliOptions := options.Client().
224+
SetTimeout(2 * time.Second).
225+
SetMonitor(cm).
226+
ApplyURI(mtest.ClusterURI())
227+
integtest.AddTestServerAPIVersion(cliOptions)
228+
cli, err := mongo.Connect(cliOptions)
229+
require.NoError(mt, err, "Connect error: %v", err)
230+
_, err = cli.BulkWrite(context.Background(), models)
231+
assert.ErrorContains(mt, err, "context deadline exceeded", "expected a timeout error, got: %v", err)
232+
assert.Equal(mt, 2, cnt, "expected bulkWrite calls: %d, got: %d", 2, cnt)
233+
})
180234
}
181235

182236
func TestCSOTProse_GridFS(t *testing.T) {

0 commit comments

Comments
 (0)