diff options
author | XueruiFa <xuerui.fa@mongodb.com> | 2020-07-16 18:03:11 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-07-29 15:23:07 +0000 |
commit | 7b910aba3c500839692d142b4c64560b1fc2f29b (patch) | |
tree | f56189478f203aac17cbe9d10bf91b1969653155 /src/mongo/dbtests | |
parent | 4b880132b11c16a4a0cba4e5c3ce77892dd01f7c (diff) | |
download | mongo-7b910aba3c500839692d142b4c64560b1fc2f29b.tar.gz |
SERVER-49376: Ensure cursors inherit API settings of the initiating command
Diffstat (limited to 'src/mongo/dbtests')
-rw-r--r-- | src/mongo/dbtests/cursor_manager_test.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/mongo/dbtests/cursor_manager_test.cpp b/src/mongo/dbtests/cursor_manager_test.cpp index b8a841b56a3..31ad5c0c8a9 100644 --- a/src/mongo/dbtests/cursor_manager_test.cpp +++ b/src/mongo/dbtests/cursor_manager_test.cpp @@ -89,6 +89,7 @@ public: makeFakePlanExecutor(opCtx), kTestNss, {}, + APIParameters(), opCtx->getWriteConcern(), repl::ReadConcernArgs(repl::ReadConcernLevel::kLocalReadConcern), BSONObj(), @@ -140,6 +141,7 @@ TEST_F(CursorManagerTest, ShouldBeAbleToKillPinnedCursor) { {makeFakePlanExecutor(), kTestNss, {}, + APIParameters(), {}, repl::ReadConcernArgs(repl::ReadConcernLevel::kLocalReadConcern), BSONObj(), @@ -166,6 +168,7 @@ TEST_F(CursorManagerTest, ShouldBeAbleToKillPinnedCursorMultiClient) { {makeFakePlanExecutor(), kTestNss, {}, + APIParameters(), {}, repl::ReadConcernArgs(repl::ReadConcernLevel::kLocalReadConcern), BSONObj(), @@ -202,6 +205,7 @@ TEST_F(CursorManagerTest, InactiveCursorShouldTimeout) { {makeFakePlanExecutor(), NamespaceString{"test.collection"}, {}, + APIParameters(), {}, repl::ReadConcernArgs(repl::ReadConcernLevel::kLocalReadConcern), BSONObj(), @@ -217,6 +221,7 @@ TEST_F(CursorManagerTest, InactiveCursorShouldTimeout) { {makeFakePlanExecutor(), NamespaceString{"test.collection"}, {}, + APIParameters(), {}, repl::ReadConcernArgs(repl::ReadConcernLevel::kLocalReadConcern), BSONObj(), @@ -237,6 +242,7 @@ TEST_F(CursorManagerTest, InactivePinnedCursorShouldNotTimeout) { {makeFakePlanExecutor(), NamespaceString{"test.collection"}, {}, + APIParameters(), {}, repl::ReadConcernArgs(repl::ReadConcernLevel::kLocalReadConcern), BSONObj(), @@ -261,6 +267,7 @@ TEST_F(CursorManagerTest, MarkedAsKilledCursorsShouldBeDeletedOnCursorPin) { {makeFakePlanExecutor(), NamespaceString{"test.collection"}, {}, + APIParameters(), {}, repl::ReadConcernArgs(repl::ReadConcernLevel::kLocalReadConcern), BSONObj(), @@ -294,6 +301,7 @@ TEST_F(CursorManagerTest, InactiveKilledCursorsShouldTimeout) { {makeFakePlanExecutor(), NamespaceString{"test.collection"}, {}, + APIParameters(), {}, repl::ReadConcernArgs(repl::ReadConcernLevel::kLocalReadConcern), BSONObj(), @@ -326,6 +334,7 @@ TEST_F(CursorManagerTest, UsingACursorShouldUpdateTimeOfLastUse) { {makeFakePlanExecutor(), kTestNss, {}, + APIParameters(), {}, repl::ReadConcernArgs(repl::ReadConcernLevel::kLocalReadConcern), BSONObj(), @@ -339,6 +348,7 @@ TEST_F(CursorManagerTest, UsingACursorShouldUpdateTimeOfLastUse) { {makeFakePlanExecutor(), kTestNss, {}, + APIParameters(), {}, repl::ReadConcernArgs(repl::ReadConcernLevel::kLocalReadConcern), BSONObj(), @@ -376,6 +386,7 @@ TEST_F(CursorManagerTest, CursorShouldNotTimeOutUntilIdleForLongEnoughAfterBeing {makeFakePlanExecutor(), kTestNss, {}, + APIParameters(), {}, repl::ReadConcernArgs(repl::ReadConcernLevel::kLocalReadConcern), BSONObj(), @@ -403,6 +414,34 @@ TEST_F(CursorManagerTest, CursorShouldNotTimeOutUntilIdleForLongEnoughAfterBeing } /** + * Test that a cursor correctly stores API parameters. + */ +TEST_F(CursorManagerTest, CursorStoresAPIParameters) { + APIParameters apiParams = APIParameters(); + apiParams.setAPIVersion("2"); + apiParams.setAPIStrict(true); + apiParams.setAPIDeprecationErrors(true); + + CursorManager* cursorManager = useCursorManager(); + auto cursorPin = cursorManager->registerCursor( + _opCtx.get(), + {makeFakePlanExecutor(), + kTestNss, + {}, + apiParams, + {}, + repl::ReadConcernArgs(repl::ReadConcernLevel::kLocalReadConcern), + BSONObj(), + PrivilegeVector()}); + + auto storedAPIParams = cursorPin->getAPIParameters(); + + ASSERT_EQ(apiParams.getAPIVersion(), storedAPIParams.getAPIVersion()); + ASSERT_EQ(apiParams.getAPIStrict(), storedAPIParams.getAPIStrict()); + ASSERT_EQ(apiParams.getAPIDeprecationErrors(), storedAPIParams.getAPIDeprecationErrors()); +} + +/** * Test that cursors inherit the logical session id from their operation context */ TEST_F(CursorManagerTestCustomOpCtx, LogicalSessionIdOnOperationCtxTest) { |