diff options
Diffstat (limited to 'src/mongo/dbtests/rollbacktests.cpp')
-rw-r--r-- | src/mongo/dbtests/rollbacktests.cpp | 118 |
1 files changed, 55 insertions, 63 deletions
diff --git a/src/mongo/dbtests/rollbacktests.cpp b/src/mongo/dbtests/rollbacktests.cpp index bade34cb7ea..3d3523e4268 100644 --- a/src/mongo/dbtests/rollbacktests.cpp +++ b/src/mongo/dbtests/rollbacktests.cpp @@ -54,7 +54,7 @@ const auto kIndexVersion = IndexDescriptor::IndexVersion::kV2; void dropDatabase(OperationContext* opCtx, const NamespaceString& nss) { Lock::GlobalWrite globalWriteLock(opCtx); - Database* db = DatabaseHolder::getDatabaseHolder().get(opCtx, nss.db()); + Database* db = dbHolder().get(opCtx, nss.db()); if (db) { Database::dropDatabase(opCtx, db); @@ -72,7 +72,7 @@ void createCollection(OperationContext* opCtx, const NamespaceString& nss) { { WriteUnitOfWork uow(opCtx); ASSERT(!collectionExists(&ctx, nss.ns())); - ASSERT_OK(Database::userCreateNS( + ASSERT_OK(userCreateNS( opCtx, ctx.db(), nss.ns(), BSONObj(), CollectionOptions::parseForCommand, false)); ASSERT(collectionExists(&ctx, nss.ns())); uow.commit(); @@ -85,20 +85,17 @@ Status renameCollection(OperationContext* opCtx, return renameCollection(opCtx, source, target, {}); } Status truncateCollection(OperationContext* opCtx, const NamespaceString& nss) { - Collection* coll = - DatabaseHolder::getDatabaseHolder().get(opCtx, nss.db())->getCollection(opCtx, nss); + Collection* coll = dbHolder().get(opCtx, nss.db())->getCollection(opCtx, nss); return coll->truncate(opCtx); } void insertRecord(OperationContext* opCtx, const NamespaceString& nss, const BSONObj& data) { - Collection* coll = - DatabaseHolder::getDatabaseHolder().get(opCtx, nss.db())->getCollection(opCtx, nss); + Collection* coll = dbHolder().get(opCtx, nss.db())->getCollection(opCtx, nss); OpDebug* const nullOpDebug = nullptr; ASSERT_OK(coll->insertDocument(opCtx, InsertStatement(data), nullOpDebug, false)); } void assertOnlyRecord(OperationContext* opCtx, const NamespaceString& nss, const BSONObj& data) { - Collection* coll = - DatabaseHolder::getDatabaseHolder().get(opCtx, nss.db())->getCollection(opCtx, nss); + Collection* coll = dbHolder().get(opCtx, nss.db())->getCollection(opCtx, nss); auto cursor = coll->getCursor(opCtx); auto record = cursor->next(); @@ -108,18 +105,15 @@ void assertOnlyRecord(OperationContext* opCtx, const NamespaceString& nss, const ASSERT(!cursor->next()); } void assertEmpty(OperationContext* opCtx, const NamespaceString& nss) { - Collection* coll = - DatabaseHolder::getDatabaseHolder().get(opCtx, nss.db())->getCollection(opCtx, nss); + Collection* coll = dbHolder().get(opCtx, nss.db())->getCollection(opCtx, nss); ASSERT(!coll->getCursor(opCtx)->next()); } bool indexExists(OperationContext* opCtx, const NamespaceString& nss, const string& idxName) { - Collection* coll = - DatabaseHolder::getDatabaseHolder().get(opCtx, nss.db())->getCollection(opCtx, nss); + Collection* coll = dbHolder().get(opCtx, nss.db())->getCollection(opCtx, nss); return coll->getIndexCatalog()->findIndexByName(opCtx, idxName, true) != NULL; } bool indexReady(OperationContext* opCtx, const NamespaceString& nss, const string& idxName) { - Collection* coll = - DatabaseHolder::getDatabaseHolder().get(opCtx, nss.db())->getCollection(opCtx, nss); + Collection* coll = dbHolder().get(opCtx, nss.db())->getCollection(opCtx, nss); return coll->getIndexCatalog()->findIndexByName(opCtx, idxName, false) != NULL; } size_t getNumIndexEntries(OperationContext* opCtx, @@ -127,8 +121,7 @@ size_t getNumIndexEntries(OperationContext* opCtx, const string& idxName) { size_t numEntries = 0; - Collection* coll = - DatabaseHolder::getDatabaseHolder().get(opCtx, nss.db())->getCollection(opCtx, nss); + Collection* coll = dbHolder().get(opCtx, nss.db())->getCollection(opCtx, nss); IndexCatalog* catalog = coll->getIndexCatalog(); IndexDescriptor* desc = catalog->findIndexByName(opCtx, idxName, false); @@ -144,8 +137,7 @@ size_t getNumIndexEntries(OperationContext* opCtx, } void dropIndex(OperationContext* opCtx, const NamespaceString& nss, const string& idxName) { - Collection* coll = - DatabaseHolder::getDatabaseHolder().get(opCtx, nss.db())->getCollection(opCtx, nss); + Collection* coll = dbHolder().get(opCtx, nss.db())->getCollection(opCtx, nss); IndexDescriptor* desc = coll->getIndexCatalog()->findIndexByName(opCtx, idxName); ASSERT(desc); ASSERT_OK(coll->getIndexCatalog()->dropIndex(opCtx, desc)); @@ -168,7 +160,7 @@ public: WriteUnitOfWork uow(&opCtx); ASSERT(!collectionExists(&ctx, ns)); auto options = capped ? BSON("capped" << true << "size" << 1000) : BSONObj(); - ASSERT_OK(Database::userCreateNS( + ASSERT_OK(userCreateNS( &opCtx, ctx.db(), ns, options, CollectionOptions::parseForCommand, defaultIndexes)); ASSERT(collectionExists(&ctx, ns)); if (!rollback) { @@ -199,7 +191,7 @@ public: WriteUnitOfWork uow(&opCtx); ASSERT(!collectionExists(&ctx, ns)); auto options = capped ? BSON("capped" << true << "size" << 1000) : BSONObj(); - ASSERT_OK(Database::userCreateNS( + ASSERT_OK(userCreateNS( &opCtx, ctx.db(), ns, options, CollectionOptions::parseForCommand, defaultIndexes)); uow.commit(); } @@ -244,12 +236,12 @@ public: ASSERT(!collectionExists(&ctx, source.ns())); ASSERT(!collectionExists(&ctx, target.ns())); auto options = capped ? BSON("capped" << true << "size" << 1000) : BSONObj(); - ASSERT_OK(Database::userCreateNS(&opCtx, - ctx.db(), - source.ns(), - options, - CollectionOptions::parseForCommand, - defaultIndexes)); + ASSERT_OK(userCreateNS(&opCtx, + ctx.db(), + source.ns(), + options, + CollectionOptions::parseForCommand, + defaultIndexes)); uow.commit(); } ASSERT(collectionExists(&ctx, source.ns())); @@ -301,18 +293,18 @@ public: ASSERT(!collectionExists(&ctx, source.ns())); ASSERT(!collectionExists(&ctx, target.ns())); auto options = capped ? BSON("capped" << true << "size" << 1000) : BSONObj(); - ASSERT_OK(Database::userCreateNS(&opCtx, - ctx.db(), - source.ns(), - options, - CollectionOptions::parseForCommand, - defaultIndexes)); - ASSERT_OK(Database::userCreateNS(&opCtx, - ctx.db(), - target.ns(), - options, - CollectionOptions::parseForCommand, - defaultIndexes)); + ASSERT_OK(userCreateNS(&opCtx, + ctx.db(), + source.ns(), + options, + CollectionOptions::parseForCommand, + defaultIndexes)); + ASSERT_OK(userCreateNS(&opCtx, + ctx.db(), + target.ns(), + options, + CollectionOptions::parseForCommand, + defaultIndexes)); insertRecord(&opCtx, source, sourceDoc); insertRecord(&opCtx, target, targetDoc); @@ -376,12 +368,12 @@ public: { WriteUnitOfWork uow(&opCtx); ASSERT(!collectionExists(&ctx, nss.ns())); - ASSERT_OK(Database::userCreateNS(&opCtx, - ctx.db(), - nss.ns(), - BSONObj(), - CollectionOptions::parseForCommand, - defaultIndexes)); + ASSERT_OK(userCreateNS(&opCtx, + ctx.db(), + nss.ns(), + BSONObj(), + CollectionOptions::parseForCommand, + defaultIndexes)); insertRecord(&opCtx, nss, oldDoc); uow.commit(); } @@ -400,12 +392,12 @@ public: {}, DropCollectionSystemCollectionMode::kDisallowSystemCollectionDrops)); ASSERT(!collectionExists(&ctx, nss.ns())); - ASSERT_OK(Database::userCreateNS(&opCtx, - ctx.db(), - nss.ns(), - BSONObj(), - CollectionOptions::parseForCommand, - defaultIndexes)); + ASSERT_OK(userCreateNS(&opCtx, + ctx.db(), + nss.ns(), + BSONObj(), + CollectionOptions::parseForCommand, + defaultIndexes)); ASSERT(collectionExists(&ctx, nss.ns())); insertRecord(&opCtx, nss, newDoc); assertOnlyRecord(&opCtx, nss, newDoc); @@ -441,12 +433,12 @@ public: { WriteUnitOfWork uow(&opCtx); - ASSERT_OK(Database::userCreateNS(&opCtx, - ctx.db(), - nss.ns(), - BSONObj(), - CollectionOptions::parseForCommand, - defaultIndexes)); + ASSERT_OK(userCreateNS(&opCtx, + ctx.db(), + nss.ns(), + BSONObj(), + CollectionOptions::parseForCommand, + defaultIndexes)); ASSERT(collectionExists(&ctx, nss.ns())); insertRecord(&opCtx, nss, doc); assertOnlyRecord(&opCtx, nss, doc); @@ -487,12 +479,12 @@ public: { WriteUnitOfWork uow(&opCtx); - ASSERT_OK(Database::userCreateNS(&opCtx, - ctx.db(), - nss.ns(), - BSONObj(), - CollectionOptions::parseForCommand, - defaultIndexes)); + ASSERT_OK(userCreateNS(&opCtx, + ctx.db(), + nss.ns(), + BSONObj(), + CollectionOptions::parseForCommand, + defaultIndexes)); ASSERT(collectionExists(&ctx, nss.ns())); insertRecord(&opCtx, nss, doc); assertOnlyRecord(&opCtx, nss, doc); @@ -751,7 +743,7 @@ public: { WriteUnitOfWork uow(&opCtx); ASSERT(!collectionExists(&ctx, nss.ns())); - ASSERT_OK(Database::userCreateNS( + ASSERT_OK(userCreateNS( &opCtx, ctx.db(), nss.ns(), BSONObj(), CollectionOptions::parseForCommand, false)); ASSERT(collectionExists(&ctx, nss.ns())); Collection* coll = ctx.db()->getCollection(&opCtx, nss); |