summaryrefslogtreecommitdiff
path: root/src/mongo/db/storage/sorted_data_interface_test_insert.cpp
diff options
context:
space:
mode:
authorAndy Schwerin <schwerin@mongodb.com>2016-05-24 16:34:45 -0400
committerAndy Schwerin <schwerin@mongodb.com>2016-06-03 12:48:38 -0400
commit910e782aa5d8329c5e8b2531cf0116052e8a187e (patch)
tree8c7b17d5808ffaf4b8b9c4ff6a973e34d4b851eb /src/mongo/db/storage/sorted_data_interface_test_insert.cpp
parent0b5cbbadf49da830f20fba6e779b7278f211e394 (diff)
downloadmongo-910e782aa5d8329c5e8b2531cf0116052e8a187e.tar.gz
SERVER-23905 Unify lifetime management for LockState on OperationContexts into OperationContext.
This change also moves responsibility for registering OperationContexts to Clients into ServiceContext::makeOperationContext.
Diffstat (limited to 'src/mongo/db/storage/sorted_data_interface_test_insert.cpp')
-rw-r--r--src/mongo/db/storage/sorted_data_interface_test_insert.cpp74
1 files changed, 39 insertions, 35 deletions
diff --git a/src/mongo/db/storage/sorted_data_interface_test_insert.cpp b/src/mongo/db/storage/sorted_data_interface_test_insert.cpp
index 71ec797cc17..5c10b1f6828 100644
--- a/src/mongo/db/storage/sorted_data_interface_test_insert.cpp
+++ b/src/mongo/db/storage/sorted_data_interface_test_insert.cpp
@@ -43,12 +43,12 @@ TEST(SortedDataInterface, Insert) {
const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
{
- const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
+ const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
ASSERT(sorted->isEmpty(opCtx.get()));
}
{
- const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
+ const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
{
WriteUnitOfWork uow(opCtx.get());
ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, true));
@@ -57,7 +57,7 @@ TEST(SortedDataInterface, Insert) {
}
{
- const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
+ const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
ASSERT_EQUALS(1, sorted->numEntries(opCtx.get()));
}
}
@@ -68,12 +68,12 @@ TEST(SortedDataInterface, InsertCompoundKey) {
const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
{
- const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
+ const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
ASSERT(sorted->isEmpty(opCtx.get()));
}
{
- const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
+ const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
{
WriteUnitOfWork uow(opCtx.get());
ASSERT_OK(sorted->insert(opCtx.get(), compoundKey1a, loc1, true));
@@ -82,7 +82,7 @@ TEST(SortedDataInterface, InsertCompoundKey) {
}
{
- const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
+ const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
ASSERT_EQUALS(1, sorted->numEntries(opCtx.get()));
}
}
@@ -95,12 +95,12 @@ TEST(SortedDataInterface, InsertSameDiskLoc) {
const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
{
- const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
+ const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
ASSERT(sorted->isEmpty(opCtx.get()));
}
{
- const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
+ const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
{
WriteUnitOfWork uow(opCtx.get());
ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, true));
@@ -110,12 +110,12 @@ TEST(SortedDataInterface, InsertSameDiskLoc) {
}
{
- const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
+ const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
ASSERT_EQUALS(2, sorted->numEntries(opCtx.get()));
}
{
- const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
+ const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
{
WriteUnitOfWork uow(opCtx.get());
ASSERT_OK(sorted->insert(opCtx.get(), key3, loc1, true));
@@ -124,7 +124,7 @@ TEST(SortedDataInterface, InsertSameDiskLoc) {
}
{
- const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
+ const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
ASSERT_EQUALS(3, sorted->numEntries(opCtx.get()));
}
}
@@ -137,12 +137,12 @@ TEST(SortedDataInterface, InsertSameDiskLocWithDupsAllowed) {
const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(true));
{
- const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
+ const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
ASSERT(sorted->isEmpty(opCtx.get()));
}
{
- const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
+ const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
{
WriteUnitOfWork uow(opCtx.get());
ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, false));
@@ -152,12 +152,12 @@ TEST(SortedDataInterface, InsertSameDiskLocWithDupsAllowed) {
}
{
- const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
+ const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
ASSERT_EQUALS(2, sorted->numEntries(opCtx.get()));
}
{
- const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
+ const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
{
WriteUnitOfWork uow(opCtx.get());
ASSERT_OK(sorted->insert(opCtx.get(), key3, loc1, true /* allow duplicates */));
@@ -166,7 +166,7 @@ TEST(SortedDataInterface, InsertSameDiskLocWithDupsAllowed) {
}
{
- const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
+ const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
ASSERT_EQUALS(3, sorted->numEntries(opCtx.get()));
}
}
@@ -178,12 +178,12 @@ TEST(SortedDataInterface, InsertSameKey) {
const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(true));
{
- const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
+ const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
ASSERT(sorted->isEmpty(opCtx.get()));
}
{
- const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
+ const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
{
WriteUnitOfWork uow(opCtx.get());
ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, false));
@@ -193,12 +193,12 @@ TEST(SortedDataInterface, InsertSameKey) {
}
{
- const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
+ const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
ASSERT_EQUALS(1, sorted->numEntries(opCtx.get()));
}
{
- const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
+ const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
{
WriteUnitOfWork uow(opCtx.get());
ASSERT_NOT_OK(sorted->insert(opCtx.get(), key1, loc2, false));
@@ -207,7 +207,7 @@ TEST(SortedDataInterface, InsertSameKey) {
}
{
- const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
+ const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
ASSERT_EQUALS(1, sorted->numEntries(opCtx.get()));
}
}
@@ -225,12 +225,14 @@ void _testInsertSameKeyWithDupsAllowed(const RecordId locs[3]) {
harnessHelper->newSortedDataInterface(true));
{
- const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
+ const ServiceContext::UniqueOperationContext opCtx(
+ harnessHelper->newOperationContext());
ASSERT(sorted->isEmpty(opCtx.get()));
}
{
- const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
+ const ServiceContext::UniqueOperationContext opCtx(
+ harnessHelper->newOperationContext());
{
WriteUnitOfWork uow(opCtx.get());
ASSERT_OK(sorted->insert(opCtx.get(), key1, locs[0], false));
@@ -241,7 +243,8 @@ void _testInsertSameKeyWithDupsAllowed(const RecordId locs[3]) {
}
{
- const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
+ const ServiceContext::UniqueOperationContext opCtx(
+ harnessHelper->newOperationContext());
{
WriteUnitOfWork uow(opCtx.get());
for (int i = 0; i < 3; i++) {
@@ -254,7 +257,8 @@ void _testInsertSameKeyWithDupsAllowed(const RecordId locs[3]) {
}
{
- const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
+ const ServiceContext::UniqueOperationContext opCtx(
+ harnessHelper->newOperationContext());
ASSERT_EQUALS(1, sorted->numEntries(opCtx.get()));
const std::unique_ptr<SortedDataInterface::Cursor> cursor(
@@ -283,12 +287,12 @@ TEST(SortedDataInterface, InsertMultiple) {
const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(true));
{
- const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
+ const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
ASSERT(sorted->isEmpty(opCtx.get()));
}
{
- const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
+ const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
{
WriteUnitOfWork uow(opCtx.get());
ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, false));
@@ -298,12 +302,12 @@ TEST(SortedDataInterface, InsertMultiple) {
}
{
- const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
+ const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
ASSERT_EQUALS(2, sorted->numEntries(opCtx.get()));
}
{
- const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
+ const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
{
WriteUnitOfWork uow(opCtx.get());
ASSERT_OK(sorted->insert(opCtx.get(), key3, loc3, false));
@@ -312,7 +316,7 @@ TEST(SortedDataInterface, InsertMultiple) {
}
{
- const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
+ const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
ASSERT_EQUALS(3, sorted->numEntries(opCtx.get()));
}
}
@@ -324,12 +328,12 @@ TEST(SortedDataInterface, InsertMultipleCompoundKeys) {
const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(true));
{
- const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
+ const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
ASSERT(sorted->isEmpty(opCtx.get()));
}
{
- const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
+ const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
{
WriteUnitOfWork uow(opCtx.get());
ASSERT_OK(sorted->insert(opCtx.get(), compoundKey1a, loc1, false));
@@ -340,12 +344,12 @@ TEST(SortedDataInterface, InsertMultipleCompoundKeys) {
}
{
- const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
+ const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
ASSERT_EQUALS(3, sorted->numEntries(opCtx.get()));
}
{
- const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
+ const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
{
WriteUnitOfWork uow(opCtx.get());
ASSERT_OK(sorted->insert(opCtx.get(), compoundKey1c, loc4, false));
@@ -355,7 +359,7 @@ TEST(SortedDataInterface, InsertMultipleCompoundKeys) {
}
{
- const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());
+ const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
ASSERT_EQUALS(5, sorted->numEntries(opCtx.get()));
}
}