summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorFaustoleyva54 <fausto.leyva@mongodb.com>2022-12-16 16:19:16 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-12-16 16:57:24 +0000
commit42a5735233ce607c39ccb52e4139fdd95519b865 (patch)
tree572fe7407d68e6d7b274565bac576682d622e12b /jstests
parent4cb4b84d88c783af575195d934c236beebbb47c6 (diff)
downloadmongo-42a5735233ce607c39ccb52e4139fdd95519b865.tar.gz
SERVER-70809 Simplify logic in timeseries options
Diffstat (limited to 'jstests')
-rw-r--r--jstests/core/timeseries/bucket_span_and_rounding_seconds.js2
-rw-r--r--jstests/core/timeseries/timeseries_collmod.js21
-rw-r--r--jstests/core/timeseries/timeseries_list_collections.js2
-rw-r--r--jstests/noPassthrough/timeseries_bucketing_parameters_downgrade.js9
-rw-r--r--jstests/noPassthrough/timeseries_create.js28
5 files changed, 32 insertions, 30 deletions
diff --git a/jstests/core/timeseries/bucket_span_and_rounding_seconds.js b/jstests/core/timeseries/bucket_span_and_rounding_seconds.js
index dc60e8a208e..2b339b810c7 100644
--- a/jstests/core/timeseries/bucket_span_and_rounding_seconds.js
+++ b/jstests/core/timeseries/bucket_span_and_rounding_seconds.js
@@ -85,8 +85,6 @@ const verifyCreateCommandFails = function(secondsOptions = {}, errorCode) {
timeseries: {
timeField: timeFieldName,
granularity: granularityTime,
- bucketRoundingSeconds:
- TimeseriesTest.getBucketRoundingSecondsFromGranularity(granularityTime),
bucketMaxSpanSeconds:
TimeseriesTest.getBucketMaxSpanSecondsFromGranularity(granularityTime)
}
diff --git a/jstests/core/timeseries/timeseries_collmod.js b/jstests/core/timeseries/timeseries_collmod.js
index b98ce4b674e..2d4888690e3 100644
--- a/jstests/core/timeseries/timeseries_collmod.js
+++ b/jstests/core/timeseries/timeseries_collmod.js
@@ -102,15 +102,24 @@ if (TimeseriesTest.timeseriesScalabilityImprovementsEnabled(db.getMongo())) {
}),
ErrorCodes.InvalidOptions);
- // Tries to set bucketMaxSpanSeconds and bucketRoundingSeconds with different values, but with
- // the same current values. Should pass but no changes should be made.
+ // Expect setting the bucketMaxSpanSeconds corresponding to the granularity default value to
+ // succeed.
assert.commandWorked(db.runCommand({
"collMod": collName,
+ "timeseries": {"granularity": "hours", "bucketMaxSpanSeconds": bucketMaxSpanSecondsHours}
+ }));
+
+ // Tries to set bucketMaxSpanSeconds and bucketRoundingSeconds with different values
+ // corresponding to the granularity default values. This should fail since they are not equal.
+ assert.commandFailedWithCode(db.runCommand({
+ "collMod": collName,
"timeseries": {
+ "granularity": "hours",
"bucketMaxSpanSeconds": bucketMaxSpanSecondsHours,
"bucketRoundingSeconds": bucketRoundingSecondsHours
}
- }));
+ }),
+ ErrorCodes.InvalidOptions);
// Tries to set bucketMaxSpanSeconds and bucketRoundingSeconds with different values.
assert.commandFailedWithCode(db.runCommand({
@@ -138,11 +147,7 @@ if (TimeseriesTest.timeseriesScalabilityImprovementsEnabled(db.getMongo())) {
// value. This accepts the 3 parameters because they are the same as the current set values.
assert.commandWorked(db.runCommand({
"collMod": collName,
- "timeseries": {
- "granularity": "hours",
- "bucketMaxSpanSeconds": bucketMaxSpanSecondsHours,
- "bucketRoundingSeconds": bucketRoundingSecondsHours
- }
+ "timeseries": {"granularity": "hours", "bucketMaxSpanSeconds": bucketMaxSpanSecondsHours}
}));
// Successfully sets the bucketMaxSpanSeconds and bucketRoundingSeconds to a higher value for a
diff --git a/jstests/core/timeseries/timeseries_list_collections.js b/jstests/core/timeseries/timeseries_list_collections.js
index da25b78e7bb..235c2115256 100644
--- a/jstests/core/timeseries/timeseries_list_collections.js
+++ b/jstests/core/timeseries/timeseries_list_collections.js
@@ -96,7 +96,6 @@ if (!TimeseriesTest.timeseriesScalabilityImprovementsEnabled(testDB)) {
timeField: timeFieldName,
granularity: 'minutes',
bucketMaxSpanSeconds: bucketMaxSpanSecondsFromMinutes,
- bucketRoundingSeconds: buckeRoundingSecondsFromMinutes,
}
});
}
@@ -139,7 +138,6 @@ if (!TimeseriesTest.timeseriesScalabilityImprovementsEnabled(testDB)) {
metaField: metaFieldName,
granularity: 'minutes',
bucketMaxSpanSeconds: bucketMaxSpanSecondsFromMinutes,
- bucketRoundingSeconds: buckeRoundingSecondsFromMinutes,
},
storageEngine: {wiredTiger: {}},
indexOptionDefaults: {storageEngine: {wiredTiger: {}}},
diff --git a/jstests/noPassthrough/timeseries_bucketing_parameters_downgrade.js b/jstests/noPassthrough/timeseries_bucketing_parameters_downgrade.js
index 42f4b084fa8..5a50f30c6d5 100644
--- a/jstests/noPassthrough/timeseries_bucketing_parameters_downgrade.js
+++ b/jstests/noPassthrough/timeseries_bucketing_parameters_downgrade.js
@@ -134,17 +134,12 @@ const checkBucketCount = function(count = 1) {
checkDowngradeSucceeds();
}
-// 2. We expect to successfully downgrade if the 'bucketMaxSpanSeconds' and 'bucketRoundingSeconds'
-// correspond to a granularity.
+// 2. We expect to successfully downgrade if 'bucketMaxSpanSeconds' corresponds to a granularity.
{
resetCollection({granularity: 'seconds', bucketMaxSpanSeconds: secondsMaxSpan});
checkDowngradeSucceeds();
- resetCollection({
- granularity: 'seconds',
- bucketMaxSpanSeconds: secondsMaxSpan,
- bucketRoundingSeconds: secondsRoundingSeconds
- });
+ resetCollection({granularity: 'seconds', bucketMaxSpanSeconds: secondsMaxSpan});
checkDowngradeSucceeds();
resetCollection({granularity: 'minutes', bucketMaxSpanSeconds: minutesMaxSpan});
diff --git a/jstests/noPassthrough/timeseries_create.js b/jstests/noPassthrough/timeseries_create.js
index 34d05c59d26..b13d166d35e 100644
--- a/jstests/noPassthrough/timeseries_create.js
+++ b/jstests/noPassthrough/timeseries_create.js
@@ -118,31 +118,37 @@ if (!TimeseriesTest.timeseriesScalabilityImprovementsEnabled(testDB)) {
bucketMaxSpanSeconds: 60 * 60 * 24 * 30
});
} else {
- // Granularity may be provided with bucketMaxSpanSeconds and bucketRoundingSeconds,
- // but only if they are the default (seconds)).
- testValidTimeseriesOptions({
+ // Granularity can include a corresponding bucketMaxSpanSeconds value, but not a
+ // bucketRoundingSeconds value (even if the value corresponds to the granularity).
+ testInvalidTimeseriesOptions({
timeField: "time",
metaField: "meta",
granularity: "seconds",
bucketMaxSpanSeconds: 60 * 60,
bucketRoundingSeconds: 60
+ },
+ ErrorCodes.InvalidOptions);
+
+ // Granularity may be provided with bucketMaxSpanSeconds as long as it corresponds to the
+ // granularity.
+ testValidTimeseriesOptions({
+ timeField: "time",
+ metaField: "meta",
+ granularity: "seconds",
+ bucketMaxSpanSeconds: 60 * 60
});
testValidTimeseriesOptions({
timeField: "time",
metaField: "meta",
granularity: "minutes",
- bucketMaxSpanSeconds: 60 * 60 * 24,
- bucketRoundingSeconds: 60 * 60,
- },
- bucketGranularityError);
+ bucketMaxSpanSeconds: 60 * 60 * 24
+ });
testValidTimeseriesOptions({
timeField: "time",
metaField: "meta",
granularity: "hours",
- bucketMaxSpanSeconds: 60 * 60 * 24 * 30,
- bucketRoundingSeconds: 60 * 60 * 24,
- },
- bucketGranularityError);
+ bucketMaxSpanSeconds: 60 * 60 * 24 * 30
+ });
}
testValidTimeseriesOptions({timeField: "time", metaField: "meta", granularity: "minutes"});