summaryrefslogtreecommitdiff
path: root/jstests/cqf
diff options
context:
space:
mode:
authorRuoxin Xu <ruoxin.xu@mongodb.com>2022-11-14 12:29:57 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-11-14 13:01:10 +0000
commit2c485054578b7172439da7103b4d9a35881e087d (patch)
tree31a2c93c619335d9a91595c6c9dfbe46f0f5c851 /jstests/cqf
parent1854c66a7dc76d891912356cf1646ccd4b146e8c (diff)
downloadmongo-2c485054578b7172439da7103b4d9a35881e087d.tar.gz
SERVER-71300 Reset cost coefficients to default value if "internalCostModelCoefficients" is empty
Diffstat (limited to 'jstests/cqf')
-rw-r--r--jstests/cqf/cost_model_override.js20
1 files changed, 14 insertions, 6 deletions
diff --git a/jstests/cqf/cost_model_override.js b/jstests/cqf/cost_model_override.js
index cdf424250ad..5f03cbeeca2 100644
--- a/jstests/cqf/cost_model_override.js
+++ b/jstests/cqf/cost_model_override.js
@@ -21,12 +21,7 @@ assert.commandWorked(coll.insert(Array.from({length: nDocuments}, (_, i) => {
})));
function executeAndGetScanCost(scanIncrementalCost) {
- try {
- assert.commandWorked(db.adminCommand({
- 'setParameter': 1,
- 'internalCostModelCoefficients': `{"scanIncrementalCost": ${scanIncrementalCost}}`
- }));
-
+ const getScanCost = function() {
const explain = coll.explain("executionStats").aggregate([]);
assert.eq(nDocuments, explain.executionStats.nReturned);
@@ -34,9 +29,22 @@ function executeAndGetScanCost(scanIncrementalCost) {
assertValueOnPath("PhysicalScan", scanNode, "nodeType");
return scanNode.properties.cost;
+ };
+ const initCost = getScanCost();
+ try {
+ assert.commandWorked(db.adminCommand({
+ 'setParameter': 1,
+ 'internalCostModelCoefficients': `{"scanIncrementalCost": ${scanIncrementalCost}}`
+ }));
+
+ return getScanCost();
} finally {
+ // Empty "internalCostModelCoefficients" should reset the cost model to default.
assert.commandWorked(
db.adminCommand({'setParameter': 1, 'internalCostModelCoefficients': ''}));
+ const resetCost = getScanCost();
+
+ assert.close(initCost, resetCost, 8 /*decimal places*/);
}
}