diff options
author | Charlie Swanson <charlie.swanson@mongodb.com> | 2018-01-11 14:00:27 -0500 |
---|---|---|
committer | Charlie Swanson <charlie.swanson@mongodb.com> | 2018-01-19 09:55:59 -0500 |
commit | 87c9442cc30d4101693bb8ccb6fd4509aa048558 (patch) | |
tree | 99ab7b36d89776693c09f271e4de4fd4f64846e3 /jstests/core/explain_count.js | |
parent | 71ae3ed5b7e99ddb629ec64b85f4bd75b73aff17 (diff) | |
download | mongo-87c9442cc30d4101693bb8ccb6fd4509aa048558.tar.gz |
SERVER-31785 Use 2 shards in sharded jscore passthrough.
Diffstat (limited to 'jstests/core/explain_count.js')
-rw-r--r-- | jstests/core/explain_count.js | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/jstests/core/explain_count.js b/jstests/core/explain_count.js index 0351db29f9c..ee7cb31de94 100644 --- a/jstests/core/explain_count.js +++ b/jstests/core/explain_count.js @@ -15,13 +15,17 @@ function checkCountExplain(explain, nCounted) { printjson(explain); var execStages = explain.executionStats.executionStages; - // If passed through mongos, then the root stage should be the mongos SINGLE_SHARD stage, - // with COUNT as its child. If explaining directly on the shard, then COUNT is the root - // stage. - if ("SINGLE_SHARD" == execStages.stage) { - var countStage = execStages.shards[0].executionStages; - assert.eq(countStage.stage, "COUNT", "root stage on shard is not COUNT"); - assert.eq(countStage.nCounted, nCounted, "wrong count result"); + // If passed through mongos, then the root stage should be the mongos SINGLE_SHARD stage or + // SHARD_MERGE stages, with COUNT as the root stage on each shard. If explaining directly on the + // shard, then COUNT is the root stage. + if ("SINGLE_SHARD" == execStages.stage || "SHARD_MERGE" == execStages.stage) { + let totalCounted = 0; + for (let shardExplain of execStages.shards) { + const countStage = shardExplain.executionStages; + assert.eq(countStage.stage, "COUNT", "root stage on shard is not COUNT"); + totalCounted += countStage.nCounted; + } + assert.eq(totalCounted, nCounted, "wrong count result"); } else { assert.eq(execStages.stage, "COUNT", "root stage is not COUNT"); assert.eq(execStages.nCounted, nCounted, "wrong count result"); |