diff options
author | Bernard Gorman <bernard.gorman@gmail.com> | 2018-03-08 15:01:58 +0000 |
---|---|---|
committer | Bernard Gorman <bernard.gorman@gmail.com> | 2018-03-24 00:14:22 +0000 |
commit | 83031a24b9e7bcc55ead1b838fba1e0a11503409 (patch) | |
tree | c52280faf316fe87e28895fa53898fe0d94a6500 /jstests/sharding/mongos_local_explain.js | |
parent | 3c39645662cca8467de11f32bb2d0032a0c4458e (diff) | |
download | mongo-83031a24b9e7bcc55ead1b838fba1e0a11503409.tar.gz |
SERVER-33718 Explain does not produce a plan for mongoS-only aggregation pipelines
Diffstat (limited to 'jstests/sharding/mongos_local_explain.js')
-rw-r--r-- | jstests/sharding/mongos_local_explain.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/jstests/sharding/mongos_local_explain.js b/jstests/sharding/mongos_local_explain.js new file mode 100644 index 00000000000..0200c334d85 --- /dev/null +++ b/jstests/sharding/mongos_local_explain.js @@ -0,0 +1,37 @@ +/** + * Test that a mongos-only aggregation pipeline is explainable, and that the resulting explain plan + * confirms that the pipeline ran entirely on mongoS. + */ +(function() { + "use strict"; + + const st = new ShardingTest({name: "mongos_comment_test", mongos: 1, shards: 1}); + const mongosConn = st.s; + + // MongoS-only stages to be tested and the expected 'explain' output for that stage. + const testStages = { + "$listLocalSessions": {allUsers: false, users: [{user: "nobody", db: "nothing"}]}, + "$listLocalCursors": {} + }; + + for (let stage in testStages) { + // Use the test stage to create a pipeline that runs exclusively on mongoS. + const mongosOnlyPipeline = [{[stage]: testStages[stage]}, {$match: {dummyField: 1}}]; + + // We expect the explain output to reflect the stage's spec. + const expectedExplainStages = + [{[stage]: testStages[stage]}, {$match: {dummyField: {$eq: 1}}}]; + + // Test that the mongoS-only pipeline is explainable. + const explainPlan = assert.commandWorked(mongosConn.getDB("admin").runCommand( + {aggregate: 1, pipeline: mongosOnlyPipeline, explain: true})); + + // We expect the stages to appear under the 'mongos' heading, for 'splitPipeline' to be + // null, and for the 'mongos.host' field to be the hostname:port of the mongoS itself. + assert.docEq(explainPlan.mongos.stages, expectedExplainStages); + assert.eq(explainPlan.mongos.host, mongosConn.name); + assert.isnull(explainPlan.splitPipeline); + } + + st.stop(); +})();
\ No newline at end of file |