diff options
author | Tess Avitabile <tess.avitabile@mongodb.com> | 2020-01-16 21:22:45 +0000 |
---|---|---|
committer | A. Jesse Jiryu Davis <jesse@mongodb.com> | 2020-01-27 15:40:36 -0500 |
commit | 0023f438a456839f2dbe53b5aa491aa12b09f1fa (patch) | |
tree | 4590326d93fe93711abefd2d11e818523367cd25 /jstests | |
parent | b40bfb22895bf70e3c277b18aa61841bb218f446 (diff) | |
download | mongo-0023f438a456839f2dbe53b5aa491aa12b09f1fa.tar.gz |
SERVER-44814 Support waitInIsMaster failpoint on mongos
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/noPassthrough/waitInIsMaster_failpoint.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/jstests/noPassthrough/waitInIsMaster_failpoint.js b/jstests/noPassthrough/waitInIsMaster_failpoint.js new file mode 100644 index 00000000000..7534ff8eaf4 --- /dev/null +++ b/jstests/noPassthrough/waitInIsMaster_failpoint.js @@ -0,0 +1,37 @@ +// Tests the waitInIsMaster failpoint. +// @tags: [requires_replication] +(function() { +"use strict"; +load("jstests/libs/fail_point_util.js"); + +function runTest(conn) { + function runIsMasterCommand() { + const now = new Date(); + assert.commandWorked(db.runCommand({isMaster: 1})); + const isMasterDuration = new Date() - now; + assert.gte(isMasterDuration, 100); + } + // Use a skip of 1, since the parallel shell runs isMaster when it starts. + const isMasterFailpoint = configureFailPoint(conn, "waitInIsMaster", {}, {skip: 1}); + const awaitIsMaster = startParallelShell(runIsMasterCommand, conn.port); + isMasterFailpoint.wait(); + sleep(100); + isMasterFailpoint.off(); + awaitIsMaster(); +} + +const standalone = MongoRunner.runMongod({}); +assert.neq(null, standalone, "mongod was unable to start up"); +runTest(standalone); +MongoRunner.stopMongod(standalone); + +const rst = new ReplSetTest({nodes: 1}); +rst.startSet(); +rst.initiate(); +runTest(rst.getPrimary()); +rst.stopSet(); + +const st = new ShardingTest({mongos: 1, shards: [{nodes: 1}], config: 1}); +runTest(st.s); +st.stop(); +}()); |