summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/document_source_plan_cache_stats_test.cpp
diff options
context:
space:
mode:
authorLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-11 15:07:35 -0300
committerLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-11 15:07:35 -0300
commit4cb8841196d0625dfa3825aa326f071cd27c7b8b (patch)
tree1682a647d4463397c119183369ae6f750d5fdcff /src/mongo/db/pipeline/document_source_plan_cache_stats_test.cpp
parentaa03c6362cbaa767638e6eed9b031d86dd2643d1 (diff)
parent8f0827553e09872941945a093b647a4211a9db7f (diff)
Update upstream source from tag 'upstream/6.0.0'master
Update to upstream version '6.0.0' with Debian dir 5604a80ec1c96ca76f25f40d78e6ef855abec322
Diffstat (limited to 'src/mongo/db/pipeline/document_source_plan_cache_stats_test.cpp')
-rw-r--r--src/mongo/db/pipeline/document_source_plan_cache_stats_test.cpp27
1 files changed, 2 insertions, 25 deletions
diff --git a/src/mongo/db/pipeline/document_source_plan_cache_stats_test.cpp b/src/mongo/db/pipeline/document_source_plan_cache_stats_test.cpp
index 262806e0780..4f89e47acdf 100644
--- a/src/mongo/db/pipeline/document_source_plan_cache_stats_test.cpp
+++ b/src/mongo/db/pipeline/document_source_plan_cache_stats_test.cpp
@@ -41,8 +41,6 @@ namespace mongo {
using DocumentSourcePlanCacheStatsTest = AggregationContextFixture;
-static const SerializationOptions kExplain =
- SerializationOptions{boost::make_optional(ExplainOptions::Verbosity::kQueryPlanner)};
/**
* A MongoProcessInterface used for testing which returns artificial plan cache stats.
*/
@@ -108,9 +106,7 @@ TEST_F(DocumentSourcePlanCacheStatsTest, CanParseAndSerializeAsExplainSuccessful
const auto specObj = fromjson("{$planCacheStats: {}}");
auto stage = DocumentSourcePlanCacheStats::createFromBson(specObj.firstElement(), getExpCtx());
std::vector<Value> serialized;
- stage->serializeToArray(
- serialized,
- SerializationOptions{boost::make_optional(ExplainOptions::Verbosity::kQueryPlanner)});
+ stage->serializeToArray(serialized, ExplainOptions::Verbosity::kQueryPlanner);
ASSERT_EQ(1u, serialized.size());
ASSERT_BSONOBJ_EQ(specObj, serialized[0].getDocument().toBson());
}
@@ -143,31 +139,12 @@ TEST_F(DocumentSourcePlanCacheStatsTest, SerializesSuccessfullyAfterAbsorbingMat
pipeline->optimizePipeline();
ASSERT_EQ(1u, pipeline->getSources().size());
- auto serialized = pipeline->writeExplainOps(kExplain);
+ auto serialized = pipeline->writeExplainOps(ExplainOptions::Verbosity::kQueryPlanner);
ASSERT_EQ(1u, serialized.size());
ASSERT_BSONOBJ_EQ(fromjson("{$planCacheStats: {match: {foo: 'bar'}}}"),
serialized[0].getDocument().toBson());
}
-TEST_F(DocumentSourcePlanCacheStatsTest, RedactsSuccessfullyAfterAbsorbingMatch) {
- const auto specObj = fromjson("{$planCacheStats: {}}");
- auto planCacheStats =
- DocumentSourcePlanCacheStats::createFromBson(specObj.firstElement(), getExpCtx());
- auto match = DocumentSourceMatch::create(fromjson("{foo: 'bar'}"), getExpCtx());
- auto pipeline = Pipeline::create({planCacheStats, match}, getExpCtx());
- ASSERT_EQ(2u, pipeline->getSources().size());
-
- pipeline->optimizePipeline();
- ASSERT_EQ(1u, pipeline->getSources().size());
- auto serialized = redactToArray(*pipeline->getSources().front());
- ASSERT_EQ(2u, serialized.size());
-
- ASSERT_BSONOBJ_EQ(specObj, serialized[0].getDocument().toBson());
- ASSERT_BSONOBJ_EQ_AUTO( // NOLINT
- R"({"$match":{"HASH<foo>":{"$eq":"?string"}}})",
- serialized[1].getDocument().toBson().getOwned());
-}
-
TEST_F(DocumentSourcePlanCacheStatsTest, ReturnsImmediateEOFWithEmptyPlanCache) {
getExpCtx()->mongoProcessInterface =
std::make_shared<PlanCacheStatsMongoProcessInterface>(std::vector<BSONObj>{});