diff options
author | Marcos José Grillo Ramirez <marcos.grillo@mongodb.com> | 2021-07-07 14:22:37 +0200 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-07-07 16:12:35 +0000 |
commit | e5c7116913d04d66eb1c9d5cc15250167c37e2c3 (patch) | |
tree | da7226ee9eda9ffcd7c55cfbca573e2828158072 /jstests/sharding/localhostAuthBypass.js | |
parent | a862b5d0279bb681634f698def16b90c1117b3f5 (diff) | |
download | mongo-e5c7116913d04d66eb1c9d5cc15250167c37e2c3.tar.gz |
SERVER-58315 Change jstests to not use standalone nodes as shards nor config server
Diffstat (limited to 'jstests/sharding/localhostAuthBypass.js')
-rw-r--r-- | jstests/sharding/localhostAuthBypass.js | 47 |
1 files changed, 12 insertions, 35 deletions
diff --git a/jstests/sharding/localhostAuthBypass.js b/jstests/sharding/localhostAuthBypass.js index eb9f3f771c8..449c928e467 100644 --- a/jstests/sharding/localhostAuthBypass.js +++ b/jstests/sharding/localhostAuthBypass.js @@ -18,6 +18,7 @@ var keyfile = "jstests/libs/key1"; var numShards = 2; var username = "foo"; var password = "bar"; +var adhocShard = 0; var createUser = function(mongo) { print("============ adding a user."); @@ -33,14 +34,19 @@ var addUsersToEachShard = function(st) { }; var addShard = function(st, shouldPass) { - var m = MongoRunner.runMongod({auth: "", keyFile: keyfile, useHostname: false, 'shardsvr': ''}); - var res = st.getDB("admin").runCommand({addShard: m.host}); + adhocShard++; + var rs = + new ReplSetTest({nodes: 1, host: 'localhost', name: 'localhostAuthShard-' + adhocShard}); + rs.startSet({shardsvr: "", keyFile: keyfile, auth: ""}); + rs.initiate(); + + var res = st.getDB("admin").runCommand({addShard: rs.getURL()}); if (shouldPass) { assert.commandWorked(res, "Add shard"); } else { assert.commandFailed(res, "Add shard"); } - return m; + return rs; }; var findEmptyShard = function(st, ns) { @@ -192,35 +198,6 @@ var start = function() { }); }; -var shutdown = function(st) { - print("============ shutting down."); - - // SERVER-8445 - // Unlike MongoRunner.stopMongod and ReplSetTest.stopSet, - // ShardingTest.stop does not have a way to provide auth - // information. Therefore, we'll do this manually for now. - - for (var i = 0; i < st._mongos.length; i++) { - var conn = st["s" + i]; - MongoRunner.stopMongos(conn, - /*signal*/ false, - {auth: {user: username, pwd: password}}); - } - - for (var i = 0; i < st._connections.length; i++) { - st["rs" + i].stopSet(/*signal*/ false, {auth: {user: username, pwd: password}}); - } - - for (var i = 0; i < st._configServers.length; i++) { - var conn = st["config" + i]; - MongoRunner.stopMongod(conn, - /*signal*/ false, - {auth: {user: username, pwd: password}}); - } - - st.stop(); -}; - print("====================="); print("starting shards"); print("====================="); @@ -259,8 +236,8 @@ assertCanRunCommands(mongo, st); extraShards.push(addShard(mongo, 1)); st.printShardingStatus(); -shutdown(st); -extraShards.forEach(function(sh) { - MongoRunner.stopMongod(sh); +extraShards.forEach(function(rs) { + rs.stopSet(); }); +st.stop(); })(); |