summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/telemetry/telemetry_sampling_rate.js
diff options
context:
space:
mode:
authorliubov.molchanova <liubov.molchanova@mongodb.com>2023-05-17 08:16:48 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-05-17 10:20:42 +0000
commit87160f876c6fb94f5d03062b2caee57539ec5d8e (patch)
treeb78d9ca9e853a236e0a2f6432a6ac02dc50119cd /jstests/noPassthrough/telemetry/telemetry_sampling_rate.js
parent1c390a0c50104a04cbd8ecbefb99eaf22e1bc914 (diff)
downloadmongo-87160f876c6fb94f5d03062b2caee57539ec5d8e.tar.gz
Revert "SERVER-76427: Rename $telemetry to $queryStats"
This reverts commit d646e44b7801a3e5b3230bbae7dcfe05a5ed8707.
Diffstat (limited to 'jstests/noPassthrough/telemetry/telemetry_sampling_rate.js')
-rw-r--r--jstests/noPassthrough/telemetry/telemetry_sampling_rate.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/jstests/noPassthrough/telemetry/telemetry_sampling_rate.js b/jstests/noPassthrough/telemetry/telemetry_sampling_rate.js
new file mode 100644
index 00000000000..1bada398a03
--- /dev/null
+++ b/jstests/noPassthrough/telemetry/telemetry_sampling_rate.js
@@ -0,0 +1,38 @@
+/**
+ * Test that calls to read from telemetry store fail when sampling rate is not greater than 0 even
+ * if feature flag is on.
+ * @tags: [featureFlagTelemetry]
+ */
+load('jstests/libs/analyze_plan.js');
+
+(function() {
+"use strict";
+
+let options = {
+ setParameter: {internalQueryConfigureTelemetrySamplingRate: 0},
+};
+
+const conn = MongoRunner.runMongod(options);
+const testdb = conn.getDB('test');
+var coll = testdb[jsTestName()];
+coll.drop();
+for (var i = 0; i < 20; i++) {
+ coll.insert({foo: 0, bar: Math.floor(Math.random() * 3)});
+}
+
+coll.aggregate([{$match: {foo: 1}}], {cursor: {batchSize: 2}});
+
+// Reading telemetry store with a sampling rate of 0 should return 0 documents.
+let telStore = testdb.adminCommand({aggregate: 1, pipeline: [{$telemetry: {}}], cursor: {}});
+assert.eq(telStore.cursor.firstBatch.length, 0);
+
+// Reading telemetry store should work now with a sampling rate of greater than 0.
+assert.commandWorked(testdb.adminCommand(
+ {setParameter: 1, internalQueryConfigureTelemetrySamplingRate: 2147483647}));
+coll.aggregate([{$match: {foo: 1}}], {cursor: {batchSize: 2}});
+telStore = assert.commandWorked(
+ testdb.adminCommand({aggregate: 1, pipeline: [{$telemetry: {}}], cursor: {}}));
+assert.eq(telStore.cursor.firstBatch.length, 1);
+
+MongoRunner.stopMongod(conn);
+}());