@@ -21,7 +21,8 @@ import {
21
21
promiseWithResolvers ,
22
22
squashError
23
23
} from '../../mongodb' ;
24
- import { type FailPoint } from '../../tools/utils' ;
24
+ import { type FailPoint , makeMultiBatchWrite } from '../../tools/utils' ;
25
+ import { filterForCommands } from '../shared' ;
25
26
26
27
// TODO(NODE-5824): Implement CSOT prose tests
27
28
describe ( 'CSOT spec prose tests' , function ( ) {
@@ -1183,9 +1184,9 @@ describe('CSOT spec prose tests', function () {
1183
1184
} ) ;
1184
1185
} ) ;
1185
1186
1186
- describe . skip (
1187
+ describe (
1187
1188
'11. Multi-batch bulkWrites' ,
1188
- { requires : { mongodb : '>=8.0' , serverless : 'forbid' } } ,
1189
+ { requires : { mongodb : '>=8.0' , serverless : 'forbid' , topology : 'single' } } ,
1189
1190
function ( ) {
1190
1191
/**
1191
1192
* ### 11. Multi-batch bulkWrites
@@ -1245,9 +1246,6 @@ describe('CSOT spec prose tests', function () {
1245
1246
}
1246
1247
} ;
1247
1248
1248
- let maxBsonObjectSize : number ;
1249
- let maxMessageSizeBytes : number ;
1250
-
1251
1249
beforeEach ( async function ( ) {
1252
1250
await internalClient
1253
1251
. db ( 'db' )
@@ -1256,29 +1254,20 @@ describe('CSOT spec prose tests', function () {
1256
1254
. catch ( ( ) => null ) ;
1257
1255
await internalClient . db ( 'admin' ) . command ( failpoint ) ;
1258
1256
1259
- const hello = await internalClient . db ( 'admin' ) . command ( { hello : 1 } ) ;
1260
- maxBsonObjectSize = hello . maxBsonObjectSize ;
1261
- maxMessageSizeBytes = hello . maxMessageSizeBytes ;
1262
-
1263
1257
client = this . configuration . newClient ( { timeoutMS : 2000 , monitorCommands : true } ) ;
1264
1258
} ) ;
1265
1259
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 ( ) {
1267
1261
const writes = [ ] ;
1268
- client . on ( 'commandStarted' , ev => writes . push ( ev ) ) ;
1262
+ client . on ( 'commandStarted' , filterForCommands ( 'bulkWrite' , writes ) ) ;
1269
1263
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 ) ;
1276
1265
1277
1266
const error = await client . bulkWrite ( models ) . catch ( error => error ) ;
1278
1267
1279
1268
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
+ } ) ;
1282
1271
}
1283
1272
) ;
1284
1273
} ) ;
0 commit comments