diff options
author | Ali Mir <ali.mir@mongodb.com> | 2020-10-12 16:31:03 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-10-12 22:06:54 +0000 |
commit | 46835741b3abaeb10aea8b3c1ef67616f95115b0 (patch) | |
tree | 0f381988e7553b930eb40c2aca1085f01ead4f58 | |
parent | bfd4d609f71b3ef7e7ef6947486ceb54da26ec2b (diff) | |
download | mongo-46835741b3abaeb10aea8b3c1ef67616f95115b0.tar.gz |
SERVER-51497 Remove additional timestamps from response objects in ismaster.js
-rw-r--r-- | jstests/core/ismaster.js | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/jstests/core/ismaster.js b/jstests/core/ismaster.js index aee8086225b..d4efc80462d 100644 --- a/jstests/core/ismaster.js +++ b/jstests/core/ismaster.js @@ -66,16 +66,25 @@ checkResponseFields("hello"); checkResponseFields("ismaster"); checkResponseFields("isMaster"); +// As operations happen concurrently, the response objects may have different timestamps. To compare +// response objects returned from calling commands directly and shell helpers below, we must remove +// the timestamps. +function removeTimestamps(cmdResponse) { + delete cmdResponse.localTime; + delete cmdResponse.operationTime; + delete cmdResponse.$clusterTime; + if (cmdResponse.lastWrite) { + delete cmdResponse.lastWrite.opTime; + delete cmdResponse.lastWrite.majorityOpTime; + } +} + // We also test the db.hello() and db.isMaster() helpers to ensure that they return // the same response objects as from running the commands directly. -let cmdResponse1 = db.runCommand("hello"); -let cmdResponse2 = db.hello(); -delete cmdResponse1.localTime; -delete cmdResponse2.localTime; +let cmdResponse1 = removeTimestamps(db.runCommand("hello")); +let cmdResponse2 = removeTimestamps(db.hello()); assert.eq(cmdResponse1, cmdResponse2); -cmdResponse1 = db.runCommand("isMaster"); -cmdResponse2 = db.isMaster(); -delete cmdResponse1.localTime; -delete cmdResponse2.localTime; +cmdResponse1 = removeTimestamps(db.runCommand("isMaster")); +cmdResponse2 = removeTimestamps(db.isMaster()); assert.eq(cmdResponse1, cmdResponse2); |