mongo/jstests/query_golden/plan_stability2.js

67 lines
2.4 KiB
JavaScript

/**
* Tests that the plans remain stable across releases by comparing the expected plans against the
* current ones. A product of SPM-3816. See README.plan_stability.md for more information.
*
* The dataset used in this test is generated by the data_generator in
* `mongo:src/mongo/db/query/benchmark/data_generator`
* using the specification in
* `mongo:src/mongo/db/query/benchmark/specs/plan_stability_pipelines2.js`.
*
* The queries used in this test are generated using jstestfuzz, using the following grammar:
* `jstestfuzz:src/fuzzers/plan_stability/plan_stability2.ne`
* before being processed by the scripts in the `feature-extractor` repository at:
* `feature-extractor:scripts/cbr/`
*
* The main differences to the plan_stability.js are:
* - coverage of more data types
* - more columns and indexes
* - more data distributions
* - additional MQL operators
*
* @tags: [
* incompatible_aubsan,
* tsan_incompatible,
* ]
*
*/
import {isSlowBuild} from "jstests/libs/query/aggregation_pipeline_utils.js";
import {checkSbeFullyEnabled} from "jstests/libs/query/sbe_util.js";
import {runPlanStabilityPipelines} from "jstests/query_golden/libs/utils.js";
import {pipelines} from "jstests/query_golden/test_inputs/plan_stability_pipelines2.js";
import {DataGenerator} from "jstests/libs/query/data_generator.js";
import {checkPauseAfterPopulate} from "jstests/libs/pause_after_populate.js";
if (checkSbeFullyEnabled(db)) {
jsTest.log.info("Skipping the test because CBR only applies to the classic engine.");
quit();
}
if (isSlowBuild(db)) {
jsTest.log.info("Skipping the test because a sanitizer is active.");
quit();
}
/**
* We use a dataset with 10K rows so that:
* 1. The generation step completes in a reasonable amount of time,
* as we have dozens of columns and indexes to generate.
* 2. There will be sufficient difference between plans,
* rather than simple "off-by-one" counter increments/decrements.
*/
const collSize = 100_000;
const collName = jsTestName();
jsTest.log.info("See README.plan_stability.md for more information.");
const dg = new DataGenerator({db: db, module: "specs." + collName, seed: 1});
try {
dg.execute({spec: collName, size: collSize, indexes: "indexes", analyze: true, drop: true, serial_inserts: true});
checkPauseAfterPopulate();
runPlanStabilityPipelines(db, collName, pipelines);
} finally {
dg.cleanup();
}