@@ -370,54 +370,15 @@ Assert that a CommandStartedEvent was observed for the `killCursors` command.
370370
371371### 10. ` MongoClient.bulkWrite ` returns error for unacknowledged too-large insert
372372
373- This test must only be run on 8.0+ servers. This test must be skipped on Atlas Serverless.
374-
375- Construct a ` MongoClient ` (referred to as ` client ` ).
376-
377- Perform a ` hello ` command using ` client ` and record the following values from the response: ` maxBsonObjectSize ` .
378-
379- Then, construct the following document (referred to as ` document ` ):
380-
381- ``` javascript
382- {
383- " a" : " b" .repeat (maxBsonObjectSize)
384- }
385- ```
373+ Removed.
386374
387375#### With insert
388376
389- Construct the following write model (referred to as ` model ` ):
390-
391- ``` javascript
392- InsertOne: {
393- " namespace" : " db.coll" ,
394- " document" : document
395- }
396- ```
397-
398- Construct as list of write models (referred to as ` models ` ) with the one ` model ` .
399-
400- Call ` MongoClient.bulkWrite ` with ` models ` and ` BulkWriteOptions.writeConcern ` set to an unacknowledged write concern.
401-
402- Expect a client-side error due the size.
377+ Removed.
403378
404379#### With replace
405380
406- Construct the following write model (referred to as ` model ` ):
407-
408- ``` javascript
409- ReplaceOne: {
410- " namespace" : " db.coll" ,
411- " filter" : {},
412- " replacement" : document
413- }
414- ```
415-
416- Construct as list of write models (referred to as ` models ` ) with the one ` model ` .
417-
418- Call ` MongoClient.bulkWrite ` with ` models ` and ` BulkWriteOptions.writeConcern ` set to an unacknowledged write concern.
419-
420- Expect a client-side error due the size.
381+ Removed.
421382
422383### 11. ` MongoClient.bulkWrite ` batch splits when the addition of a new namespace exceeds the maximum message size
423384
@@ -437,7 +398,7 @@ CommandStartedEvents. Perform a `hello` command using `client` and record the fo
437398
438399Calculate the following values:
439400
440- ```
401+ ``` javascript
441402opsBytes = maxMessageSizeBytes - 1122
442403numModels = opsBytes / maxBsonObjectSize
443404remainderBytes = opsBytes % maxBsonObjectSize
@@ -493,7 +454,7 @@ Assert that the namespace contained in `event.command.nsInfo` is "db.coll".
493454
494455Construct the following namespace (referred to as ` namespace ` ):
495456
496- ```
457+ ``` javascript
497458" db." + " c" .repeat (200 )
498459```
499460
@@ -533,19 +494,19 @@ changed in the bulk write specification.
533494
534495The command document for the ` bulkWrite ` has the following structure and size:
535496
536- ``` javascript
497+ ``` typescript
537498{
538499 " bulkWrite" : 1 ,
539500 " errorsOnly" : true ,
540501 " ordered" : true
541502}
542503
543- Size: 43 bytes
504+ // Size: 43 bytes
544505```
545506
546507Each write model will create an ` ops ` document with the following structure and size:
547508
548- ``` javascript
509+ ``` typescript
549510{
550511 " insert" : <0 | 1 >,
551512 " document" : {
@@ -554,7 +515,7 @@ Each write model will create an `ops` document with the following structure and
554515 }
555516}
556517
557- Size: 57 bytes + < number of characters in string>
518+ // Size: 57 bytes + <number of characters in string>
558519```
559520
560521The ` ops ` document for both ` newNamespaceModel ` and ` sameNamespaceModel ` has a string with one character, so it is a
@@ -567,7 +528,7 @@ The models using the "db.coll" namespace will create one `nsInfo` document with
567528 " ns" : " db.coll"
568529}
569530
570- Size: 21 bytes
531+ // Size: 21 bytes
571532```
572533
573534` newNamespaceModel ` will create an ` nsInfo ` document with the following structure and size:
@@ -577,13 +538,13 @@ Size: 21 bytes
577538 " ns" : " db.<c repeated 200 times>"
578539}
579540
580- Size: 217 bytes
541+ // Size: 217 bytes
581542```
582543
583544We need to fill up the rest of the message with bytes such that another ` ops ` document will fit, but another ` nsInfo `
584545entry will not. The following calculations are used:
585546
586- ```
547+ ``` python
587548# 1000 is the OP_MSG overhead required in the spec
588549maxBulkWriteBytes = maxMessageSizeBytes - 1000
589550
@@ -628,7 +589,7 @@ Assert that `error` is a client error.
628589
629590Construct the following namespace (referred to as ` namespace ` ):
630591
631- ```
592+ ``` javascript
632593" db." + " c" .repeat (maxMessageSizeBytes)
633594```
634595
@@ -693,3 +654,57 @@ maxTimeMS value of 2000ms for the `explain`.
693654
694655Obtain the command started event for the explain. Confirm that the top-level explain command should has a ` maxTimeMS `
695656value of ` 2000 ` .
657+
658+ ### 15. ` MongoClient.bulkWrite ` with unacknowledged write concern uses ` w:0 ` for all batches
659+
660+ This test must only be run on 8.0+ servers. This test must be skipped on Atlas Serverless.
661+
662+ If testing with a sharded cluster, only connect to one mongos. This is intended to ensure the ` countDocuments ` operation
663+ uses the same connection as the ` bulkWrite ` to get the correct connection count. (See
664+ [ DRIVERS-2921] ( https://jira.mongodb.org/browse/DRIVERS-2921 ) ).
665+
666+ Construct a ` MongoClient ` (referred to as ` client ` ) with
667+ [ command monitoring] ( ../../command-logging-and-monitoring/command-logging-and-monitoring.md ) enabled to observe
668+ CommandStartedEvents. Perform a ` hello ` command using ` client ` and record the ` maxBsonObjectSize ` and
669+ ` maxMessageSizeBytes ` values in the response.
670+
671+ Construct a ` MongoCollection ` (referred to as ` coll ` ) for the collection "db.coll". Drop ` coll ` .
672+
673+ Use the ` create ` command to create "db.coll" to workaround [ SERVER-95537] ( https://jira.mongodb.org/browse/SERVER-95537 ) .
674+
675+ Construct the following write model (referred to as ` model ` ):
676+
677+ ``` javascript
678+ InsertOne: {
679+ " namespace" : " db.coll" ,
680+ " document" : { " a" : " b" .repeat (maxBsonObjectSize - 500 ) }
681+ }
682+ ```
683+
684+ Construct a list of write models (referred to as ` models ` ) with ` model ` repeated
685+ ` maxMessageSizeBytes / maxBsonObjectSize + 1 ` times.
686+
687+ Call ` client.bulkWrite ` with ` models ` . Pass ` BulkWriteOptions ` with ` ordered ` set to ` false ` and ` writeConcern ` set to
688+ an unacknowledged write concern. Assert no error occurred. Assert the result indicates the write was unacknowledged.
689+
690+ Assert that two CommandStartedEvents (referred to as ` firstEvent ` and ` secondEvent ` ) were observed for the ` bulkWrite `
691+ command. Assert that the length of ` firstEvent.command.ops ` is ` maxMessageSizeBytes / maxBsonObjectSize ` . Assert that
692+ the length of ` secondEvent.command.ops ` is 1. If the driver exposes ` operationId ` s in its CommandStartedEvents, assert
693+ that ` firstEvent.operationId ` is equal to ` secondEvent.operationId ` . Assert both commands include
694+ ` writeConcern: {w: 0} ` .
695+
696+ To force completion of the ` w:0 ` writes, execute ` coll.countDocuments ` and expect the returned count is
697+ ` maxMessageSizeBytes / maxBsonObjectSize + 1 ` . This is intended to avoid incomplete writes interfering with other tests
698+ that may use this collection.
699+
700+ ### 16. Generated document identifiers are the first field in their document
701+
702+ Construct a ` MongoClient ` (referred to as ` client ` ) with
703+ [ command monitoring] ( ../../command-logging-and-monitoring/command-logging-and-monitoring.md ) enabled to observe
704+ CommandStartedEvents. For each of ` insertOne ` , client ` bulkWrite ` , and collection ` bulkWrite ` , do the following:
705+
706+ - Execute the command with a document that does not contain an ` _id ` field.
707+ - If possible, capture the wire protocol message (referred to as ` request ` ) of the command and assert that the first
708+ field of ` request.documents[0] ` is ` _id ` .
709+ - Otherwise, capture the CommandStartedEvent (referred to as ` event ` ) emitted by the command and assert that the first
710+ field of ` event.command.documents[0] ` is ` _id ` .
0 commit comments