summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2020-11-20 17:38:29 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-11-21 00:44:02 +0000
commit943845d1ea81f8f99620af5aa96737bbaae37b5d (patch)
tree47c4c8a8a1e193ddca94913779ab11e95ef7aa56
parent0eb237e7f452e1d5239f7e9b7520f37c8730d0d3 (diff)
downloadmongo-943845d1ea81f8f99620af5aa96737bbaae37b5d.tar.gz
SERVER-52529 add test case for schema validation on time-series bucket collection
-rw-r--r--jstests/noPassthroughWithMongod/time_series_create.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/jstests/noPassthroughWithMongod/time_series_create.js b/jstests/noPassthroughWithMongod/time_series_create.js
index 20a68811472..d3c6020ccb6 100644
--- a/jstests/noPassthroughWithMongod/time_series_create.js
+++ b/jstests/noPassthroughWithMongod/time_series_create.js
@@ -120,4 +120,29 @@ testTimeseriesNamespaceExists((testDB, collName) => {
testTimeseriesNamespaceExists((testDB, collName) => {
assert.commandWorked(testDB.createView(collName, collName + '_source', []));
});
+
+// Tests that schema validation is enabled on the bucket collection.
+{
+ const testDB = db.getSiblingDB(jsTestName());
+ const coll = testDB.getCollection('timeseries_' + collCount++);
+ assert.commandWorked(
+ testDB.createCollection(coll.getName(), {timeseries: {timeField: "time"}}));
+ const bucketsColl = testDB.getCollection('system.buckets.' + coll.getName());
+ assert.commandWorked(bucketsColl.insert(
+ {control: {version: 1, min: {time: ISODate()}, max: {time: ISODate()}}, data: {}}));
+ assert.commandWorked(bucketsColl.insert({
+ control: {version: 'not a number', min: {time: ISODate()}, max: {time: ISODate()}},
+ data: {}
+ }));
+ assert.commandWorked(bucketsColl.insert(
+ {control: {version: 1, min: {time: 'not a date'}, max: {time: ISODate()}}, data: {}}));
+ assert.commandWorked(bucketsColl.insert(
+ {control: {version: 1, min: {time: ISODate()}, max: {time: 'not a date'}}, data: {}}));
+ assert.commandWorked(bucketsColl.insert({
+ control: {version: 1, min: {time: ISODate()}, max: {time: ISODate()}},
+ data: 'not an object'
+ }));
+ assert.commandWorked(bucketsColl.insert({invalid_bucket_field: 1}));
+ assert.commandWorked(testDB.runCommand({drop: coll.getName(), writeConcern: {w: "majority"}}));
+}
})();