File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -2256,3 +2256,48 @@ exports['Should correctly execute parallelCollectionScan with single cursor emit
2256
2256
} ) ;
2257
2257
}
2258
2258
}
2259
+
2260
+ exports [ 'Should simulate closed cursor' ] = {
2261
+ // Add a tag that our runner can trigger on
2262
+ // in this case we are setting that node needs to be higher than 0.10.X to run
2263
+ metadata : { requires : { mongodb : ">2.5.5" , topology : [ "single" , "replicaset" ] } } ,
2264
+
2265
+ // The actual test we wish to run
2266
+ test : function ( configuration , test ) {
2267
+ var db = configuration . newDbInstance ( configuration . writeConcernMax ( ) , { poolSize :1 , auto_reconnect :false } ) ;
2268
+ // Establish connection to db
2269
+ db . open ( function ( err , db ) {
2270
+ var docs = [ ] ;
2271
+
2272
+ // Insert some documents
2273
+ for ( var i = 0 ; i < 1000 ; i ++ ) {
2274
+ docs . push ( { a :i } ) ;
2275
+ }
2276
+
2277
+ // Get the collection
2278
+ var collection = db . collection ( 'parallelCollectionScan_4' ) ;
2279
+ // Insert 1000 documents in a batch
2280
+ collection . insert ( docs , function ( err , result ) {
2281
+ var results = [ ] ;
2282
+ var numCursors = 1 ;
2283
+
2284
+ // Get the cursor
2285
+ var cursor = collection . find ( { } ) . batchSize ( 2 ) ;
2286
+ // Get next document
2287
+ cursor . next ( function ( err , doc ) {
2288
+ test . equal ( null , err ) ;
2289
+ test . ok ( doc != null ) ;
2290
+
2291
+ // Mess with state forcing a call to isDead on the cursor
2292
+ cursor . s . state = 2 ;
2293
+
2294
+ cursor . next ( function ( err , doc ) {
2295
+ test . ok ( err != null ) ;
2296
+ db . close ( ) ;
2297
+ test . done ( ) ;
2298
+ } )
2299
+ } ) ;
2300
+ } ) ;
2301
+ } ) ;
2302
+ }
2303
+ }
You can’t perform that action at this time.
0 commit comments