SERVER-86412 Test coverage for v:1 indexes (#19321)

GitOrigin-RevId: 57d62db40972745a30f743649588832c718429a7
This commit is contained in:
Wei Hu 2024-02-28 11:23:22 -08:00 committed by MongoDB Bot
parent 9598020ce3
commit 2e2a1b47ea
8 changed files with 111 additions and 3 deletions

View File

View File

@ -0,0 +1,61 @@
# Test indexes with an override to create v:1 indexes by default.
# Based on replica_sets_jscore_passthrough.yml.
test_kind: js_test
selector:
roots:
- jstests/core/**/*.js
exclude_files:
# v:1 index does not support NumberDecimal.
- jstests/core/index/index_decimal.js
- jstests/core/query/distinct/distinct_semantics.js
- jstests/core/query/double_decimal_compare.js
- jstests/core/query/nan.js
# v:1 index does not support wildcard.
- jstests/core/index/wildcard/**/*.js
# v:1 index does not support collation.
- jstests/core/collation.js
- jstests/core/query/expr/expr_index_use.js
# Timeseries collections are clustered, which use v:2 indexes.
- jstests/core/timeseries/**/*.js
# Excluded by replica_sets_jscore_passthrough
- jstests/core/txns/abort_expired_transaction.js
- jstests/core/txns/abort_transaction_thread_does_not_block_on_locks.js
- jstests/core/txns/kill_op_on_txn_expiry.js
- jstests/core/**/set_param1.js
- jstests/core/query/awaitdata_getmore_cmd.js
- jstests/core/administrative/current_op/currentop.js
- jstests/core/fsync.js
- jstests/core/txns/prepare_conflict.js
exclude_with_any_tags:
- assumes_standalone_mongod
- requires_profiling
executor:
archive:
hooks:
- RunDBCheckInBackground
- CheckReplDBHashInBackground
- ValidateCollectionsInBackground
- CheckReplDBHash
- CheckReplOplogs
- ValidateCollections
config:
shell_options:
eval: >-
globalThis.testingReplication = true;
await import("jstests/libs/override_methods/create_v1_index.js");
hooks:
- class: RunDBCheckInBackground
- class: CheckReplDBHashInBackground
- class: ValidateCollectionsInBackground
- class: CheckReplOplogs
- class: CheckReplDBHash
- class: ValidateCollections
- class: CleanEveryN
n: 20
fixture:
class: ReplicaSetFixture
mongod_options:
set_parameters:
enableTestCommands: 1
num_nodes: 2

View File

@ -21,7 +21,7 @@ Knowing there was a lot this touched we expected to see some bugs and were quick
[SERVER-81122](https://jira.mongodb.org/browse/SERVER-81122) found that poetry broke the spawnhost script. This was caught after merge.
[SERVER-81061](https://jira.mongodb.org/browse/SERVER-81061) and [BF-29909](https://jira.mongodb.org/browse/BF-29909) were found by sys-perf since they run their own build and do not use the standard build process. Therefor it was very hard to test for this one. This was caught post merge.
[SERVER-81061](https://jira.mongodb.org/browse/SERVER-81061) and [BF-29909](https://jira.mongodb.org/browse/BF-29909) were found by sys-perf since they run their own build and do not use the standard build process. Therefore it was very hard to test for this one. This was caught post merge.
[SERVER-80799](https://jira.mongodb.org/browse/SERVER-80799) found that poetry broke mongo tooling metrics collection (not OTel). This was only found since an engineer on the team saw this bug in the code. This was caught post merge.

View File

@ -1347,3 +1347,11 @@ tasks:
- func: "generate resmoke tasks"
vars:
suite: timeseries_crud_jscore_passthrough
- <<: *gen_task_template
name: v1index_jscore_passthrough_gen
tags: ["assigned_to_jira_team_server_execution", "misc_js"]
commands:
- func: "generate resmoke tasks"
vars:
suite: v1index_jscore_passthrough

View File

@ -481,6 +481,7 @@ buildvariants:
- name: test_packages
distros:
- ubuntu2204-large
- name: v1index_jscore_passthrough_gen
- name: vector_search
- name: vector_search_auth
- name: vector_search_ssl

View File

@ -0,0 +1,38 @@
/**
* This file defines command overrides to create v:1 indexes by default.
*/
import {OverrideHelpers} from "jstests/libs/override_methods/override_helpers.js";
function runCommandOverride(conn, dbName, cmdName, cmdObj, clientFunction, makeFuncArgs) {
if (cmdName == "createIndexes") {
cmdObj["indexes"].forEach(index => {
// Ignore empty specs
if (Object.keys(index).length == 0) {
return;
}
// Avoid conflicts with the default _id index
if (Object.keys(index["key"]).length == 1 && index["key"]["_id"] == 1) {
return;
}
// v:1 does not support wildcards
for (let key in index["key"]) {
if (key.includes("$**")) {
return;
}
}
// v:1 does not support collation
if ("collation" in index) {
return;
}
// If v is not specified, default to v:1
if (!("v" in index)) {
index["v"] = 1;
}
});
}
// Call the original function, with a potentially modified command object.
return clientFunction.apply(conn, makeFuncArgs(cmdObj));
}
// Override the default runCommand with our custom version.
OverrideHelpers.overrideRunCommand(runCommandOverride);

View File

@ -97,7 +97,7 @@ function killCurrentOpTest() {
createCollFP.off();
// the current op was killed therefor the thread will throw an exception and wil return
// the current op was killed therefore the thread will throw an exception and wil return
// code 252.
const exitCode = parallelShell({checkExitSuccess: false});
assert.neq(0, exitCode, "Expected shell to exit with failure due to operation kill");

View File

@ -336,7 +336,7 @@ const double kInvPow256[] = {1.0, //
const uint8_t kEnd = 0x4;
// These overlay with CType or kEnd bytes and therefor must be less/greater than all of
// These overlay with CType or kEnd bytes and therefore must be less/greater than all of
// them (and their inverses). They also can't equal 0 or 255 since that would collide with
// the encoding of NUL bytes in strings as "\x00\xff".
const uint8_t kLess = 1;