@@ -21,7 +21,8 @@ import {
2121 promiseWithResolvers ,
2222 squashError
2323} from '../../mongodb' ;
24- import { type FailPoint } from '../../tools/utils' ;
24+ import { type FailPoint , makeMultiBatchWrite } from '../../tools/utils' ;
25+ import { filterForCommands } from '../shared' ;
2526
2627// TODO(NODE-5824): Implement CSOT prose tests
2728describe ( 'CSOT spec prose tests' , function ( ) {
@@ -1183,9 +1184,9 @@ describe('CSOT spec prose tests', function () {
11831184 } ) ;
11841185 } ) ;
11851186
1186- describe . skip (
1187+ describe (
11871188 '11. Multi-batch bulkWrites' ,
1188- { requires : { mongodb : '>=8.0' , serverless : 'forbid' } } ,
1189+ { requires : { mongodb : '>=8.0' , serverless : 'forbid' , topology : 'single' } } ,
11891190 function ( ) {
11901191 /**
11911192 * ### 11. Multi-batch bulkWrites
@@ -1245,9 +1246,6 @@ describe('CSOT spec prose tests', function () {
12451246 }
12461247 } ;
12471248
1248- let maxBsonObjectSize : number ;
1249- let maxMessageSizeBytes : number ;
1250-
12511249 beforeEach ( async function ( ) {
12521250 await internalClient
12531251 . db ( 'db' )
@@ -1256,29 +1254,20 @@ describe('CSOT spec prose tests', function () {
12561254 . catch ( ( ) => null ) ;
12571255 await internalClient . db ( 'admin' ) . command ( failpoint ) ;
12581256
1259- const hello = await internalClient . db ( 'admin' ) . command ( { hello : 1 } ) ;
1260- maxBsonObjectSize = hello . maxBsonObjectSize ;
1261- maxMessageSizeBytes = hello . maxMessageSizeBytes ;
1262-
12631257 client = this . configuration . newClient ( { timeoutMS : 2000 , monitorCommands : true } ) ;
12641258 } ) ;
12651259
1266- it . skip ( 'performs two bulkWrites which fail to complete before 2000 ms' , async function ( ) {
1260+ it ( 'performs two bulkWrites which fail to complete before 2000 ms' , async function ( ) {
12671261 const writes = [ ] ;
1268- client . on ( 'commandStarted' , ev => writes . push ( ev ) ) ;
1262+ client . on ( 'commandStarted' , filterForCommands ( 'bulkWrite' , writes ) ) ;
12691263
1270- const length = maxMessageSizeBytes / maxBsonObjectSize + 1 ;
1271- const models = Array . from ( { length } , ( ) => ( {
1272- namespace : 'db.coll' ,
1273- name : 'insertOne' as const ,
1274- document : { a : 'b' . repeat ( maxBsonObjectSize - 500 ) }
1275- } ) ) ;
1264+ const models = await makeMultiBatchWrite ( this . configuration ) ;
12761265
12771266 const error = await client . bulkWrite ( models ) . catch ( error => error ) ;
12781267
12791268 expect ( error , error . stack ) . to . be . instanceOf ( MongoOperationTimeoutError ) ;
1280- expect ( writes . map ( ev => ev . commandName ) ) . to . deep . equal ( [ 'bulkWrite' , 'bulkWrite' ] ) ;
1281- } ) . skipReason = 'TODO(NODE-6403): client.bulkWrite is implemented in a follow up' ;
1269+ expect ( writes ) . to . have . lengthOf ( 2 ) ;
1270+ } ) ;
12821271 }
12831272 ) ;
12841273} ) ;
0 commit comments