|
2 | 2 | const test = require('./shared').assert;
|
3 | 3 | const setupDatabase = require('./shared').setupDatabase;
|
4 | 4 | const expect = require('chai').expect;
|
| 5 | +const MongoClient = require('../../lib/mongo_client'); |
5 | 6 |
|
6 | 7 | describe('Find', function() {
|
7 | 8 | before(function() {
|
@@ -2624,6 +2625,59 @@ describe('Find', function() {
|
2624 | 2625 | }
|
2625 | 2626 | });
|
2626 | 2627 |
|
| 2628 | + it('Should not use a session when using parallelCollectionScan', { |
| 2629 | + metadata: { |
| 2630 | + requires: { |
| 2631 | + mongodb: '>=3.6.0', |
| 2632 | + topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] |
| 2633 | + } |
| 2634 | + }, |
| 2635 | + test: function(done) { |
| 2636 | + const configuration = this.configuration; |
| 2637 | + const client = new MongoClient(configuration.url()); |
| 2638 | + |
| 2639 | + client.connect(function(err, client) { |
| 2640 | + var db = client.db(configuration.db); |
| 2641 | + var docs = []; |
| 2642 | + |
| 2643 | + // Insert some documents |
| 2644 | + for (var i = 0; i < 1000; i++) { |
| 2645 | + docs.push({ a: i }); |
| 2646 | + } |
| 2647 | + |
| 2648 | + // Get the collection |
| 2649 | + var collection = db.collection('parallelCollectionScan_4'); |
| 2650 | + // Insert 1000 documents in a batch |
| 2651 | + collection.insert(docs, function(err) { |
| 2652 | + expect(err).to.be.null; |
| 2653 | + var numCursors = 1; |
| 2654 | + |
| 2655 | + // Execute parallelCollectionScan command |
| 2656 | + collection.parallelCollectionScan({ numCursors: numCursors }, function(err, cursors) { |
| 2657 | + expect(err).to.be.null; |
| 2658 | + expect(cursors) |
| 2659 | + .to.be.an('array') |
| 2660 | + .with.lengthOf(1); |
| 2661 | + |
| 2662 | + const cursor = cursors[0]; |
| 2663 | + |
| 2664 | + expect(cursor).to.not.have.nested.property('s.session'); |
| 2665 | + expect(cursor) |
| 2666 | + .to.have.nested.property('s.explicitlyIgnoreSession') |
| 2667 | + .that.equals(true); |
| 2668 | + |
| 2669 | + cursor.toArray(err => { |
| 2670 | + expect(err).to.be.null; |
| 2671 | + expect(cursor).to.not.have.nested.property('s.session'); |
| 2672 | + |
| 2673 | + cursor.close().then(() => client.close().then(() => done())); |
| 2674 | + }); |
| 2675 | + }); |
| 2676 | + }); |
| 2677 | + }); |
| 2678 | + } |
| 2679 | + }); |
| 2680 | + |
2627 | 2681 | it('Should correctly sort using text search on 2.6 or higher in find', {
|
2628 | 2682 | // Add a tag that our runner can trigger on
|
2629 | 2683 | // in this case we are setting that node needs to be higher than 0.10.X to run
|
|
0 commit comments