0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00
mongodb/jstests/noPassthroughWithMongod/log_component_helpers.js
2014-11-18 23:02:54 -05:00

43 lines
1.4 KiB
JavaScript

// Basic sanity check of log component helpers
(function(db) {
"use strict";
var mongo = db.getMongo();
// Get current log component setttings. We will reset to these later.
var originalSettings = assert.commandWorked(
db.adminCommand({ getParameter:1, logComponentVerbosity:1 })
).logComponentVerbosity;
// getLogComponents
var components1 = mongo.getLogComponents();
assert.docEq(components1, originalSettings);
// getLogComponents via db
var components2 = db.getLogComponents();
assert.docEq(components2, originalSettings);
// setLogLevel - default component
mongo.setLogLevel(2);
assert.eq(mongo.getLogComponents().verbosity, 2);
db.setLogLevel(0);
assert.eq(mongo.getLogComponents().verbosity, 0);
// setLogLevel - valid log component
mongo.setLogLevel(2, "storage.journal");
assert.eq(mongo.getLogComponents().storage.journal.verbosity, 2);
db.setLogLevel(1, "storage.journal");
assert.eq(mongo.getLogComponents().storage.journal.verbosity, 1);
// setLogLevel - invalid argument
assert.throws(mongo.setLogLevel, [2, 24]);
assert.throws(db.setLogLevel, [2, ["array", "not.allowed"]]);
// Restore originalSettings
assert.commandWorked(
db.adminCommand({setParameter:1, logComponentVerbosity:originalSettings })
);
}(db));