diff options
author | Jason Chan <jason.chan@10gen.com> | 2019-04-08 12:55:52 -0400 |
---|---|---|
committer | Jason Chan <jason.chan@10gen.com> | 2019-04-08 13:49:56 -0400 |
commit | ac77a440f9df976234c2fe92c6726348e592ca8d (patch) | |
tree | e1bb1ad9c0b786750740d1edc7f5b152af2ccdcb /src/mongo/db/repl/sync_tail_test_fixture.cpp | |
parent | bfa61a6b053de26ca47b7baad7a415f5bcdfae2c (diff) | |
download | mongo-ac77a440f9df976234c2fe92c6726348e592ca8d.tar.gz |
SERVER-39793 Update the state in transaction table for running transactions on secondary
Diffstat (limited to 'src/mongo/db/repl/sync_tail_test_fixture.cpp')
-rw-r--r-- | src/mongo/db/repl/sync_tail_test_fixture.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/mongo/db/repl/sync_tail_test_fixture.cpp b/src/mongo/db/repl/sync_tail_test_fixture.cpp index 7811b128fc8..9e9b5ed6fab 100644 --- a/src/mongo/db/repl/sync_tail_test_fixture.cpp +++ b/src/mongo/db/repl/sync_tail_test_fixture.cpp @@ -34,6 +34,7 @@ #include "mongo/db/catalog/document_validation.h" #include "mongo/db/curop.h" #include "mongo/db/db_raii.h" +#include "mongo/db/dbdirectclient.h" #include "mongo/db/op_observer_registry.h" #include "mongo/db/repl/drop_pending_collection_reaper.h" #include "mongo/db/repl/replication_consistency_markers_mock.h" @@ -248,6 +249,34 @@ Status SyncTailTest::runOpsInitialSync(std::vector<OplogEntry> ops) { return Status::OK(); } +void checkTxnTable(OperationContext* opCtx, + const LogicalSessionId& lsid, + const TxnNumber& txnNum, + const repl::OpTime& expectedOpTime, + Date_t expectedWallClock, + boost::optional<repl::OpTime> expectedStartOpTime, + boost::optional<DurableTxnStateEnum> expectedState) { + DBDirectClient client(opCtx); + auto result = client.findOne(NamespaceString::kSessionTransactionsTableNamespace.ns(), + {BSON(SessionTxnRecord::kSessionIdFieldName << lsid.toBSON())}); + ASSERT_FALSE(result.isEmpty()); + + auto txnRecord = + SessionTxnRecord::parse(IDLParserErrorContext("parse txn record for test"), result); + + ASSERT_EQ(txnNum, txnRecord.getTxnNum()); + ASSERT_EQ(expectedOpTime, txnRecord.getLastWriteOpTime()); + ASSERT_EQ(expectedWallClock, txnRecord.getLastWriteDate()); + if (expectedStartOpTime) { + ASSERT(txnRecord.getStartOpTime()); + ASSERT_EQ(*expectedStartOpTime, *txnRecord.getStartOpTime()); + } else { + ASSERT(!txnRecord.getStartOpTime()); + } + if (expectedState) { + ASSERT(*expectedState == txnRecord.getState()); + } +} } // namespace repl } // namespace mongo |