summaryrefslogtreecommitdiff
path: root/jstests/httpinterface
diff options
context:
space:
mode:
authorAndy Schwerin <schwerin@mongodb.com>2015-11-17 18:58:17 -0500
committerAndy Schwerin <schwerin@mongodb.com>2015-11-18 15:57:05 -0500
commit5d22dc0c4ea4e611464c75b356f52741184359e6 (patch)
treebb2903c11cec0eae83d03e743e66c29b753a33b7 /jstests/httpinterface
parentf59b2b7634b1c4c84e3f8f096a4e895986bf4d30 (diff)
downloadmongo-5d22dc0c4ea4e611464c75b356f52741184359e6.tar.gz
SERVER-21320 When no port is provided for a configdb argument to mongos, assume
port 27019. This is the behavior for mongodb 3.0 and prior, which was inadvertently removed while refactoring sharding code in preparation for SERVER-1448.
Diffstat (limited to 'jstests/httpinterface')
-rw-r--r--jstests/httpinterface/sharding_configdb_on_default_ports.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/jstests/httpinterface/sharding_configdb_on_default_ports.js b/jstests/httpinterface/sharding_configdb_on_default_ports.js
new file mode 100644
index 00000000000..c11e3ce06af
--- /dev/null
+++ b/jstests/httpinterface/sharding_configdb_on_default_ports.js
@@ -0,0 +1,37 @@
+// This test confirms that mongos interprets host names passed to it via the
+// --configdb command line argument *without* a port number as referring to
+// processes listening on the config server port (27019) rather than the default
+// mongod port of 27017.
+//
+// That is, mongos --configdb=localhost should look for a config server on port 27019,
+// not port 27017.
+//
+// The test confirms this behavior for 1-node config servers, SCCC config servers and
+// CSRS config servers.
+
+(function() {
+ "use strict";
+
+ function getHostPart(hostAndPort) {
+ return hostAndPort.substr(0, hostAndPort.lastIndexOf(':'));
+ }
+ var c1, c2, c3;
+
+ c1 = MongoRunner.runMongod({configsvr: "", port: 27019, replSet: "csrs"});
+ assert.commandWorked(c1.adminCommand("replSetInitiate"));
+ c2 = MongoRunner.runMongod({configsvr: ""});
+ c3 = MongoRunner.runMongod({configsvr: ""});
+
+ var configstrs = [
+ getHostPart(c1.host) + "," + c2.host + "," + c3.host,
+ getHostPart(c1.host),
+ "csrs/" + getHostPart(c1.host)
+ ];
+ var failureMessages = [];
+ configstrs.forEach(function (configdb) {
+ if (!MongoRunner.runMongos({configdb: configdb})) {
+ failureMessages.push("Failed to start mongos with configdb=\"" + configdb + "\"");
+ }
+ });
+ assert.eq(0, failureMessages.length, tojson(failureMessages));
+}());