blob: cefc2c1f3d8e40823f3ba3f53ba14305dcc39d1d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
/**
* Verifies that a direct $sample stage on system.buckets collection works.
*/
(function() {
"use strict";
const conn = MongoRunner.runMongod();
const dbName = jsTestName();
const testDB = conn.getDB(dbName);
assert.commandWorked(testDB.dropDatabase());
// 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);
})();
|