diff options
author | Anton Korshunov <anton.korshunov@mongodb.com> | 2019-03-25 16:20:25 +0000 |
---|---|---|
committer | Anton Korshunov <anton.korshunov@mongodb.com> | 2019-05-02 17:03:31 +0100 |
commit | fc6c65c0d4ffff4104e355af6f6c3d73b79ad713 (patch) | |
tree | e17af8d59a97450d965190c9f16c51376538ef24 /jstests/libs | |
parent | 923bb8465cf13a81c90ca3002e5386411ce5d14b (diff) | |
download | mongo-fc6c65c0d4ffff4104e355af6f6c3d73b79ad713.tar.gz |
SERVER-40429 Add merge stage to write output to existing collection
Diffstat (limited to 'jstests/libs')
5 files changed, 10 insertions, 14 deletions
diff --git a/jstests/libs/override_methods/implicitly_wrap_pipelines_in_facets.js b/jstests/libs/override_methods/implicitly_wrap_pipelines_in_facets.js index c5c26b6e8b1..84da15b1b8f 100644 --- a/jstests/libs/override_methods/implicitly_wrap_pipelines_in_facets.js +++ b/jstests/libs/override_methods/implicitly_wrap_pipelines_in_facets.js @@ -31,14 +31,8 @@ return originalRunCommand.apply(this, arguments); } - const stagesDisallowedInsideFacet = [ - '$changeStream', - '$collStats', - '$facet', - '$geoNear', - '$indexStats', - '$out', - ]; + const stagesDisallowedInsideFacet = + ['$changeStream', '$collStats', '$facet', '$geoNear', '$indexStats', '$merge', '$out']; for (let stageSpec of originalPipeline) { // Skip wrapping the pipeline in a $facet stage if it has an invalid stage // specification. 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 526e343c8c7..9394ca836cc 100644 --- a/jstests/libs/override_methods/network_error_and_txn_override.js +++ b/jstests/libs/override_methods/network_error_and_txn_override.js @@ -386,7 +386,7 @@ shouldForceReadConcern = false; } - if (OverrideHelpers.isAggregationWithOutStage(cmdName, cmdObj)) { + if (OverrideHelpers.isAggregationWithOutOrMergeStage(cmdName, cmdObj)) { // The $out stage can only be used with readConcern={level: "local"}. shouldForceReadConcern = false; } else { diff --git a/jstests/libs/override_methods/override_helpers.js b/jstests/libs/override_methods/override_helpers.js index 94d7f72cb06..bd49e0d7191 100644 --- a/jstests/libs/override_methods/override_helpers.js +++ b/jstests/libs/override_methods/override_helpers.js @@ -25,7 +25,7 @@ var OverrideHelpers = (function() { }; } - function isAggregationWithOutStage(commandName, commandObj) { + function isAggregationWithOutOrMergeStage(commandName, commandObj) { if (commandName !== "aggregate" || typeof commandObj !== "object" || commandObj === null) { return false; } @@ -39,7 +39,8 @@ var OverrideHelpers = (function() { return false; } - return Object.keys(lastStage)[0] === "$out"; + const lastStageName = Object.keys(lastStage)[0]; + return lastStageName === "$out" || lastStageName === "$merge"; } function isMapReduceWithInlineOutput(commandName, commandObj) { @@ -99,7 +100,7 @@ var OverrideHelpers = (function() { return { isAggregationWithListLocalSessionsStage: makeIsAggregationWithFirstStage("$listLocalSessions"), - isAggregationWithOutStage: isAggregationWithOutStage, + isAggregationWithOutOrMergeStage: isAggregationWithOutOrMergeStage, isMapReduceWithInlineOutput: isMapReduceWithInlineOutput, prependOverrideInParallelShell: prependOverrideInParallelShell, overrideRunCommand: overrideRunCommand, 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 e8c37681f25..4b9adfb23fa 100644 --- a/jstests/libs/override_methods/set_read_and_write_concerns.js +++ b/jstests/libs/override_methods/set_read_and_write_concerns.js @@ -68,7 +68,8 @@ shouldForceReadConcern = false; } - if (OverrideHelpers.isAggregationWithOutStage(commandName, commandObjUnwrapped)) { + if (OverrideHelpers.isAggregationWithOutOrMergeStage(commandName, + commandObjUnwrapped)) { // The $out stage can only be used with readConcern={level: "local"} or // readConcern={level: "majority"} if (TestData.defaultReadConcernLevel === "linearizable") { diff --git a/jstests/libs/override_methods/set_read_preference_secondary.js b/jstests/libs/override_methods/set_read_preference_secondary.js index 3646198fff0..70dfc5737a5 100644 --- a/jstests/libs/override_methods/set_read_preference_secondary.js +++ b/jstests/libs/override_methods/set_read_preference_secondary.js @@ -110,7 +110,7 @@ } let shouldForceReadPreference = kCommandsSupportingReadPreference.has(commandName); - if (OverrideHelpers.isAggregationWithOutStage(commandName, commandObjUnwrapped)) { + if (OverrideHelpers.isAggregationWithOutOrMergeStage(commandName, commandObjUnwrapped)) { // An aggregation with a $out stage must be sent to the primary. shouldForceReadPreference = false; } else if ((commandName === "mapReduce" || commandName === "mapreduce") && |