summaryrefslogtreecommitdiff
path: root/jstests/sharding/agg_explain_fmt.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/sharding/agg_explain_fmt.js')
-rw-r--r--jstests/sharding/agg_explain_fmt.js66
1 files changed, 33 insertions, 33 deletions
diff --git a/jstests/sharding/agg_explain_fmt.js b/jstests/sharding/agg_explain_fmt.js
index c331b2686b1..3d88d8a2383 100644
--- a/jstests/sharding/agg_explain_fmt.js
+++ b/jstests/sharding/agg_explain_fmt.js
@@ -1,42 +1,42 @@
// This test ensuexplain an explain of an aggregate through mongos has the intended format.
(function() {
- "use strict";
+"use strict";
- load('jstests/libs/analyze_plan.js'); // For planHasStage.
+load('jstests/libs/analyze_plan.js'); // For planHasStage.
- const st = new ShardingTest({shards: 2});
- const mongosDB = st.s.getDB("test");
- const coll = mongosDB.agg_explain_fmt;
- // Insert documents with {_id: -5} to {_id: 4}.
- assert.commandWorked(coll.insert(Array.from({length: 10}, (_, i) => ({_id: i - 5}))));
+const st = new ShardingTest({shards: 2});
+const mongosDB = st.s.getDB("test");
+const coll = mongosDB.agg_explain_fmt;
+// Insert documents with {_id: -5} to {_id: 4}.
+assert.commandWorked(coll.insert(Array.from({length: 10}, (_, i) => ({_id: i - 5}))));
- // Test that with an unsharded collection we don't get any kind of 'splitPipeline', just the
- // normal explain with 'stages'.
- let explain = coll.explain().aggregate([{$project: {a: 1}}]);
- assert(!explain.hasOwnProperty("splitPipeline"), explain);
- assert(explain.hasOwnProperty("stages"), explain);
+// Test that with an unsharded collection we don't get any kind of 'splitPipeline', just the
+// normal explain with 'stages'.
+let explain = coll.explain().aggregate([{$project: {a: 1}}]);
+assert(!explain.hasOwnProperty("splitPipeline"), explain);
+assert(explain.hasOwnProperty("stages"), explain);
- // Now shard the collection by _id and move a chunk to each shard.
- st.shardColl(coll, {_id: 1}, {_id: 0}, {_id: 0});
+// Now shard the collection by _id and move a chunk to each shard.
+st.shardColl(coll, {_id: 1}, {_id: 0}, {_id: 0});
- // Test that we now have a split pipeline with information about what pipeline ran on each
- // shard.
- explain = coll.explain().aggregate([{$project: {a: 1}}]);
- assert(explain.hasOwnProperty("splitPipeline"), explain);
- assert(explain.splitPipeline.hasOwnProperty("shardsPart"), explain.splitPipeline);
- assert(explain.splitPipeline.hasOwnProperty("mergerPart"), explain.splitPipeline);
- assert(explain.hasOwnProperty("shards"), explain);
- for (let shardId in explain.shards) {
- const shardExplain = explain.shards[shardId];
- assert(shardExplain.hasOwnProperty("host"), shardExplain);
- assert(shardExplain.hasOwnProperty("stages") || shardExplain.hasOwnProperty("queryPlanner"),
- shardExplain);
- }
+// Test that we now have a split pipeline with information about what pipeline ran on each
+// shard.
+explain = coll.explain().aggregate([{$project: {a: 1}}]);
+assert(explain.hasOwnProperty("splitPipeline"), explain);
+assert(explain.splitPipeline.hasOwnProperty("shardsPart"), explain.splitPipeline);
+assert(explain.splitPipeline.hasOwnProperty("mergerPart"), explain.splitPipeline);
+assert(explain.hasOwnProperty("shards"), explain);
+for (let shardId in explain.shards) {
+ const shardExplain = explain.shards[shardId];
+ assert(shardExplain.hasOwnProperty("host"), shardExplain);
+ assert(shardExplain.hasOwnProperty("stages") || shardExplain.hasOwnProperty("queryPlanner"),
+ shardExplain);
+}
- // Do a sharded explain from a mongod, not mongos, to ensure that it does not have a
- // SHARDING_FILTER stage.");
- const shardDB = st.shard0.getDB(mongosDB.getName());
- explain = shardDB[coll.getName()].explain().aggregate([{$match: {}}]);
- assert(!planHasStage(shardDB, explain.queryPlanner.winningPlan, "SHARDING_FILTER"), explain);
- st.stop();
+// Do a sharded explain from a mongod, not mongos, to ensure that it does not have a
+// SHARDING_FILTER stage.");
+const shardDB = st.shard0.getDB(mongosDB.getName());
+explain = shardDB[coll.getName()].explain().aggregate([{$match: {}}]);
+assert(!planHasStage(shardDB, explain.queryPlanner.winningPlan, "SHARDING_FILTER"), explain);
+st.stop();
}());