diff options
author | Sara Golemon <sara.golemon@mongodb.com> | 2018-04-27 15:38:44 -0400 |
---|---|---|
committer | Sara Golemon <sara.golemon@mongodb.com> | 2018-05-03 16:04:43 -0400 |
commit | 397af5415328cbf53c7d70b514d25d32c7b8c3c6 (patch) | |
tree | 25b8572fcc09255096130d8cd2aa63d64c53a661 /jstests/free_mon | |
parent | 91db8033a2ddc65b682d16f46fc00cde7949e9fc (diff) | |
download | mongo-397af5415328cbf53c7d70b514d25d32c7b8c3c6.tar.gz |
SERVER-34233 Implement shell helpers for free monitoring
Diffstat (limited to 'jstests/free_mon')
-rw-r--r-- | jstests/free_mon/free_mon_announce.js | 34 | ||||
-rw-r--r-- | jstests/free_mon/free_mon_server_status.js | 6 | ||||
-rw-r--r-- | jstests/free_mon/libs/mock_http_server.py | 1 |
3 files changed, 38 insertions, 3 deletions
diff --git a/jstests/free_mon/free_mon_announce.js b/jstests/free_mon/free_mon_announce.js new file mode 100644 index 00000000000..a2a10df8162 --- /dev/null +++ b/jstests/free_mon/free_mon_announce.js @@ -0,0 +1,34 @@ +// Validate connect message display. +// +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'); + + function getConnectAnnounce() { + // Capture message as it'd be presented to a user. + clearRawMongoProgramOutput(); + const exitCode = runMongoProgram('mongo', '--port', mongod.port, '--eval', ';'); + assert.eq(exitCode, 0); + return rawMongoProgramOutput(); + } + + // state === 'enabled'. + admin.enableFreeMonitoring(); + WaitForRegistration(mongod); + const reminder = "Don't forget to check your metrics"; + assert.neq(getConnectAnnounce().search(reminder), -1, 'userReminder not found'); + + // Cleanup. + MongoRunner.stopMongod(mongod); + mock_web.stop(); +})(); diff --git a/jstests/free_mon/free_mon_server_status.js b/jstests/free_mon/free_mon_server_status.js index 5a7fc991831..0dce068a494 100644 --- a/jstests/free_mon/free_mon_server_status.js +++ b/jstests/free_mon/free_mon_server_status.js @@ -22,9 +22,10 @@ load("jstests/free_mon/libs/free_mon.js"); // Initial state. assert.eq(freeMonStats().state, 'undecided'); - assert.commandWorked(admin.runCommand({setFreeMonitoring: 1, action: 'enable'})); + admin.enableFreeMonitoring(); WaitForRegistration(mongod); + // Enabled. const enabled = freeMonStats(); assert.eq(enabled.state, 'enabled'); assert.eq(enabled.retryIntervalSecs, kRetryIntervalSecs); @@ -32,7 +33,7 @@ load("jstests/free_mon/libs/free_mon.js"); assert.eq(enabled.metricsErrors, 0); // Explicitly disabled. - assert.commandWorked(admin.runCommand({setFreeMonitoring: 1, action: 'disable'})); + admin.disableFreeMonitoring(); sleep(2); // Give the async command time to run. const disabled = freeMonStats(); @@ -41,7 +42,6 @@ load("jstests/free_mon/libs/free_mon.js"); assert.eq(disabled.registerErrors, 0); assert.eq(disabled.metricsErrors, 0); - // Enabled. // Cleanup. MongoRunner.stopMongod(mongod); mock_web.stop(); diff --git a/jstests/free_mon/libs/mock_http_server.py b/jstests/free_mon/libs/mock_http_server.py index 4e85a762e76..a6c0c7add66 100644 --- a/jstests/free_mon/libs/mock_http_server.py +++ b/jstests/free_mon/libs/mock_http_server.py @@ -124,6 +124,7 @@ class FreeMonHandler(http.server.BaseHTTPRequestHandler): 'informationalURL': 'http://www.example.com/123', 'message': 'Welcome to the Mock Free Monitoring Endpoint', 'reportingInterval': bson.int64.Int64(1), + 'userReminder': "Don't forget to check your metrics!", }) self._send_header() |