0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 17:10:48 +01:00
mongodb/jstests/noPassthrough/timeseries/timeseries_time_backward.js
Matt Kneiser 125b156d7b SERVER-88976 Test more time-series execution stats (#20945)
GitOrigin-RevId: ec066a00367b0747360d82709e3186b222c1866e
2024-04-10 16:33:18 +00:00

55 lines
1.7 KiB
JavaScript

/**
* Insert measurements backwards in time to test bucket archiving.
*
* @tags: [
* requires_timeseries,
* featureFlagTimeseriesAlwaysUseCompressedBuckets,
* requires_fcv_80,
* ]
*/
jsTestLog("Running " + jsTestName());
const conn = MongoRunner.runMongod({});
const db = conn.getDB("test");
const timeFieldName = "t";
const metaFieldName = "m";
assert.commandWorked(db.createCollection(
jsTestName(), {timeseries: {timeField: timeFieldName, metaField: metaFieldName}}));
const coll = db.getCollection(jsTestName());
const bucketsColl = db.getCollection("system.buckets." + jsTestName());
let times = [
ISODate("2024-04-08T00:10:00.000Z"),
ISODate("2024-04-08T00:09:00.000Z"),
ISODate("2024-04-08T00:08:00.000Z"),
ISODate("2024-04-08T00:07:00.000Z"),
ISODate("2024-04-08T00:06:00.000Z"),
ISODate("2024-04-08T00:05:00.000Z"),
ISODate("2024-04-08T00:04:00.000Z"),
ISODate("2024-04-08T00:03:00.000Z"),
ISODate("2024-04-08T00:02:00.000Z"),
ISODate("2024-04-08T00:01:00.000Z"),
];
for (let i = 0; i < times.length; i++) {
assert.commandWorked(coll.insert({[timeFieldName]: times[i], [metaFieldName]: 1, x: 1}));
}
let stats = coll.stats().timeseries;
jsTestLog(stats);
assert.eq(stats["bucketCount"], 10);
assert.eq(stats["numBucketInserts"], 10);
assert.eq(stats["numBucketUpdates"], 0);
assert.eq(stats["numBucketsArchivedDueToTimeBackward"], 9);
assert.eq(stats["numBucketsOpenedDueToMetadata"], 1);
assert.eq(stats["numCommits"], 10);
assert.eq(stats["numMeasurementsCommitted"], 10);
assert.eq(stats["numBucketQueriesFailed"], 10);
assert.eq(stats["numCompressedBucketsConvertedToUnsorted"], 0);
MongoRunner.stopMongod(conn);