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