diff options
author | Sara Golemon <sara.golemon@mongodb.com> | 2022-02-04 19:05:54 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-02-24 02:51:46 +0000 |
commit | e4032fe5c39f1974c76de4cefdc07d98ab25aeef (patch) | |
tree | 3bba629166e40d1455cfc1cd65d299311670c535 /jstests/multiVersion/libs | |
parent | e9f462ba1ec6c1c105fab71239b9a958ae106484 (diff) | |
download | mongo-e4032fe5c39f1974c76de4cefdc07d98ab25aeef.tar.gz |
SERVER-57369 Disable concurrent authentication
Diffstat (limited to 'jstests/multiVersion/libs')
-rw-r--r-- | jstests/multiVersion/libs/multi_rs.js | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/jstests/multiVersion/libs/multi_rs.js b/jstests/multiVersion/libs/multi_rs.js index 48d8f57bd2e..058f6e7c404 100644 --- a/jstests/multiVersion/libs/multi_rs.js +++ b/jstests/multiVersion/libs/multi_rs.js @@ -78,20 +78,21 @@ ReplSetTest.prototype.upgradeArbiters = function(options, user, pwd) { }; ReplSetTest.prototype.upgradePrimary = function(primary, options, user, pwd) { + function authNode(node) { + if (user !== undefined) { + assert(node.getDB('admin').auth(user, pwd)); + } else { + jsTest.authenticate(node); + } + } + // Merge new options into node settings. this.nodeOptions = mergeNodeOptions(this.nodeOptions, options); - jsTest.authenticate(primary); + authNode(primary); let oldPrimary = this.stepdown(primary); - this.waitForState(oldPrimary, ReplSetTest.State.SECONDARY); - - // stepping down the node can close the connection and lose the authentication state, so - // re-authenticate here before calling awaitNodesAgreeOnPrimary(). - if (user != undefined) { - oldPrimary.getDB('admin').auth(user, pwd); - } - jsTest.authenticate(oldPrimary); + this.waitForState(oldPrimary, ReplSetTest.State.SECONDARY, undefined, authNode); // waitForState() runs the logout command via asCluster() on either the current primary or the // first node in the replica set so we re-authenticate on all connections before calling @@ -105,10 +106,7 @@ ReplSetTest.prototype.upgradePrimary = function(primary, options, user, pwd) { continue; } - if (user != undefined) { - node.getDB('admin').auth(user, pwd); - } - jsTest.authenticate(node); + authNode(node); } this.awaitNodesAgreeOnPrimary(); @@ -126,7 +124,7 @@ ReplSetTest.prototype.upgradePrimary = function(primary, options, user, pwd) { }; ReplSetTest.prototype.upgradeNode = function(node, opts = {}, user, pwd) { - if (user != undefined) { + if (user !== undefined) { assert.eq(1, node.getDB("admin").auth(user, pwd)); } jsTest.authenticate(node); @@ -145,7 +143,7 @@ ReplSetTest.prototype.upgradeNode = function(node, opts = {}, user, pwd) { } var newNode = this.restart(node, opts); - if (user != undefined) { + if (user !== undefined) { newNode.getDB("admin").auth(user, pwd); } @@ -153,6 +151,10 @@ ReplSetTest.prototype.upgradeNode = function(node, opts = {}, user, pwd) { [ReplSetTest.State.PRIMARY, ReplSetTest.State.SECONDARY, ReplSetTest.State.ARBITER]; this.waitForState(newNode, waitForStates); + if (user !== undefined) { + newNode.getDB('admin').logout(); + } + return newNode; }; |