diff options
author | Matt Cotter <matt.cotter@mongodb.com> | 2016-12-12 16:43:11 -0500 |
---|---|---|
committer | Matt Cotter <matt.cotter@mongodb.com> | 2016-12-12 16:43:11 -0500 |
commit | 94fefd0851c4436fd7dc7b084101a7ed59eee7ed (patch) | |
tree | b761bed292c47099ed3aa4c4c052e66da8428a54 | |
parent | 3878fd8993b361207a853b8db11a1a3b484ea837 (diff) | |
download | mongo-94fefd0851c4436fd7dc7b084101a7ed59eee7ed.tar.gz |
Revert "SERVER-27289 fix ConnectionString parsing in shell"
This reverts commit b9c59fd5c79c0b0d9c845e3c05e50ab1dd9f7f4a.
-rw-r--r-- | jstests/noPassthroughWithMongod/resplset_host_connection_validation.js | 59 | ||||
-rw-r--r-- | src/mongo/shell/mongo.js | 6 |
2 files changed, 4 insertions, 61 deletions
diff --git a/jstests/noPassthroughWithMongod/resplset_host_connection_validation.js b/jstests/noPassthroughWithMongod/resplset_host_connection_validation.js deleted file mode 100644 index 1e556b00fb9..00000000000 --- a/jstests/noPassthroughWithMongod/resplset_host_connection_validation.js +++ /dev/null @@ -1,59 +0,0 @@ -// Test --host with a replica set. - -const replSetName = 'hostTestReplSetName'; - -// This "inner_mode" method of spawning a replset and re-running was copied from -// host_connection_string_validation.js -if ("undefined" == typeof inner_mode) { - jsTest.log("Outer mode test starting a replica set"); - - const replTest = new ReplSetTest({name: replSetName, nodes: 2}); - replTest.startSet(); - replTest.initiate(); - - const primary = replTest.getPrimary(); - - const args = [ - "mongo", - "--nodb", - "--eval", - "inner_mode=true;port=" + primary.port + ";", - "jstests/noPassthroughWithMongod/host_connection_string_validation.js" - ]; - var exitCode = _runMongoProgram(...args); - jsTest.log("Inner mode test finished, exit code was " + exitCode); - - // Stop the server we started - jsTest.log("Outer mode test stopping server"); - MongoRunner.stopMongod(mongod.port, 15); - - // Pass the inner test's exit code back as the outer test's exit code - quit(exitCode); -} - -var testHost = function(host) { - var exitCode = runMongoProgram('mongo', '--eval', ';', '--host', host); - if (exitCode !== 0) { - doassert("failed to connect with `--host " + host + "`, but expected success. Exit code: " + - exitCode); - } -}; - -var connStrings = [ - `localhost:${port}`, - `${replSetName}/localhost:${port}`, - `mongodb://localhost:${port}/admin?replicaSet=${replSetName}`, - `mongodb://localhost:${port}`, -]; - -function runConnectionStringTestFor(i, connectionString) { - print("Testing connection string " + i + "..."); - print(" * testing " + connectionString); - testHost(connectionString); -} - -for (const i = 0; i < goodStrings.length; ++i) { - runConnectionStringTestFor(i, connStrings[i]); -} - -jsTest.log("SUCCESSFUL test completion"); diff --git a/src/mongo/shell/mongo.js b/src/mongo/shell/mongo.js index d50463bc3bc..cbc7386f0f9 100644 --- a/src/mongo/shell/mongo.js +++ b/src/mongo/shell/mongo.js @@ -221,10 +221,12 @@ connect = function(url, user, pass) { } if (!url.startsWith("mongodb://")) { - const colon = url.lastIndexOf(":"); - const slash = url.lastIndexOf("/"); + var colon = url.lastIndexOf(":"); + var slash = url.lastIndexOf("/"); if (slash == -1 && colon == -1) { url = "mongodb://127.0.0.1:27017/" + url; + } else { + url = "mongodb://" + url; } } |