summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/parsed_add_fields_test.cpp
diff options
context:
space:
mode:
authorDavid Storch <david.storch@10gen.com>2017-02-10 11:52:18 -0500
committerDavid Storch <david.storch@10gen.com>2017-03-13 09:46:14 -0400
commit82b16740f8a66093b453a73a04b3b9bd00e5d7a0 (patch)
tree62d156fc9676526ecbea19cd03ef7a293579c4df /src/mongo/db/pipeline/parsed_add_fields_test.cpp
parent73f9e8b8a8422becf8694fe3d82c0e647dc71189 (diff)
downloadmongo-82b16740f8a66093b453a73a04b3b9bd00e5d7a0.tar.gz
SERVER-19758 add support for "executionStats" and "allPlansExecution" to agg explain
Like other explainable commands, aggregate can now be explained using the explain command, e.g. db.runCommand({explain: {aggregate: ...}, verbosity: "executionStats"}). The existing explain:true flag corresponds to "queryPlanner" mode and is still supported. However, explain:true cannot be specified when explaining aggregate via the explain command. Additional execution information is provided only in the $cursor section of the aggregation explain output. Having aggregation stages themselves track and report execution info is further work.
Diffstat (limited to 'src/mongo/db/pipeline/parsed_add_fields_test.cpp')
-rw-r--r--src/mongo/db/pipeline/parsed_add_fields_test.cpp45
1 files changed, 35 insertions, 10 deletions
diff --git a/src/mongo/db/pipeline/parsed_add_fields_test.cpp b/src/mongo/db/pipeline/parsed_add_fields_test.cpp
index d7b68afca1d..c9adc2b1a36 100644
--- a/src/mongo/db/pipeline/parsed_add_fields_test.cpp
+++ b/src/mongo/db/pipeline/parsed_add_fields_test.cpp
@@ -176,8 +176,13 @@ TEST(ParsedAddFieldsSerialize, SerializesToCorrectForm) {
fromjson("{a: {$add: [\"$a\", {$const: 2}]}, b: {d: {$const: 3}}, x: {y: {$const: 4}}}"));
// Should be the same if we're serializing for explain or for internal use.
- ASSERT_DOCUMENT_EQ(expectedSerialization, addition.serialize(false));
- ASSERT_DOCUMENT_EQ(expectedSerialization, addition.serialize(true));
+ ASSERT_DOCUMENT_EQ(expectedSerialization, addition.serialize(boost::none));
+ ASSERT_DOCUMENT_EQ(expectedSerialization,
+ addition.serialize(ExplainOptions::Verbosity::kQueryPlanner));
+ ASSERT_DOCUMENT_EQ(expectedSerialization,
+ addition.serialize(ExplainOptions::Verbosity::kExecStats));
+ ASSERT_DOCUMENT_EQ(expectedSerialization,
+ addition.serialize(ExplainOptions::Verbosity::kExecAllPlans));
}
// Verify that serialize treats the _id field as any other field: including when explicity included.
@@ -190,8 +195,13 @@ TEST(ParsedAddFieldsSerialize, AddsIdToSerializeWhenExplicitlyIncluded) {
auto expectedSerialization = Document(fromjson("{_id: {$const: false}}"));
// Should be the same if we're serializing for explain or for internal use.
- ASSERT_DOCUMENT_EQ(expectedSerialization, addition.serialize(false));
- ASSERT_DOCUMENT_EQ(expectedSerialization, addition.serialize(true));
+ ASSERT_DOCUMENT_EQ(expectedSerialization, addition.serialize(boost::none));
+ ASSERT_DOCUMENT_EQ(expectedSerialization,
+ addition.serialize(ExplainOptions::Verbosity::kQueryPlanner));
+ ASSERT_DOCUMENT_EQ(expectedSerialization,
+ addition.serialize(ExplainOptions::Verbosity::kExecStats));
+ ASSERT_DOCUMENT_EQ(expectedSerialization,
+ addition.serialize(ExplainOptions::Verbosity::kExecAllPlans));
}
// Verify that serialize treats the _id field as any other field: excluded when not explicitly
@@ -207,8 +217,13 @@ TEST(ParsedAddFieldsSerialize, OmitsIdFromSerializeWhenNotIncluded) {
auto expectedSerialization = Document(fromjson("{a: {$const: true}}"));
// Should be the same if we're serializing for explain or for internal use.
- ASSERT_DOCUMENT_EQ(expectedSerialization, addition.serialize(false));
- ASSERT_DOCUMENT_EQ(expectedSerialization, addition.serialize(true));
+ ASSERT_DOCUMENT_EQ(expectedSerialization, addition.serialize(boost::none));
+ ASSERT_DOCUMENT_EQ(expectedSerialization,
+ addition.serialize(ExplainOptions::Verbosity::kQueryPlanner));
+ ASSERT_DOCUMENT_EQ(expectedSerialization,
+ addition.serialize(ExplainOptions::Verbosity::kExecStats));
+ ASSERT_DOCUMENT_EQ(expectedSerialization,
+ addition.serialize(ExplainOptions::Verbosity::kExecAllPlans));
}
// Verify that the $addFields stage optimizes expressions into simpler forms when possible.
@@ -220,8 +235,13 @@ TEST(ParsedAddFieldsOptimize, OptimizesTopLevelExpressions) {
auto expectedSerialization = Document{{"a", Document{{"$const", 3}}}};
// Should be the same if we're serializing for explain or for internal use.
- ASSERT_DOCUMENT_EQ(expectedSerialization, addition.serialize(false));
- ASSERT_DOCUMENT_EQ(expectedSerialization, addition.serialize(true));
+ ASSERT_DOCUMENT_EQ(expectedSerialization, addition.serialize(boost::none));
+ ASSERT_DOCUMENT_EQ(expectedSerialization,
+ addition.serialize(ExplainOptions::Verbosity::kQueryPlanner));
+ ASSERT_DOCUMENT_EQ(expectedSerialization,
+ addition.serialize(ExplainOptions::Verbosity::kExecStats));
+ ASSERT_DOCUMENT_EQ(expectedSerialization,
+ addition.serialize(ExplainOptions::Verbosity::kExecAllPlans));
}
// Verify that the $addFields stage optimizes expressions even when they are nested.
@@ -233,8 +253,13 @@ TEST(ParsedAddFieldsOptimize, ShouldOptimizeNestedExpressions) {
auto expectedSerialization = Document{{"a", Document{{"b", Document{{"$const", 3}}}}}};
// Should be the same if we're serializing for explain or for internal use.
- ASSERT_DOCUMENT_EQ(expectedSerialization, addition.serialize(false));
- ASSERT_DOCUMENT_EQ(expectedSerialization, addition.serialize(true));
+ ASSERT_DOCUMENT_EQ(expectedSerialization, addition.serialize(boost::none));
+ ASSERT_DOCUMENT_EQ(expectedSerialization,
+ addition.serialize(ExplainOptions::Verbosity::kQueryPlanner));
+ ASSERT_DOCUMENT_EQ(expectedSerialization,
+ addition.serialize(ExplainOptions::Verbosity::kExecStats));
+ ASSERT_DOCUMENT_EQ(expectedSerialization,
+ addition.serialize(ExplainOptions::Verbosity::kExecAllPlans));
}
//