SERVER-100130 Add support to pass traceCtx from resmoke to legacy shell (#42761)

GitOrigin-RevId: 81e65e5c27af369f1f7046e1ee0f21a68b232a1f
This commit is contained in:
Cheahuychou Mao 2025-10-22 23:14:09 +07:00 committed by MongoDB Bot
parent 1b4d40802e
commit 104e8d9aca
73 changed files with 228 additions and 9 deletions

View File

@ -23,6 +23,7 @@ executor:
await import('jstests/libs/override_methods/implicitly_shard_accessed_collections.js');
global_vars:
TestData:
enableOTELTracing: false
logRetryAttempts: true
networkErrorAndTxnOverrideConfig:
retryOnNetworkErrors: true

View File

@ -23,6 +23,7 @@ executor:
await import('jstests/libs/override_methods/implicitly_shard_accessed_collections.js');
global_vars:
TestData:
enableOTELTracing: false
logRetryAttempts: true
networkErrorAndTxnOverrideConfig:
retryOnNetworkErrors: true

View File

@ -20,6 +20,7 @@ executor:
global_vars:
TestData:
defaultReadConcernLevel: null
enableOTELTracing: false
setShellParameter: defaultFindReplicaSetHostTimeoutMS=120000
fixture:
class: ReplicaSetFixture

View File

@ -20,6 +20,7 @@ executor:
global_vars:
TestData:
defaultReadConcernLevel: null
enableOTELTracing: false
setShellParameter: defaultFindReplicaSetHostTimeoutMS=120000
fixture:
class: ReplicaSetFixture

View File

@ -20,6 +20,7 @@ executor:
global_vars:
TestData:
defaultReadConcernLevel: null
enableOTELTracing: false
setShellParameter: defaultFindReplicaSetHostTimeoutMS=120000
fixture:
class: ReplicaSetFixture

View File

@ -20,6 +20,7 @@ executor:
global_vars:
TestData:
defaultReadConcernLevel: null
enableOTELTracing: false
setShellParameter: defaultFindReplicaSetHostTimeoutMS=120000
fixture:
class: ReplicaSetFixture

View File

@ -20,6 +20,7 @@ executor:
global_vars:
TestData:
defaultReadConcernLevel: null
enableOTELTracing: false
setShellParameter: defaultFindReplicaSetHostTimeoutMS=120000
fixture:
class: ReplicaSetFixture

View File

@ -20,6 +20,7 @@ executor:
global_vars:
TestData:
defaultReadConcernLevel: null
enableOTELTracing: false
setShellParameter: defaultFindReplicaSetHostTimeoutMS=120000
fixture:
class: ReplicaSetFixture

View File

@ -20,6 +20,7 @@ executor:
global_vars:
TestData:
defaultReadConcernLevel: null
enableOTELTracing: false
setShellParameter: defaultFindReplicaSetHostTimeoutMS=120000
fixture:
class: ShardedClusterFixture

View File

@ -20,6 +20,7 @@ executor:
global_vars:
TestData:
defaultReadConcernLevel: null
enableOTELTracing: false
setShellParameter: defaultFindReplicaSetHostTimeoutMS=120000
fixture:
class: ShardedClusterFixture

View File

@ -15,7 +15,11 @@ executor:
- CheckReplDBHash
- ValidateCollections
tests: true
config: {}
config:
shell_options:
global_vars:
TestData:
enableOTELTracing: false
fixture:
class: ReplicaSetFixture
mixed_bin_versions: new_new_old

View File

@ -15,7 +15,11 @@ executor:
- CheckReplDBHash
- ValidateCollections
tests: true
config: {}
config:
shell_options:
global_vars:
TestData:
enableOTELTracing: false
fixture:
class: ReplicaSetFixture
mixed_bin_versions: new_old_new

View File

@ -15,7 +15,11 @@ executor:
- CheckReplDBHash
- ValidateCollections
tests: true
config: {}
config:
shell_options:
global_vars:
TestData:
enableOTELTracing: false
fixture:
class: ReplicaSetFixture
mixed_bin_versions: old_new_new

View File

@ -15,7 +15,11 @@ executor:
- CheckReplDBHash
- ValidateCollections
tests: true
config: {}
config:
shell_options:
global_vars:
TestData:
enableOTELTracing: false
fixture:
class: ReplicaSetFixture
mixed_bin_versions: new_new_old

View File

@ -15,7 +15,11 @@ executor:
- CheckReplDBHash
- ValidateCollections
tests: true
config: {}
config:
shell_options:
global_vars:
TestData:
enableOTELTracing: false
fixture:
class: ReplicaSetFixture
mixed_bin_versions: new_old_new

View File

@ -15,7 +15,11 @@ executor:
- CheckReplDBHash
- ValidateCollections
tests: true
config: {}
config:
shell_options:
global_vars:
TestData:
enableOTELTracing: false
fixture:
class: ReplicaSetFixture
mixed_bin_versions: old_new_new

View File

@ -19,6 +19,7 @@ executor:
eval: await import("jstests/libs/override_methods/implicitly_shard_accessed_collections.js");
global_vars:
TestData:
enableOTELTracing: false
implicitlyShardOnCreateCollectionOnly: true
runningWithBalancer: false
fixture:

View File

@ -19,6 +19,7 @@ executor:
eval: await import("jstests/libs/override_methods/implicitly_shard_accessed_collections.js");
global_vars:
TestData:
enableOTELTracing: false
implicitlyShardOnCreateCollectionOnly: true
runningWithBalancer: false
fixture:

View File

@ -18,6 +18,7 @@ executor:
global_vars:
TestData:
disableImplicitSessions: true
enableOTELTracing: false
objcheck: ""
fixture:
class: ReplicaSetFixture

View File

@ -18,6 +18,7 @@ executor:
global_vars:
TestData:
disableImplicitSessions: true
enableOTELTracing: false
objcheck: ""
fixture:
class: ReplicaSetFixture

View File

@ -18,6 +18,7 @@ executor:
global_vars:
TestData:
disableImplicitSessions: true
enableOTELTracing: false
objcheck: ""
fixture:
class: ReplicaSetFixture

View File

@ -18,6 +18,7 @@ executor:
global_vars:
TestData:
disableImplicitSessions: true
enableOTELTracing: false
objcheck: ""
fixture:
class: ReplicaSetFixture

View File

@ -18,6 +18,7 @@ executor:
global_vars:
TestData:
disableImplicitSessions: true
enableOTELTracing: false
objcheck: ""
fixture:
class: ReplicaSetFixture

View File

@ -18,6 +18,7 @@ executor:
global_vars:
TestData:
disableImplicitSessions: true
enableOTELTracing: false
objcheck: ""
fixture:
class: ReplicaSetFixture

View File

@ -18,6 +18,7 @@ executor:
global_vars:
TestData:
disableImplicitSessions: true
enableOTELTracing: false
objcheck: ""
fixture:
class: ShardedClusterFixture

View File

@ -18,6 +18,7 @@ executor:
global_vars:
TestData:
disableImplicitSessions: true
enableOTELTracing: false
objcheck: ""
fixture:
class: ShardedClusterFixture

View File

@ -16,6 +16,7 @@ executor:
global_vars:
TestData:
auth: true
enableOTELTracing: false
keyFile: jstests/libs/authTestsKey
keyFileData: Thiskeyisonlyforrunningthesuitewithauthenticationdontuseitinanytestsdirectly
setParameters:

View File

@ -15,6 +15,7 @@ executor:
shell_options:
global_vars:
TestData:
enableOTELTracing: false
setParameters:
bsonTestValidationVersion: 1
nodb: ""

View File

@ -18,6 +18,9 @@ executor:
config:
shell_options:
eval: globalThis.testingReplication = true;
global_vars:
TestData:
enableOTELTracing: false
fixture:
class: ReplicaSetFixture
mixed_bin_versions: new_new_old

View File

@ -18,6 +18,9 @@ executor:
config:
shell_options:
eval: globalThis.testingReplication = true;
global_vars:
TestData:
enableOTELTracing: false
fixture:
class: ReplicaSetFixture
mixed_bin_versions: new_old_new

View File

@ -18,6 +18,9 @@ executor:
config:
shell_options:
eval: globalThis.testingReplication = true;
global_vars:
TestData:
enableOTELTracing: false
fixture:
class: ReplicaSetFixture
mixed_bin_versions: old_new_new

View File

@ -18,6 +18,9 @@ executor:
config:
shell_options:
eval: globalThis.testingReplication = true;
global_vars:
TestData:
enableOTELTracing: false
fixture:
class: ReplicaSetFixture
mixed_bin_versions: new_new_old

View File

@ -18,6 +18,9 @@ executor:
config:
shell_options:
eval: globalThis.testingReplication = true;
global_vars:
TestData:
enableOTELTracing: false
fixture:
class: ReplicaSetFixture
mixed_bin_versions: new_old_new

View File

@ -18,6 +18,9 @@ executor:
config:
shell_options:
eval: globalThis.testingReplication = true;
global_vars:
TestData:
enableOTELTracing: false
fixture:
class: ReplicaSetFixture
mixed_bin_versions: old_new_new

View File

@ -18,6 +18,9 @@ executor:
config:
shell_options:
eval: globalThis.testingReplication = true;
global_vars:
TestData:
enableOTELTracing: false
fixture:
class: ReplicaSetFixture
mixed_bin_versions: new_new_old

View File

@ -18,6 +18,9 @@ executor:
config:
shell_options:
eval: globalThis.testingReplication = true;
global_vars:
TestData:
enableOTELTracing: false
fixture:
class: ReplicaSetFixture
mixed_bin_versions: new_old_new

View File

@ -18,6 +18,9 @@ executor:
config:
shell_options:
eval: globalThis.testingReplication = true;
global_vars:
TestData:
enableOTELTracing: false
fixture:
class: ReplicaSetFixture
mixed_bin_versions: old_new_new

View File

@ -18,6 +18,9 @@ executor:
config:
shell_options:
eval: globalThis.testingReplication = true;
global_vars:
TestData:
enableOTELTracing: false
fixture:
class: ReplicaSetFixture
mixed_bin_versions: new_new_old

View File

@ -18,6 +18,9 @@ executor:
config:
shell_options:
eval: globalThis.testingReplication = true;
global_vars:
TestData:
enableOTELTracing: false
fixture:
class: ReplicaSetFixture
mixed_bin_versions: new_old_new

View File

@ -18,6 +18,9 @@ executor:
config:
shell_options:
eval: globalThis.testingReplication = true;
global_vars:
TestData:
enableOTELTracing: false
fixture:
class: ReplicaSetFixture
mixed_bin_versions: old_new_new

View File

@ -25,6 +25,7 @@ executor:
TestData:
alwaysInjectTransactionNumber: true
defaultReadConcernLevel: majority
enableOTELTracing: false
logRetryAttempts: true
networkErrorAndTxnOverrideConfig:
retryOnNetworkErrors: true

View File

@ -25,6 +25,7 @@ executor:
TestData:
alwaysInjectTransactionNumber: true
defaultReadConcernLevel: majority
enableOTELTracing: false
logRetryAttempts: true
networkErrorAndTxnOverrideConfig:
retryOnNetworkErrors: true

View File

@ -17,6 +17,7 @@ executor:
eval: await import("jstests/libs/override_methods/implicitly_shard_accessed_collections.js");
global_vars:
TestData:
enableOTELTracing: false
mongosBinVersion: last-continuous
fixture:
class: ShardedClusterFixture

View File

@ -17,6 +17,7 @@ executor:
eval: await import("jstests/libs/override_methods/implicitly_shard_accessed_collections.js");
global_vars:
TestData:
enableOTELTracing: false
mongosBinVersion: last-lts
fixture:
class: ShardedClusterFixture

View File

@ -26,6 +26,7 @@ executor:
TestData:
alwaysInjectTransactionNumber: true
defaultReadConcernLevel: majority
enableOTELTracing: false
logRetryAttempts: true
networkErrorAndTxnOverrideConfig:
retryOnNetworkErrors: true

View File

@ -26,6 +26,7 @@ executor:
TestData:
alwaysInjectTransactionNumber: true
defaultReadConcernLevel: majority
enableOTELTracing: false
logRetryAttempts: true
networkErrorAndTxnOverrideConfig:
retryOnNetworkErrors: true

View File

@ -16,6 +16,7 @@ executor:
shell_options:
global_vars:
TestData:
enableOTELTracing: false
mongosBinVersion: last-continuous
fixture:
class: ShardedClusterFixture

View File

@ -16,6 +16,7 @@ executor:
shell_options:
global_vars:
TestData:
enableOTELTracing: false
mongosBinVersion: last-lts
fixture:
class: ShardedClusterFixture

View File

@ -29,6 +29,7 @@ executor:
TestData:
alwaysInjectTransactionNumber: true
defaultReadConcernLevel: majority
enableOTELTracing: false
logRetryAttempts: true
networkErrorAndTxnOverrideConfig:
retryOnNetworkErrors: true

View File

@ -29,6 +29,7 @@ executor:
TestData:
alwaysInjectTransactionNumber: true
defaultReadConcernLevel: majority
enableOTELTracing: false
logRetryAttempts: true
networkErrorAndTxnOverrideConfig:
retryOnNetworkErrors: true

View File

@ -14,6 +14,7 @@ executor:
global_vars:
TestData:
clusterType: standalone
enableOTELTracing: false
internalQueryAppendIdToSetWindowFieldsSort: true
internalQueryMaxAllowedDensifyDocs: 1000
traceExceptions: false

View File

@ -14,6 +14,7 @@ executor:
global_vars:
TestData:
clusterType: standalone
enableOTELTracing: false
internalQueryAppendIdToSetWindowFieldsSort: true
internalQueryMaxAllowedDensifyDocs: 1000
traceExceptions: false

View File

@ -14,6 +14,7 @@ executor:
global_vars:
TestData:
clusterType: replset
enableOTELTracing: false
nodb: ""
matrix_suite: true
selector:

View File

@ -14,6 +14,7 @@ executor:
global_vars:
TestData:
clusterType: replset
enableOTELTracing: false
nodb: ""
matrix_suite: true
selector:

View File

@ -14,6 +14,7 @@ executor:
global_vars:
TestData:
clusterType: replset
enableOTELTracing: false
nodb: ""
matrix_suite: true
selector:

View File

@ -14,6 +14,7 @@ executor:
global_vars:
TestData:
clusterType: replset
enableOTELTracing: false
nodb: ""
matrix_suite: true
selector:

View File

@ -1 +1,3 @@
base_suite: update_fuzzer
overrides:
- "multiversion.otel_tracing"

View File

@ -1 +1,3 @@
base_suite: update_fuzzer
overrides:
- "multiversion.otel_tracing"

View File

@ -1 +1,3 @@
base_suite: update_fuzzer_replication
overrides:
- "multiversion.otel_tracing"

View File

@ -1 +1,3 @@
base_suite: update_fuzzer_replication
overrides:
- "multiversion.otel_tracing"

View File

@ -1 +1,3 @@
base_suite: update_fuzzer_replication
overrides:
- "multiversion.otel_tracing"

View File

@ -1 +1,3 @@
base_suite: update_fuzzer_replication
overrides:
- "multiversion.otel_tracing"

View File

@ -6,6 +6,12 @@
num_nodes: 3
old_bin_version: last_lts
mixed_bin_versions: new_new_old
config:
shell_options:
global_vars:
TestData:
# TODO (SERVER-111403): Enable OpenTelemetry tracing in multiversion suites.
enableOTELTracing: false
- name: replica_fixture_last_lts_new_old_new
value:
@ -14,6 +20,12 @@
num_nodes: 3
old_bin_version: last_lts
mixed_bin_versions: new_old_new
config:
shell_options:
global_vars:
TestData:
# TODO (SERVER-111403): Enable OpenTelemetry tracing in multiversion suites.
enableOTELTracing: false
- name: replica_fixture_last_lts_old_new_new
value:
@ -22,6 +34,12 @@
num_nodes: 3
old_bin_version: last_lts
mixed_bin_versions: old_new_new
config:
shell_options:
global_vars:
TestData:
# TODO (SERVER-111403): Enable OpenTelemetry tracing in multiversion suites.
enableOTELTracing: false
- name: replica_fixture_last_continuous_new_new_old
value:
@ -30,6 +48,12 @@
num_nodes: 3
old_bin_version: last_continuous
mixed_bin_versions: new_new_old
config:
shell_options:
global_vars:
TestData:
# TODO (SERVER-111403): Enable OpenTelemetry tracing in multiversion suites.
enableOTELTracing: false
- name: replica_fixture_last_continuous_new_old_new
value:
@ -38,6 +62,12 @@
num_nodes: 3
old_bin_version: last_continuous
mixed_bin_versions: new_old_new
config:
shell_options:
global_vars:
TestData:
# TODO (SERVER-111403): Enable OpenTelemetry tracing in multiversion suites.
enableOTELTracing: false
- name: replica_fixture_last_continuous_old_new_new
value:
@ -46,6 +76,12 @@
num_nodes: 3
old_bin_version: last_continuous
mixed_bin_versions: old_new_new
config:
shell_options:
global_vars:
TestData:
# TODO (SERVER-111403): Enable OpenTelemetry tracing in multiversion suites.
enableOTELTracing: false
- name: sharded_fixture_last_lts_new_old_old_new
value:
@ -55,6 +91,12 @@
num_rs_nodes_per_shard: 2
old_bin_version: last_lts
mixed_bin_versions: new_old_old_new
config:
shell_options:
global_vars:
TestData:
# TODO (SERVER-111403): Enable OpenTelemetry tracing in multiversion suites.
enableOTELTracing: false
- name: sharded_fixture_last_continuous_new_old_old_new
value:
@ -64,6 +106,12 @@
num_rs_nodes_per_shard: 2
old_bin_version: last_continuous
mixed_bin_versions: new_old_old_new
config:
shell_options:
global_vars:
TestData:
# TODO (SERVER-111403): Enable OpenTelemetry tracing in multiversion suites.
enableOTELTracing: false
- name: sharded_fixture_last_lts_3_nodes
value:
@ -78,6 +126,8 @@
global_vars:
TestData:
nonClusteredConfigTransactions: true
# TODO (SERVER-111403): Enable OpenTelemetry tracing in multiversion suites.
enableOTELTracing: false
- name: sharded_fixture_last_continuous_3_nodes
value:
@ -92,6 +142,8 @@
global_vars:
TestData:
nonClusteredConfigTransactions: true
# TODO (SERVER-111403): Enable OpenTelemetry tracing in multiversion suites.
enableOTELTracing: false
### Suite-specific overrides ###
- name: replica_sets_temporarily_disable_due_to_fcv_upgrade
@ -345,3 +397,13 @@
global_vars:
TestData:
skipValidationOnInvalidViewDefinitions: true
- name: otel_tracing
value:
executor:
config:
shell_options:
global_vars:
TestData:
# TODO (SERVER-111403): Enable OpenTelemetry tracing in multiversion suites.
enableOTELTracing: false

View File

@ -48,8 +48,21 @@ executor:
# The backup_restore*.js tests are expected to run the FSM workloads directly against the
# primary of the replica set without being aware of the other members.
discoverTopology: False
# TODO (SERVER-111403): Enable OpenTelemetry tracing in multiversion suites.
# When running in the multiversion suite, incremental_backup_helpers.js and
# backup_restore.js runs resmoke with this suite without using any multiversion
# overrides.
enableOTELTracing: false
hooks:
- class: WaitForReplication
shell_options:
global_vars:
TestData:
# TODO (SERVER-111403): Enable OpenTelemetry tracing in multiversion suites.
# When running in the multiversion suite, incremental_backup_helpers.js and
# backup_restore.js runs resmoke with this suite without using any multiversion
# overrides.
enableOTELTracing: false
- class: CleanupConcurrencyWorkloads
exclude_dbs:
- crud

View File

@ -11,3 +11,7 @@ executor:
config:
shell_options:
nodb: ""
global_vars:
TestData:
# TODO (SERVER-111403): Enable OpenTelemetry tracing in multiversion suites.
enableOTELTracing: false

View File

@ -36,3 +36,5 @@ executor:
TestData:
setParameters:
bsonTestValidationVersion: 1
# TODO (SERVER-111403): Enable OpenTelemetry tracing in multiversion suites.
enableOTELTracing: false

View File

@ -43,6 +43,8 @@ executor:
# authMechanism: SCRAM-SHA-256
keyFile: *keyFile
keyFileData: *keyFileData
# TODO (SERVER-111403): Enable OpenTelemetry tracing in multiversion suites.
enableOTELTracing: false
authenticationDatabase: local
# authenticationMechanism: SCRAM-SHA-256
password: *keyFileData

View File

@ -11,13 +11,14 @@ class WaitForReplication(interface.Hook):
IS_BACKGROUND = False
def __init__(self, hook_logger, fixture):
def __init__(self, hook_logger, fixture, shell_options=None):
"""Initialize WaitForReplication."""
description = "WaitForReplication waits on a replica set"
interface.Hook.__init__(self, hook_logger, fixture, description)
self.hook_logger = hook_logger
self.fixture = fixture
self.shell_options = shell_options
def after_test(self, test, test_report):
"""Run mongo shell to call replSetTest.awaitReplication()."""
@ -36,7 +37,10 @@ class WaitForReplication(interface.Hook):
}}
jsTestLog("Ignoring shutdown error in quiesce mode");
}}"""
shell_options = {"nodb": "", "eval": js_cmds.format(client_conn)}
shell_options = {
**{"nodb": "", "eval": js_cmds.format(client_conn)},
**(self.shell_options or {}),
}
shell_proc = core.programs.mongo_shell_program(
self.hook_logger,
test_name="wait_for_replication",

View File

@ -191,6 +191,7 @@ export var QuerySamplingUtil = (function () {
for (let key in subsetObj) {
const value = subsetObj[key];
if (typeof value === "object") {
assert(supersetObj.hasOwnProperty(key), {key, actual: supersetObj, expected: subsetObj});
assertSubObject(supersetObj[key], subsetObj[key]);
} else {
assert.eq(supersetObj[key], subsetObj[key], {key, actual: supersetObj, expected: subsetObj});

View File

@ -29,6 +29,7 @@ function ensureNoResponses() {
// Now run a search command.
let resp = assert.commandWorked(testDB.runCommand(searchCmd));
delete resp["$traceCtx"];
assert.eq(resp, {ok: 1, foo: 1});
// Run a getMore which succeeds.

View File

@ -46,6 +46,7 @@ const auto getMongotMockStateDecoration = ServiceContext::declareDecoration<Mong
const std::set<std::string> ignoredFields = {"lsid",
"uid",
"$db",
"$traceCtx",
"comment",
"cursorOptions.docsRequested",
"docsRequested",

View File

@ -173,7 +173,17 @@ Mongo.prototype._setSecurityToken = function (token) {
};
Mongo.prototype.runCommand = function (dbname, cmd, options) {
return this._runCommandImpl(dbname, cmd, options, this._securityToken);
let cmdToSend = {...cmd};
if (
jsTestOptions().enableOTELTracing &&
jsTestOptions().traceCtx != null &&
!cmdToSend.hasOwnProperty("$traceCtx")
) {
cmdToSend["$traceCtx"] = {traceparent: jsTestOptions().traceCtx};
}
return this._runCommandImpl(dbname, cmdToSend, options, this._securityToken);
};
/**

View File

@ -353,6 +353,10 @@ let _jsTestOptions = {};
function jsTestOptions() {
if (TestData) {
// TODO (SERVER-112812): Enable OpenTelemetry tracing.
// const isMultiversion =
// TestData.useRandomBinVersionsWithinReplicaSet || TestData.mixedBinVersions || TestData.mongosBinVersion;
return Object.merge(_jsTestOptions, {
// Test commands should be enabled by default if no enableTestCommands were present in
// TestData
@ -467,6 +471,11 @@ function jsTestOptions() {
performTimeseriesCompressionIntermediateDataIntegrityCheckOnInsert: true,
fuzzMongodConfigs: TestData.fuzzMongodConfigs || false,
mozJSGCZeal: TestData.mozJSGCZeal || "",
// TODO (SERVER-112812): Enable OpenTelemetry tracing.
enableOTELTracing: false, // TestData.enableOTELTracing ?? !isMultiversion,
// TODO (SERVER-100133): Replace the mock 'traceCtx' with the actual one from resmoke.
traceCtx: TestData.traceCtx ?? "mockTraceCtx",
});
}
return _jsTestOptions;