diff options
Diffstat (limited to 'jstests/cqf/cost_model_override.js')
-rw-r--r-- | jstests/cqf/cost_model_override.js | 20 |
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*/); } } |