diff options
Diffstat (limited to 'jstests/noPassthrough/queryStats/query_stats_upgrade.js')
-rw-r--r-- | jstests/noPassthrough/queryStats/query_stats_upgrade.js | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/jstests/noPassthrough/queryStats/query_stats_upgrade.js b/jstests/noPassthrough/queryStats/query_stats_upgrade.js new file mode 100644 index 00000000000..919d9f87baf --- /dev/null +++ b/jstests/noPassthrough/queryStats/query_stats_upgrade.js @@ -0,0 +1,43 @@ +/** + * Test that telemetry doesn't work on a lower FCV version but works after an FCV upgrade. + * @tags: [featureFlagQueryStats] + */ +load('jstests/libs/analyze_plan.js'); +load("jstests/libs/feature_flag_util.js"); + +(function() { +"use strict"; + +const dbpath = MongoRunner.dataPath + jsTestName(); +let conn = MongoRunner.runMongod({dbpath: dbpath}); +let testDB = conn.getDB(jsTestName()); +// This test should only be run with the flag enabled. +assert(FeatureFlagUtil.isEnabled(testDB, "QueryStats")); + +function testLower(restart = false) { + let adminDB = conn.getDB("admin"); + assert.commandWorked(adminDB.runCommand( + {setFeatureCompatibilityVersion: binVersionToFCV("last-lts"), confirm: true})); + if (restart) { + MongoRunner.stopMongod(conn); + conn = MongoRunner.runMongod({dbpath: dbpath, noCleanData: true}); + testDB = conn.getDB(jsTestName()); + adminDB = conn.getDB("admin"); + } + + assert.commandFailedWithCode( + testDB.adminCommand({aggregate: 1, pipeline: [{$queryStats: {}}], cursor: {}}), 6579000); + + // Upgrade FCV. + assert.commandWorked(adminDB.runCommand( + {setFeatureCompatibilityVersion: binVersionToFCV("latest"), confirm: true})); + + // We should be able to run a telemetry pipeline now that the FCV is correct. + assert.commandWorked( + testDB.adminCommand({aggregate: 1, pipeline: [{$queryStats: {}}], cursor: {}}), + ); +} +testLower(true); +testLower(false); +MongoRunner.stopMongod(conn); +})(); |