diff options
author | Randolph Tan <randolph@10gen.com> | 2017-08-18 20:19:59 -0400 |
---|---|---|
committer | Randolph Tan <randolph@10gen.com> | 2017-08-26 02:14:50 -0400 |
commit | dc8a9cc980e84734d90ffc0f71c50c123cdd9543 (patch) | |
tree | 3357fd45cf8d3ddfdae938aed58a85e545a14344 /src/mongo/db/transaction_history_iterator_test.cpp | |
parent | ec42f5f16ff7809c5b1ed29601978e9e98aa5925 (diff) | |
download | mongo-dc8a9cc980e84734d90ffc0f71c50c123cdd9543.tar.gz |
SERVER-28914 Create a test fixture with mock replication coordinator and ephemeral storage engine
Diffstat (limited to 'src/mongo/db/transaction_history_iterator_test.cpp')
-rw-r--r-- | src/mongo/db/transaction_history_iterator_test.cpp | 58 |
1 files changed, 2 insertions, 56 deletions
diff --git a/src/mongo/db/transaction_history_iterator_test.cpp b/src/mongo/db/transaction_history_iterator_test.cpp index 18464573f94..687ced1b8cf 100644 --- a/src/mongo/db/transaction_history_iterator_test.cpp +++ b/src/mongo/db/transaction_history_iterator_test.cpp @@ -37,6 +37,7 @@ #include "mongo/db/dbdirectclient.h" #include "mongo/db/namespace_string.h" #include "mongo/db/operation_context.h" +#include "mongo/db/repl/mock_repl_coord_server_fixture.h" #include "mongo/db/repl/oplog.h" #include "mongo/db/repl/oplog_entry.h" #include "mongo/db/repl/optime.h" @@ -49,62 +50,7 @@ namespace mongo { -class SessionHistoryIteratorTest : public ServiceContextMongoDTest { -public: - void setUp() override { - ServiceContextMongoDTest::setUp(); - - _opCtx = cc().makeOperationContext(); - - // Insert code path assumes existence of repl coordinator! - repl::ReplSettings replSettings; - replSettings.setReplSetString( - ConnectionString::forReplicaSet("sessionTxnStateTest", {HostAndPort("a:1")}) - .toString()); - replSettings.setMaster(true); - - auto service = getServiceContext(); - repl::ReplicationCoordinator::set( - service, stdx::make_unique<repl::ReplicationCoordinatorMock>(service, replSettings)); - - // Note: internal code does not allow implicit creation of non-capped oplog collection. - DBDirectClient client(opCtx()); - ASSERT_TRUE( - client.createCollection(NamespaceString::kRsOplogNamespace.ns(), 1024 * 1024, true)); - } - - void tearDown() override { - // ServiceContextMongoDTest::tearDown() will try to create it's own opCtx, and it's not - // allowed to have 2 present per client, so destroy this one. - _opCtx.reset(); - - ServiceContextMongoDTest::tearDown(); - } - - /** - * Helper method for inserting new entries to the oplog. This completely bypasses - * fixDocumentForInsert. - */ - void insertOplogEntry(const repl::OplogEntry newOplog) { - AutoGetCollection autoColl(opCtx(), NamespaceString::kRsOplogNamespace, MODE_IX); - auto coll = autoColl.getCollection(); - ASSERT_TRUE(coll != nullptr); - - auto status = coll->insertDocument(opCtx(), - InsertStatement(newOplog.toBSON()), - &CurOp::get(opCtx())->debug(), - /* enforceQuota */ false, - /* fromMigrate */ false); - ASSERT_OK(status); - } - - OperationContext* opCtx() { - return _opCtx.get(); - } - -private: - ServiceContext::UniqueOperationContext _opCtx; -}; +using SessionHistoryIteratorTest = MockReplCoordServerFixture; TEST_F(SessionHistoryIteratorTest, NormalHistory) { repl::OplogEntry entry1(repl::OpTime(Timestamp(52, 345), 2), |