Skip to content

Commit 85c8b96

Browse files
committed
NODE-529 Undefined options variable in Db.prototype.dropDatabase
1 parent e1b1b37 commit 85c8b96

File tree

10 files changed

+495
-464
lines changed

10 files changed

+495
-464
lines changed

HISTORY.md

Lines changed: 448 additions & 446 deletions
Large diffs are not rendered by default.

lib/db.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,6 @@ Db.prototype.dropCollection = function(name, callback) {
733733
*/
734734
Db.prototype.dropDatabase = function(callback) {
735735
var self = this;
736-
if(typeof options == 'function') callback = options, options = {};
737736
// Drop database command
738737
var cmd = {'dropDatabase':1};
739738

lib/mongo_client.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,16 +242,19 @@ var connect = function(url, options, callback) {
242242
new Db(object.dbName, __server, {w:1, native_parser:false}).open(function(err, db) {
243243
// Update number of servers
244244
totalNumberOfServers = totalNumberOfServers - 1;
245+
245246
// If no error do the correct checks
246247
if(!err) {
247248
// Close the connection
248249
db.close();
249250
var isMasterDoc = db.serverConfig.isMasterDoc;
251+
250252
// Check what type of server we have
251253
if(isMasterDoc.setName) {
252254
totalNumberOfMongodServers++;
253255
setName = isMasterDoc.setName;
254256
}
257+
255258
if(isMasterDoc.msg && isMasterDoc.msg == "isdbgrid") totalNumberOfMongosServers++;
256259
} else {
257260
error = err;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"legacy"
1414
],
1515
"dependencies": {
16-
"mongodb-core": "1.2.8"
16+
"mongodb-core": "1.2.9"
1717
, "readable-stream": "1.0.31"
1818
, "es6-promise": "2.1.1"
1919
},

test/functional/authentication_tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ exports.shouldCorrectlyRetrieveReplSetGetStatusWithPromises = {
7171
* @ignore
7272
*/
7373
exports.shouldCorrectlyCallValidateCollectionUsingAuthenticatedMode = {
74-
metadata: { requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } },
74+
metadata: { requires: { topology: ['single', 'ssl', 'heap', 'wiredtiger'] } },
7575

7676
// The actual test we wish to run
7777
test: function(configure, test) {

test/functional/gridfs_tests.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,20 +246,37 @@ exports.shouldCorrectlyHandleMultipleChunkGridStore = {
246246
var fs_client = configuration.newDbInstance(configuration.writeConcernMax(), {poolSize:1});
247247

248248
fs_client.open(function(err, fs_client) {
249+
test.equal(null, err);
250+
249251
fs_client.dropDatabase(function(err, done) {
252+
test.equal(null, err);
253+
250254
var gridStore = new GridStore(fs_client, "test_gs_multi_chunk", "w");
251255
gridStore.open(function(err, gridStore) {
256+
test.equal(null, err);
257+
252258
gridStore.chunkSize = 512;
253259
var file1 = ''; var file2 = ''; var file3 = '';
254260
for(var i = 0; i < gridStore.chunkSize; i++) { file1 = file1 + 'x'; }
255261
for(var i = 0; i < gridStore.chunkSize; i++) { file2 = file2 + 'y'; }
256262
for(var i = 0; i < gridStore.chunkSize; i++) { file3 = file3 + 'z'; }
257263

258264
gridStore.write(file1, function(err, gridStore) {
265+
console.dir(err)
266+
test.equal(null, err);
267+
259268
gridStore.write(file2, function(err, gridStore) {
269+
test.equal(null, err);
270+
260271
gridStore.write(file3, function(err, gridStore) {
272+
test.equal(null, err);
273+
261274
gridStore.close(function(err, result) {
275+
test.equal(null, err);
276+
262277
fs_client.collection('fs.chunks', function(err, collection) {
278+
test.equal(null, err);
279+
263280
collection.count(function(err, count) {
264281
test.equal(3, count);
265282

test/functional/index_tests.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,6 @@ exports.shouldCorrectlyHandleGeospatialIndexes = {
367367
test.equal(err,null);
368368

369369
collection.insert({'loc': [200,200]}, configuration.writeConcernMax(), function(err, result) {
370-
console.dir(err)
371-
console.dir(result)
372370
test.ok(err.errmsg.indexOf("point not in interval of") != -1);
373371
test.ok(err.errmsg.indexOf("-180") != -1);
374372
test.ok(err.errmsg.indexOf("180") != -1);

test/functional/mongo_client_tests.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,3 +352,26 @@ exports['Should fail due to wrong uri user:password@localhost'] = {
352352
}
353353
}
354354
}
355+
356+
/**
357+
* @ignore
358+
*/
359+
exports["correctly timeout MongoClient connect using custom connectTimeoutMS"] = {
360+
metadata: { requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } },
361+
362+
// The actual test we wish to run
363+
test: function(configuration, test) {
364+
var MongoClient = configuration.require.MongoClient;
365+
366+
var start = new Date();
367+
368+
MongoClient.connect('mongodb://example.com/test?connectTimeoutMS=1000&maxPoolSize=1', function(err, db) {
369+
// db.close();
370+
371+
var end = new Date();
372+
console.dir(end.getTime() - start.getTime())
373+
374+
test.done();
375+
});
376+
}
377+
}

test/functional/operation_generators_example_tests.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4164,21 +4164,10 @@ exports.shouldCorrectlyRetrieveReplSetGetStatusWithGenerators = {
41644164
// Use the admin database for the operation
41654165
var adminDb = db.admin();
41664166

4167-
// Add the new user to the admin database
4168-
var result = yield adminDb.addUser('admin14', 'admin14');
4169-
test.ok(result != null);
4170-
4171-
// Authenticate using the newly added user
4172-
var result = yield adminDb.authenticate('admin14', 'admin14');
4173-
test.equal(true, result);
4174-
41754167
// Retrive the server Info, returns error if we are not
41764168
// running a replicaset
41774169
yield adminDb.replSetGetStatus();
41784170

4179-
var result = yield adminDb.removeUser('admin14');
4180-
test.ok(result);
4181-
41824171
db.close();
41834172
test.done();
41844173
});

test/runner.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ if(argv.t == 'functional') {
366366
port: 31000,
367367
host: 'localhost',
368368
url: "mongodb://%slocalhost:31000/integration_tests?rs_name=rs",
369-
writeConcernMax: {w: 'majority', wtimeout: 5000},
369+
writeConcernMax: {w: 'majority', wtimeout: 30000},
370370
replicasetName: 'rs',
371371

372372
topology: function(host, port, serverOptions) {
@@ -395,7 +395,7 @@ if(argv.t == 'functional') {
395395
port: 50000,
396396
host: 'localhost',
397397
url: "mongodb://%slocalhost:50000/integration_tests",
398-
writeConcernMax: {w: 'majority', wtimeout: 5000},
398+
writeConcernMax: {w: 'majority', wtimeout: 30000},
399399

400400
topology: function(host, port, serverOptions) {
401401
var m = require('../');

0 commit comments

Comments
 (0)