blob: bfdb4be7299de2f062e3586934453ea86682b9f1 (
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
|
// Tests --networkMessageCompressors options.
(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({hello: 1}));
clearRawMongoProgramOutput();
assert.eq(runMongoProgram("mongo",
"--eval",
"tostrictjson(db.hello());",
"--port",
mongo.port,
"--networkMessageCompressors=snappy"),
0);
var output = rawMongoProgramOutput()
.split("\n")
.map(function(str) {
str = str.replace(/^sh[0-9]+\| /, "");
if (!/^{.*isWritablePrimary/.test(str)) {
return "";
}
return str;
})
.join("\n")
.trim();
output = JSON.parse(output);
assert.eq(output.compression, expected);
MongoRunner.stopMongod(mongo);
};
assert.throws(() => MongoRunner.runMongod({networkMessageCompressors: "snappy,disabled"}));
runTest("snappy", ["snappy"]);
runTest("disabled", undefined);
}());
|