diff options
author | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2018-07-13 17:10:01 -0400 |
---|---|---|
committer | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2018-07-13 17:10:01 -0400 |
commit | 5a7537b07dbf7d8db74531632dc06883042b4234 (patch) | |
tree | c23c3a29923c6b77c0d3553b77f4e43d4523ef4c /jstests/free_mon | |
parent | daa559be8821b7c06ca9ca6f3638a1842348ef8d (diff) | |
download | mongo-5a7537b07dbf7d8db74531632dc06883042b4234.tar.gz |
SERVER-35903 Free monitoring disable without enabling does not work
Diffstat (limited to 'jstests/free_mon')
-rw-r--r-- | jstests/free_mon/free_mon_disable.js | 35 | ||||
-rw-r--r-- | jstests/free_mon/free_mon_rs_delete.js | 12 | ||||
-rw-r--r-- | jstests/free_mon/free_mon_rs_halt.js | 12 | ||||
-rw-r--r-- | jstests/free_mon/free_mon_rs_perm_del.js | 12 | ||||
-rw-r--r-- | jstests/free_mon/free_mon_rs_register.js | 4 | ||||
-rw-r--r-- | jstests/free_mon/libs/free_mon.js | 14 |
6 files changed, 68 insertions, 21 deletions
diff --git a/jstests/free_mon/free_mon_disable.js b/jstests/free_mon/free_mon_disable.js new file mode 100644 index 00000000000..2de9de1c651 --- /dev/null +++ b/jstests/free_mon/free_mon_disable.js @@ -0,0 +1,35 @@ +// Validate disable works +// +load("jstests/free_mon/libs/free_mon.js"); + +(function() { + 'use strict'; + + let mock_web = new FreeMonWebServer(); + + mock_web.start(); + + let options = { + setParameter: "cloudFreeMonitoringEndpointURL=" + mock_web.getURL(), + freeMonitoringTag: "foo", + verbose: 1, + }; + + const conn = MongoRunner.runMongod(options); + assert.neq(null, conn, 'mongod was unable to start up'); + + assert.commandWorked(conn.adminCommand({setFreeMonitoring: 1, action: "disable"})); + + const stats = mock_web.queryStats(); + print(tojson(stats)); + + assert.eq(stats.registers, 0); + + assert.eq(FreeMonGetStatus(conn).state, "disabled"); + + assert.eq(FreeMonGetServerStatus(conn).state, "disabled"); + + MongoRunner.stopMongod(conn); + + mock_web.stop(); +})(); diff --git a/jstests/free_mon/free_mon_rs_delete.js b/jstests/free_mon/free_mon_rs_delete.js index 6f14d17d1ad..335d93cfef4 100644 --- a/jstests/free_mon/free_mon_rs_delete.js +++ b/jstests/free_mon/free_mon_rs_delete.js @@ -24,8 +24,8 @@ load("jstests/free_mon/libs/free_mon.js"); mock_web.waitRegisters(2); - assert.eq(FreeMonGetStatus(rst.getPrimary()).state, 'enabled'); - assert.eq(FreeMonGetStatus(rst.getSecondary()).state, 'enabled'); + assert.eq(FreeMonGetServerStatus(rst.getPrimary()).state, 'enabled'); + assert.eq(FreeMonGetServerStatus(rst.getSecondary()).state, 'enabled'); const qs1 = mock_web.queryStats(); @@ -42,8 +42,8 @@ load("jstests/free_mon/libs/free_mon.js"); assert.eq(qs1.registers, qs2.registers); // Make sure we are back to the initial state. - assert.eq(FreeMonGetStatus(rst.getPrimary()).state, 'undecided'); - assert.eq(FreeMonGetStatus(rst.getSecondary()).state, 'undecided'); + assert.eq(FreeMonGetServerStatus(rst.getPrimary()).state, 'undecided'); + assert.eq(FreeMonGetServerStatus(rst.getSecondary()).state, 'undecided'); // Enable it again to be sure we can resume assert.commandWorked(rst.getPrimary().adminCommand({setFreeMonitoring: 1, action: "enable"})); @@ -52,8 +52,8 @@ load("jstests/free_mon/libs/free_mon.js"); sleep(20 * 1000); - assert.eq(FreeMonGetStatus(rst.getPrimary()).state, 'enabled'); - assert.eq(FreeMonGetStatus(rst.getSecondary()).state, 'enabled'); + assert.eq(FreeMonGetServerStatus(rst.getPrimary()).state, 'enabled'); + assert.eq(FreeMonGetServerStatus(rst.getSecondary()).state, 'enabled'); rst.stopSet(); diff --git a/jstests/free_mon/free_mon_rs_halt.js b/jstests/free_mon/free_mon_rs_halt.js index 0694f504254..5a5b94accc2 100644 --- a/jstests/free_mon/free_mon_rs_halt.js +++ b/jstests/free_mon/free_mon_rs_halt.js @@ -23,8 +23,8 @@ load("jstests/free_mon/libs/free_mon.js"); mock_web.waitRegisters(2); - assert.eq(FreeMonGetStatus(rst.getPrimary()).state, 'enabled'); - assert.eq(FreeMonGetStatus(rst.getSecondary()).state, 'enabled'); + assert.eq(FreeMonGetServerStatus(rst.getPrimary()).state, 'enabled'); + assert.eq(FreeMonGetServerStatus(rst.getSecondary()).state, 'enabled'); mock_web.enableFaults(); mock_web.waitFaults(1); @@ -40,8 +40,8 @@ load("jstests/free_mon/libs/free_mon.js"); assert.eq(qs1.registers, qs2.registers); // Halt causes us to disable free monitoring, not return it to initial state. - assert.eq(FreeMonGetStatus(rst.getPrimary()).state, 'disabled'); - assert.eq(FreeMonGetStatus(rst.getSecondary()).state, 'disabled'); + assert.eq(FreeMonGetServerStatus(rst.getPrimary()).state, 'disabled'); + assert.eq(FreeMonGetServerStatus(rst.getSecondary()).state, 'disabled'); // Disable the fault so we can re-enable again mock_web.disableFaults(); @@ -53,8 +53,8 @@ load("jstests/free_mon/libs/free_mon.js"); sleep(20 * 1000); - assert.eq(FreeMonGetStatus(rst.getPrimary()).state, 'enabled'); - assert.eq(FreeMonGetStatus(rst.getSecondary()).state, 'enabled'); + assert.eq(FreeMonGetServerStatus(rst.getPrimary()).state, 'enabled'); + assert.eq(FreeMonGetServerStatus(rst.getSecondary()).state, 'enabled'); rst.stopSet(); diff --git a/jstests/free_mon/free_mon_rs_perm_del.js b/jstests/free_mon/free_mon_rs_perm_del.js index be8176ef8a5..3f15719062d 100644 --- a/jstests/free_mon/free_mon_rs_perm_del.js +++ b/jstests/free_mon/free_mon_rs_perm_del.js @@ -24,8 +24,8 @@ load("jstests/free_mon/libs/free_mon.js"); mock_web.waitRegisters(2); - assert.eq(FreeMonGetStatus(rst.getPrimary()).state, 'enabled'); - assert.eq(FreeMonGetStatus(rst.getSecondary()).state, 'enabled'); + assert.eq(FreeMonGetServerStatus(rst.getPrimary()).state, 'enabled'); + assert.eq(FreeMonGetServerStatus(rst.getSecondary()).state, 'enabled'); mock_web.enableFaults(); mock_web.waitFaults(1); @@ -33,9 +33,9 @@ load("jstests/free_mon/libs/free_mon.js"); sleep(20 * 1000); // Make sure we are back to the initial state. - assert.eq(FreeMonGetStatus(rst.getPrimary()).state, 'undecided'); + assert.eq(FreeMonGetServerStatus(rst.getPrimary()).state, 'undecided'); - assert.eq(FreeMonGetStatus(rst.getSecondary()).state, 'undecided'); + assert.eq(FreeMonGetServerStatus(rst.getSecondary()).state, 'undecided'); // Disable the fault so we can re-enable again mock_web.disableFaults(); @@ -47,8 +47,8 @@ load("jstests/free_mon/libs/free_mon.js"); sleep(20 * 1000); - assert.eq(FreeMonGetStatus(rst.getPrimary()).state, 'enabled'); - assert.eq(FreeMonGetStatus(rst.getSecondary()).state, 'enabled'); + assert.eq(FreeMonGetServerStatus(rst.getPrimary()).state, 'enabled'); + assert.eq(FreeMonGetServerStatus(rst.getSecondary()).state, 'enabled'); rst.stopSet(); diff --git a/jstests/free_mon/free_mon_rs_register.js b/jstests/free_mon/free_mon_rs_register.js index 2c988e299fa..1c518456a2f 100644 --- a/jstests/free_mon/free_mon_rs_register.js +++ b/jstests/free_mon/free_mon_rs_register.js @@ -27,8 +27,8 @@ load("jstests/free_mon/libs/free_mon.js"); mock_web.waitRegisters(2); - assert.eq(FreeMonGetStatus(rst.getPrimary()).state, 'enabled'); - assert.eq(FreeMonGetStatus(rst.getSecondary()).state, 'enabled'); + assert.eq(FreeMonGetServerStatus(rst.getPrimary()).state, 'enabled'); + assert.eq(FreeMonGetServerStatus(rst.getSecondary()).state, 'enabled'); const last_register = mock_web.query("last_register"); print(tojson(last_register)); diff --git a/jstests/free_mon/libs/free_mon.js b/jstests/free_mon/libs/free_mon.js index 21d42fb3e66..3cb9f90e364 100644 --- a/jstests/free_mon/libs/free_mon.js +++ b/jstests/free_mon/libs/free_mon.js @@ -251,9 +251,21 @@ function FreeMonGetRegistration(conn) { * * @param {object} serverStatus.freeMonitoring section */ -function FreeMonGetStatus(conn) { +function FreeMonGetServerStatus(conn) { 'use strict'; const admin = conn.getDB("admin"); return assert.commandWorked(admin.runCommand({serverStatus: 1})).freeMonitoring; } + +/** + * Get current Free Monitoring Status via getFreeMonitoringStatus. + * + * @param {object} getFreeMonitoringStatus document + */ +function FreeMonGetStatus(conn) { + 'use strict'; + + const admin = conn.getDB("admin"); + return assert.commandWorked(admin.runCommand({getFreeMonitoringStatus: 1})); +} |