forked from mongodb/node-mongodb-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed the HA to run on it's own connection instead of using the exist…
…ing connections so any problem in HA will not cause a driver ripple effect
- Loading branch information
Showing
7 changed files
with
211 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
test/auxilliary/replicaset_auth_connection_handling_test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
var mongodb = process.env['TEST_NATIVE'] != null ? require('../../lib/mongodb').native() : require('../../lib/mongodb').pure(); | ||
|
||
var testCase = require('nodeunit').testCase, | ||
debug = require('util').debug, | ||
inspect = require('util').inspect, | ||
nodeunit = require('nodeunit'), | ||
gleak = require('../../dev/tools/gleak'), | ||
Db = mongodb.Db, | ||
Cursor = mongodb.Cursor, | ||
Collection = mongodb.Collection, | ||
Server = mongodb.Server, | ||
ReadPreference = mongodb.ReadPreference, | ||
ReplSetServers = mongodb.ReplSetServers, | ||
ReplicaSetManager = require('../../test/tools/replica_set_manager').ReplicaSetManager, | ||
Step = require("step"); | ||
|
||
var MONGODB = 'integration_tests'; | ||
var serverManager = null; | ||
var RS = RS == null ? null : RS; | ||
|
||
/** | ||
* Retrieve the server information for the current | ||
* instance of the db client | ||
* | ||
* @ignore | ||
*/ | ||
exports.setUp = function(callback) { | ||
RS = new ReplicaSetManager({retries:120, | ||
// auth:true, | ||
journal:true, | ||
arbiter_count:0, | ||
secondary_count:2, | ||
passive_count:0}); | ||
RS.startSet(true, function(err, result) { | ||
if(err != null) throw err; | ||
// Finish setup | ||
callback(); | ||
}); | ||
} | ||
|
||
/** | ||
* Retrieve the server information for the current | ||
* instance of the db client | ||
* | ||
* @ignore | ||
*/ | ||
exports.tearDown = function(callback) { | ||
callback(); | ||
} | ||
|
||
exports['Should correctly handle replicaset master stepdown and stepup without loosing auth'] = function(test) { | ||
var replSet = new ReplSetServers( [ | ||
new Server( 'localhost', 30000), | ||
new Server( 'localhost', 30001) | ||
], | ||
{rs_name:"replica-set-foo", poolSize:1} | ||
); | ||
|
||
// Connect | ||
new Db('replicaset_test_auth', replSet, {safe:false}).open(function(err, db) { | ||
// Just set auths for the manager to handle it correctly | ||
RS.setAuths("root", "root"); | ||
// Add a user | ||
db.admin().addUser("root", "root", function(err, result) { | ||
test.equal(null, err); | ||
|
||
db.admin().authenticate("root", "root", function(err, result) { | ||
test.equal(null, err); | ||
test.ok(result); | ||
|
||
RS.killPrimary(9, function(err, result) { | ||
db.collection('replicaset_test_auth').insert({a:1}, {safe:true}, function(err, result) { | ||
test.equal(null, err); | ||
|
||
db.close(); | ||
test.done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} |
Oops, something went wrong.