summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/plan_cache_commands_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/commands/plan_cache_commands_test.cpp')
-rw-r--r--src/mongo/db/commands/plan_cache_commands_test.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/mongo/db/commands/plan_cache_commands_test.cpp b/src/mongo/db/commands/plan_cache_commands_test.cpp
index 43d0f7d3830..fb0ed6c3e03 100644
--- a/src/mongo/db/commands/plan_cache_commands_test.cpp
+++ b/src/mongo/db/commands/plan_cache_commands_test.cpp
@@ -273,6 +273,24 @@ TEST(PlanCacheCommandsTest, Canonicalize) {
ASSERT_NOT_EQUALS(planCache.computeKey(*query), planCache.computeKey(*projectionQuery));
}
+TEST(PlanCacheCommandsTest, PlanCacheIgnoresIsolated) {
+ PlanCache planCache;
+ QueryTestServiceContext serviceContext;
+ auto opCtx = serviceContext.makeOperationContext();
+
+ // Query with $isolated should generate the same key as a query without $siolated.
+ auto statusWithCQ =
+ PlanCacheCommand::canonicalize(opCtx.get(), nss.ns(), fromjson("{query: {a: 1, b: 1}}"));
+ ASSERT_OK(statusWithCQ.getStatus());
+ unique_ptr<CanonicalQuery> query = std::move(statusWithCQ.getValue());
+
+ statusWithCQ = PlanCacheCommand::canonicalize(
+ opCtx.get(), nss.ns(), fromjson("{query: {a: 1, b: 1}, $isolated: 1}"));
+ ASSERT_OK(statusWithCQ.getStatus());
+ unique_ptr<CanonicalQuery> queryWithIsolated = std::move(statusWithCQ.getValue());
+ ASSERT_EQUALS(planCache.computeKey(*query), planCache.computeKey(*queryWithIsolated));
+}
+
/**
* Tests for planCacheClear (single query shape)
*/