diff options
author | Bernard Gorman <bernard.gorman@gmail.com> | 2017-08-18 00:29:08 +0100 |
---|---|---|
committer | Bernard Gorman <bernard.gorman@gmail.com> | 2017-08-21 02:19:57 +0100 |
commit | 6ce6b59a2b0031b212c2bc8ba47ae61b2f81ac46 (patch) | |
tree | 4694bcaed4fa910bd92889e49f24ac752efd39fd /jstests/aggregation/mongos_merge.js | |
parent | 0cfe4dfc2cf371f9e8196cb79414c3432b95b5af (diff) | |
download | mongo-6ce6b59a2b0031b212c2bc8ba47ae61b2f81ac46.tar.gz |
SERVER-30480 Update aggregation explain format to provide details of merge location
Diffstat (limited to 'jstests/aggregation/mongos_merge.js')
-rw-r--r-- | jstests/aggregation/mongos_merge.js | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/jstests/aggregation/mongos_merge.js b/jstests/aggregation/mongos_merge.js index 9d7becfb87f..ea00739d739 100644 --- a/jstests/aggregation/mongos_merge.js +++ b/jstests/aggregation/mongos_merge.js @@ -74,23 +74,23 @@ /** * Runs the aggregation specified by 'pipeline', verifying that: * - The number of documents returned by the aggregation matches 'expectedCount'. - * - The merge was performed on a mongoS if 'mergeOnMongoS' is true, and on a shard otherwise. + * - The merge was performed on a mongoS if 'mergeType' is 'mongos', and on a shard otherwise. */ - function assertMergeBehaviour({testName, pipeline, mergeOnMongoS, expectedCount}) { + function assertMergeBehaviour({testName, pipeline, mergeType, expectedCount}) { // Verify that the 'mergeOnMongoS' explain() output for this pipeline matches our // expectation. assert.eq( assert.commandWorked(mongosColl.explain().aggregate(pipeline, {comment: testName})) - .mergeOnMongoS, - mergeOnMongoS); + .mergeType, + mergeType); assert.eq(mongosColl.aggregate(pipeline, {comment: testName}).itcount(), expectedCount); - // Verify that a $mergeCursors aggregation ran on the primary shard if 'mergeOnMongoS' is - // false, and that no such aggregation ran if 'mergeOnMongoS' is true. + // Verify that a $mergeCursors aggregation ran on the primary shard if 'mergeType' is not + // 'mongos', and that no such aggregation ran otherwise. profilerHasNumMatchingEntriesOrThrow({ profileDB: primaryShardDB, - numExpectedMatches: (mergeOnMongoS ? 0 : 1), + numExpectedMatches: (mergeType === "mongos" ? 0 : 1), filter: { "command.aggregate": mongosColl.getName(), "command.comment": testName, @@ -107,7 +107,7 @@ assertMergeBehaviour({ testName: testName, pipeline: pipeline, - mergeOnMongoS: true, + mergeType: "mongos", expectedCount: expectedCount }); } @@ -116,11 +116,11 @@ * Throws an assertion if the aggregation specified by 'pipeline' does not produce * 'expectedCount' results, or if the merge phase was not performed on a shard. */ - function assertMergeOnMongoD({testName, pipeline, expectedCount}) { + function assertMergeOnMongoD({testName, pipeline, mergeType, expectedCount}) { assertMergeBehaviour({ testName: testName, pipeline: pipeline, - mergeOnMongoS: false, + mergeType: (mergeType || "anyShard"), expectedCount: expectedCount }); } @@ -152,6 +152,17 @@ expectedCount: 400 }); + // Test that a merge pipeline which needs to run on the primary shard is NOT merged on mongoS. + assertMergeOnMongoD({ + testName: "agg_mongos_merge_primary_shard", + pipeline: [ + {$match: {_id: {$gte: -200, $lte: 200}}}, + {$_internalSplitPipeline: {mergeType: "primaryShard"}} + ], + mergeType: "primaryShard", + expectedCount: 400 + }); + // Test that $skip is merged on mongoS. assertMergeOnMongoS({ testName: "agg_mongos_merge_skip", |