diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 8a46c03b37b..3004f103ac1 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -955,6 +955,7 @@ WORKSPACE.bazel @10gen/devprod-build @svc-auto-approve-bot /jstests/libs/**/replicated_ident_utils.js @10gen/server-storage-engine-integration @svc-auto-approve-bot /jstests/libs/**/replicated_record_ids_utils.js @10gen/server-storage-engine-integration @svc-auto-approve-bot /jstests/libs/**/host_ipaddr.js @10gen/server-networking-and-observability @svc-auto-approve-bot +/jstests/libs/**/feature_compatibility_version.js @10gen/server-fcv @svc-auto-approve-bot /jstests/libs/**/*.pem @10gen/server-security @svc-auto-approve-bot /jstests/libs/**/*.sha1 @10gen/server-security @svc-auto-approve-bot /jstests/libs/**/*.sha256 @10gen/server-security @svc-auto-approve-bot diff --git a/jstests/core/timeseries/ddl/timeseries_collmod_timeseries_options.js b/jstests/core/timeseries/ddl/timeseries_collmod_timeseries_options.js index b6ba026081e..89ab9f8243a 100644 --- a/jstests/core/timeseries/ddl/timeseries_collmod_timeseries_options.js +++ b/jstests/core/timeseries/ddl/timeseries_collmod_timeseries_options.js @@ -9,6 +9,8 @@ * ] */ +import {isFCVgte} from "jstests/libs/feature_compatibility_version.js"; + const coll = db["coll"]; const indexField = "a"; const bucketRoundingSecondsHours = 60 * 60 * 24; @@ -25,7 +27,7 @@ function createTestColl() { assert.commandWorked(coll.createIndex({[indexField]: 1})); } -const timeseriesOptions = [ +let timeseriesOptions = [ {"timeseries": {"granularity": "minutes"}}, { "timeseries": { @@ -33,8 +35,15 @@ const timeseriesOptions = [ "bucketRoundingSeconds": bucketRoundingSecondsHours, }, }, - {"timeseriesBucketsMayHaveMixedSchemaData": true}, ]; + +// TODO SERVER-105548 always include `timeseriesBucketsMayHaveMixedSchemaData` in the list of timeseries options above. +if (isFCVgte(db, "8.3")) { + // Starting from SERVER-105337 (8.3) we started blocking CRUD operations also for + // timeseriesBucketsMayHaveMixedSchemaData collmod options. + timeseriesOptions.push({"timeseriesBucketsMayHaveMixedSchemaData": true}); +} + const nonTimeseriesValidOptions = [ {"index": {"keyPattern": {[indexField]: 1}, "hidden": true}}, {"expireAfterSeconds": 60}, diff --git a/jstests/libs/OWNERS.yml b/jstests/libs/OWNERS.yml index b11a18dcd4e..fc4171243cc 100644 --- a/jstests/libs/OWNERS.yml +++ b/jstests/libs/OWNERS.yml @@ -96,6 +96,9 @@ filters: - "host_ipaddr.js": approvers: - 10gen/server-networking-and-observability + - "feature_compatibility_version.js": + approvers: + - 10gen/server-fcv - "*.pem": approvers: - 10gen/server-security diff --git a/jstests/libs/feature_compatibility_version.js b/jstests/libs/feature_compatibility_version.js new file mode 100644 index 00000000000..8fc6e250fbf --- /dev/null +++ b/jstests/libs/feature_compatibility_version.js @@ -0,0 +1,47 @@ +/** + * Utility function for working with cluster Feature Compatibilty Version. + */ + +function getFCVDocument(conn) { + let adminDB = typeof conn.getDB === "function" ? conn.getDB("admin") : conn.getSiblingDB("admin"); + return adminDB["system.version"].findOne({_id: "featureCompatibilityVersion"}); +} + +export function getCurrentFCV(conn) { + const FCVDoc = getFCVDocument(conn); + assert(FCVDoc, "Failed to retrieve FCV document"); + return FCVDoc.version; +} + +/** + * Returns true if we are running in a test suite with stable FCV. + */ +export function isStableFCVSuite() { + return !TestData.isRunningFCVUpgradeDowngradeSuite; +} + +export function isFCVgt(conn, targetVersion) { + const lowestFCV = isStableFCVSuite() ? getCurrentFCV(conn) : lastLTSFCV; + return MongoRunner.compareBinVersions(lowestFCV, targetVersion) > 0; +} + +export function isFCVgte(conn, targetVersion) { + const lowestFCV = isStableFCVSuite() ? getCurrentFCV(conn) : lastLTSFCV; + return MongoRunner.compareBinVersions(lowestFCV, targetVersion) >= 0; +} + +export function isFCVlt(conn, targetVersion) { + const highestFCV = isStableFCVSuite() ? getCurrentFCV(conn) : latestFCV; + return MongoRunner.compareBinVersions(highestFCV, targetVersion) < 0; +} + +export function isFCVlte(conn, targetVersion) { + const highestFCV = isStableFCVSuite() ? getCurrentFCV(conn) : latestFCV; + return MongoRunner.compareBinVersions(highestFCV, targetVersion) <= 0; +} + +export function isFCVeq(conn, targetVersion) { + assert(isStableFCVSuite(), "Can't use `isFCVeq` function in suites that perform backround FCV transitions."); + const currentFCV = getCurrentFCV(conn); + return MongoRunner.compareBinVersions(currentFCV, targetVersion) == 0; +}