summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoan Bruguera Micó (at MongoDB) <joan.bruguera-mico@mongodb.com>2024-08-02 11:49:27 +0000
committerMongoDB Bot <mongo-bot@mongodb.com>2024-08-02 12:36:46 +0000
commita658c9bc1ebf07317162e7067370b61d3eb5c7bd (patch)
tree374b8e4801d38710d6c56dcaf5fb40d85768d725
parent9f9ff9911bba8380d70734b76b214e4c4220ba4a (diff)
SERVER-92426 Adapt tests to rely on new timeseriesBucketsMayHaveMixedSchemaData catalog option format (#25680)
GitOrigin-RevId: c3975a80e1c75adf33124d7bb6fbdb0f772e6ed8
-rw-r--r--jstests/core/timeseries/libs/timeseries.js14
-rw-r--r--jstests/core/timeseries/timeseries_insert_mixed_schema_bucket.js17
-rw-r--r--jstests/core/timeseries/timeseries_update_mixed_schema_bucket.js16
-rw-r--r--jstests/noPassthrough/timeseries_validate_mixed_schema_bucket.js9
-rw-r--r--jstests/replsets/timeseries_mixed_schema_bucket_initial_sync.js15
5 files changed, 37 insertions, 34 deletions
diff --git a/jstests/core/timeseries/libs/timeseries.js b/jstests/core/timeseries/libs/timeseries.js
index a5cf0866c5e..0186d49058a 100644
--- a/jstests/core/timeseries/libs/timeseries.js
+++ b/jstests/core/timeseries/libs/timeseries.js
@@ -32,6 +32,20 @@ var TimeseriesTest = class {
}
}
+ static bucketsMayHaveMixedSchemaData(coll) {
+ const catalog = coll.aggregate([{$listCatalog: {}}]).toArray()[0];
+ const tsMixedSchemaOptionNewFormat = catalog.md.options.storageEngine &&
+ catalog.md.options.storageEngine.wiredTiger &&
+ catalog.md.options.storageEngine.wiredTiger.configString;
+ // TODO SERVER-92533 Simplify once SERVER-91195 is backported to all supported branches
+ if (tsMixedSchemaOptionNewFormat !== undefined) {
+ return tsMixedSchemaOptionNewFormat ==
+ "app_metadata=(timeseriesBucketsMayHaveMixedSchemaData=true)";
+ } else {
+ return catalog.md.timeseriesBucketsMayHaveMixedSchemaData;
+ }
+ }
+
/**
* Returns whether time-series scalability improvements (like bucket reopening) are enabled.
* TODO SERVER-66438 remove this helper.
diff --git a/jstests/core/timeseries/timeseries_insert_mixed_schema_bucket.js b/jstests/core/timeseries/timeseries_insert_mixed_schema_bucket.js
index f75cf476e74..9e5a28920be 100644
--- a/jstests/core/timeseries/timeseries_insert_mixed_schema_bucket.js
+++ b/jstests/core/timeseries/timeseries_insert_mixed_schema_bucket.js
@@ -7,6 +7,10 @@
* requires_timeseries,
* ]
*/
+(function() {
+"use strict";
+
+load("jstests/core/timeseries/libs/timeseries.js"); // For 'TimeseriesTest'.
TestData.skipEnforceTimeseriesBucketsAreAlwaysCompressedOnValidate = true;
@@ -19,12 +23,6 @@ assert.commandWorked(
const coll = testDB[collName];
const bucketsColl = testDB["system.buckets." + collName];
-const timeseriesBucketsMayHaveMixedSchemaData = function() {
- return bucketsColl.aggregate([{$listCatalog: {}}])
- .toArray()[0]
- .md.timeseriesBucketsMayHaveMixedSchemaData;
-};
-
const bucket = {
_id: ObjectId("65a6eb806ffc9fa4280ecac4"),
control: {
@@ -59,13 +57,14 @@ const bucket = {
assert.commandFailedWithCode(bucketsColl.insert(bucket),
ErrorCodes.CannotInsertTimeseriesBucketsWithMixedSchema);
-assert.eq(timeseriesBucketsMayHaveMixedSchemaData(), false);
+assert.eq(TimeseriesTest.bucketsMayHaveMixedSchemaData(bucketsColl), false);
assert.commandWorked(
testDB.runCommand({collMod: collName, timeseriesBucketsMayHaveMixedSchemaData: true}));
-assert.eq(timeseriesBucketsMayHaveMixedSchemaData(), true);
+assert.eq(TimeseriesTest.bucketsMayHaveMixedSchemaData(bucketsColl), true);
assert.commandWorked(bucketsColl.insert(bucket));
assert.commandFailedWithCode(
testDB.runCommand({collMod: collName, timeseriesBucketsMayHaveMixedSchemaData: false}),
ErrorCodes.InvalidOptions);
assert.commandWorked(bucketsColl.deleteOne({_id: bucket._id}));
-assert.eq(timeseriesBucketsMayHaveMixedSchemaData(), true);
+assert.eq(TimeseriesTest.bucketsMayHaveMixedSchemaData(bucketsColl), true);
+})();
diff --git a/jstests/core/timeseries/timeseries_update_mixed_schema_bucket.js b/jstests/core/timeseries/timeseries_update_mixed_schema_bucket.js
index c8f334e215e..718fd432a65 100644
--- a/jstests/core/timeseries/timeseries_update_mixed_schema_bucket.js
+++ b/jstests/core/timeseries/timeseries_update_mixed_schema_bucket.js
@@ -7,6 +7,9 @@
* requires_timeseries,
* ]
*/
+(function() {
+"use strict";
+load("jstests/core/timeseries/libs/timeseries.js"); // For 'TimeseriesTest'.
TestData.skipEnforceTimeseriesBucketsAreAlwaysCompressedOnValidate = true;
@@ -19,12 +22,6 @@ assert.commandWorked(
const coll = testDB[collName];
const bucketsColl = testDB["system.buckets." + collName];
-const timeseriesBucketsMayHaveMixedSchemaData = function() {
- return bucketsColl.aggregate([{$listCatalog: {}}])
- .toArray()[0]
- .md.timeseriesBucketsMayHaveMixedSchemaData;
-};
-
const bucket = {
_id: ObjectId("65a6eb806ffc9fa4280ecac4"),
control: {
@@ -64,13 +61,14 @@ const update = function() {
assert.commandWorked(bucketsColl.insert(bucket));
assert.commandFailedWithCode(update(), ErrorCodes.CannotInsertTimeseriesBucketsWithMixedSchema);
-assert.eq(timeseriesBucketsMayHaveMixedSchemaData(), false);
+assert.eq(TimeseriesTest.bucketsMayHaveMixedSchemaData(bucketsColl), false);
assert.commandWorked(
testDB.runCommand({collMod: collName, timeseriesBucketsMayHaveMixedSchemaData: true}));
-assert.eq(timeseriesBucketsMayHaveMixedSchemaData(), true);
+assert.eq(TimeseriesTest.bucketsMayHaveMixedSchemaData(bucketsColl), true);
assert.commandWorked(update());
assert.commandFailedWithCode(
testDB.runCommand({collMod: collName, timeseriesBucketsMayHaveMixedSchemaData: false}),
ErrorCodes.InvalidOptions);
assert.commandWorked(bucketsColl.deleteOne({_id: bucket._id}));
-assert.eq(timeseriesBucketsMayHaveMixedSchemaData(), true);
+assert.eq(TimeseriesTest.bucketsMayHaveMixedSchemaData(bucketsColl), true);
+})();
diff --git a/jstests/noPassthrough/timeseries_validate_mixed_schema_bucket.js b/jstests/noPassthrough/timeseries_validate_mixed_schema_bucket.js
index d46f365c816..6b1632234b5 100644
--- a/jstests/noPassthrough/timeseries_validate_mixed_schema_bucket.js
+++ b/jstests/noPassthrough/timeseries_validate_mixed_schema_bucket.js
@@ -4,6 +4,7 @@
(function() {
"use strict";
+load("jstests/core/timeseries/libs/timeseries.js"); // For 'TimeseriesTest'.
load("jstests/libs/fail_point_util.js");
const conn = MongoRunner.runMongod();
@@ -21,12 +22,6 @@ assert.commandWorked(
const coll = testDB[collName];
const bucketsColl = testDB["system.buckets." + collName];
-const timeseriesBucketsMayHaveMixedSchemaData = function() {
- return bucketsColl.aggregate([{$listCatalog: {}}])
- .toArray()[0]
- .md.timeseriesBucketsMayHaveMixedSchemaData;
-};
-
const bucket = {
_id: ObjectId("65a6eb806ffc9fa4280ecac4"),
control: {
@@ -61,7 +56,7 @@ const bucket = {
assert.commandWorked(
testDB.runCommand({collMod: collName, timeseriesBucketsMayHaveMixedSchemaData: true}));
-assert.eq(timeseriesBucketsMayHaveMixedSchemaData(), true);
+assert.eq(TimeseriesTest.bucketsMayHaveMixedSchemaData(bucketsColl), true);
// There should be no reason to have validation errors in the empty collection.
let res = assert.commandWorked(coll.validate());
diff --git a/jstests/replsets/timeseries_mixed_schema_bucket_initial_sync.js b/jstests/replsets/timeseries_mixed_schema_bucket_initial_sync.js
index 3fd643c4bf3..b5f5a60a18e 100644
--- a/jstests/replsets/timeseries_mixed_schema_bucket_initial_sync.js
+++ b/jstests/replsets/timeseries_mixed_schema_bucket_initial_sync.js
@@ -4,6 +4,8 @@
(function() {
"use strict";
+load("jstests/core/timeseries/libs/timeseries.js"); // For 'TimeseriesTest'.
+
TestData.skipEnforceTimeseriesBucketsAreAlwaysCompressedOnValidate = true;
const replTest = new ReplSetTest({nodes: 1});
@@ -58,16 +60,11 @@ replTest.reInitiate();
replTest.waitForState(secondary, ReplSetTest.State.SECONDARY);
replTest.awaitReplication();
-const timeseriesBucketsMayHaveMixedSchemaData = function(node) {
- return node.getDB(db.getName())[bucketsColl.getName()]
- .aggregate([{$listCatalog: {}}])
- .toArray()[0]
- .md.options.storageEngine.wiredTiger.configString ==
- "app_metadata=(timeseriesBucketsMayHaveMixedSchemaData=true)";
-};
+const primaryColl = primary.getDB(db.getName())[bucketsColl.getName()];
+const secondaryColl = secondary.getDB(db.getName())[bucketsColl.getName()];
-assert(timeseriesBucketsMayHaveMixedSchemaData(primary));
-assert(timeseriesBucketsMayHaveMixedSchemaData(secondary));
+assert(TimeseriesTest.bucketsMayHaveMixedSchemaData(primaryColl));
+assert(TimeseriesTest.bucketsMayHaveMixedSchemaData(secondaryColl));
replTest.stopSet();
})();