summaryrefslogtreecommitdiff
path: root/src/mongo/db/transaction_participant_test.cpp
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/transaction_participant_test.cpp
parent0ff6ae4f5e0a69a36610b0ea645ad2dd48132926 (diff)
downloadmongo-00d3ec0d3a9d7c4077148f528bb1f7293fd1b238.tar.gz
SERVER-47123 remove AutoGetOrCreateDb from non-catalog unit tests
Diffstat (limited to 'src/mongo/db/transaction_participant_test.cpp')
-rw-r--r--src/mongo/db/transaction_participant_test.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/mongo/db/transaction_participant_test.cpp b/src/mongo/db/transaction_participant_test.cpp
index 5880f41783b..64b93e4eda2 100644
--- a/src/mongo/db/transaction_participant_test.cpp
+++ b/src/mongo/db/transaction_participant_test.cpp
@@ -257,8 +257,8 @@ protected:
{
// Set up a collection so that TransactionParticipant::prepareTransaction() can safely
// access it.
- AutoGetOrCreateDb autoDb(opCtx(), kNss.db(), MODE_X);
- auto db = autoDb.getDb();
+ AutoGetDb autoDb(opCtx(), kNss.db(), MODE_X);
+ auto db = autoDb.ensureDbExists();
ASSERT_TRUE(db);
WriteUnitOfWork wuow(opCtx());
@@ -334,7 +334,9 @@ void insertTxnRecord(OperationContext* opCtx, unsigned i, DurableTxnStateEnum st
record.setLastWriteOpTime(repl::OpTime(ts, 0));
record.setLastWriteDate(Date_t::now());
- AutoGetOrCreateDb autoDb(opCtx, nss.db(), MODE_X);
+ AutoGetDb autoDb(opCtx, nss.db(), MODE_X);
+ auto db = autoDb.ensureDbExists();
+ ASSERT(db);
WriteUnitOfWork wuow(opCtx);
auto coll = CollectionCatalog::get(opCtx)->lookupCollectionByNamespace(opCtx, nss);
ASSERT(coll);
@@ -592,8 +594,8 @@ TEST_F(TxnParticipantTest, PrepareFailsOnTemporaryCollection) {
// Create a temporary collection so that we can write to it.
{
- AutoGetOrCreateDb autoDb(opCtx(), kNss.db(), MODE_X);
- auto db = autoDb.getDb();
+ AutoGetDb autoDb(opCtx(), kNss.db(), MODE_X);
+ auto db = autoDb.ensureDbExists();
ASSERT_TRUE(db);
WriteUnitOfWork wuow(opCtx());
@@ -4267,7 +4269,9 @@ TEST_F(TxnParticipantTest, OldestActiveTransactionTimestamp) {
auto deleteTxnRecord = [&](unsigned i) {
Timestamp ts(1, i);
- AutoGetOrCreateDb autoDb(opCtx(), nss.db(), MODE_X);
+ AutoGetDb autoDb(opCtx(), nss.db(), MODE_X);
+ auto db = autoDb.ensureDbExists();
+ ASSERT(db);
WriteUnitOfWork wuow(opCtx());
auto coll = CollectionCatalog::get(opCtx())->lookupCollectionByNamespace(opCtx(), nss);
ASSERT(coll);
@@ -4322,7 +4326,9 @@ TEST_F(TxnParticipantTest, OldestActiveTransactionTimestamp) {
TEST_F(TxnParticipantTest, OldestActiveTransactionTimestampTimeout) {
// Block getOldestActiveTimestamp() by locking the config database.
auto nss = NamespaceString::kSessionTransactionsTableNamespace;
- AutoGetOrCreateDb autoDb(opCtx(), nss.db(), MODE_X);
+ AutoGetDb autoDb(opCtx(), nss.db(), MODE_X);
+ auto db = autoDb.ensureDbExists();
+ ASSERT(db);
auto statusWith = TransactionParticipant::getOldestActiveTimestamp(Timestamp());
ASSERT_FALSE(statusWith.isOK());
ASSERT_TRUE(ErrorCodes::isInterruption(statusWith.getStatus().code()));