SERVER-115004 Add test for delayed secondary oplog replication (#45069)

GitOrigin-RevId: b7811c292534edb620a642023a1274cfe679eebc
This commit is contained in:
Felipe Farinon 2025-12-11 11:25:32 -05:00 committed by MongoDB Bot
parent aaada80f38
commit 61a3f84ed8
1 changed files with 68 additions and 36 deletions

View File

@ -13,16 +13,47 @@ import {configureFailPoint} from "jstests/libs/fail_point_util.js";
import {assertCommandWorkedInParallelShell} from "jstests/libs/parallel_shell_helpers.js";
import {ReplSetTest} from "jstests/libs/replsettest.js";
// An array of test cases that will be used to check the delayed secondary oplog replication.
const tests = [
{
// TODO(SERVER-72538): Change the test to check this validator only on the specific version under
// which it's going to be released.
validator: {
$expr: {
$eq: [
{
$map: {
input: "$a",
arrayIndexAs: "i",
in: "$$i",
},
},
[0, 1, 2],
],
},
},
featureFlag: "featureFlagExposeArrayIndexInMapFilterReduce",
},
{
// '$_testFeatureFlagLatest' is an expression that is permanently enabled in the latest FCV.
validator: {$expr: {$eq: ["$stuff", {$_testFeatureFlagLatest: 1}]}},
},
];
const rst = new ReplSetTest({nodes: 2});
rst.startSet();
rst.initiate();
const primary = rst.getPrimary();
const collName = jsTestName();
// '$_testFeatureFlagLatest' is an expression that is permanently enabled in the latest FCV.
const validatorSpec = {
$expr: {$eq: ["$stuff", {$_testFeatureFlagLatest: 1}]},
};
for (const test of tests) {
if (test.featureFlag) {
const res = assert.commandWorked(primary.adminCommand({"getParameter": 1, [test.featureFlag]: 1}));
if (!res[test.featureFlag].value) {
jsTest.log.warning("Skipping test because the " + test.featureFlag + " feature flag is disabled");
continue;
}
}
// Start creating a collection that has a validator with new query features.
// Hang it after the validator has been parsed, but before the create entry has been put in the
@ -31,7 +62,7 @@ const fpCreate = configureFailPoint(primary, "hangAfterParsingValidator");
const awaitCreate = assertCommandWorkedInParallelShell(primary, primary.getDB("test"), {
create: collName,
validator: validatorSpec,
validator: test.validator,
});
fpCreate.wait();
@ -61,5 +92,6 @@ awaitSetFCV();
// Reset for the next test.
assertDropCollection(primary.getDB("test"), collName);
assert.commandWorked(primary.adminCommand({setFeatureCompatibilityVersion: latestFCV, confirm: true}));
}
rst.stopSet();