diff options
author | Huayu Ouyang <huayu.ouyang@mongodb.com> | 2020-09-23 21:39:11 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-10-01 15:49:47 +0000 |
commit | d5b1d3a1eb23e3249c3dee05c29c010c7693fbaf (patch) | |
tree | 4afbb807f831327952bbbc71fb9f8b9abbf35a83 | |
parent | 078aa203f8625c4e1227ffc4e316cea218eb15c9 (diff) | |
download | mongo-d5b1d3a1eb23e3249c3dee05c29c010c7693fbaf.tar.gz |
SERVER-50419 Test that serverStatus metrics correctly print commands.hello if the user sends hello
-rw-r--r-- | jstests/noPassthrough/server_status_metrics_hello_command.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/jstests/noPassthrough/server_status_metrics_hello_command.js b/jstests/noPassthrough/server_status_metrics_hello_command.js new file mode 100644 index 00000000000..8aacfedae2f --- /dev/null +++ b/jstests/noPassthrough/server_status_metrics_hello_command.js @@ -0,0 +1,44 @@ +/** + * Tests that serverStatus metrics correctly print commands.hello if the user sends hello + * and commands.isMaster if the user sends isMaster or ismaster + */ +(function() { +"use strict"; +const mongod = MongoRunner.runMongod(); +const dbName = "server_status_metrics_hello_command"; +const db = mongod.getDB(dbName); +let serverStatusMetrics = db.serverStatus().metrics.commands; +const initialIsMasterTotal = serverStatusMetrics.isMaster.total; +const initialHelloTotal = 0; + +// Running hello command. +jsTestLog("Running hello command"); +assert.commandWorked(db.runCommand({hello: 1})); +serverStatusMetrics = db.serverStatus().metrics.commands; +assert.eq( + serverStatusMetrics.hello.total, initialHelloTotal + 1, "commands.hello should increment"); +assert.eq(serverStatusMetrics.isMaster.total, + initialIsMasterTotal, + "commands.isMaster should not increment"); + +// Running isMaster command. +jsTestLog("Running isMaster command"); +assert.commandWorked(db.runCommand({isMaster: 1})); +serverStatusMetrics = db.serverStatus().metrics.commands; +assert.eq( + serverStatusMetrics.hello.total, initialHelloTotal + 1, "commands.hello should not increment"); +assert.eq(serverStatusMetrics.isMaster.total, + initialIsMasterTotal + 1, + "commands.isMaster should increment"); + +// Running ismaster command. +jsTestLog("Running ismaster command"); +assert.commandWorked(db.runCommand({ismaster: 1})); +serverStatusMetrics = db.serverStatus().metrics.commands; +assert.eq( + serverStatusMetrics.hello.total, initialHelloTotal + 1, "commands.hello should not increment"); +assert.eq(serverStatusMetrics.isMaster.total, + initialIsMasterTotal + 2, + "commands.isMaster should increment"); +MongoRunner.stopMongod(mongod); +})(); |