diff --git a/jstests/core/timeseries/libs/viewless_timeseries_util.js b/jstests/core/timeseries/libs/viewless_timeseries_util.js index 60e81154c27..61846db16f0 100644 --- a/jstests/core/timeseries/libs/viewless_timeseries_util.js +++ b/jstests/core/timeseries/libs/viewless_timeseries_util.js @@ -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. diff --git a/jstests/hooks/run_fcv_upgrade_downgrade_background.js b/jstests/hooks/run_fcv_upgrade_downgrade_background.js index 69f7e4632bf..304c0e02475 100644 --- a/jstests/hooks/run_fcv_upgrade_downgrade_background.js +++ b/jstests/hooks/run_fcv_upgrade_downgrade_background.js @@ -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();