summaryrefslogtreecommitdiff
path: root/src/mongo/db/s
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2021-04-28 18:40:52 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-04-28 23:01:06 +0000
commit00d3ec0d3a9d7c4077148f528bb1f7293fd1b238 (patch)
treef978b5eb645081d2f73b655ce57dfa86bab12d4b /src/mongo/db/s
parent0ff6ae4f5e0a69a36610b0ea645ad2dd48132926 (diff)
downloadmongo-00d3ec0d3a9d7c4077148f528bb1f7293fd1b238.tar.gz
SERVER-47123 remove AutoGetOrCreateDb from non-catalog unit tests
Diffstat (limited to 'src/mongo/db/s')
-rw-r--r--src/mongo/db/s/implicit_collection_creation_test.cpp12
-rw-r--r--src/mongo/db/s/resharding/resharding_oplog_fetcher_test.cpp5
2 files changed, 9 insertions, 8 deletions
diff --git a/src/mongo/db/s/implicit_collection_creation_test.cpp b/src/mongo/db/s/implicit_collection_creation_test.cpp
index 7754e1acbd2..cd299acf0c8 100644
--- a/src/mongo/db/s/implicit_collection_creation_test.cpp
+++ b/src/mongo/db/s/implicit_collection_creation_test.cpp
@@ -43,11 +43,11 @@ class ImplicitCollectionCreationTest : public ShardServerTestFixture {};
TEST_F(ImplicitCollectionCreationTest, ImplicitCreateDisallowedByDefault) {
NamespaceString nss("ImplicitCreateDisallowedByDefaultDB.TestColl");
- AutoGetOrCreateDb db(operationContext(), nss.db(), MODE_IX);
- Lock::CollectionLock collLock(operationContext(), nss, MODE_IX);
+ AutoGetCollection autoColl(operationContext(), nss, MODE_IX);
+ auto db = autoColl.ensureDbExists();
WriteUnitOfWork wuow(operationContext());
ASSERT_THROWS_CODE(
- uassertStatusOK(db.getDb()->userCreateNS(operationContext(), nss, CollectionOptions{})),
+ uassertStatusOK(db->userCreateNS(operationContext(), nss, CollectionOptions{})),
DBException,
ErrorCodes::CannotImplicitlyCreateCollection);
wuow.commit();
@@ -57,10 +57,10 @@ TEST_F(ImplicitCollectionCreationTest, AllowImplicitCollectionCreate) {
NamespaceString nss("AllowImplicitCollectionCreateDB.TestColl");
OperationShardingState::ScopedAllowImplicitCollectionCreate_UNSAFE unsafeCreateCollection(
operationContext());
- AutoGetOrCreateDb db(operationContext(), nss.db(), MODE_IX);
- Lock::CollectionLock collLock(operationContext(), nss, MODE_IX);
+ AutoGetCollection autoColl(operationContext(), nss, MODE_IX);
+ auto db = autoColl.ensureDbExists();
WriteUnitOfWork wuow(operationContext());
- ASSERT_OK(db.getDb()->userCreateNS(operationContext(), nss, CollectionOptions{}));
+ ASSERT_OK(db->userCreateNS(operationContext(), nss, CollectionOptions{}));
wuow.commit();
}
diff --git a/src/mongo/db/s/resharding/resharding_oplog_fetcher_test.cpp b/src/mongo/db/s/resharding/resharding_oplog_fetcher_test.cpp
index 9712f9ff63c..25d7e6f96a0 100644
--- a/src/mongo/db/s/resharding/resharding_oplog_fetcher_test.cpp
+++ b/src/mongo/db/s/resharding/resharding_oplog_fetcher_test.cpp
@@ -209,7 +209,7 @@ public:
void create(NamespaceString nss) {
writeConflictRetry(_opCtx, "create", nss.ns(), [&] {
- AutoGetOrCreateDb dbRaii(_opCtx, nss.db(), LockMode::MODE_X);
+ AutoGetDb autoDb(_opCtx, nss.db(), LockMode::MODE_X);
WriteUnitOfWork wunit(_opCtx);
if (_opCtx->recoveryUnit()->getCommitTimestamp().isNull()) {
ASSERT_OK(_opCtx->recoveryUnit()->setTimestamp(Timestamp(1, 1)));
@@ -217,7 +217,8 @@ public:
OperationShardingState::ScopedAllowImplicitCollectionCreate_UNSAFE
unsafeCreateCollection(_opCtx);
- ASSERT(dbRaii.getDb()->createCollection(_opCtx, nss));
+ auto db = autoDb.ensureDbExists();
+ ASSERT(db->createCollection(_opCtx, nss)) << nss;
wunit.commit();
});
}