diff options
author | Yoonsoo Kim <yoonsoo.kim@mongodb.com> | 2021-07-08 21:04:43 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-07-09 21:04:04 +0000 |
commit | 2ae8ceb242c3a7b69db13b8011bbdfd5d02254ef (patch) | |
tree | 303f4ff0c41995e7b1d0d7bf4936db88130e600f /jstests/noPassthrough | |
parent | b37a1693e338414ece2efa46cad8be3ae9087a39 (diff) | |
download | mongo-2ae8ceb242c3a7b69db13b8011bbdfd5d02254ef.tar.gz |
SERVER-58369 Don't take ARHASH optimization path for a direct $sample stage on system.buckets collection
Diffstat (limited to 'jstests/noPassthrough')
-rw-r--r-- | jstests/noPassthrough/timeseries_sample_on_system_buckets.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/jstests/noPassthrough/timeseries_sample_on_system_buckets.js b/jstests/noPassthrough/timeseries_sample_on_system_buckets.js new file mode 100644 index 00000000000..bc079ef5cde --- /dev/null +++ b/jstests/noPassthrough/timeseries_sample_on_system_buckets.js @@ -0,0 +1,33 @@ +/** + * Verifies that a direct $sample stage on system.buckets collection works. + */ +(function() { +"use strict"; + +load("jstests/core/timeseries/libs/timeseries.js"); + +const conn = MongoRunner.runMongod(); + +const dbName = jsTestName(); +const testDB = conn.getDB(dbName); +assert.commandWorked(testDB.dropDatabase()); + +if (!TimeseriesTest.timeseriesCollectionsEnabled(testDB.getMongo())) { + jsTestLog("Skipping test because the time-series collection feature flag is disabled"); + MongoRunner.stopMongod(conn); + return; +} + +// Prepares a timeseries collection. +assert.commandWorked( + testDB.createCollection("t", {timeseries: {timeField: "time", metaField: "meta"}})); +assert.commandWorked( + testDB.t.insert([{time: ISODate(), meta: 1, a: 1}, {time: ISODate(), meta: 1, a: 2}])); + +// Verifies that a direct $sample stage on system.buckets collection works. +const kNoOfSamples = 1; +const res = testDB.system.buckets.t.aggregate([{$sample: {size: kNoOfSamples}}]).toArray(); +assert.eq(res.length, kNoOfSamples); + +MongoRunner.stopMongod(conn); +})(); |