SERVER-124470 Validate all timeseries are in expected viewful/viewless format after setFCV (#52132)
GitOrigin-RevId: e7d125de59dae75e916bd6f7b0664a927eb16e3e
This commit is contained in:
parent
593b99ebfc
commit
9f07e9bf7d
@ -73,6 +73,37 @@ export function isViewfulTimeseriesOnlySuite(db) {
|
||||
return !FeatureFlagUtil.isPresentAndEnabled(db, "CreateViewlessTimeseriesCollections", true /* ignoreFCV */);
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts the format of all timeseries collections matches the current value of the viewless timeseries feature flag.
|
||||
* TODO SERVER-101609 remove this function once 9.0 becomes lastLTS.
|
||||
*/
|
||||
export function assertTimeseriesConsistentWithViewlessFlag(db) {
|
||||
const viewlessEnabled = FeatureFlagUtil.isPresentAndEnabled(db, "CreateViewlessTimeseriesCollections");
|
||||
const dbNames = assert
|
||||
.commandWorked(db.adminCommand({listDatabases: 1, nameOnly: true}))
|
||||
.databases.map((d) => d.name);
|
||||
for (const dbName of dbNames) {
|
||||
// Use {type: {$ne: "view"}} to skip loading the view catalog (so we don't fail if there are invalid views).
|
||||
const listCollections = db.getSiblingDB(dbName).getCollectionInfos({type: {$ne: "view"}});
|
||||
for (const coll of listCollections) {
|
||||
if (coll.type !== "timeseries") continue;
|
||||
const isViewlessTimeseries = coll.info.uuid !== undefined;
|
||||
assert.eq(
|
||||
isViewlessTimeseries,
|
||||
viewlessEnabled,
|
||||
`Expected timeseries '${coll.name}' to be ${viewlessEnabled ? "viewless" : "viewful"}: ${tojson(listCollections)}`,
|
||||
);
|
||||
}
|
||||
|
||||
if (viewlessEnabled) {
|
||||
assert(
|
||||
!listCollections.some((coll) => coll.name.startsWith("system.buckets.")),
|
||||
`Unexpected system.buckets.* collection with viewless timeseries enabled: ${tojson(listCollections)}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that `value` is truthy for viewless timeseries and falsy for viewful timeseries.
|
||||
* In suites with mixed viewless/viewful timeseries, no assertion is made.
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
import {handleRandomSetFCVErrors} from "jstests/concurrency/fsm_workload_helpers/fcv/handle_setFCV_errors.js";
|
||||
import {assertTimeseriesConsistentWithViewlessFlag} from "jstests/core/timeseries/libs/viewless_timeseries_util.js";
|
||||
|
||||
if (typeof db === "undefined") {
|
||||
throw new Error("Expected mongo shell to be connected a server, but global 'db' object isn't defined");
|
||||
@ -63,6 +64,7 @@ const sendFCVUpDown = function (ver) {
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
assertTimeseriesConsistentWithViewlessFlag(db);
|
||||
};
|
||||
|
||||
Random.setRandomSeed();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user