summaryrefslogtreecommitdiff
path: root/src/mongo/db/catalog/multi_index_block_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/catalog/multi_index_block_test.cpp')
-rw-r--r--src/mongo/db/catalog/multi_index_block_test.cpp48
1 files changed, 28 insertions, 20 deletions
diff --git a/src/mongo/db/catalog/multi_index_block_test.cpp b/src/mongo/db/catalog/multi_index_block_test.cpp
index ed5da9d7957..4f379451bec 100644
--- a/src/mongo/db/catalog/multi_index_block_test.cpp
+++ b/src/mongo/db/catalog/multi_index_block_test.cpp
@@ -90,11 +90,12 @@ void MultiIndexBlockTest::tearDown() {
TEST_F(MultiIndexBlockTest, CommitWithoutInsertingDocuments) {
auto indexer = getIndexer();
- AutoGetCollection autoColl(operationContext(), getNSS(), MODE_X);
- Collection* coll = autoColl.getCollection();
+ AutoGetCollection coll(operationContext(), getNSS(), MODE_X);
- auto specs = unittest::assertGet(indexer->init(
- operationContext(), coll, std::vector<BSONObj>(), MultiIndexBlock::kNoopOnInitFn));
+ auto specs = unittest::assertGet(indexer->init(operationContext(),
+ coll.getWritableCollection(),
+ std::vector<BSONObj>(),
+ MultiIndexBlock::kNoopOnInitFn));
ASSERT_EQUALS(0U, specs.size());
ASSERT_OK(indexer->dumpInsertsFromBulk(operationContext()));
@@ -103,7 +104,7 @@ TEST_F(MultiIndexBlockTest, CommitWithoutInsertingDocuments) {
{
WriteUnitOfWork wunit(operationContext());
ASSERT_OK(indexer->commit(operationContext(),
- coll,
+ coll.getWritableCollection(),
MultiIndexBlock::kNoopOnCreateEachFn,
MultiIndexBlock::kNoopOnCommitFn));
wunit.commit();
@@ -113,11 +114,12 @@ TEST_F(MultiIndexBlockTest, CommitWithoutInsertingDocuments) {
TEST_F(MultiIndexBlockTest, CommitAfterInsertingSingleDocument) {
auto indexer = getIndexer();
- AutoGetCollection autoColl(operationContext(), getNSS(), MODE_X);
- Collection* coll = autoColl.getCollection();
+ AutoGetCollection coll(operationContext(), getNSS(), MODE_X);
- auto specs = unittest::assertGet(indexer->init(
- operationContext(), coll, std::vector<BSONObj>(), MultiIndexBlock::kNoopOnInitFn));
+ auto specs = unittest::assertGet(indexer->init(operationContext(),
+ coll.getWritableCollection(),
+ std::vector<BSONObj>(),
+ MultiIndexBlock::kNoopOnInitFn));
ASSERT_EQUALS(0U, specs.size());
ASSERT_OK(indexer->insertSingleDocumentForInitialSyncOrRecovery(operationContext(), {}, {}));
@@ -127,24 +129,26 @@ TEST_F(MultiIndexBlockTest, CommitAfterInsertingSingleDocument) {
{
WriteUnitOfWork wunit(operationContext());
ASSERT_OK(indexer->commit(operationContext(),
- coll,
+ coll.getWritableCollection(),
MultiIndexBlock::kNoopOnCreateEachFn,
MultiIndexBlock::kNoopOnCommitFn));
wunit.commit();
}
// abort() should have no effect after the index build is committed.
- indexer->abortIndexBuild(operationContext(), coll, MultiIndexBlock::kNoopOnCleanUpFn);
+ indexer->abortIndexBuild(
+ operationContext(), coll.getWritableCollection(), MultiIndexBlock::kNoopOnCleanUpFn);
}
TEST_F(MultiIndexBlockTest, AbortWithoutCleanupAfterInsertingSingleDocument) {
auto indexer = getIndexer();
- AutoGetCollection autoColl(operationContext(), getNSS(), MODE_X);
- Collection* coll = autoColl.getCollection();
+ AutoGetCollection coll(operationContext(), getNSS(), MODE_X);
- auto specs = unittest::assertGet(indexer->init(
- operationContext(), coll, std::vector<BSONObj>(), MultiIndexBlock::kNoopOnInitFn));
+ auto specs = unittest::assertGet(indexer->init(operationContext(),
+ coll.getWritableCollection(),
+ std::vector<BSONObj>(),
+ MultiIndexBlock::kNoopOnInitFn));
ASSERT_EQUALS(0U, specs.size());
ASSERT_OK(indexer->insertSingleDocumentForInitialSyncOrRecovery(operationContext(), {}, {}));
auto isResumable = false;
@@ -154,8 +158,7 @@ TEST_F(MultiIndexBlockTest, AbortWithoutCleanupAfterInsertingSingleDocument) {
TEST_F(MultiIndexBlockTest, InitWriteConflictException) {
auto indexer = getIndexer();
- AutoGetCollection autoColl(operationContext(), getNSS(), MODE_X);
- Collection* coll = autoColl.getCollection();
+ AutoGetCollection coll(operationContext(), getNSS(), MODE_X);
BSONObj spec = BSON("key" << BSON("a" << 1) << "name"
<< "a_1"
@@ -164,7 +167,7 @@ TEST_F(MultiIndexBlockTest, InitWriteConflictException) {
{
WriteUnitOfWork wuow(operationContext());
ASSERT_THROWS_CODE(indexer->init(operationContext(),
- coll,
+ coll.getWritableCollection(),
{spec},
[](std::vector<BSONObj>& specs) -> Status {
throw WriteConflictException();
@@ -175,12 +178,17 @@ TEST_F(MultiIndexBlockTest, InitWriteConflictException) {
{
WriteUnitOfWork wuow(operationContext());
- ASSERT_OK(indexer->init(operationContext(), coll, {spec}, MultiIndexBlock::kNoopOnInitFn)
+ ASSERT_OK(indexer
+ ->init(operationContext(),
+ coll.getWritableCollection(),
+ {spec},
+ MultiIndexBlock::kNoopOnInitFn)
.getStatus());
wuow.commit();
}
- indexer->abortIndexBuild(operationContext(), coll, MultiIndexBlock::kNoopOnCleanUpFn);
+ indexer->abortIndexBuild(
+ operationContext(), coll.getWritableCollection(), MultiIndexBlock::kNoopOnCleanUpFn);
}
} // namespace