summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/setparameter_config_alias_not_overwritten_by_default.js
blob: 9275e18f12d32eb8dc5a58acb9c92afd115963a6 (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
// Verify setParameters paramaters which are an alias to a config parameter do not have the value
// passed with setParameter as a startup argument overwritten by the config default.

(function() {
'use strict';

const defaultsConn = MongoRunner.runMongod();
function getDefaultValue(parameterName) {
    const res =
        assert.commandWorked(defaultsConn.adminCommand({getParameter: 1, [parameterName]: 1}));
    return res[parameterName];
}

let paramsDict = {};
const parameters = ['journalCommitInterval', 'syncdelay'];
parameters.forEach(param => {
    const defaultValue = getDefaultValue(param);
    const setValue = defaultValue + 1;
    paramsDict[param] = setValue;
});
MongoRunner.stopMongod(defaultsConn);

function runTestOnConn(conn, setParams) {
    Object.keys(setParams).forEach(param => {
        const res = assert.commandWorked(conn.adminCommand({getParameter: 1, [param]: 1}));
        assert.eq(res[param], setParams[param]);
    });
}

// Run the test on a standalone mongod.
const standaloneConn = MongoRunner.runMongod({setParameter: paramsDict});
runTestOnConn(standaloneConn, paramsDict);
MongoRunner.stopMongod(standaloneConn);
}());