summaryrefslogtreecommitdiff
path: root/jstests/libs
diff options
context:
space:
mode:
authorKatherine Wu <katherine.wu@mongodb.com>2021-07-01 14:57:37 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-08-17 17:31:35 +0000
commitafdebef974ba087301976e32e36e78802cf89dc8 (patch)
treed5d7be450052b2ea4403c4b3261fa4ea161762ea /jstests/libs
parent26bcd0f788184402ecefdc1221faf13a1f9b6e47 (diff)
downloadmongo-afdebef974ba087301976e32e36e78802cf89dc8.tar.gz
SERVER-55175 Maintain original read concern and read preference for $currentOp in passthrough suites
Diffstat (limited to 'jstests/libs')
-rw-r--r--jstests/libs/override_methods/network_error_and_txn_override.js7
-rw-r--r--jstests/libs/override_methods/override_helpers.js1
-rw-r--r--jstests/libs/override_methods/set_read_and_write_concerns.js5
-rw-r--r--jstests/libs/override_methods/set_read_preference_secondary.js10
4 files changed, 20 insertions, 3 deletions
diff --git a/jstests/libs/override_methods/network_error_and_txn_override.js b/jstests/libs/override_methods/network_error_and_txn_override.js
index 4de5cd9ba65..adf8a46a7fd 100644
--- a/jstests/libs/override_methods/network_error_and_txn_override.js
+++ b/jstests/libs/override_methods/network_error_and_txn_override.js
@@ -414,9 +414,10 @@ function appendReadAndWriteConcern(conn, dbName, cmdName, cmdObj) {
}
} else if (cmdName === "aggregate") {
if (OverrideHelpers.isAggregationWithListLocalSessionsStage(cmdName, cmdObj) ||
- OverrideHelpers.isAggregationWithChangeStreamStage(cmdName, cmdObj)) {
- // The $listLocalSessions stage can only be used with readConcern={level: "local"},
- // and the $changeStream stage can only be used with
+ OverrideHelpers.isAggregationWithChangeStreamStage(cmdName, cmdObj) ||
+ OverrideHelpers.isAggregationWithCurrentOpStage(cmdName, cmdObj)) {
+ // The $listLocalSessions and $currentOp stages can only be used with
+ // readConcern={level: "local"}, and the $changeStream stage can only be used with
// readConcern={level: "majority"}.
shouldForceReadConcern = false;
}
diff --git a/jstests/libs/override_methods/override_helpers.js b/jstests/libs/override_methods/override_helpers.js
index 8afeb999332..f4db0871bcf 100644
--- a/jstests/libs/override_methods/override_helpers.js
+++ b/jstests/libs/override_methods/override_helpers.js
@@ -101,6 +101,7 @@ var OverrideHelpers = (function() {
isAggregationWithListLocalSessionsStage:
makeIsAggregationWithFirstStage("$listLocalSessions"),
isAggregationWithOutOrMergeStage: isAggregationWithOutOrMergeStage,
+ isAggregationWithCurrentOpStage: makeIsAggregationWithFirstStage("$currentOp"),
isAggregationWithChangeStreamStage: makeIsAggregationWithFirstStage("$changeStream"),
isMapReduceWithInlineOutput: isMapReduceWithInlineOutput,
prependOverrideInParallelShell: prependOverrideInParallelShell,
diff --git a/jstests/libs/override_methods/set_read_and_write_concerns.js b/jstests/libs/override_methods/set_read_and_write_concerns.js
index 4679cf58092..9397c682010 100644
--- a/jstests/libs/override_methods/set_read_and_write_concerns.js
+++ b/jstests/libs/override_methods/set_read_and_write_concerns.js
@@ -87,6 +87,11 @@ function runCommandWithReadAndWriteConcerns(
shouldForceWriteConcern = false;
}
+ if (OverrideHelpers.isAggregationWithCurrentOpStage(commandName, commandObjUnwrapped)) {
+ // The $currentOp stage can only be used with readConcern={level: "local"}.
+ shouldForceReadConcern = false;
+ }
+
if (commandObjUnwrapped.explain) {
// Attempting to specify a readConcern while explaining an aggregation would always
// return an error prior to SERVER-30582 and it otherwise only compatible with
diff --git a/jstests/libs/override_methods/set_read_preference_secondary.js b/jstests/libs/override_methods/set_read_preference_secondary.js
index 9685449103e..68128b2ba93 100644
--- a/jstests/libs/override_methods/set_read_preference_secondary.js
+++ b/jstests/libs/override_methods/set_read_preference_secondary.js
@@ -117,6 +117,16 @@ function runCommandWithReadPreferenceSecondary(
shouldForceReadPreference = false;
}
+ if (commandName === "aggregate") {
+ if (OverrideHelpers.isAggregationWithCurrentOpStage(commandName, commandObjUnwrapped)) {
+ // Setting read preference secondary for an aggregation with $currentOp doesn't make
+ // much sense, since there's no guarantee *which* secondary you get results from. We
+ // will mirror the currentOp server command behavior here and maintain original read
+ // preference.
+ shouldForceReadPreference = false;
+ }
+ }
+
if (TestData.doNotOverrideReadPreference) {
// Use this TestData flag to allow certain runCommands to be exempted from
// setting secondary read preference.