diff options
author | Sara Golemon <sara.golemon@mongodb.com> | 2018-05-01 13:42:15 -0400 |
---|---|---|
committer | Sara Golemon <sara.golemon@mongodb.com> | 2018-05-01 14:43:47 -0400 |
commit | 97245f7c13ee8d18e3d82fc87dd44b9fd72b4da3 (patch) | |
tree | d512f78f20b7fd1acb43ecbd09b28883be8fc963 /jstests/free_mon | |
parent | 52c1fe02a0cd0f64a4d97f7c1e17792b38c67ca4 (diff) | |
download | mongo-97245f7c13ee8d18e3d82fc87dd44b9fd72b4da3.tar.gz |
SERVER-34229 Add free monitoring to serverStatus
Diffstat (limited to 'jstests/free_mon')
-rw-r--r-- | jstests/free_mon/free_mon_http_down.js | 4 | ||||
-rw-r--r-- | jstests/free_mon/free_mon_server_status.js | 48 |
2 files changed, 52 insertions, 0 deletions
diff --git a/jstests/free_mon/free_mon_http_down.js b/jstests/free_mon/free_mon_http_down.js index aff229614c4..019b50f23eb 100644 --- a/jstests/free_mon/free_mon_http_down.js +++ b/jstests/free_mon/free_mon_http_down.js @@ -17,9 +17,13 @@ load("jstests/free_mon/libs/free_mon.js"); const conn = MongoRunner.runMongod(options); assert.neq(null, conn, 'mongod was unable to start up'); + const admin = conn.getDB('admin'); mock_web.waitRegisters(3); + const freeMonStats = assert.commandWorked(admin.runCommand({serverStatus: 1})).freeMonitoring; + assert.gte(freeMonStats.registerErrors, 3); + MongoRunner.stopMongod(conn); mock_web.stop(); diff --git a/jstests/free_mon/free_mon_server_status.js b/jstests/free_mon/free_mon_server_status.js new file mode 100644 index 00000000000..5a7fc991831 --- /dev/null +++ b/jstests/free_mon/free_mon_server_status.js @@ -0,0 +1,48 @@ +// Validate serverStatus output. +// +load("jstests/free_mon/libs/free_mon.js"); + +(function() { + 'use strict'; + + const mock_web = new FreeMonWebServer(); + mock_web.start(); + + const mongod = MongoRunner.runMongod({ + setParameter: "cloudFreeMonitoringEndpointURL=" + mock_web.getURL(), + }); + assert.neq(mongod, null, 'mongod not running'); + const admin = mongod.getDB('admin'); + + const kRetryIntervalSecs = 1; + function freeMonStats() { + return assert.commandWorked(admin.runCommand({serverStatus: 1})).freeMonitoring; + } + + // Initial state. + assert.eq(freeMonStats().state, 'undecided'); + + assert.commandWorked(admin.runCommand({setFreeMonitoring: 1, action: 'enable'})); + WaitForRegistration(mongod); + + const enabled = freeMonStats(); + assert.eq(enabled.state, 'enabled'); + assert.eq(enabled.retryIntervalSecs, kRetryIntervalSecs); + assert.eq(enabled.registerErrors, 0); + assert.eq(enabled.metricsErrors, 0); + + // Explicitly disabled. + assert.commandWorked(admin.runCommand({setFreeMonitoring: 1, action: 'disable'})); + sleep(2); // Give the async command time to run. + + const disabled = freeMonStats(); + assert.eq(disabled.state, 'disabled'); + assert.eq(disabled.retryIntervalSecs, kRetryIntervalSecs); + assert.eq(disabled.registerErrors, 0); + assert.eq(disabled.metricsErrors, 0); + + // Enabled. + // Cleanup. + MongoRunner.stopMongod(mongod); + mock_web.stop(); +})(); |