@@ -563,10 +563,13 @@ First, perform the setup.
563
563
2. Using ` client ` , drop and create the collection ` db.coll ` configured with the included JSON schema
564
564
[limits / limits - schema .json ](../ limits / limits - schema .json ).
565
565
566
- 3. Using ` client ` , drop the collection ` keyvault.datakeys ` . Insert the document
566
+ 3. If using MongoDB 8.0 + , use ` client ` to drop and create the collection ` db.coll2 ` configured with the included
567
+ encryptedFields [limits / limits - encryptedFields .json ](../ limits / limits - encryptedFields .json ).
568
+
569
+ 4. Using ` client ` , drop the collection ` keyvault.datakeys ` . Insert the document
567
570
[limits / limits - key .json ](../ limits / limits - key .json )
568
571
569
- 4 . Create a MongoClient configured with auto encryption (referred to as ` client_encrypted ` )
572
+ 5 . Create a MongoClient configured with auto encryption (referred to as ` client_encrypted ` )
570
573
571
574
Configure with the ` local ` KMS provider as follows :
572
575
@@ -578,27 +581,27 @@ First, perform the setup.
578
581
579
582
Using ` client_encrypted ` perform the following operations :
580
583
581
- 1. Insert ` { "_id": "over_2mib_under_16mib", "unencrypted": <the string "a" repeated 2097152 times> } ` .
584
+ 1. Insert ` { "_id": "over_2mib_under_16mib", "unencrypted": <the string "a" repeated 2097152 times> } ` into ` coll ` .
582
585
583
586
Expect this to succeed since this is still under the ` maxBsonObjectSize ` limit .
584
587
585
588
2. Insert the document [limits / limits - doc .json ](../ limits / limits - doc .json ) concatenated with
586
- ` { "_id": "encryption_exceeds_2mib", "unencrypted": < the string "a" repeated (2097152 - 2000) times > } ` Note :
587
- limits - doc .json is a 1005 byte BSON document that encrypts to a ~ 10 ,000 byte document .
589
+ ` { "_id": "encryption_exceeds_2mib", "unencrypted": < the string "a" repeated (2097152 - 2000) times > } ` into
590
+ ` coll ` . Note : limits - doc .json is a 1005 byte BSON document that encrypts to a ~ 10 ,000 byte document .
588
591
589
592
Expect this to succeed since after encryption this still is below the normal maximum BSON document size . Note , before
590
593
auto encryption this document is under the 2 MiB limit . After encryption it exceeds the 2 MiB limit , but does NOT
591
594
exceed the 16 MiB limit .
592
595
593
- 3. Bulk insert the following :
596
+ 3. Use MongoCollection . bulkWrite to insert the following into ` coll ` :
594
597
595
598
- ` { "_id": "over_2mib_1", "unencrypted": <the string "a" repeated (2097152) times> } `
596
599
- ` { "_id": "over_2mib_2", "unencrypted": <the string "a" repeated (2097152) times> } `
597
600
598
601
Expect the bulk write to succeed and split after first doc (i .e . two inserts occur ). This may be verified using
599
602
[command monitoring ](../ ../ command - logging - and - monitoring / command - logging - and - monitoring .md ).
600
603
601
- 4. Bulk insert the following :
604
+ 4. Use MongoCollection . bulkWrite insert the following into ` coll ` :
602
605
603
606
- The document [limits / limits - doc .json ](../ limits / limits - doc .json ) concatenated with
604
607
` { "_id": "encryption_exceeds_2mib_1", "unencrypted": < the string "a" repeated (2097152 - 2000) times > } `
@@ -608,15 +611,34 @@ Using `client_encrypted` perform the following operations:
608
611
Expect the bulk write to succeed and split after first doc (i .e . two inserts occur ). This may be verified using
609
612
[command logging and monitoring ](../ ../ command - logging - and - monitoring / command - logging - and - monitoring .md ).
610
613
611
- 5. Insert ` { "_id": "under_16mib", "unencrypted": <the string "a" repeated 16777216 - 2000 times> ` .
614
+ 5. Insert ` { "_id": "under_16mib", "unencrypted": <the string "a" repeated 16777216 - 2000 times> ` into ` coll ` .
612
615
613
616
Expect this to succeed since this is still (just ) under the ` maxBsonObjectSize ` limit .
614
617
615
618
6. Insert the document [limits / limits - doc .json ](../ limits / limits - doc .json ) concatenated with
616
- ` { "_id": "encryption_exceeds_16mib", "unencrypted": < the string "a" repeated (16777216 - 2000) times > } `
619
+ ` { "_id": "encryption_exceeds_16mib", "unencrypted": < the string "a" repeated (16777216 - 2000) times > } ` into
620
+ ` coll ` .
617
621
618
622
Expect this to fail since encryption results in a document exceeding the ` maxBsonObjectSize ` limit .
619
623
624
+ 7. If using MongoDB 8.0 + , use MongoClient .bulkWrite to insert the following into ` coll2 ` :
625
+
626
+ - ` { "_id": "over_2mib_3", "unencrypted": <the string "a" repeated (2097152 - 1500) times> } `
627
+ - ` { "_id": "over_2mib_4", "unencrypted": <the string "a" repeated (2097152 - 1500) times> } `
628
+
629
+ Expect the bulk write to succeed and split after first doc (i .e . two inserts occur ). This may be verified using
630
+ [command logging and monitoring ](../ ../ command - logging - and - monitoring / command - logging - and - monitoring .md ).
631
+
632
+ 8. If using MongoDB 8.0 + , use MongoClient .bulkWrite to insert the following into ` coll2 ` :
633
+
634
+ - The document [limits / limits - qe - doc .json ](../ limits / limits - qe - doc .json ) concatenated with
635
+ ` { "_id": "encryption_exceeds_2mib_3", "foo": < the string "a" repeated (2097152 - 2000 - 1500) times > } `
636
+ - The document [limits / limits - qe - doc .json ](../ limits / limits - qe - doc .json ) concatenated with
637
+ ` { "_id": "encryption_exceeds_2mib_4", "foo": < the string "a" repeated (2097152 - 2000 - 1500) times > } `
638
+
639
+ Expect the bulk write to succeed and split after first doc (i .e . two inserts occur ). This may be verified using
640
+ [command logging and monitoring ](../ ../ command - logging - and - monitoring / command - logging - and - monitoring .md ).
641
+
620
642
Optionally , if it is possible to mock the maxWriteBatchSize (i .e . the maximum number of documents in a batch ) test that
621
643
setting maxWriteBatchSize = 1 and inserting the two documents ` { "_id": "a" }, { "_id": "b" } ` with ` client_encrypted `
622
644
splits the operation into two inserts .
0 commit comments