summaryrefslogtreecommitdiff
path: root/jstests/free_mon
diff options
context:
space:
mode:
authorSara Golemon <sara.golemon@mongodb.com>2018-04-26 14:57:17 -0400
committerSara Golemon <sara.golemon@mongodb.com>2018-05-01 12:53:05 -0400
commit1c5629c05fa9b08752688c021f7a6beef3a20dca (patch)
treedbaacdd92639b5be5b7a6f6884e1496c7af0b803 /jstests/free_mon
parente5f4331b710b0c933699e26e8c65f702231038cc (diff)
downloadmongo-1c5629c05fa9b08752688c021f7a6beef3a20dca.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.js4
-rw-r--r--jstests/free_mon/free_mon_server_status.js48
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();
+})();