diff options
author | David Storch <david.storch@10gen.com> | 2014-09-25 08:56:22 -0400 |
---|---|---|
committer | David Storch <david.storch@10gen.com> | 2014-10-01 15:29:23 -0400 |
commit | 2481ccd2e79008bece816a585a9748a6f359784c (patch) | |
tree | d6dd4b101dbe49a5e12baa5b21bb6ccc3eb38852 /jstests/core/explain_count.js | |
parent | 8de392055e1ba38621c695c3d379d87fd74b84a7 (diff) | |
download | mongo-2481ccd2e79008bece816a585a9748a6f359784c.tar.gz |
SERVER-14102 implement the explain command on mongos
Diffstat (limited to 'jstests/core/explain_count.js')
-rw-r--r-- | jstests/core/explain_count.js | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/jstests/core/explain_count.js b/jstests/core/explain_count.js index d774a8745dc..6e42657fd3b 100644 --- a/jstests/core/explain_count.js +++ b/jstests/core/explain_count.js @@ -11,9 +11,20 @@ t.drop(); */ function checkCountExplain(explain, nCounted) { printjson(explain); - var rootStage = explain.executionStats.executionStages; - assert.eq(rootStage.stage, "COUNT", "root stage is not COUNT"); - assert.eq(rootStage.nCounted, nCounted, "wrong count result"); + 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"); + } + else { + assert.eq(execStages.stage, "COUNT", "root stage is not COUNT"); + assert.eq(execStages.nCounted, nCounted, "wrong count result"); + } } // Collection does not exist. |