SERVER-76005: Fix evergreen redness post 7.1 FCV upgrade

This commit is contained in:
XueruiFa
2023-04-12 14:07:18 +00:00
committed by Evergreen Agent
parent 0bc188cbdf
commit 1809b6dfc2
29 changed files with 49 additions and 1584 deletions

View File

@@ -3,7 +3,7 @@
* feature compatibility version is older than the latest version.
*
* We restart mongod during the test and expect it to have the same data after restarting.
* @tags: [requires_persistence]
* @tags: [requires_persistence, DISABLED_TEMPORARILY_DUE_TO_FCV_UPGRADE]
*/
(function() {
@@ -21,10 +21,7 @@ const featureFlagsToEnable = ["featureFlagUserRoles"];
// latest version, and rejects it when the feature compatibility version is the last
// version.
const testCasesLastContinuous = [];
const testCasesLastContinuousWithFeatureFlags = [
// TODO SERVER-70689: Remove this case when 7.0 becomes lastLTS.
[{$project: {z: "$$USER_ROLES"}}]
];
const testCasesLastContinuousWithFeatureFlags = [];
// Anything that's incompatible with the last continuous release is incompatible with the last
// stable release.
@@ -32,14 +29,6 @@ const testCasesLastStable = testCasesLastContinuous.concat([]);
const testCasesLastStableWithFeatureFlags = testCasesLastContinuousWithFeatureFlags.concat([]);
// The addition of the $$USER_ROLES system variable is slightly different than the usual use case of
// this test file. This means that some of the following commands won't work/fail as expected for
// the $$USER_ROLES test case.
// TODO SERVER-70689: Remove this function and references to it.
function testCaseDoesNotReferenceUserRoles(testCase) {
return testCase[0].$project.z != "$$USER_ROLES";
}
// Tests Feature Compatibility Version behavior of view creation while using aggregation pipelines
// 'testCases' and using a previous stable version 'lastVersion' of mongod.
// 'lastVersion' can have values "last-lts" and "last-continuous".
@@ -94,27 +83,21 @@ function testViewDefinitionFCVBehavior(lastVersion, testCases, featureFlags = []
// Read against an existing view using new query features should not fail.
testCases.forEach((pipe, i) => {
if (testCaseDoesNotReferenceUserRoles(pipe)) {
// The $$USER_ROLES value will be evaluated every time the view is queried, so the
// following query would fail since we are running an older FCV.
// TODO SERVER-70689: Remove the guard of this if-statement and keep the body.
assert.commandWorked(testDB.runCommand({find: "firstView" + i}),
`Failed to query view with pipeline ${tojson(pipe)}`);
}
// The $$USER_ROLES value will be evaluated every time the view is queried, so the
// following query would fail since we are running an older FCV.
assert.commandWorked(testDB.runCommand({find: "firstView" + i}),
`Failed to query view with pipeline ${tojson(pipe)}`);
});
// Trying to create a new view in the same database as existing invalid view should fail,
// even if the new view doesn't use any new query features.
if (testCaseDoesNotReferenceUserRoles(testCases[0])) {
// Since the $$USER_ROLES variable won't be evaluated during this view creation, the view
// creation will succeed even though we are on an older FCV.
// TODO SERVER-70689: Remove the guard of this if-statement and keep the body.
assert.commandFailedWithCode(
testDB.createView("newViewOldFeatures", "coll", [{$project: {_id: 1}}]),
ErrorCodes.QueryFeatureNotAllowed,
`Expected *not* to be able to create view on database ${testDB} while in FCV ${
binVersionToFCV(lastVersion)}`);
}
// Since the $$USER_ROLES variable won't be evaluated during this view creation, the view
// creation will succeed even though we are on an older FCV.
assert.commandFailedWithCode(
testDB.createView("newViewOldFeatures", "coll", [{$project: {_id: 1}}]),
ErrorCodes.QueryFeatureNotAllowed,
`Expected *not* to be able to create view on database ${testDB} while in FCV ${
binVersionToFCV(lastVersion)}`);
// Trying to create a new view succeeds if it's on a separate database.
const testDB2 = conn.getDB(testName + '2');
@@ -171,13 +154,10 @@ function testViewDefinitionFCVBehavior(lastVersion, testCases, featureFlags = []
// Read against an existing view using new query features should not fail.
testCases.forEach((pipe, i) => {
if (testCaseDoesNotReferenceUserRoles(pipe)) {
// The view is evaluated on the fly, and the FCV is still set to the last version so the
// evaluation of $$USER_ROLES will cause this to fail.
// TODO SERVER-70689: Remove the guard of this if-statement and keep the body.
assert.commandWorked(testDB.runCommand({find: "firstView" + i}),
`Failed to query view with pipeline ${tojson(pipe)}`);
}
// The view is evaluated on the fly, and the FCV is still set to the last version so the
// evaluation of $$USER_ROLES will cause this to fail.
assert.commandWorked(testDB.runCommand({find: "firstView" + i}),
`Failed to query view with pipeline ${tojson(pipe)}`);
});
// Set the feature compatibility version back to the latest version.
@@ -220,29 +200,21 @@ function testViewDefinitionFCVBehavior(lastVersion, testCases, featureFlags = []
// In this case, using $$USER_ROLES on the last FCV version will cause the view
// creation to fail during parsing because the necessary feature flag will not have been
// enabled due to the older FCV.
// TODO SERVER-70689: Remove the guard of this if-statement and keep the body.
if (testCaseDoesNotReferenceUserRoles(pipe)) {
// Even though the feature compatibility version is the last version, we should still be
// able to create a view using new query features, because
// internalValidateFeaturesAsPrimary is false.
assert.commandWorked(
testDB.createView("thirdView" + i, "coll", pipe),
`Expected to be able to create view with pipeline ${tojson(pipe)} while in FCV` +
` ${
binVersionToFCV(
lastVersion)} with internalValidateFeaturesAsPrimary=false`);
// Even though the feature compatibility version is the last version, we should still be
// able to create a view using new query features, because
// internalValidateFeaturesAsPrimary is false.
assert.commandWorked(
testDB.createView("thirdView" + i, "coll", pipe),
`Expected to be able to create view with pipeline ${tojson(pipe)} while in FCV` +
` ${binVersionToFCV(lastVersion)} with internalValidateFeaturesAsPrimary=false`);
// We should also be able to modify a view to use new query features.
assert(testDB["thirdView" + i].drop(),
`Drop of view with pipeline ${tojson(pipe)} failed`);
assert.commandWorked(testDB.createView("thirdView" + i, "coll", []));
assert.commandWorked(
testDB.runCommand({collMod: "thirdView" + i, viewOn: "coll", pipeline: pipe}),
`Expected to be able to modify view to use pipeline ${tojson(pipe)} while in FCV` +
` ${
binVersionToFCV(
lastVersion)} with internalValidateFeaturesAsPrimary=false`);
}
// We should also be able to modify a view to use new query features.
assert(testDB["thirdView" + i].drop(), `Drop of view with pipeline ${tojson(pipe)} failed`);
assert.commandWorked(testDB.createView("thirdView" + i, "coll", []));
assert.commandWorked(
testDB.runCommand({collMod: "thirdView" + i, viewOn: "coll", pipeline: pipe}),
`Expected to be able to modify view to use pipeline ${tojson(pipe)} while in FCV` +
` ${binVersionToFCV(lastVersion)} with internalValidateFeaturesAsPrimary=false`);
});
MongoRunner.stopMongod(conn);