diff --git a/package.json b/package.json index 9eee8f07ba..23a8396719 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "dependencies": { "es6-promise": "3.2.1", "mongodb-core": "2.1.2", + "mongodb-core": "christkv/mongodb-core#2.0", "readable-stream": "2.1.5" }, "devDependencies": { diff --git a/test/functional/replicaset_mock_tests.js b/test/functional/replicaset_mock_tests.js index 796d8b3347..537518e646 100644 --- a/test/functional/replicaset_mock_tests.js +++ b/test/functional/replicaset_mock_tests.js @@ -222,3 +222,94 @@ exports['Should correctly print warning and error when no mongos proxies in seed }); } } + +exports['Should correctly set socketTimeoutMS and connectTimeoutMS for mongos'] = { + metadata: { + requires: { + generators: true, + topology: "single" + } + }, + + test: function(configuration, test) { + var MongoClient = configuration.require.MongoClient, + ObjectId = configuration.require.ObjectId, + ReadPreference = configuration.require.ReadPreference, + Long = configuration.require.Long, + co = require('co'), + mockupdb = require('../mock'); + + // Contain mock server + var mongos1 = null; + var mongos2 = null; + var running = true; + + // Extend the object + var extend = function(template, fields) { + for(var name in template) fields[name] = template[name]; + return fields; + } + + // Default message fields + var defaultFields = { + "ismaster" : true, + "msg" : "isdbgrid", + "maxBsonObjectSize" : 16777216, + "maxMessageSizeBytes" : 48000000, + "maxWriteBatchSize" : 1000, + "localTime" : new Date(), + "maxWireVersion" : 5, + "minWireVersion" : 0, + "ok" : 1 + } + + // Primary server states + var serverIsMaster = [extend(defaultFields, {})]; + // Received command on server + var command = null; + // Boot the mock + co(function*() { + mongos1 = yield mockupdb.createServer(52000, 'localhost'); + mongos2 = yield mockupdb.createServer(52001, 'localhost'); + + // Mongos + co(function*() { + while(running) { + var request = yield mongos1.receive(); + + // Get the document + var doc = request.document; + + if(doc.ismaster) { + request.reply(serverIsMaster[0]); + } + } + }); + + // Mongos + co(function*() { + while(running) { + var request = yield mongos2.receive(); + + // Get the document + var doc = request.document; + + if(doc.ismaster) { + request.reply(serverIsMaster[0]); + } + } + }); + + MongoClient.connect('mongodb://localhost:52000,localhost:52001/test?socketTimeoutMS=120000&connectTimeoutMS=15000', function(err, db) { + test.equal(null, err); + test.equal(15000, db.serverConfig.s.mongos.s.options.connectionTimeout); + test.equal(120000, db.serverConfig.s.mongos.s.options.socketTimeout); + + db.close(); + mongos1.destroy(); + running = false; + test.done(); + }); + }); + } +} diff --git a/test/functional/sharding_connection_tests.js b/test/functional/sharding_connection_tests.js index 63ccb237e7..02dcaab16a 100644 --- a/test/functional/sharding_connection_tests.js +++ b/test/functional/sharding_connection_tests.js @@ -207,94 +207,3 @@ exports['Should correctly modify the server reconnectTries for all sharded proxy }); } } - -exports['Should correctly set socketTimeoutMS and connectTimeoutMS for mongos'] = { - metadata: { - requires: { - generators: true, - topology: "single" - } - }, - - test: function(configuration, test) { - var MongoClient = configuration.require.MongoClient, - ObjectId = configuration.require.ObjectId, - ReadPreference = configuration.require.ReadPreference, - Long = configuration.require.Long, - co = require('co'), - mockupdb = require('../mock'); - - // Contain mock server - var mongos1 = null; - var mongos2 = null; - var running = true; - - // Extend the object - var extend = function(template, fields) { - for(var name in template) fields[name] = template[name]; - return fields; - } - - // Default message fields - var defaultFields = { - "ismaster" : true, - "msg" : "isdbgrid", - "maxBsonObjectSize" : 16777216, - "maxMessageSizeBytes" : 48000000, - "maxWriteBatchSize" : 1000, - "localTime" : new Date(), - "maxWireVersion" : 5, - "minWireVersion" : 0, - "ok" : 1 - } - - // Primary server states - var serverIsMaster = [extend(defaultFields, {})]; - // Received command on server - var command = null; - // Boot the mock - co(function*() { - mongos1 = yield mockupdb.createServer(52000, 'localhost'); - mongos2 = yield mockupdb.createServer(52001, 'localhost'); - - // Mongos - co(function*() { - while(running) { - var request = yield mongos1.receive(); - - // Get the document - var doc = request.document; - - if(doc.ismaster) { - request.reply(serverIsMaster[0]); - } - } - }); - - // Mongos - co(function*() { - while(running) { - var request = yield mongos2.receive(); - - // Get the document - var doc = request.document; - - if(doc.ismaster) { - request.reply(serverIsMaster[0]); - } - } - }); - - MongoClient.connect('mongodb://localhost:52000,localhost:52001/test?socketTimeoutMS=120000&connectTimeoutMS=15000', function(err, db) { - test.equal(null, err); - test.equal(15000, db.serverConfig.s.mongos.s.options.connectionTimeout); - test.equal(120000, db.serverConfig.s.mongos.s.options.socketTimeout); - - db.close(); - mongos1.destroy(); - running = false; - test.done(); - }); - }); - } -}