summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavi Vetriselvan <pvselvan@umich.edu>2020-05-06 11:25:31 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-05-26 18:00:49 +0000
commit928320fcd24806a8292216fb17642cd69410459c (patch)
tree265c521f337505ed34412607ea1dd62b4a2e5b1b
parent15e384e1938cb8c64dae29f4a02d9da9defecd7f (diff)
downloadmongo-928320fcd24806a8292216fb17642cd69410459c.tar.gz
SERVER-47798 ismaster.js tests should ensure ismaster field is a boolean
(cherry picked from commit d5d0401e518beab5b659c1a01a092286f8a9c792) (cherry picked from commit 9c1ce38d7c87f625be1c2d5d7f5a6b709ebfb72e)
-rw-r--r--jstests/core/ismaster.js5
-rw-r--r--jstests/sharding/ismaster.js5
2 files changed, 8 insertions, 2 deletions
diff --git a/jstests/core/ismaster.js b/jstests/core/ismaster.js
index d920e20383b..22b19ac734e 100644
--- a/jstests/core/ismaster.js
+++ b/jstests/core/ismaster.js
@@ -1,3 +1,4 @@
+"use strict";
var res = db.isMaster();
// check that the fields that should be there are there and have proper values
assert(res.maxBsonObjectSize && isNumber(res.maxBsonObjectSize) && res.maxBsonObjectSize > 0,
@@ -6,7 +7,8 @@ assert(res.maxMessageSizeBytes && isNumber(res.maxMessageSizeBytes) && res.maxBs
"maxMessageSizeBytes possibly missing:" + tojson(res));
assert(res.maxWriteBatchSize && isNumber(res.maxWriteBatchSize) && res.maxWriteBatchSize > 0,
"maxWriteBatchSize possibly missing:" + tojson(res));
-assert(res.ismaster, "ismaster missing or false:" + 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));
if (!testingReplication) {
@@ -27,6 +29,7 @@ if (!testingReplication) {
"buildIndexes",
"me"
];
+ var field;
// check that the fields that shouldn't be there are not there
for (field in res) {
if (!res.hasOwnProperty(field)) {
diff --git a/jstests/sharding/ismaster.js b/jstests/sharding/ismaster.js
index 47dff297e96..2d5cea7b586 100644
--- a/jstests/sharding/ismaster.js
+++ b/jstests/sharding/ismaster.js
@@ -1,3 +1,4 @@
+"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
@@ -5,7 +6,8 @@ assert(res.maxBsonObjectSize && isNumber(res.maxBsonObjectSize) && res.maxBsonOb
"maxBsonObjectSize possibly missing:" + tojson(res));
assert(res.maxMessageSizeBytes && isNumber(res.maxMessageSizeBytes) && res.maxBsonObjectSize > 0,
"maxMessageSizeBytes possibly missing:" + tojson(res));
-assert(res.ismaster, "ismaster missing or false:" + 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 = [
@@ -26,6 +28,7 @@ var unwantedFields = [
];
// 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;