diff options
Diffstat (limited to 'jstests/noPassthrough/compression_options.js')
-rw-r--r-- | jstests/noPassthrough/compression_options.js | 77 |
1 files changed, 38 insertions, 39 deletions
diff --git a/jstests/noPassthrough/compression_options.js b/jstests/noPassthrough/compression_options.js index c6f4ccadc68..db4b9b4d050 100644 --- a/jstests/noPassthrough/compression_options.js +++ b/jstests/noPassthrough/compression_options.js @@ -1,43 +1,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({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); - +'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); }()); |