summaryrefslogtreecommitdiff
path: root/jstests/free_mon/free_mon_announce.js
blob: a2a10df8162ce30efbb65d1a6b9843016a4f406a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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();
})();