Skip to content

Commit 64992e1

Browse files
committed
added some minor tests for single server/replicaset for disconnect
1 parent 0b49170 commit 64992e1

File tree

3 files changed

+41
-5
lines changed

3 files changed

+41
-5
lines changed

lib/collection.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -513,9 +513,7 @@ Collection.prototype.insertMany = function(docs, options, callback) {
513513

514514
// Return a Promise
515515
return new this.s.promiseLibrary(function(resolve, reject) {
516-
// console.log("########## insertMany 0")
517516
bulkWrite(self, operations, options, function(err, r) {
518-
// console.log("########## insertMany 1")
519517
if(err) return reject(err);
520518
resolve(mapInserManyResults(docs, r));
521519
});
@@ -2478,8 +2476,10 @@ var findAndRemove = function(self, query, sort, options, callback) {
24782476
define.classMethod('findAndRemove', {callback: true, promise:true});
24792477

24802478
function decorateWithWriteConcern(command, self, options) {
2479+
// Do we support collation 3.4 and higher
2480+
var capabilities = self.s.topology.capabilities();
24812481
// Do we support write concerns 3.4 and higher
2482-
if(self.s.topology.capabilities().commandsTakeWriteConcern) {
2482+
if(capabilities && capabilities.commandsTakeWriteConcern) {
24832483
// Get the write concern settings
24842484
var finalOptions = writeConcern(shallowClone(options), self.s.db, self, options);
24852485
// Add the write concern to the command
@@ -2491,7 +2491,9 @@ function decorateWithWriteConcern(command, self, options) {
24912491

24922492
function decorateWithCollation(command, self, options) {
24932493
// Do we support collation 3.4 and higher
2494-
if(self.s.topology.capabilities().commandsTakeCollation) {
2494+
var capabilities = self.s.topology.capabilities();
2495+
// Do we support write concerns 3.4 and higher
2496+
if(capabilities && capabilities.commandsTakeCollation) {
24952497
if(options.collation && typeof options.collation == 'object') {
24962498
command.collation = options.collation;
24972499
} else if(self.s.collation && typeof self.s.collation == 'object') {
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* @ignore
3+
*/
4+
exports['Should correctly recover when bufferMaxEntries: -1 and restart'] = {
5+
metadata: { requires: { topology: ['single', 'replicaset'] }, ignore: { travis:true } },
6+
7+
// The actual test we wish to run
8+
test: function(configuration, test) {
9+
var MongoClient = configuration.require.MongoClient
10+
, f = require('util').format;
11+
12+
var done = false;
13+
14+
MongoClient.connect(configuration.url(), {}, function(err, db) {
15+
test.equal(null, err);
16+
17+
configuration.manager.stop(9).then(function() {
18+
db.collection('disconnect_handler_tests').update({a:1}, {$set: {b:1}}, function(err, r) {
19+
test.equal(null, err);
20+
test.equal(0, r.result.nModified);
21+
22+
db.close();
23+
test.done();
24+
});
25+
26+
setTimeout(function() {
27+
configuration.manager.restart(9, {waitMS: 5000}).then(function() {
28+
});
29+
}, 5000)
30+
});
31+
});
32+
}
33+
}

test/runner.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,8 @@ var testFiles = [
298298
, '/test/functional/mongo_client_options_tests.js'
299299
, '/test/functional/decimal128_tests.js'
300300
, '/test/functional/find_and_modify_tests.js'
301-
, '/test/functional/hang_tests.js'
301+
, '/test/functional/hang_tests.js',
302+
, '/test/functional/disconnect_handler_tests.js',
302303

303304
// Replicaset tests
304305
, '/test/functional/replset_read_preference_tests.js'

0 commit comments

Comments
 (0)