summaryrefslogtreecommitdiff
path: root/jstests/noPassthroughWithMongod/time_series_create.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/noPassthroughWithMongod/time_series_create.js')
-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"}}));
+}
})();