summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/plan_cache_commands_test.cpp
diff options
context:
space:
mode:
authorNick Zolnierz <nicholas.zolnierz@mongodb.com>2017-10-17 17:41:26 -0400
committerNick Zolnierz <nicholas.zolnierz@mongodb.com>2017-10-23 16:12:40 -0400
commitec7af3523d4aa5130c56a05d76169755d9b5a611 (patch)
tree82c73c32e697eaebe00faca69ab62f573bdc283c /src/mongo/db/commands/plan_cache_commands_test.cpp
parent6475f004ad0db96d907e996dd24bad9a2228d3f6 (diff)
downloadmongo-ec7af3523d4aa5130c56a05d76169755d9b5a611.tar.gz
SERVER-17846: Forbid $isolated outside of update/delete user operations
Diffstat (limited to 'src/mongo/db/commands/plan_cache_commands_test.cpp')
-rw-r--r--src/mongo/db/commands/plan_cache_commands_test.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/mongo/db/commands/plan_cache_commands_test.cpp b/src/mongo/db/commands/plan_cache_commands_test.cpp
index e8a80bf2266..b93b9da43e2 100644
--- a/src/mongo/db/commands/plan_cache_commands_test.cpp
+++ b/src/mongo/db/commands/plan_cache_commands_test.cpp
@@ -231,7 +231,6 @@ TEST(PlanCacheCommandsTest, Canonicalize) {
ASSERT_OK(statusWithCQ.getStatus());
unique_ptr<CanonicalQuery> query = std::move(statusWithCQ.getValue());
-
// Equivalent query should generate same key.
statusWithCQ =
PlanCacheCommand::canonicalize(opCtx.get(), nss.ns(), fromjson("{query: {b: 1, a: 1}}"));
@@ -268,6 +267,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)
*/