diff options
author | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2019-04-05 15:49:09 -0400 |
---|---|---|
committer | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2019-04-05 15:50:14 -0400 |
commit | b5883226855662d54f990ebb7dcfd952c037a11c (patch) | |
tree | d0d4064f4634298b321cffd00c3009dfc1a40b99 /jstests | |
parent | fc47f37ed80a2ec3ee36939eb164fe0d1c65bb80 (diff) | |
download | mongo-b5883226855662d54f990ebb7dcfd952c037a11c.tar.gz |
SERVER-40112 db.disableFreeMonitoring() returns 'not master' on secondary after restart
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/free_mon/free_mon_rs_register.js | 23 | ||||
-rw-r--r-- | jstests/free_mon/libs/free_mon.js | 25 |
2 files changed, 44 insertions, 4 deletions
diff --git a/jstests/free_mon/free_mon_rs_register.js b/jstests/free_mon/free_mon_rs_register.js index cabb82077fb..60b6dee5a72 100644 --- a/jstests/free_mon/free_mon_rs_register.js +++ b/jstests/free_mon/free_mon_rs_register.js @@ -56,7 +56,6 @@ load("jstests/free_mon/libs/free_mon.js"); assert.eq(isUUID(last_register.payload.uuid['local.oplog.rs']), true); // Restart the secondary - // Now we're going to shut down all nodes var s1 = rst._slaves[0]; var s1Id = rst.getNodeId(s1); @@ -67,6 +66,28 @@ load("jstests/free_mon/libs/free_mon.js"); mock_web.waitRegisters(3); + // Now disable it + assert.commandWorked(rst.getPrimary().adminCommand({setFreeMonitoring: 1, action: "disable"})); + + WaitForUnRegistration(rst.getPrimary()); + WaitForUnRegistration(rst.getSecondary()); + + assert.eq(FreeMonGetServerStatus(rst.getPrimary()).state, 'disabled'); + assert.eq(FreeMonGetServerStatus(rst.getSecondary()).state, 'disabled'); + + // Restart the secondary with it disabled + var s1 = rst._slaves[0]; + var s1Id = rst.getNodeId(s1); + + rst.stop(s1Id); + rst.waitForState(s1, ReplSetTest.State.DOWN); + + rst.restart(s1Id); + + // Make sure it is disabled + assert.eq(FreeMonGetServerStatus(rst.getPrimary()).state, 'disabled'); + assert.eq(FreeMonGetServerStatus(rst.getSecondary()).state, 'disabled'); + rst.stopSet(); mock_web.stop(); diff --git a/jstests/free_mon/libs/free_mon.js b/jstests/free_mon/libs/free_mon.js index b8824fa5bcc..3b08a905153 100644 --- a/jstests/free_mon/libs/free_mon.js +++ b/jstests/free_mon/libs/free_mon.js @@ -223,8 +223,9 @@ class FreeMonWebServer { * Wait for registration information to be populated in the database. * * @param {object} conn + * @param {string} state */ -function WaitForRegistration(conn) { +function WaitForDiskState(conn, state) { 'use strict'; const admin = conn.getDB("admin"); @@ -233,8 +234,26 @@ function WaitForRegistration(conn) { assert.soon(function() { const docs = admin.system.version.find({_id: "free_monitoring"}); const da = docs.toArray(); - return da.length === 1 && da[0].state === "enabled"; - }, "Failed to register", 60 * 1000); + return da.length === 1 && da[0].state === state; + }, "Failed to disk state", 60 * 1000); +} + +/** + * Wait for registration information to be populated in the database. + * + * @param {object} conn + */ +function WaitForRegistration(conn) { + WaitForDiskState(conn, 'enabled'); +} + +/** + * Wait for unregistration information to be populated in the database. + * + * @param {object} conn + */ +function WaitForUnRegistration(conn) { + WaitForDiskState(conn, 'disabled'); } /** |