forked from mongodb/mongo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compression_options.js
44 lines (36 loc) · 1.57 KB
/
compression_options.js
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
// Checks storage-engine specific sections of db.severStatus() output.
(function() {
'use strict';
var runTest = function(optionValue, expected) {
jsTest.log("Testing with --networkMessageCompressors=\"" + optionValue + "\" expecting: " +
expected);
var mongo = MongoRunner.runMongod({networkMessageCompressors: optionValue});
assert.commandWorked(mongo.adminCommand({isMaster: 1}));
clearRawMongoProgramOutput();
assert.eq(runMongoProgram("mongo",
"--eval",
"tostrictjson(db.isMaster());",
"--port",
mongo.port,
"--networkMessageCompressors=snappy"),
0);
var output = rawMongoProgramOutput()
.split("\n")
.map(function(str) {
str = str.replace(/^sh[0-9]+\| /, "");
if (!/^{/.test(str)) {
return "";
}
return str;
})
.join("\n")
.trim();
output = JSON.parse(output);
assert.eq(output.compression, expected);
MongoRunner.stopMongod(mongo);
};
assert.isnull(MongoRunner.runMongod({networkMessageCompressors: "snappy,disabled"}));
runTest("snappy", ["snappy"]);
runTest("disabled", undefined);
runTest("", undefined);
}());