mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-21 12:39:08 +01:00
SERVER-95628 Make rawMongoProgramOutput more robust (#28204)
GitOrigin-RevId: 6b01ab93e5ba70a22cc816931cd464b6f2ddbd13
This commit is contained in:
parent
d8534a3e10
commit
be39a8421f
@ -18,7 +18,7 @@ if (!_isWindows()) {
|
||||
binshell, '-c', `echo password | ${mongo} --host ${host} --port ${port} --eval ${auth}`);
|
||||
|
||||
assert.soon(() => {
|
||||
const output = rawMongoProgramOutput();
|
||||
const output = rawMongoProgramOutput("(Enter password:|Successfully authenticated)");
|
||||
return output.includes("Enter password:") && output.includes("Successfully authenticated");
|
||||
});
|
||||
|
||||
|
@ -9,7 +9,6 @@ assert.throws(function() {
|
||||
rsTest.startSet({auth: "", oplogSize: 10});
|
||||
});
|
||||
|
||||
const mongoOutput = rawMongoProgramOutput();
|
||||
assert(mongoOutput.indexOf(
|
||||
"security.keyFile is required when authorization is enabled with replica sets") >= 0,
|
||||
"Expected error message about missing keyFile on startup");
|
||||
const subStr = "security.keyFile is required when authorization is enabled with replica sets";
|
||||
const mongoOutput = rawMongoProgramOutput(subStr);
|
||||
assert(mongoOutput.indexOf(subStr) >= 0, "Expected error message about missing keyFile on startup");
|
@ -106,7 +106,7 @@ export let assertErrorOnStartupWhenStartingAsReplSet = function(dbpath, port, rs
|
||||
let node = MongoRunner.runMongod(
|
||||
{dbpath: dbpath, port: port, replSet: rsName, noCleanData: true, waitForConnect: false});
|
||||
assert.soon(function() {
|
||||
return rawMongoProgramOutput().search(/Fatal assertion.*50923/) >= 0;
|
||||
return rawMongoProgramOutput("Fatal assertion").search(/50923/) >= 0;
|
||||
});
|
||||
MongoRunner.stopMongod(node, null, {allowedExitCode: MongoRunner.EXIT_ABRUPT});
|
||||
};
|
||||
@ -122,7 +122,7 @@ export let assertErrorOnStartupAfterIncompleteRepair = function(dbpath, port) {
|
||||
let node = MongoRunner.runMongod(
|
||||
{dbpath: dbpath, port: port, noCleanData: true, waitForConnect: false});
|
||||
assert.soon(function() {
|
||||
return rawMongoProgramOutput().search(/Fatal assertion.*50922/) >= 0;
|
||||
return rawMongoProgramOutput("Fatal assertion").search(/50922/) >= 0;
|
||||
});
|
||||
MongoRunner.stopMongod(node, null, {allowedExitCode: MongoRunner.EXIT_ABRUPT});
|
||||
};
|
||||
@ -151,7 +151,7 @@ export let assertErrorOnStartupWhenInitialSyncingWithData = function(replSet, or
|
||||
jsTestLog("Ignoring exception from replsettest.start: " + tojson(e));
|
||||
} finally {
|
||||
assert.soon(function() {
|
||||
return rawMongoProgramOutput().search(/Fatal assertion.*9184100/) >= 0;
|
||||
return rawMongoProgramOutput("Fatal assertion").search(/9184100/) >= 0;
|
||||
});
|
||||
if (node) {
|
||||
MongoRunner.stopMongod(node, null, {allowedExitCode: MongoRunner.EXIT_ABRUPT});
|
||||
|
@ -51,7 +51,7 @@ let port;
|
||||
startMongodOnExistingPath(dbPath);
|
||||
});
|
||||
|
||||
assert(rawMongoProgramOutput().match("Fatal assertion.*28782"),
|
||||
assert(rawMongoProgramOutput("Fatal assertion").match("28782"),
|
||||
"Mongod should have aborted due to an invalid index descriptor.");
|
||||
jsTestLog("Exiting restartAndVerifyMongodCrashes.");
|
||||
})();
|
||||
|
@ -67,7 +67,7 @@ testDB = mongod.getDB(dbName);
|
||||
assert.throws(() => {
|
||||
assert.commandWorked(testDB.getCollection("a").insert({}));
|
||||
});
|
||||
assert.gte(rawMongoProgramOutput().search("Fatal assertion.*50883"), 0);
|
||||
assert.gte(rawMongoProgramOutput("Fatal assertion").search("50883"), 0);
|
||||
|
||||
// Perform a startup, drop collection "a" and shutdown.
|
||||
mongod = startMongodOnExistingPath(dbpath);
|
||||
|
@ -5,7 +5,7 @@ export function getPython3Binary() {
|
||||
// or else we will pick up a python that is not in our venv
|
||||
clearRawMongoProgramOutput();
|
||||
assert.eq(runNonMongoProgram("python", "--version"), 0);
|
||||
const pythonVersion = rawMongoProgramOutput(); // Will look like "Python 3.10.4\n"
|
||||
const pythonVersion = rawMongoProgramOutput("Python"); // Will look like "Python 3.10.4\n"
|
||||
const usingPython310 = /Python 3\.10/.exec(pythonVersion);
|
||||
if (usingPython310) {
|
||||
print(
|
||||
|
@ -11,7 +11,7 @@ const conn = MongoRunner.runMongod();
|
||||
// convert the float to a string to make sure it's correctly represented.
|
||||
runNonMongoProgram('/bin/kill', '-s', 'SIGUSR2', conn.pid.valueOf().toString());
|
||||
MongoRunner.stopMongod(conn);
|
||||
const output = rawMongoProgramOutput();
|
||||
const output = rawMongoProgramOutput("(processInfo|backtrace)");
|
||||
assert(output.search(/"processInfo":/) >= 0, output);
|
||||
// Will be several of these
|
||||
assert(output.search(/"backtrace":/) >= 0, output);
|
||||
|
@ -45,7 +45,7 @@ function runStandaloneTest() {
|
||||
adminDB = conn.getDB("admin");
|
||||
// The FCV should still be the original FCV, not the provided defaultStartupFCV.
|
||||
checkFCV(adminDB, lastContinuousFCV);
|
||||
assert(rawMongoProgramOutput().includes(
|
||||
assert(rawMongoProgramOutput(".*").includes(
|
||||
"Ignoring the provided defaultStartupFCV parameter since the FCV already exists"));
|
||||
MongoRunner.stopMongod(conn);
|
||||
|
||||
@ -63,7 +63,8 @@ function runStandaloneTest() {
|
||||
assert.neq(null, conn);
|
||||
adminDB = conn.getDB("admin");
|
||||
checkFCV(adminDB, latestFCV);
|
||||
assert(rawMongoProgramOutput().includes("The provided 'defaultStartupFCV' is not a valid FCV"));
|
||||
assert(rawMongoProgramOutput(".*").includes(
|
||||
"The provided 'defaultStartupFCV' is not a valid FCV"));
|
||||
MongoRunner.stopMongod(conn);
|
||||
|
||||
clearRawMongoProgramOutput();
|
||||
@ -72,7 +73,8 @@ function runStandaloneTest() {
|
||||
assert.neq(null, conn);
|
||||
adminDB = conn.getDB("admin");
|
||||
checkFCV(adminDB, latestFCV);
|
||||
assert(rawMongoProgramOutput().includes("The provided 'defaultStartupFCV' is not a valid FCV"));
|
||||
assert(rawMongoProgramOutput(".*").includes(
|
||||
"The provided 'defaultStartupFCV' is not a valid FCV"));
|
||||
MongoRunner.stopMongod(conn);
|
||||
}
|
||||
|
||||
@ -166,7 +168,8 @@ function runReplicaSetTest() {
|
||||
secondaryAdminDB = rst.getSecondary().getDB("admin");
|
||||
checkFCV(primaryAdminDB, latestFCV);
|
||||
checkFCV(secondaryAdminDB, latestFCV);
|
||||
assert(rawMongoProgramOutput().includes("The provided 'defaultStartupFCV' is not a valid FCV"));
|
||||
assert(rawMongoProgramOutput(".*").includes(
|
||||
"The provided 'defaultStartupFCV' is not a valid FCV"));
|
||||
rst.stopSet();
|
||||
|
||||
clearRawMongoProgramOutput();
|
||||
@ -180,7 +183,8 @@ function runReplicaSetTest() {
|
||||
secondaryAdminDB = rst.getSecondary().getDB("admin");
|
||||
checkFCV(primaryAdminDB, latestFCV);
|
||||
checkFCV(secondaryAdminDB, latestFCV);
|
||||
assert(rawMongoProgramOutput().includes("The provided 'defaultStartupFCV' is not a valid FCV"));
|
||||
assert(rawMongoProgramOutput(".*").includes(
|
||||
"The provided 'defaultStartupFCV' is not a valid FCV"));
|
||||
rst.stopSet();
|
||||
}
|
||||
|
||||
|
@ -40,8 +40,8 @@ function runTest(downgradeFCV) {
|
||||
}, primary.port);
|
||||
|
||||
assert.soon(function() {
|
||||
return rawMongoProgramOutput().match(
|
||||
/\"id\":20320.*test.mycoll/); // Create Collection log
|
||||
return rawMongoProgramOutput("\"id\":20320")
|
||||
.match(/\"id\":20320.*test.mycoll/); // Create Collection log
|
||||
});
|
||||
|
||||
awaitUpgradeFCV = startParallelShell(
|
||||
|
@ -56,7 +56,7 @@ function testVersion(binVersion, fcv, shouldCorrupt) {
|
||||
|
||||
MongoRunner.runMongod({port: port, dbpath: dbpath, validate: "", noCleanData: true});
|
||||
|
||||
let validateLogs = rawMongoProgramOutput()
|
||||
let validateLogs = rawMongoProgramOutput("(9437301|9437303|9437304)")
|
||||
.split("\n")
|
||||
.filter(line => line.trim() !== "")
|
||||
.map(line => JSON.parse(line.split("|").slice(1).join("|")));
|
||||
|
@ -9,7 +9,7 @@ function runTest(config, opt, expectStar, expectLocalhost) {
|
||||
const mongod =
|
||||
runMongoProgram('mongod', '--port', port, '--config', config, opt, '--outputConfig');
|
||||
assert.eq(mongod, 0);
|
||||
const output = rawMongoProgramOutput();
|
||||
const output = rawMongoProgramOutput("bindIp");
|
||||
assert.eq(output.search(/bindIp: "\*"/) >= 0, expectStar, output);
|
||||
assert.eq(output.search(/bindIp: localhost/) >= 0, expectLocalhost, output);
|
||||
assert.eq(output.search(/bindIpAll:/) >= 0, false, output);
|
||||
|
@ -120,7 +120,7 @@ function runTest(conn) {
|
||||
evalCmd(uri, `print("Kill Test\\n"); sleep(${kShellShutdownDelay});`, false, function(pid) {
|
||||
// Wait for the output from the eval string so that we know prefix ops have completed,
|
||||
// then kill the shell so that the stream shuts down unsuccessfully.
|
||||
assert.soon(() => rawMongoProgramOutput().includes("Kill Test"),
|
||||
assert.soon(() => rawMongoProgramOutput("Kill Test").includes("Kill Test"),
|
||||
"Shell start failure",
|
||||
kShellStartTimeout,
|
||||
kShellStartInterval);
|
||||
|
@ -16,7 +16,7 @@ function runTest(bindIP, expectOk) {
|
||||
|
||||
// We use assert.soonNoExcept() here because the mongod may not be logging yet.
|
||||
assert.soonNoExcept(() => {
|
||||
const logContents = rawMongoProgramOutput();
|
||||
const logContents = rawMongoProgramOutput("\"id\":(7401305|23016)");
|
||||
let found;
|
||||
if (jsTestOptions().shellGRPC) {
|
||||
found = logContents.match(
|
||||
@ -47,7 +47,7 @@ function runTest(bindIP, expectOk) {
|
||||
const ec = waitProgram(pid);
|
||||
assert.eq(ec, MongoRunner.EXIT_NET_ERROR);
|
||||
assert.soonNoExcept(() => {
|
||||
const logContents = rawMongoProgramOutput();
|
||||
const logContents = rawMongoProgramOutput("ephemeral port");
|
||||
const found = logContents.match(
|
||||
/Port 0 \(ephemeral port\) is not allowed when listening on multiple IP interfaces/);
|
||||
return (found !== null);
|
||||
|
@ -16,10 +16,10 @@ const clientMetadataLogLineRegex = /\"NETWORK.+51800.+client metadata\"/;
|
||||
// Issue a command and wait for a log line acknowledging it to be sure any client metadata log
|
||||
// lines have been flushed.
|
||||
conn.getDB(dbName).runCommand({ping: 1});
|
||||
assert.soon(() => rawMongoProgramOutput().match(firstCommandLogLineRegex),
|
||||
assert.soon(() => rawMongoProgramOutput(".*").match(firstCommandLogLineRegex),
|
||||
"did not see log line acknowledging first command");
|
||||
|
||||
const mongoOutput = rawMongoProgramOutput();
|
||||
const mongoOutput = rawMongoProgramOutput(".*");
|
||||
assert.gte(mongoOutput.match(clientMetadataLogLineRegex).length,
|
||||
1,
|
||||
"did not see client metadata log line while not in quiet mode");
|
||||
@ -35,10 +35,10 @@ const clientMetadataLogLineRegex = /\"NETWORK.+51800.+client metadata\"/;
|
||||
// Issue a command and wait for a log line acknowledging it to be sure any client metadata log
|
||||
// lines have been flushed.
|
||||
conn.getDB(dbName).runCommand({ping: 1});
|
||||
assert.soon(() => rawMongoProgramOutput().match(firstCommandLogLineRegex),
|
||||
assert.soon(() => rawMongoProgramOutput(".*").match(firstCommandLogLineRegex),
|
||||
"did not see log line acknowledging first command");
|
||||
|
||||
const mongoOutput = rawMongoProgramOutput();
|
||||
const mongoOutput = rawMongoProgramOutput(".*");
|
||||
assert.eq(mongoOutput.match(clientMetadataLogLineRegex),
|
||||
null,
|
||||
"saw client metadata log line while in quiet mode");
|
||||
|
@ -14,7 +14,7 @@ var runTest = function(optionValue, expected) {
|
||||
"--networkMessageCompressors=snappy"),
|
||||
0);
|
||||
|
||||
var output = rawMongoProgramOutput()
|
||||
var output = rawMongoProgramOutput(".*")
|
||||
.split("\n")
|
||||
.map(function(str) {
|
||||
str = str.replace(/^sh[0-9]+\| /, "");
|
||||
|
@ -28,7 +28,7 @@ function testShutdownLogging(launcher, crashFn, matchFn, expectedExitCode) {
|
||||
var conn = launcher.start({});
|
||||
|
||||
function checkOutput() {
|
||||
var logContents = rawMongoProgramOutput();
|
||||
var logContents = rawMongoProgramOutput(".*");
|
||||
function printLog() {
|
||||
// We can't just return a string because it will be well over the max
|
||||
// line length.
|
||||
|
@ -29,7 +29,7 @@ let doDuringFailpoint = function(
|
||||
|
||||
hitFailpointFunc();
|
||||
|
||||
assert.soon(() => structuredLogRegEx.test(rawMongoProgramOutput()));
|
||||
assert.soon(() => structuredLogRegEx.test(rawMongoProgramOutput(".*")));
|
||||
|
||||
duringFailpointFunc();
|
||||
|
||||
|
@ -70,14 +70,14 @@ const gracefulIndexBuildFlag = FeatureFlagUtil.isEnabled(testDB, "IndexBuildGrac
|
||||
if (!gracefulIndexBuildFlag) {
|
||||
// We expect this to crash the secondary because this error is not recoverable
|
||||
assert.soon(function() {
|
||||
return rawMongoProgramOutput().search(/Fatal assertion.*(51101)/) >= 0;
|
||||
return rawMongoProgramOutput(".*").search(/Fatal assertion.*(51101)/) >= 0;
|
||||
});
|
||||
} else {
|
||||
// Expect the secondary to crash. Depending on timing, this can be either because the secondary
|
||||
// was waiting for a primary abort when a 'commitIndexBuild' is applied, or because the build
|
||||
// fails and tries to request an abort while a 'commitIndexBuild' is being applied.
|
||||
assert.soon(function() {
|
||||
return rawMongoProgramOutput().search(/Fatal assertion.*(7329403|7329407)/) >= 0;
|
||||
return rawMongoProgramOutput(".*").search(/Fatal assertion.*(7329403|7329407)/) >= 0;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ function killopIndexBuildOnSecondaryOnFailpoint(rst, failpointName, shouldSuccee
|
||||
} else {
|
||||
// We expect this to crash the secondary because this error is not recoverable.
|
||||
assert.soon(function() {
|
||||
return rawMongoProgramOutput().search(/Fatal assertion.*(51101)/) >= 0;
|
||||
return rawMongoProgramOutput(".*").search(/Fatal assertion.*(51101)/) >= 0;
|
||||
});
|
||||
|
||||
// After restarting the secondary, expect that the index build completes successfully.
|
||||
|
@ -77,8 +77,8 @@ let runTest = function(conn) {
|
||||
// Unpause the index build from the first failpoint so that it can resume and pause at the
|
||||
// next failpoint.
|
||||
IndexBuildTest.resumeIndexBuilds(conn);
|
||||
assert.soon(() =>
|
||||
rawMongoProgramOutput().indexOf("Hanging after index build first drain") >= 0);
|
||||
assert.soon(
|
||||
() => rawMongoProgramOutput(".*").indexOf("Hanging after index build first drain") >= 0);
|
||||
|
||||
// Right before the index build completes, ensure no prepare conflicts were hit.
|
||||
IndexBuildTest.assertIndexBuildCurrentOpContents(testDB, opId, (op) => {
|
||||
|
@ -87,7 +87,7 @@ assert.eq(MongoRunner.EXIT_ABORT, res.exitCode);
|
||||
// Expect the secondary to crash. Depending on timing, this can be either because the secondary was
|
||||
// waiting for a primary abort when a 'commitIndexBuild' is applied, or because the build fails and
|
||||
// tries to request an abort while a 'commitIndexBuild' is being applied.
|
||||
assert(rawMongoProgramOutput().match('Fatal assertion.*(7329403|7329407)'),
|
||||
assert(rawMongoProgramOutput(".*").match('Fatal assertion.*(7329403|7329407)'),
|
||||
'Receiving a commit from the primary for a failing index build should crash the secondary');
|
||||
|
||||
createIdx();
|
||||
|
@ -77,7 +77,7 @@ assert.soon(function() {
|
||||
|
||||
// Secondary should crash on receiving the unexpected commitIndexBuild oplog entry.
|
||||
assert.eq(MongoRunner.EXIT_ABORT, res.exitCode);
|
||||
assert(rawMongoProgramOutput().match('Fatal assertion.*4698902'),
|
||||
assert(rawMongoProgramOutput(".*").match('Fatal assertion.*4698902'),
|
||||
'Index build should have aborted secondary due to unexpected commitIndexBuild oplog entry.');
|
||||
|
||||
// Check indexes on primary.
|
||||
|
@ -73,7 +73,7 @@ assert.commandWorked(secondaryDB.killOp(opId));
|
||||
if (!gracefulIndexBuildFlag) {
|
||||
// We expect this to crash the secondary because this error is not recoverable
|
||||
assert.soon(function() {
|
||||
return rawMongoProgramOutput().search(/Fatal assertion.*(51101)/) >= 0;
|
||||
return rawMongoProgramOutput(".*").search(/Fatal assertion.*(51101)/) >= 0;
|
||||
});
|
||||
|
||||
// After restarting the secondary, expect that the index build completes successfully.
|
||||
|
@ -75,7 +75,7 @@ const gracefulIndexBuildFlag = FeatureFlagUtil.isEnabled(testDB, "IndexBuildGrac
|
||||
if (!gracefulIndexBuildFlag) {
|
||||
// We expect the node to crash without this feature enabled.
|
||||
assert.soon(function() {
|
||||
return rawMongoProgramOutput().search(/Fatal assertion.*51101/) >= 0;
|
||||
return rawMongoProgramOutput(".*").search(/Fatal assertion.*51101/) >= 0;
|
||||
});
|
||||
|
||||
// After restarting the old primary, we expect that the index build completes successfully.
|
||||
|
@ -85,7 +85,7 @@ tests.forEach(function(t) {
|
||||
clearRawMongoProgramOutput();
|
||||
assert.throws(startParallelShell(
|
||||
code + ";\nrecurser(0," + depth + "," + tojson(t.callback) + ");", false, true));
|
||||
let output = rawMongoProgramOutput();
|
||||
let output = rawMongoProgramOutput(".*");
|
||||
let lines = output.split(/\s*\n|\\n/);
|
||||
let matchShellExp = false;
|
||||
while (lines.length > 0 & matchShellExp !== true) {
|
||||
|
@ -68,7 +68,7 @@ export class ConfigExpandRestServer {
|
||||
|
||||
// Wait for the web server to start
|
||||
assert.soon(function() {
|
||||
return rawMongoProgramOutput().search("Mock Web Server Listening") !== -1;
|
||||
return rawMongoProgramOutput(".*").search("Mock Web Server Listening") !== -1;
|
||||
});
|
||||
|
||||
print("Mock HTTP Server sucessfully started.");
|
||||
@ -194,7 +194,7 @@ export function configExpandFailure(config, test = null, opts = {}) {
|
||||
const mongod = _startMongoProgram({args: args});
|
||||
|
||||
assert.soon(function() {
|
||||
return rawMongoProgramOutput().match(test);
|
||||
return rawMongoProgramOutput(".*").match(test);
|
||||
});
|
||||
if (mongod) {
|
||||
stopMongoProgramByPid(mongod);
|
||||
|
@ -566,7 +566,7 @@ export const ResumableIndexBuildTest = class {
|
||||
|
||||
// Ensure that the resumable index build state was written to disk upon clean shutdown.
|
||||
for (const buildUUID of buildUUIDs) {
|
||||
assert(RegExp("4841502.*" + buildUUID).test(rawMongoProgramOutput()));
|
||||
assert(RegExp("4841502.*" + buildUUID).test(rawMongoProgramOutput(".*")));
|
||||
}
|
||||
|
||||
if (runBeforeStartup)
|
||||
@ -833,7 +833,7 @@ export const ResumableIndexBuildTest = class {
|
||||
|
||||
clearRawMongoProgramOutput();
|
||||
rst.stop(resumeNode);
|
||||
assert(RegExp("4841502.*" + buildUUID).test(rawMongoProgramOutput()));
|
||||
assert(RegExp("4841502.*" + buildUUID).test(rawMongoProgramOutput(".*")));
|
||||
|
||||
rst.start(resumeNode, {noCleanData: true});
|
||||
otherNodeFp.off();
|
||||
|
@ -123,7 +123,7 @@ function forkThenShutdownMongoProgram(program, args) {
|
||||
|
||||
clearRawMongoProgramOutput();
|
||||
assert.eq(0, runMongoProgram.apply(this, arrOpts));
|
||||
const rawOutput = rawMongoProgramOutput();
|
||||
const rawOutput = rawMongoProgramOutput(".*");
|
||||
const pid = getPidFromRawProgramOutput(rawOutput);
|
||||
assert.neq(null, pid, "Failed to parse forked process pid");
|
||||
|
||||
|
@ -12,7 +12,7 @@ clearRawMongoProgramOutput();
|
||||
// dbpath.
|
||||
assert.throws(() => MongoRunner.runMongod({dbpath: dbPath, noCleanData: true}));
|
||||
|
||||
var logContents = rawMongoProgramOutput();
|
||||
var logContents = rawMongoProgramOutput(".*");
|
||||
assert(logContents.indexOf("Unable to lock the lock file") > 0 ||
|
||||
// Windows error message is different.
|
||||
logContents.indexOf("Unable to create/open the lock file") > 0);
|
||||
|
@ -9,7 +9,7 @@ function makeRegExMatchFn(pattern) {
|
||||
}
|
||||
|
||||
function testStartupLogging(launcher, matchFn, expectedExitCode) {
|
||||
assert(matchFn(rawMongoProgramOutput()));
|
||||
assert(matchFn(rawMongoProgramOutput(".*")));
|
||||
}
|
||||
|
||||
function validateWaitingMessage(launcher) {
|
||||
|
@ -43,7 +43,7 @@ let conn = MongoRunner.runMongod({
|
||||
});
|
||||
assert(conn);
|
||||
MongoRunner.stopMongod(conn);
|
||||
verifyOplogCapMaintainerThreadNotStarted(rawMongoProgramOutput());
|
||||
verifyOplogCapMaintainerThreadNotStarted(rawMongoProgramOutput(".*"));
|
||||
|
||||
jsTestLog("Testing recoverFromOplogAsStandalone mode");
|
||||
clearRawMongoProgramOutput();
|
||||
@ -54,7 +54,7 @@ conn = MongoRunner.runMongod({
|
||||
});
|
||||
assert(conn);
|
||||
MongoRunner.stopMongod(conn);
|
||||
verifyOplogCapMaintainerThreadNotStarted(rawMongoProgramOutput());
|
||||
verifyOplogCapMaintainerThreadNotStarted(rawMongoProgramOutput(".*"));
|
||||
|
||||
jsTestLog("Testing repair mode");
|
||||
clearRawMongoProgramOutput();
|
||||
@ -65,4 +65,4 @@ conn = MongoRunner.runMongod({
|
||||
setParameter: {logComponentVerbosity: tojson({storage: 1})},
|
||||
});
|
||||
assert(!conn);
|
||||
verifyOplogCapMaintainerThreadNotStarted(rawMongoProgramOutput());
|
||||
verifyOplogCapMaintainerThreadNotStarted(rawMongoProgramOutput(".*"));
|
@ -108,7 +108,7 @@ function runTest(op, result) {
|
||||
assert.eq(exitCode, MongoRunner.EXIT_ABORT);
|
||||
assert.soon(
|
||||
function() {
|
||||
return rawMongoProgramOutput().search(/Fatal assertion.*5415000/) >= 0;
|
||||
return rawMongoProgramOutput("Fatal assertion").search(/5415000/) >= 0;
|
||||
},
|
||||
"Node should have fasserted upon encountering a fatal error during startup",
|
||||
ReplSetTest.kDefaultTimeoutMS);
|
||||
|
@ -4,7 +4,7 @@ assert.throws(
|
||||
() => MongoRunner.runMongod({timeZoneInfo: "jstests/libs/config_files/bad_timezone_info"}),
|
||||
[],
|
||||
"expected launching mongod with bad timezone rules to fail");
|
||||
assert.neq(-1, rawMongoProgramOutput().search(/Fatal assertion.*40475/));
|
||||
assert.neq(-1, rawMongoProgramOutput(".*").search(/Fatal assertion.*40475/));
|
||||
|
||||
// Test that a non-existent directory causes startup to fail.
|
||||
assert.throws(
|
||||
@ -13,8 +13,8 @@ assert.throws(
|
||||
"expected launching mongod with bad timezone rules to fail");
|
||||
|
||||
// Look for either old or new error message
|
||||
assert(rawMongoProgramOutput().includes("Error creating service context") ||
|
||||
rawMongoProgramOutput().includes("Failed to create service context"));
|
||||
assert(rawMongoProgramOutput(".*").includes("Error creating service context") ||
|
||||
rawMongoProgramOutput(".*").includes("Failed to create service context"));
|
||||
|
||||
function testWithGoodTimeZoneDir(tz_good_path) {
|
||||
let conn = MongoRunner.runMongod({timeZoneInfo: tz_good_path});
|
||||
|
@ -22,8 +22,8 @@ assert.eq(res.internalValidateFeaturesAsMaster, false);
|
||||
let joinShell = startParallelShell(
|
||||
"db.adminCommand({getParameter: 1, internalValidateFeaturesAsMaster: 1});", conn.port);
|
||||
joinShell();
|
||||
assert(rawMongoProgramOutput().match(
|
||||
"\"Use of deprecated server parameter name\",\"attr\":{\"deprecatedName\":\"internalValidateFeaturesAsMaster\""));
|
||||
assert(rawMongoProgramOutput("Use of deprecated server parameter name")
|
||||
.match("\"attr\":{\"deprecatedName\":\"internalValidateFeaturesAsMaster\""));
|
||||
MongoRunner.stopMongod(conn);
|
||||
|
||||
// internalValidateFeaturesAsMaster can be set via startup parameter.
|
||||
@ -59,7 +59,7 @@ joinShell = startParallelShell(() => {
|
||||
{replSet: "replSetName", setParameter: "internalValidateFeaturesAsPrimary=0"}));
|
||||
}, conn.port);
|
||||
joinShell();
|
||||
let joinShellOutput = rawMongoProgramOutput();
|
||||
let joinShellOutput = rawMongoProgramOutput("Cannot specify both .* and replication.replSet");
|
||||
assert(joinShellOutput.match(
|
||||
"Cannot specify both internalValidateFeaturesAsPrimary and replication.replSet"));
|
||||
assert(!joinShellOutput.match(
|
||||
@ -72,7 +72,7 @@ joinShell = startParallelShell(() => {
|
||||
{replSet: "replSetName", setParameter: "internalValidateFeaturesAsMaster=0"}));
|
||||
}, conn.port);
|
||||
joinShell();
|
||||
joinShellOutput = rawMongoProgramOutput();
|
||||
joinShellOutput = rawMongoProgramOutput("Cannot specify both .* and replication.replSet");
|
||||
assert(joinShellOutput.match(
|
||||
"Cannot specify both internalValidateFeaturesAsMaster and replication.replSet"));
|
||||
assert(!joinShellOutput.match(
|
||||
|
@ -7,24 +7,22 @@
|
||||
// too low a count
|
||||
clearRawMongoProgramOutput();
|
||||
assert.throws(() => MongoRunner.runMongod({setParameter: 'replWriterThreadCount=0'}));
|
||||
assert(
|
||||
rawMongoProgramOutput().match(
|
||||
"Invalid value for parameter replWriterThreadCount: 0 is not greater than or equal to 1"),
|
||||
"mongod started with too low a value for replWriterThreadCount");
|
||||
assert(rawMongoProgramOutput("Invalid value for parameter replWriterThreadCount: ")
|
||||
.match("0 is not greater than or equal to 1"),
|
||||
"mongod started with too low a value for replWriterThreadCount");
|
||||
|
||||
// too high a count
|
||||
clearRawMongoProgramOutput();
|
||||
assert.throws(() => MongoRunner.runMongod({setParameter: 'replWriterThreadCount=257'}));
|
||||
assert(
|
||||
rawMongoProgramOutput().match(
|
||||
"Invalid value for parameter replWriterThreadCount: 257 is not less than or equal to 256"),
|
||||
"mongod started with too high a value for replWriterThreadCount");
|
||||
assert(rawMongoProgramOutput("Invalid value for parameter replWriterThreadCount: ")
|
||||
.match("257 is not less than or equal to 256"),
|
||||
"mongod started with too high a value for replWriterThreadCount");
|
||||
|
||||
// proper count
|
||||
clearRawMongoProgramOutput();
|
||||
let mongo = MongoRunner.runMongod({setParameter: 'replWriterThreadCount=24'});
|
||||
assert.neq(null, mongo, "mongod failed to start with a suitable replWriterThreadCount value");
|
||||
assert(!rawMongoProgramOutput().match("Invalid value for parameter replWriterThreadCount"),
|
||||
assert(rawMongoProgramOutput("Invalid value for parameter replWriterThreadCount").length == 0,
|
||||
"despite accepting the replWriterThreadCount value, mongod logged an error");
|
||||
|
||||
// getParameter to confirm the value was set
|
||||
|
@ -8,7 +8,7 @@ const regexMatch = /\{.+"id":4777800.+"nodes":\[(.+)\].+\}/;
|
||||
const getInitializerOrderForSeed = (seed) => {
|
||||
clearRawMongoProgramOutput();
|
||||
const conn = MongoRunner.runMongod({verbose: 2, initializerShuffleSeed: seed});
|
||||
const logContents = rawMongoProgramOutput();
|
||||
const logContents = rawMongoProgramOutput(".*");
|
||||
const match = logContents.match(regexMatch);
|
||||
assert(match.length > 0);
|
||||
MongoRunner.stopMongod(conn);
|
||||
|
@ -17,21 +17,21 @@ function tryRun(arg) {
|
||||
clearRawMongoProgramOutput();
|
||||
const valid = tryRun('enableTestCommands=1');
|
||||
assert.eq(valid, 0);
|
||||
const validOutput = rawMongoProgramOutput();
|
||||
const validOutput = rawMongoProgramOutput(".*");
|
||||
assert.gte(validOutput.search(/enableTestCommands: 1/), 0, validOutput);
|
||||
|
||||
// Negative case, invalid setparam.
|
||||
clearRawMongoProgramOutput();
|
||||
const foo = tryRun('foo=bar');
|
||||
assert.neq(foo, 0);
|
||||
const fooOutput = rawMongoProgramOutput();
|
||||
const fooOutput = rawMongoProgramOutput(".*");
|
||||
assert.gte(fooOutput.search(/Unknown --setParameter 'foo'/), 0, fooOutput);
|
||||
|
||||
// Negative case, valid but unavailable setparam.
|
||||
clearRawMongoProgramOutput();
|
||||
const graph = tryRun('roleGraphInvalidationIsFatal=true');
|
||||
assert.neq(graph, 0);
|
||||
const graphOutput = rawMongoProgramOutput();
|
||||
const graphOutput = rawMongoProgramOutput(".*");
|
||||
assert.gte(
|
||||
graphOutput.search(
|
||||
/--setParameter 'roleGraphInvalidationIsFatal' only available when used with 'enableTestCommands'/),
|
||||
|
@ -16,6 +16,10 @@ import {ShardingTest} from "jstests/libs/shardingtest.js";
|
||||
TestData.skipCollectionAndIndexValidation = true;
|
||||
TestData.skipCheckDBHashes = true;
|
||||
|
||||
function regexForValidateAndDBHashSlowQuery() {
|
||||
return String('Slow query.*"command":\\{"(validate|db[Hh]ash)');
|
||||
}
|
||||
|
||||
function makePatternForDBHash(dbName) {
|
||||
return new RegExp(
|
||||
`Slow query.*"ns":"${dbName}\\.\\$cmd".*"appName":"MongoDB Shell","command":{"db[Hh]ash`,
|
||||
@ -55,7 +59,7 @@ function runDataConsistencyChecks(testCase) {
|
||||
// will return all of their output.
|
||||
testCase.teardown();
|
||||
|
||||
return rawMongoProgramOutput();
|
||||
return rawMongoProgramOutput(regexForValidateAndDBHashSlowQuery());
|
||||
}
|
||||
|
||||
(function testReplicaSetWithVotingSecondaries() {
|
||||
|
@ -11,7 +11,7 @@ var echoTest = function() {
|
||||
// This will produce `numLines` + 1 lines of output because echo isn't being called with
|
||||
// `-n`. This will block until the program exits.
|
||||
var exitCode = runProgram("echo", lineContents);
|
||||
var output = rawMongoProgramOutput();
|
||||
var output = rawMongoProgramOutput(".*");
|
||||
|
||||
assert.eq(0, exitCode);
|
||||
|
||||
|
@ -4,7 +4,7 @@ const regexMatch = /sh([0-9]{1,10})\|/;
|
||||
// Test that a normal mongo shell gives us some noise in the raw output.
|
||||
{
|
||||
const out = runMongoProgram('mongo', '--port', mongo.port, '--eval', ';');
|
||||
const mongoOutput = rawMongoProgramOutput();
|
||||
const mongoOutput = rawMongoProgramOutput(".*");
|
||||
|
||||
assert.gte(mongoOutput.match(regexMatch).length, 1);
|
||||
}
|
||||
@ -14,7 +14,7 @@ clearRawMongoProgramOutput();
|
||||
// Test that a quiet shell does not output anything.
|
||||
{
|
||||
const out = runMongoProgram('mongo', '--port', mongo.port, '--quiet', '--eval', ';');
|
||||
const mongoOutput = rawMongoProgramOutput();
|
||||
const mongoOutput = rawMongoProgramOutput(".*");
|
||||
|
||||
assert.eq(mongoOutput.match(regexMatch), null);
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ if (!_isWindows()) {
|
||||
var rc = runProgram("ls", "-l", file.name);
|
||||
assert.eq(rc, 0);
|
||||
|
||||
var output = rawMongoProgramOutput();
|
||||
var output = rawMongoProgramOutput(".*");
|
||||
var fields = output.split(" ");
|
||||
// First field is the prefix, second field is the `ls -l` permissions.
|
||||
assert.eq(fields[1].substr(0, 10), "-rw-------", targetFile + " has bad permissions");
|
||||
|
@ -5,7 +5,7 @@ if (!_isWindows()) {
|
||||
clearRawMongoProgramOutput();
|
||||
var rc = runProgram("mongo", "--nodb", "--quiet", "--eval", "print(isInteractive())");
|
||||
assert.eq(rc, 0);
|
||||
var output = rawMongoProgramOutput();
|
||||
var output = rawMongoProgramOutput(".*");
|
||||
var response = (output.split('\n').slice(-2)[0]).split(' ')[1];
|
||||
assert.eq(response, "false", "Expected 'false' in script mode");
|
||||
// now try interactive
|
||||
@ -13,7 +13,7 @@ if (!_isWindows()) {
|
||||
rc = runProgram(
|
||||
"mongo", "--nodb", "--quiet", "--shell", "--eval", "print(isInteractive()); quit()");
|
||||
assert.eq(rc, 0);
|
||||
output = rawMongoProgramOutput();
|
||||
output = rawMongoProgramOutput(".*");
|
||||
response = (output.split('\n').slice(-2)[0]).split(' ')[1];
|
||||
assert.eq(response, "true", "Expected 'true' in interactive mode");
|
||||
}
|
@ -53,7 +53,7 @@ function runValidateHook(testCase) {
|
||||
// will return all of their output.
|
||||
testCase.teardown();
|
||||
|
||||
return rawMongoProgramOutput();
|
||||
return rawMongoProgramOutput(".*");
|
||||
}
|
||||
|
||||
function testStandalone(additionalSetupFn, {
|
||||
|
@ -16,7 +16,7 @@ const testVersionOutput = (exePath) => {
|
||||
|
||||
runNonMongoProgram(exePath, "--version");
|
||||
|
||||
const out = rawMongoProgramOutput().split('\n');
|
||||
const out = rawMongoProgramOutput(".*").split('\n');
|
||||
|
||||
assert.neq(out[0].match(dbVersionMatch), null);
|
||||
assert.neq(out[1].match(buildInfoMatch), null);
|
||||
|
@ -12,7 +12,7 @@ const readStatRegx = /"storage":{"data":{"bytesRead":([0-9]+)/;
|
||||
|
||||
let checkLogStats = function() {
|
||||
// Check if the log output contains the expected statistics.
|
||||
let mongodLogs = rawMongoProgramOutput();
|
||||
let mongodLogs = rawMongoProgramOutput(".*");
|
||||
let lines = mongodLogs.split('\n');
|
||||
let match;
|
||||
let logLineCount = 0;
|
||||
|
@ -115,7 +115,7 @@ export class MockOCSPServer {
|
||||
|
||||
assert.soon(function() {
|
||||
// Change this line if the OCSP endpoint changes
|
||||
return rawMongoProgramOutput().search("Launching debugserver on port 8100") !== -1;
|
||||
return rawMongoProgramOutput(".*").search("Launching debugserver on port 8100") !== -1;
|
||||
});
|
||||
|
||||
sleep(2000);
|
||||
|
@ -90,7 +90,7 @@ export const OCSP_REVOKED = "OCSPCertificateStatusRevoked";
|
||||
export var assertClientConnectFails = function(conn, reason) {
|
||||
clearRawMongoProgramOutput();
|
||||
assert.neq(clientConnect(conn), 0);
|
||||
const errmsg = rawMongoProgramOutput();
|
||||
const errmsg = rawMongoProgramOutput(".*");
|
||||
if (typeof reason === 'string' || reason instanceof RegExp) {
|
||||
assert.neq(errmsg.search(reason), -1);
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ MongoRunner.stopMongod(conn);
|
||||
// a certificate is revoked.
|
||||
if (determineSSLProvider() === "apple") {
|
||||
const APPLE_OCSP_ERROR_CODE = "CSSMERR_TP_CERT_REVOKED";
|
||||
let output = rawMongoProgramOutput();
|
||||
let output = rawMongoProgramOutput(".*");
|
||||
assert(output.search(APPLE_OCSP_ERROR_CODE));
|
||||
quit();
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ let runTest = (options) => {
|
||||
1);
|
||||
runParallelShellSuccess();
|
||||
|
||||
const successOutput = rawMongoProgramOutput();
|
||||
const successOutput = rawMongoProgramOutput(".*");
|
||||
let failOutput;
|
||||
|
||||
if (ocspFaultType != "") {
|
||||
@ -88,7 +88,7 @@ let runTest = (options) => {
|
||||
"--verbose",
|
||||
1));
|
||||
|
||||
failOutput = rawMongoProgramOutput();
|
||||
failOutput = rawMongoProgramOutput(".*");
|
||||
}
|
||||
|
||||
if (ocspFaultType == FAULT_REVOKED) {
|
||||
|
@ -364,7 +364,7 @@ function allIndexKeysNotFoundDuringReverseLookup(nDocs, docSuffix, collOpts) {
|
||||
checkHealthLog(secondaryHealthLog, logQueries.allErrorsOrWarningsQuery, 0);
|
||||
|
||||
if (debugBuild) {
|
||||
assert(rawMongoProgramOutput().match(/7844803.*could not find any keys in index/),
|
||||
assert(rawMongoProgramOutput("could not find any keys in index").match(/7844803/),
|
||||
"expected 'could not find any keys in index' log");
|
||||
}
|
||||
}
|
||||
|
@ -90,8 +90,8 @@ function checkNumBatchesAndSnapshots(
|
||||
((expectedNumBatches - 1) * snapshotsPerBatch) + lastBatchSnapshots;
|
||||
}
|
||||
const actualNumSnapshots =
|
||||
rawMongoProgramOutput()
|
||||
.split(/7844808.*Catalog snapshot for reverse lookup check ending/)
|
||||
rawMongoProgramOutput("Catalog snapshot for reverse lookup check ending")
|
||||
.split(/7844808/)
|
||||
.length -
|
||||
1;
|
||||
assert.eq(actualNumSnapshots,
|
||||
|
@ -28,15 +28,16 @@ failPointBeforeFinish.wait();
|
||||
const callPrintSecondaryReplInfo = startParallelShell(
|
||||
"db.getSiblingDB('admin').printSecondaryReplicationInfo();", syncTarget.port);
|
||||
callPrintSecondaryReplInfo();
|
||||
assert(rawMongoProgramOutput().match("InitialSyncSyncSource: " + primary.name));
|
||||
assert(rawMongoProgramOutput().match("InitialSyncRemainingEstimatedDuration: "));
|
||||
assert(rawMongoProgramOutput("InitialSyncSyncSource: ").match(primary.name));
|
||||
let subStr = "InitialSyncRemainingEstimatedDuration: ";
|
||||
assert(rawMongoProgramOutput(subStr).match(subStr));
|
||||
clearRawMongoProgramOutput();
|
||||
|
||||
const callPrintSlaveReplInfo =
|
||||
startParallelShell("db.getSiblingDB('admin').printSlaveReplicationInfo();", syncTarget.port);
|
||||
callPrintSlaveReplInfo();
|
||||
assert(rawMongoProgramOutput().match("InitialSyncSyncSource: " + primary.name));
|
||||
assert(rawMongoProgramOutput().match("InitialSyncRemainingEstimatedDuration: "));
|
||||
assert(rawMongoProgramOutput("InitialSyncSyncSource: ").match(primary.name));
|
||||
assert(rawMongoProgramOutput(subStr).match(subStr));
|
||||
clearRawMongoProgramOutput();
|
||||
failPointBeforeFinish.off();
|
||||
replSet.awaitSecondaryNodes();
|
||||
@ -63,7 +64,8 @@ assert(replInfo.now, replInfoString);
|
||||
var mongo =
|
||||
startParallelShell("db.getSiblingDB('admin').printSlaveReplicationInfo();", primary.port);
|
||||
mongo();
|
||||
assert(rawMongoProgramOutput().match("behind the primary"));
|
||||
subStr = "behind the primary";
|
||||
assert(rawMongoProgramOutput(subStr).match(subStr));
|
||||
|
||||
// get to a primaryless state
|
||||
for (i in replSet.getSecondaries()) {
|
||||
@ -76,15 +78,16 @@ assert.commandWorked(primary.getDB('admin').runCommand({replSetStepDown: 120, fo
|
||||
// it still works for backwards compatibility.
|
||||
mongo = startParallelShell("db.getSiblingDB('admin').printSlaveReplicationInfo();", primary.port);
|
||||
mongo();
|
||||
assert(rawMongoProgramOutput().match("behind the freshest"));
|
||||
subStr = "behind the freshest";
|
||||
assert(rawMongoProgramOutput(subStr).match(subStr));
|
||||
|
||||
clearRawMongoProgramOutput();
|
||||
assert.eq(rawMongoProgramOutput().match("behind the freshest"), null);
|
||||
assert.eq(rawMongoProgramOutput(subStr).match(subStr), null);
|
||||
|
||||
// Ensure that the new helper, printSecondaryReplicationInfo works the same.
|
||||
mongo =
|
||||
startParallelShell("db.getSiblingDB('admin').printSecondaryReplicationInfo();", primary.port);
|
||||
mongo();
|
||||
assert(rawMongoProgramOutput().match("behind the freshest"));
|
||||
assert(rawMongoProgramOutput(subStr).match(subStr));
|
||||
|
||||
replSet.stopSet();
|
@ -28,7 +28,7 @@ function testInitiate(gleDefaults) {
|
||||
|
||||
assert.soon(
|
||||
function() {
|
||||
return rawMongoProgramOutput().search(/Fatal assertion.*5624101/) >= 0;
|
||||
return rawMongoProgramOutput("Fatal assertion").search(/5624101/) >= 0;
|
||||
},
|
||||
"Node should have fasserted when initiating with a non-default getLastErrorDefaults field",
|
||||
ReplSetTest.kDefaultTimeoutMS);
|
||||
|
@ -562,8 +562,8 @@ export function checkSecondaryIndexChecksInDbCheckFeatureFlagEnabled(conn) {
|
||||
export function checkNumSnapshots(debugBuild, expectedNumSnapshots) {
|
||||
if (debugBuild) {
|
||||
const actualNumSnapshots =
|
||||
rawMongoProgramOutput()
|
||||
.split(/7844808.*Catalog snapshot for reverse lookup check ending/)
|
||||
rawMongoProgramOutput("Catalog snapshot for reverse lookup check ending")
|
||||
.split(/7844808/)
|
||||
.length -
|
||||
1;
|
||||
assert.eq(actualNumSnapshots,
|
||||
|
@ -216,7 +216,7 @@ export class RollbackResumableIndexBuildTest {
|
||||
|
||||
// Wait until the parallel shells have all started.
|
||||
assert.soon(() => {
|
||||
return (rawMongoProgramOutput().match(/"id":5113600/g) || []).length ===
|
||||
return (rawMongoProgramOutput("\"id\":5113600").match(/"id":5113600/g) || []).length ===
|
||||
buildUUIDs.length;
|
||||
});
|
||||
getLogFp.off();
|
||||
|
@ -74,7 +74,7 @@ export function SecondaryReadsTest(name = "secondary_reads_test") {
|
||||
|
||||
return function() {
|
||||
assert.soon(function() {
|
||||
return rawMongoProgramOutput().match(failPoint + " fail point enabled");
|
||||
return rawMongoProgramOutput("fail point enabled").match(failPoint);
|
||||
});
|
||||
};
|
||||
};
|
||||
|
@ -18,7 +18,7 @@ replSet.waitForState(secondary, ReplSetTest.State.DOWN);
|
||||
const joinShell =
|
||||
startParallelShell("db.getSiblingDB('admin').printSecondaryReplicationInfo();", primary.port);
|
||||
joinShell();
|
||||
assert(
|
||||
rawMongoProgramOutput().match("no replication info, yet. State: \\(not reachable/healthy\\)"));
|
||||
assert(rawMongoProgramOutput("no replication info, yet. State: ")
|
||||
.match("\\(not reachable/healthy\\)"));
|
||||
|
||||
replSet.stopSet();
|
@ -35,7 +35,7 @@ assert.eq(exitCode, MongoRunner.EXIT_ABRUPT);
|
||||
|
||||
assert.soon(
|
||||
function() {
|
||||
return rawMongoProgramOutput().search(/Fatal assertion.*6111701/) >= 0;
|
||||
return rawMongoProgramOutput("Fatal assertion").search(/6111701/) >= 0;
|
||||
},
|
||||
"Node should have fasserted upon encountering a fatal error during startup",
|
||||
ReplSetTest.kDefaultTimeoutMS);
|
@ -17,7 +17,7 @@ assert.throws(function() {
|
||||
rstWithBadStartupOptions.startSet();
|
||||
});
|
||||
|
||||
assert(rawMongoProgramOutput().match("Bad value for parameter \"rollbackTimeLimitSecs\""),
|
||||
assert(rawMongoProgramOutput("Bad value for parameter").match("\"rollbackTimeLimitSecs\""),
|
||||
"failed to reject bad value for parameter");
|
||||
|
||||
// Now initialize the same parameter correctly on startup.
|
||||
|
@ -30,6 +30,7 @@ rollbackTest.transitionToSyncSourceOperationsDuringRollback();
|
||||
rollbackTest.transitionToSteadyStateOperations();
|
||||
|
||||
// Make sure no unclean shutdowns occurred.
|
||||
assert.eq(rawMongoProgramOutput().search(/Detected unclean shutdown/), -1);
|
||||
const subStr = "Detected unclean shutdown";
|
||||
assert.eq(rawMongoProgramOutput(subStr).search(subStr), -1);
|
||||
|
||||
rollbackTest.stop();
|
@ -150,7 +150,8 @@ assert.commandWorked(restoreNode.adminCommand(
|
||||
{'configureFailPoint': 'hangBeforeUnrecoverableRollbackError', 'mode': 'off'}));
|
||||
|
||||
// This node should not come back up, because it has no stable timestamp to recover to.
|
||||
assert.soon(() => (rawMongoProgramOutput().search("UnrecoverableRollbackError") >= 0));
|
||||
const subStr = "UnrecoverableRollbackError";
|
||||
assert.soon(() => (rawMongoProgramOutput(subStr).search(subStr) >= 0));
|
||||
// Hide the exit code from stopSet.
|
||||
waitMongoProgram(parseInt(restoreNode.port));
|
||||
|
||||
|
@ -128,23 +128,25 @@ rst.start(restoreNode,
|
||||
})
|
||||
},
|
||||
true /* restart */);
|
||||
let subStr = "hangAfterCollectionInserts fail point enabled";
|
||||
assert.soon(() => { // Can't use checklog because we can't connect to the mongo in startup mode.
|
||||
return rawMongoProgramOutput().search("hangAfterCollectionInserts fail point enabled") !== -1;
|
||||
return rawMongoProgramOutput(subStr).search(subStr) !== -1;
|
||||
});
|
||||
// We need to make sure we get a checkpoint after the failpoint is hit, so we clear the output after
|
||||
// hitting it. Occasionally we'll miss a checkpoint as a result of clearing the output, but we'll
|
||||
// get another one a second later.
|
||||
clearRawMongoProgramOutput();
|
||||
// Ensure the checkpoint starts after the insert.
|
||||
subStr = "WT_VERB_CHECKPOINT.*saving checkpoint snapshot min";
|
||||
assert.soon(() => {
|
||||
return rawMongoProgramOutput().search("WT_VERB_CHECKPOINT.*saving checkpoint snapshot min") !==
|
||||
-1;
|
||||
return rawMongoProgramOutput(subStr).search(subStr) !== -1;
|
||||
});
|
||||
// Ensure that we wait for a checkpoint completed log message that comes strictly after the above
|
||||
// checkpoint started message.
|
||||
clearRawMongoProgramOutput();
|
||||
subStr = "Completed unstable checkpoint.";
|
||||
assert.soon(() => {
|
||||
return rawMongoProgramOutput().search("Completed unstable checkpoint.") !== -1;
|
||||
return rawMongoProgramOutput(subStr).search(subStr) !== -1;
|
||||
});
|
||||
|
||||
jsTestLog("Restarting restore node uncleanly");
|
||||
|
@ -28,7 +28,7 @@ if (TestData && TestData.inEvergreen) {
|
||||
return !checkProgram(child.pid).alive;
|
||||
}, undefined, undefined, undefined, {runHangAnalyzer: false});
|
||||
|
||||
const lines = rawMongoProgramOutput().split('\n');
|
||||
const lines = rawMongoProgramOutput(".*").split('\n');
|
||||
const buildInfo = globalThis.db.getServerBuildInfo();
|
||||
if (buildInfo.isAddressSanitizerActive() || buildInfo.isThreadSanitizerActive()) {
|
||||
assert.soon(() => {
|
||||
@ -70,7 +70,7 @@ clearRawMongoProgramOutput();
|
||||
MongoRunner.runHangAnalyzer.disable();
|
||||
assert.eq(undefined, MongoRunner.runHangAnalyzer([20200125]));
|
||||
|
||||
const lines = rawMongoProgramOutput().split('\n');
|
||||
const lines = rawMongoProgramOutput(".*").split('\n');
|
||||
// Nothing should be executed, so there's no output.
|
||||
assert.eq(lines, ['']);
|
||||
})();
|
||||
@ -91,7 +91,7 @@ try {
|
||||
TestData.inEvergreen = origInEvg;
|
||||
}
|
||||
|
||||
const lines = rawMongoProgramOutput().split('\n');
|
||||
const lines = rawMongoProgramOutput(".*").split('\n');
|
||||
// Nothing should be executed, so there's no output.
|
||||
assert.eq(lines, ['']);
|
||||
})();
|
||||
|
@ -79,7 +79,7 @@ export class ProxyProtocolServer {
|
||||
|
||||
// Wait for the web server to start
|
||||
assert.soon(function() {
|
||||
return rawMongoProgramOutput().search("Starting proxy protocol server...") !== -1;
|
||||
return rawMongoProgramOutput(".*").search("Starting proxy protocol server...") !== -1;
|
||||
});
|
||||
|
||||
print("Proxy Protocol Server sucessfully started.");
|
||||
|
@ -100,7 +100,7 @@ export function waitForFailpoint(hitFailpointStr, numTimes, timeout) {
|
||||
assert.soon(
|
||||
function() {
|
||||
const re = new RegExp(hitFailpointStr, 'g' /* find all occurrences */);
|
||||
return (rawMongoProgramOutput().match(re) || []).length == numTimes;
|
||||
return (rawMongoProgramOutput(hitFailpointStr).match(re) || []).length == numTimes;
|
||||
},
|
||||
'Failed to find "' + hitFailpointStr + '" logged ' + numTimes + ' times',
|
||||
timeout,
|
||||
|
@ -22,47 +22,47 @@ const SetFCVStatus = Object.freeze({called: 1, transitioning: 2, successful: 3})
|
||||
*/
|
||||
function assertLogs(status, upgradeOrDowngrade, serverType, numShardServers) {
|
||||
if (status >= SetFCVStatus.called) {
|
||||
assert.soon(() => rawMongoProgramOutput().match(/\"id\":6744300/),
|
||||
assert.soon(() => rawMongoProgramOutput(".*").match(/\"id\":6744300/),
|
||||
'"FCV ' + upgradeOrDowngrade + ' called" log not found');
|
||||
} else {
|
||||
assert(rawMongoProgramOutput().match(/\"id\":6744300/) == null,
|
||||
assert(rawMongoProgramOutput(".*").match(/\"id\":6744300/) == null,
|
||||
'should not log but "FCV ' + upgradeOrDowngrade + ' called" log found');
|
||||
}
|
||||
if (status >= SetFCVStatus.transitioning) {
|
||||
assert.soon(() => rawMongoProgramOutput().match(/\"id\":6744301/),
|
||||
assert.soon(() => rawMongoProgramOutput(".*").match(/\"id\":6744301/),
|
||||
'"FCV ' + upgradeOrDowngrade + ' in progress" log not found');
|
||||
} else {
|
||||
assert(rawMongoProgramOutput().match(/\"id\":6744301/) == null,
|
||||
assert(rawMongoProgramOutput(".*").match(/\"id\":6744301/) == null,
|
||||
'should not log but "FCV ' + upgradeOrDowngrade + ' in progress" log found');
|
||||
}
|
||||
if (status >= SetFCVStatus.successful) {
|
||||
assert.soon(() => rawMongoProgramOutput().match(/\"id\":6744302/),
|
||||
assert.soon(() => rawMongoProgramOutput(".*").match(/\"id\":6744302/),
|
||||
'"FCV ' + upgradeOrDowngrade + ' success" log not found');
|
||||
} else {
|
||||
assert(rawMongoProgramOutput().match(/\"id\":6744302/) == null,
|
||||
assert(rawMongoProgramOutput(".*").match(/\"id\":6744302/) == null,
|
||||
'should not log but "FCV ' + upgradeOrDowngrade + ' success" log found');
|
||||
}
|
||||
|
||||
if (serverType === "replica set/maintenance mode") {
|
||||
assert.soon(() => {
|
||||
let matchRes =
|
||||
rawMongoProgramOutput().match(/\"serverType\":"replica set\/maintenance mode"/g);
|
||||
let matchRes = rawMongoProgramOutput(".*").match(
|
||||
/\"serverType\":"replica set\/maintenance mode"/g);
|
||||
return matchRes != null && matchRes.length == status;
|
||||
}, "should have " + status + " log(s) with serverType: replica set/maintenance mode");
|
||||
} else if (serverType === "shardedCluster") {
|
||||
assert.soon(() => {
|
||||
let matchRes = rawMongoProgramOutput().match(/\"serverType\":"config server"/g);
|
||||
let matchRes = rawMongoProgramOutput(".*").match(/\"serverType\":"config server"/g);
|
||||
return matchRes != null && matchRes.length == status;
|
||||
}, "should have " + status + " log(s) with serverType: config server");
|
||||
// If the FCV change failed before the config server reached the transitioning state,
|
||||
// there should not be any logs containing 'shard server'.
|
||||
if (status >= SetFCVStatus.transitioning) {
|
||||
assert.soon(() => {
|
||||
let matchRes = rawMongoProgramOutput().match(/\"serverType\":"shard server"/g);
|
||||
let matchRes = rawMongoProgramOutput(".*").match(/\"serverType\":"shard server"/g);
|
||||
return matchRes != null && matchRes.length == numShardServers * status;
|
||||
}, "should have " + numShardServers * status + " log(s) with serverType: shard server");
|
||||
} else {
|
||||
assert(rawMongoProgramOutput().match(/\"serverType\":"shard server"/g) == null,
|
||||
assert(rawMongoProgramOutput(".*").match(/\"serverType\":"shard server"/g) == null,
|
||||
'should not have log containing shard server');
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ jsTest.log("Waiting for original primary to rollback and shut down");
|
||||
// Wait until the node shuts itself down during the rollback. We will hit the first assertion if
|
||||
// we rollback using 'recoverToStableTimestamp'.
|
||||
assert.soon(() => {
|
||||
return (rawMongoProgramOutput().search(/Fatal assertion.*(40498|50712)/) !== -1);
|
||||
return (rawMongoProgramOutput(".*").search(/Fatal assertion.*(40498|50712)/) !== -1);
|
||||
});
|
||||
|
||||
// Restart the original primary again. This time, the shardIdentity document should already be
|
||||
|
@ -34,7 +34,7 @@ function testWithGoodTimeZoneDir(tzGoodInfoDir) {
|
||||
() => MongoRunner.runMongos({configdb: st.configRS.getURL(), timeZoneInfo: tzBadInfo}),
|
||||
[],
|
||||
"expected launching mongos with bad timezone rules to fail");
|
||||
assert.neq(-1, rawMongoProgramOutput().search(/Fatal assertion.*40475/));
|
||||
assert.neq(-1, rawMongoProgramOutput(".*").search(/Fatal assertion.*40475/));
|
||||
|
||||
// Test that a non-existent timezone directory causes mongoS startup to fail.
|
||||
assert.throws(
|
||||
@ -42,8 +42,8 @@ function testWithGoodTimeZoneDir(tzGoodInfoDir) {
|
||||
[],
|
||||
"expected launching mongos with bad timezone rules to fail");
|
||||
// Look for either old or new error message
|
||||
assert(rawMongoProgramOutput().includes("Error creating service context") ||
|
||||
rawMongoProgramOutput().includes("Failed to create service context"));
|
||||
assert(rawMongoProgramOutput(".*").includes("Error creating service context") ||
|
||||
rawMongoProgramOutput(".*").includes("Failed to create service context"));
|
||||
|
||||
// Enable sharding on the test DB and ensure its primary is st.shard0.shardName.
|
||||
assert.commandWorked(
|
||||
|
@ -26,7 +26,7 @@ import {
|
||||
// logged at an earlier wall clock time.
|
||||
function waitForLog(logLine, times) {
|
||||
assert.soon(function() {
|
||||
const matches = rawMongoProgramOutput().match(new RegExp(logLine, "g")) || [];
|
||||
const matches = rawMongoProgramOutput(".*").match(new RegExp(logLine, "g")) || [];
|
||||
return matches.length === times;
|
||||
}, 'Failed to find "' + logLine + '" logged ' + times + ' times');
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ while (numUncleanShutdowns < kNumUncleanShutdowns) {
|
||||
}, primary.port);
|
||||
|
||||
assert.soon(() => {
|
||||
const logContents = rawMongoProgramOutput();
|
||||
const logContents = rawMongoProgramOutput(".*");
|
||||
return logContents.indexOf("close_ckpt") > 0;
|
||||
});
|
||||
|
||||
|
@ -18,13 +18,13 @@ if (determineSSLProvider() !== "openssl") {
|
||||
jsTest.log('No clusterAuthMode set');
|
||||
clearRawMongoProgramOutput();
|
||||
assert.throws(() => MongoRunner.runMongod(opts));
|
||||
assert(rawMongoProgramOutput().includes(errmsg));
|
||||
assert(rawMongoProgramOutput(".*").includes(errmsg));
|
||||
|
||||
jsTest.log('clusterAuthMode == keyFile');
|
||||
clearRawMongoProgramOutput();
|
||||
opts.clusterAuthMode = 'keyFile';
|
||||
assert.throws(() => MongoRunner.runMongod(opts));
|
||||
assert(rawMongoProgramOutput().includes(errmsg));
|
||||
assert(rawMongoProgramOutput(".*").includes(errmsg));
|
||||
}
|
||||
|
||||
function authAndDo(port, cert, cmd = ';') {
|
||||
|
@ -14,7 +14,7 @@ requireSSLProvider('apple', function() {
|
||||
|
||||
assert.throws(() => MongoRunner.runMongod(config), [], "MongoD unexpectedly started up");
|
||||
|
||||
assert.eq(rawMongoProgramOutput().includes(
|
||||
assert.eq(rawMongoProgramOutput(".*").includes(
|
||||
"Using encrypted PKCS#1/PKCS#8 PEM files is not supported on this platform"),
|
||||
true);
|
||||
});
|
||||
|
@ -30,7 +30,7 @@ if (rc != 0) {
|
||||
}
|
||||
|
||||
// Output is of the format: 'glibc x.yz'
|
||||
var output = rawMongoProgramOutput();
|
||||
var output = rawMongoProgramOutput(".*");
|
||||
clearRawMongoProgramOutput();
|
||||
|
||||
jsTestLog(`getconf GNU_LIBC_VERSION\n${output}`);
|
||||
@ -45,7 +45,7 @@ if (rc != 0) {
|
||||
quit();
|
||||
}
|
||||
|
||||
var osRelease = rawMongoProgramOutput();
|
||||
var osRelease = rawMongoProgramOutput(".*");
|
||||
clearRawMongoProgramOutput();
|
||||
|
||||
jsTestLog(`cat /etc/os-release\n${osRelease}`);
|
||||
|
@ -53,7 +53,7 @@ function testConnect(expectPasswordPrompt, expectSuccess, ...args) {
|
||||
var clientPID = _startMongoProgram({args: command});
|
||||
|
||||
assert.soon(function() {
|
||||
const output = rawMongoProgramOutput();
|
||||
const output = rawMongoProgramOutput(".*");
|
||||
if (expectPasswordPrompt) {
|
||||
if (output.includes("Enter password:")) {
|
||||
stopMongoProgramByPid(clientPID);
|
||||
|
@ -53,7 +53,7 @@ function runTest(serverDisabledProtos, clientDisabledProtos) {
|
||||
...clientOptions,
|
||||
"--tlsDisabledProtocols",
|
||||
clientDisabledProtos);
|
||||
mongoOutput = rawMongoProgramOutput();
|
||||
mongoOutput = rawMongoProgramOutput(".*");
|
||||
return mongoOutput.match(expectedRegex);
|
||||
}, "Mongo shell output was as follows:\n" + mongoOutput + "\n************", 60 * 1000);
|
||||
|
||||
|
@ -8,7 +8,7 @@ var opts = {
|
||||
assert.throws(() => MongoRunner.runMongod(opts),
|
||||
[],
|
||||
"MongoD started successfully with neither tlsCAFile nor tlsUseSystemCA");
|
||||
assert(rawMongoProgramOutput().includes(
|
||||
assert(rawMongoProgramOutput(".*").includes(
|
||||
"The use of TLS without specifying a chain of trust is no longer supported"));
|
||||
clearRawMongoProgramOutput();
|
||||
|
||||
@ -22,7 +22,7 @@ opts = {
|
||||
assert.throws(() => MongoRunner.runMongod(opts),
|
||||
[],
|
||||
"MongoD started successfully with both tlsCAFile and tlsUseSystemCA");
|
||||
assert(rawMongoProgramOutput().includes(
|
||||
assert(rawMongoProgramOutput(".*").includes(
|
||||
"The use of both a CA File and the System Certificate store is not supported"));
|
||||
clearRawMongoProgramOutput();
|
||||
|
||||
@ -37,7 +37,7 @@ opts = {
|
||||
assert.throws(() => MongoRunner.runMongod(opts),
|
||||
[],
|
||||
"MongoD started successfully with both tlsCAFile and tlsUseSystemCA");
|
||||
assert(rawMongoProgramOutput().includes(
|
||||
assert(rawMongoProgramOutput(".*").includes(
|
||||
"The use of both a CA File and the System Certificate store is not supported"));
|
||||
clearRawMongoProgramOutput();
|
||||
|
||||
@ -50,7 +50,7 @@ opts = {
|
||||
assert.throws(() => MongoRunner.runMongod(opts),
|
||||
[],
|
||||
"MongoD started successfully with tlsClusterCAFile without tlsCAFile");
|
||||
assert(rawMongoProgramOutput().includes(
|
||||
assert(rawMongoProgramOutput(".*").includes(
|
||||
"Specifying a tlsClusterCAFile requires a tlsCAFile also be specified"));
|
||||
clearRawMongoProgramOutput();
|
||||
|
||||
@ -64,5 +64,5 @@ opts = {
|
||||
assert.throws(() => MongoRunner.runMongod(opts),
|
||||
[],
|
||||
"MongoD started successfully with tlsClusterCAFile without tlsCAFile");
|
||||
assert(rawMongoProgramOutput().includes(
|
||||
assert(rawMongoProgramOutput(".*").includes(
|
||||
"Specifying a tlsClusterCAFile requires a tlsCAFile also be specified"));
|
@ -24,7 +24,7 @@ requireSSLProvider('apple', function() {
|
||||
// criteria. In this case, we use -c, matching common name, and -Z, which includes SHA-1 and
|
||||
// SHA-256 thumbprints in the output.
|
||||
assert.eq(0, runNonMongoProgram("security", "find-certificate", "-c", subject, "-Z"));
|
||||
const out = rawMongoProgramOutput();
|
||||
const out = rawMongoProgramOutput(".*");
|
||||
|
||||
const kSearchStr = "SHA-1 hash: ";
|
||||
const kHashHexitLen = 40;
|
||||
@ -85,7 +85,7 @@ requireSSLProvider('apple', function() {
|
||||
const mongod = MongoRunner.runMongod(opts);
|
||||
|
||||
assert.soon(function() {
|
||||
const log = rawMongoProgramOutput();
|
||||
const log = rawMongoProgramOutput(".*");
|
||||
if ((cert.name === null) || (cluster.name === null)) {
|
||||
// Invalid search criteria should fail.
|
||||
return log.search('Certificate selector returned no results') >= 0;
|
||||
|
@ -12,7 +12,7 @@ function testConnect(outputLog, ...args) {
|
||||
const clientPID = _startMongoProgram({args: command});
|
||||
|
||||
assert.soon(function() {
|
||||
const output = rawMongoProgramOutput();
|
||||
const output = rawMongoProgramOutput(".*");
|
||||
if (output.includes(outputLog)) {
|
||||
stopMongoProgramByPid(clientPID);
|
||||
return true;
|
||||
|
@ -37,15 +37,15 @@ function test(suppress) {
|
||||
// logged before it.
|
||||
assert.soon(
|
||||
() => {
|
||||
const log = rawMongoProgramOutput();
|
||||
const log = rawMongoProgramOutput(".*");
|
||||
return log.search('client metadata') !== -1;
|
||||
},
|
||||
"logfile should contain 'client metadata'.\n" +
|
||||
"Log File Contents\n==============================\n" + rawMongoProgramOutput() +
|
||||
"Log File Contents\n==============================\n" + rawMongoProgramOutput(".*") +
|
||||
"\n==============================\n");
|
||||
|
||||
// Now check for the message
|
||||
const log = rawMongoProgramOutput();
|
||||
const log = rawMongoProgramOutput(".*");
|
||||
assert.eq(suppress, log.match(/[N,n]o SSL certificate provided by peer/) === null);
|
||||
|
||||
try {
|
||||
|
@ -25,7 +25,7 @@ const mongo = runMongoProgram('mongo',
|
||||
';',
|
||||
'--tlsAllowInvalidHostnames');
|
||||
assert.neq(mongo, 0, "Shell connected when it should have failed");
|
||||
assert(rawMongoProgramOutput().includes(' would have matched, but was overridden by SAN'),
|
||||
assert(rawMongoProgramOutput(".*").includes(' would have matched, but was overridden by SAN'),
|
||||
'Expected detail warning not seen');
|
||||
|
||||
// On OpenSSL only, start without `tlsAllowInvalidHostnames`
|
||||
@ -35,7 +35,7 @@ if (determineSSLProvider() === 'openssl') {
|
||||
const mongo = runMongoProgram(
|
||||
'mongo', '--tls', '--tlsCAFile', CA, 'localhost:' + mongod.port, '--eval', ';');
|
||||
assert.neq(mongo, 0, "Shell connected when it should have failed");
|
||||
assert(rawMongoProgramOutput().includes(
|
||||
assert(rawMongoProgramOutput(".*").includes(
|
||||
'CN: localhost would have matched, but was overridden by SAN'),
|
||||
'Expected detail warning not seen');
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ function testStartupFails(testCase) {
|
||||
assert.throws(() => {
|
||||
MongoRunner.runMongod(opts);
|
||||
});
|
||||
assert(rawMongoProgramOutput().includes(testCase.error));
|
||||
assert(rawMongoProgramOutput(".*").includes(testCase.error));
|
||||
}
|
||||
|
||||
requireSSLProvider('windows', function() {
|
||||
|
@ -14,7 +14,7 @@ function runTest(name, config, expect) {
|
||||
}
|
||||
assert.eq(null, mongod, 'Mongod started unexpectedly');
|
||||
|
||||
const output = rawMongoProgramOutput();
|
||||
const output = rawMongoProgramOutput(".*");
|
||||
assert.eq(
|
||||
true, output.includes(expect), "Server failure message did not include '" + expect + "'");
|
||||
}
|
||||
|
@ -86,5 +86,6 @@ assert.throws(() => MongoRunner.runMongos({
|
||||
}),
|
||||
[],
|
||||
"mongos started with x509 clusterAuthMode but no CA file");
|
||||
assert.neq(-1, rawMongoProgramOutput().search("No TLS certificate validation can be performed"));
|
||||
assert.neq(-1,
|
||||
rawMongoProgramOutput(".*").search("No TLS certificate validation can be performed"));
|
||||
configRS.stopSet();
|
||||
|
@ -21,7 +21,7 @@ function runTest(conn) {
|
||||
// We expect failure, since we can't create a user with this massive username in WT.
|
||||
// But at least make sure the error message is sensible.
|
||||
assert.neq(exitCode, 0);
|
||||
const output = rawMongoProgramOutput();
|
||||
const output = rawMongoProgramOutput(".*");
|
||||
|
||||
const NAME =
|
||||
'role=Datum-72,pseudonym=Datum-65,dmdName=Datum-54,deltaRevocationList=Datum-53,supportedAlgorithms=Datum-52,houseIdentifier=Datum-51,uniqueMember=Datum-50,distinguishedName=Datum-49,protocolInformation=Datum-48,enhancedSearchGuide=Datum-47,dnQualifier=Datum-46,x500UniqueIdentifier=Datum-45,generationQualifier=Datum-44,initials=Datum-43,GN=Datum-42,name=Datum-41,crossCertificatePair=Datum-40,certificateRevocationList=Datum-39,authorityRevocationList=Datum-38,cACertificate=Datum-37,userCertificate=Datum-36,userPassword=Datum-35,seeAlso=Datum-34,roleOccupant=Datum-33,owner=Datum-32,member=Datum-31,supportedApplicationContext=Datum-30,presentationAddress=Datum-29,preferredDeliveryMethod=Datum-28,destinationIndicator=Datum-27,registeredAddress=Datum-26,internationaliSDNNumber=Datum-25,x121Address=Datum-24,facsimileTelephoneNumber=Datum-23,teletexTerminalIdentifier=Datum-22,telexNumber=Datum-21,telephoneNumber=Datum-20,physicalDeliveryOfficeName=Datum-19,postOfficeBox=Datum-18,postalCode=Datum-17,postalAddress=Datum-16,businessCategory=Datum-15,searchGuide=Datum-14,description=Datum-13,title=Datum-12,OU=Datum-11,O=Datum-10,street=Datum-9,ST=NY,L=Datum-7,C=US,serialNumber=Datum-5,SN=Datum-4,CN=Datum-3';
|
||||
|
@ -22,7 +22,7 @@ function runTest(checkMongos, opts, expectWarningCertifcates, expectWarningHostn
|
||||
}
|
||||
|
||||
assert.soon(function() {
|
||||
const output = rawMongoProgramOutput();
|
||||
const output = rawMongoProgramOutput(".*");
|
||||
return (
|
||||
expectWarningCertifcates ==
|
||||
output.includes(
|
||||
|
@ -49,7 +49,7 @@ const serverCAFile = 'jstests/libs/ca.pem';
|
||||
function assertNoStart(opts, errmsg) {
|
||||
clearRawMongoProgramOutput();
|
||||
assert.throws(() => MongoRunner.runMongod(opts));
|
||||
assert(rawMongoProgramOutput().includes(errmsg));
|
||||
assert(rawMongoProgramOutput(".*").includes(errmsg));
|
||||
}
|
||||
|
||||
function checkInvalidConfigurations() {
|
||||
|
@ -77,7 +77,7 @@ function test(serverDP, clientDP, shouldSucceed) {
|
||||
didSucceed, shouldSucceed, "Running with " + tojson(serverDP) + "/" + tojson(clientDP));
|
||||
|
||||
assert.eq(expectLogMessage,
|
||||
rawMongoProgramOutput().search('Automatically disabling TLS 1.0') >= 0,
|
||||
rawMongoProgramOutput(".*").search('Automatically disabling TLS 1.0') >= 0,
|
||||
"TLS 1.0 was/wasn't automatically disabled");
|
||||
}
|
||||
|
||||
|
@ -87,12 +87,12 @@ function testServerSelectorKeyUsage(testCase) {
|
||||
|
||||
assert.soon(
|
||||
() => {
|
||||
const log = rawMongoProgramOutput();
|
||||
const log = rawMongoProgramOutput(".*");
|
||||
return log.search(testCase.expectIngressKeyUsed) !== -1;
|
||||
},
|
||||
`logfile did not contain expected peer certificate info: ${
|
||||
testCase.expectIngressKeyUsed}.\n` +
|
||||
"Log File Contents\n==============================\n" + rawMongoProgramOutput() +
|
||||
"Log File Contents\n==============================\n" + rawMongoProgramOutput(".*") +
|
||||
"\n==============================\n");
|
||||
|
||||
jsTestLog("Testing server uses correct key on egress");
|
||||
|
@ -35,7 +35,7 @@ if (HOST_TYPE == "linux") {
|
||||
clearRawMongoProgramOutput();
|
||||
assert.eq(
|
||||
0, runProgram("openssl", "x509", "-hash", "-noout", "-in", "jstests/libs/trusted-ca.pem"));
|
||||
let hash = rawMongoProgramOutput();
|
||||
let hash = rawMongoProgramOutput(".*");
|
||||
jsTestLog(hash); // has form: "|sh<pid> <hash>\n"
|
||||
hash = hash.trim().split(" ")[1];
|
||||
copyCertificateFile("jstests/libs/trusted-ca.pem", `${certDir}/${hash}.0`);
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include <iterator>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <regex>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
@ -144,19 +145,49 @@ void retryWithBackOff(std::function<void(void)> func) {
|
||||
}
|
||||
#endif
|
||||
|
||||
// Filters lines that match the regex pattern
|
||||
std::string filterLinesWithRegex(const std::string& input, const std::regex& pattern) {
|
||||
std::stringstream ss(input);
|
||||
std::string line;
|
||||
std::ostringstream result;
|
||||
while (std::getline(ss, line)) {
|
||||
if (std::regex_search(line, pattern)) {
|
||||
result << line << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
return result.str();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// Output up to BSONObjMaxUserSize characters of the most recent log output in order to
|
||||
// avoid hitting the 16MB size limit of a BSONObject.
|
||||
// Output up to BSONObjMaxUserSize characters of the most recent log output.
|
||||
//
|
||||
// Users must send a regex as the only argument, which will be passed as a string.
|
||||
// It is mandatory to provide this argument.
|
||||
//
|
||||
// The function will only return logs that match the specified regex.
|
||||
// If the resulting logs exceed BSONObjMaxUserSize, the function will raise an exception.
|
||||
// Ensure the provided regex is well-picked to filter only the desired logs and avoid exceeding the
|
||||
// size limit.
|
||||
BSONObj RawMongoProgramOutput(const BSONObj& args, void* data) {
|
||||
auto programOutputLogger =
|
||||
ProgramRegistry::get(getGlobalServiceContext())->getProgramOutputMultiplexer();
|
||||
std::string programLog = programOutputLogger->str();
|
||||
uassert(ErrorCodes::BadValue,
|
||||
"A regex pattern must be provided as the only argument. Please ensure you pass a valid "
|
||||
"regex string to filter the logs.",
|
||||
!singleArg(args).isNaN());
|
||||
std::string regex = singleArg(args).String();
|
||||
std::regex pattern(regex);
|
||||
programLog = filterLinesWithRegex(programLog, pattern);
|
||||
std::size_t sz = programLog.size();
|
||||
const string& outputStr =
|
||||
sz > BSONObjMaxUserSize ? programLog.substr(sz - BSONObjMaxUserSize) : programLog;
|
||||
uassert(ErrorCodes::BadValue,
|
||||
"The filtered logs exceed the BSONObjMaxUserSize limit of 16MB. Please use a more "
|
||||
"constrained regex pattern to reduce the size of the returned logs.",
|
||||
sz <= BSONObjMaxUserSize);
|
||||
|
||||
return BSON("" << outputStr);
|
||||
return BSON("" << programLog);
|
||||
}
|
||||
|
||||
BSONObj ClearRawMongoProgramOutput(const BSONObj& args, void* data) {
|
||||
|
Loading…
Reference in New Issue
Block a user