summaryrefslogtreecommitdiff
path: root/jstests/sharding/ismaster.js
diff options
context:
space:
mode:
authorPavi Vetriselvan <pavithra.vetriselvan@mongodb.com>2020-07-30 12:39:35 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-09-10 16:44:19 +0000
commite67ef16a4c619c41b9d584879351886ff1147098 (patch)
tree3bdf8a8c53843da2f503b179a9483281891cfeaf /jstests/sharding/ismaster.js
parent33887c37750c267f7ddfdeada7096d6abc0bf128 (diff)
downloadmongo-e67ef16a4c619c41b9d584879351886ff1147098.tar.gz
SERVER-49986 Convert isMaster command to hello and keep isMaster, ismaster aliases
(cherry picked from commit 9a4be902441496be7ef40e5404a91ac30dc81f77)
Diffstat (limited to 'jstests/sharding/ismaster.js')
-rw-r--r--jstests/sharding/ismaster.js94
1 files changed, 57 insertions, 37 deletions
diff --git a/jstests/sharding/ismaster.js b/jstests/sharding/ismaster.js
index 2d5cea7b586..a582f677241 100644
--- a/jstests/sharding/ismaster.js
+++ b/jstests/sharding/ismaster.js
@@ -1,42 +1,62 @@
+/**
+ * This test ensures that the hello command and its aliases, ismaster and isMaster, are all
+ * accepted by mongos.
+ */
"use strict";
var st = new ShardingTest({shards: 1, mongos: 1});
-var res = st.s0.getDB("admin").runCommand("ismaster");
-// check that the fields that should be there are there and have proper values
-assert(res.maxBsonObjectSize && isNumber(res.maxBsonObjectSize) && res.maxBsonObjectSize > 0,
- "maxBsonObjectSize possibly missing:" + tojson(res));
-assert(res.maxMessageSizeBytes && isNumber(res.maxMessageSizeBytes) && res.maxBsonObjectSize > 0,
- "maxMessageSizeBytes possibly missing:" + tojson(res));
-assert.eq("boolean", typeof res.ismaster, "ismaster field is not a boolean" + tojson(res));
-assert(res.ismaster === true, "ismaster field is false" + tojson(res));
-assert(res.localTime, "localTime possibly missing:" + tojson(res));
-assert(res.msg && res.msg == "isdbgrid", "msg possibly missing or wrong:" + tojson(res));
-var unwantedFields = [
- "setName",
- "setVersion",
- "secondary",
- "hosts",
- "passives",
- "arbiters",
- "primary",
- "aribterOnly",
- "passive",
- "slaveDelay",
- "hidden",
- "tags",
- "buildIndexes",
- "me"
-];
-// check that the fields that shouldn't be there are not there
-var badFields = [];
-var field;
-for (field in res) {
- if (!res.hasOwnProperty(field)) {
- continue;
- }
- if (Array.contains(unwantedFields, field)) {
- badFields.push(field);
+
+function checkResponseFields(commandString) {
+ jsTestLog("Running the " + commandString + " command");
+ var res = st.s0.getDB("admin").runCommand(commandString);
+
+ // check that the fields that should be there are there and have proper values
+ assert(res.maxBsonObjectSize && isNumber(res.maxBsonObjectSize) && res.maxBsonObjectSize > 0,
+ "maxBsonObjectSize possibly missing:" + tojson(res));
+ assert(
+ res.maxMessageSizeBytes && isNumber(res.maxMessageSizeBytes) && res.maxBsonObjectSize > 0,
+ "maxMessageSizeBytes possibly missing:" + tojson(res));
+
+ // TODO SERVER-49988: Check for res.isWritablePrimary instead of res.ismaster if a hello command
+ // was executed.
+ assert.eq("boolean", typeof res.ismaster, "ismaster field is not a boolean" + tojson(res));
+ assert(res.ismaster === true, "ismaster field is false" + tojson(res));
+
+ assert(res.localTime, "localTime possibly missing:" + tojson(res));
+ assert(res.msg && res.msg == "isdbgrid", "msg possibly missing or wrong:" + tojson(res));
+
+ var unwantedFields = [
+ "setName",
+ "setVersion",
+ "secondary",
+ "hosts",
+ "passives",
+ "arbiters",
+ "primary",
+ "aribterOnly",
+ "passive",
+ "slaveDelay",
+ "hidden",
+ "tags",
+ "buildIndexes",
+ "me"
+ ];
+ // check that the fields that shouldn't be there are not there
+ var badFields = [];
+ var field;
+ for (field in res) {
+ if (!res.hasOwnProperty(field)) {
+ continue;
+ }
+ if (Array.contains(unwantedFields, field)) {
+ badFields.push(field);
+ }
}
+ assert(badFields.length === 0,
+ "\nthe result:\n" + tojson(res) + "\ncontained fields it shouldn't have: " + badFields);
}
-assert(badFields.length === 0,
- "\nthe result:\n" + tojson(res) + "\ncontained fields it shouldn't have: " + badFields);
+
+checkResponseFields("hello");
+checkResponseFields("ismaster");
+checkResponseFields("isMaster");
+
st.stop();