42 lines
1.3 KiB
JavaScript
42 lines
1.3 KiB
JavaScript
/**
|
|
* Test that calls to read from telemetry store fail when sampling rate is not greater than 0 even
|
|
* if feature flag is on.
|
|
*/
|
|
load('jstests/libs/analyze_plan.js');
|
|
load("jstests/libs/feature_flag_util.js");
|
|
|
|
(function() {
|
|
"use strict";
|
|
|
|
if (!FeatureFlagUtil.isEnabled(db, "Telemetry")) {
|
|
return;
|
|
}
|
|
|
|
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);
|
|
|
|
// TODO SERVER-71531 enable below test.
|
|
// 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}}); assert.commandWorked(testdb.adminCommand({aggregate: 1, pipeline:
|
|
// [{$telemetry: {}}], cursor: {}}));
|
|
|
|
MongoRunner.stopMongod(conn);
|
|
}());
|