summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/queryStats/query_stats_feature_flag.js
blob: bcce489d8dae37ba7e8b8e5e312a68544f73a457 (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
26
27
28
29
30
31
32
33
34
/**
 * Test that calls to read from telemetry store fail when feature flag is turned off.
 */
load('jstests/libs/analyze_plan.js');
load("jstests/libs/feature_flag_util.js");

(function() {
"use strict";

// This test specifically tests error handling when the feature flag is not on.
// TODO SERVER-65800 this test can be removed when the feature flag is removed.
const conn = MongoRunner.runMongod();
const testDB = conn.getDB('test');
if (FeatureFlagUtil.isEnabled(testDB, "QueryStats")) {
    jsTestLog("Skipping test since query stats are enabled.");
    MongoRunner.stopMongod(conn);
    return;
}

// Pipeline to read telemetry store should fail without feature flag turned on.
assert.commandFailedWithCode(
    testDB.adminCommand({aggregate: 1, pipeline: [{$queryStats: {}}], cursor: {}}),
    ErrorCodes.QueryFeatureNotAllowed);

// Pipeline, with a filter, to read telemetry store fails without feature flag turned on.
assert.commandFailedWithCode(testDB.adminCommand({
    aggregate: 1,
    pipeline: [{$queryStats: {}}, {$match: {"key.queryShape.find": {$eq: "###"}}}],
    cursor: {}
}),
                             ErrorCodes.QueryFeatureNotAllowed);

MongoRunner.stopMongod(conn);
}());