summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/plan_cache_size_setparam.js
blob: a0b68ae6cbf7cf98f5272178258088b1faff2b36 (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
35
36
37
38
39
40
41
42
43
44
/**
 * Validates that the planCacheSize parameter is set correctly at startup and runtime.
 */

(function() {
"use strict";

const paramName = "planCacheSize";
const paramStartValue = "711MB";

let mongod = MongoRunner.runMongod({setParameter: `${paramName}=${paramStartValue}`});
let adminDb = mongod.getDB("admin");

function validatePlanCacheSize(paramValue) {
    let result = adminDb.runCommand({getParameter: 1, [paramName]: 1});
    assert.commandWorked(result);
    assert.eq(result[paramName], paramValue);
}

function setPlanCacheSize(paramValue, errorCode) {
    let result = adminDb.runCommand({setParameter: 1, [paramName]: paramValue});
    assert.commandWorked(result);
}

function setPlanCacheSizeThrows(paramValue, errorCode) {
    let result = adminDb.runCommand({setParameter: 1, [paramName]: paramValue});
    assert.commandFailedWithCode(result, errorCode);
}

// Validates that the parameter is set correctly at startup.
validatePlanCacheSize(paramStartValue);

// Validates that the parameter is set correctly in runtime.
const paramCorrectValue = "10%";
setPlanCacheSize(paramCorrectValue);
validatePlanCacheSize(paramCorrectValue);

// Validates that an incorrect value is not accepted.
const paramIncorrectValue = "100KB";
setPlanCacheSizeThrows(paramIncorrectValue, 6007012);
validatePlanCacheSize(paramCorrectValue);

MongoRunner.stopMongod(mongod);
})();