summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSpencer T Brody <spencer@mongodb.com>2014-07-24 12:08:11 -0400
committerSpencer T Brody <spencer@mongodb.com>2014-07-25 16:23:34 -0400
commit76c04d500f1364a3a9ec0d56877044c378d938ea (patch)
tree9b43b489dfffe893bcef538127256aec80678ae3
parenta09163ade822ce97e9bbf570bccea9781c37603d (diff)
downloadmongo-76c04d500f1364a3a9ec0d56877044c378d938ea.tar.gz
SERVER-14582 Make ReplSetTest.waitForIndicator work with auth when primary is down
-rw-r--r--src/mongo/shell/replsettest.js96
1 files changed, 48 insertions, 48 deletions
diff --git a/src/mongo/shell/replsettest.js b/src/mongo/shell/replsettest.js
index f75add0b6d9..a5964d07e19 100644
--- a/src/mongo/shell/replsettest.js
+++ b/src/mongo/shell/replsettest.js
@@ -903,64 +903,64 @@ ReplSetTest.prototype.waitForIndicator = function( node, states, ind, timeout ){
var status = undefined
var self = this;
- var checkStatusWaitForIndicator = function() {
- assert.soon(function() {
-
- try {
- status = self.status();
- }
- catch ( ex ) {
- print( "ReplSetTest waitForIndicator could not get status: " + tojson( ex ) );
- return false;
+ assert.soon(function() {
+ try {
+ var conn = self.callIsMaster();
+ if (!conn) conn = self.liveNodes.slaves[0];
+ if (!conn) return false; // Try again to load connection
+
+ var status = null;
+ var getStatusFunc = function() {
+ status = conn.getDB('admin').runCommand({replSetGetStatus: 1});
+ };
+ if (self.keyFile) {
+ // Authenticate connection used for running replSetGetStatus if needed.
+ authutil.asCluster(conn, self.keyFile, getStatusFunc);
+ } else {
+ getStatusFunc();
}
+ }
+ catch ( ex ) {
+ print( "ReplSetTest waitForIndicator could not get status: " + tojson( ex ) );
+ return false;
+ }
- var printStatus = false
- if( lastTime == null || ( currTime = new Date().getTime() ) - (1000 * 5) > lastTime ) {
- if( lastTime == null ) {
- print( "ReplSetTest waitForIndicator Initial status ( timeout : " +
- timeout + " ) :" );
- }
- printjson( status );
- lastTime = new Date().getTime();
- printStatus = true;
+ var printStatus = false
+ if( lastTime == null || ( currTime = new Date().getTime() ) - (1000 * 5) > lastTime ) {
+ if( lastTime == null ) {
+ print( "ReplSetTest waitForIndicator Initial status ( timeout : " +
+ timeout + " ) :" );
}
+ printjson( status );
+ lastTime = new Date().getTime();
+ printStatus = true;
+ }
- if (typeof status.members == 'undefined') {
- return false;
- }
+ if (typeof status.members == 'undefined') {
+ return false;
+ }
- for( var i = 0; i < status.members.length; i++ ) {
- if( printStatus ) {
- print( "Status for : " + status.members[i].name + ", checking " +
- node.host + "/" + node.name );
- }
- if( status.members[i].name == node.host || status.members[i].name == node.name ) {
- for( var j = 0; j < states.length; j++ ) {
- if( printStatus ) {
- print( "Status " + " : " + status.members[i][ind] +
- " target state : " + states[j] );
- }
- if( status.members[i][ind] == states[j] ) {
- return true;
- }
+ for( var i = 0; i < status.members.length; i++ ) {
+ if( printStatus ) {
+ print( "Status for : " + status.members[i].name + ", checking " +
+ node.host + "/" + node.name );
+ }
+ if( status.members[i].name == node.host || status.members[i].name == node.name ) {
+ for( var j = 0; j < states.length; j++ ) {
+ if( printStatus ) {
+ print( "Status " + " : " + status.members[i][ind] +
+ " target state : " + states[j] );
+ }
+ if( status.members[i][ind] == states[j] ) {
+ return true;
}
}
}
+ }
- return false;
-
- }, "waiting for state indicator " + ind + " for " + timeout + "ms", timeout);
- };
+ return false;
- if (self.keyFile) {
- // Authenticate connections to the replica set members using the keyfile,
- // if applicable, before attempting to perform operations.
- authutil.asCluster(self.getMaster(), self.keyFile, checkStatusWaitForIndicator);
- }
- else {
- // No keyfile, so no authenication necessary.
- checkStatusWaitForIndicator();
- }
+ }, "waiting for state indicator " + ind + " for " + timeout + "ms", timeout);
print( "ReplSetTest waitForIndicator final status:" )
printjson( status )