diff options
author | Pierlauro Sciarelli <pierlauro.sciarelli@mongodb.com> | 2020-07-24 16:45:21 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-07-27 10:34:38 +0000 |
commit | 4dab9b9781f943fcd7e2f15e61bdbce9953d0e23 (patch) | |
tree | f75410bc446d3b9acca6de8271b6a07180ac3296 /src/mongo/db/vector_clock_mongod_test.cpp | |
parent | 21a3ee6079eb3cc83a5210cf53d98840cbc83a20 (diff) | |
download | mongo-4dab9b9781f943fcd7e2f15e61bdbce9953d0e23.tar.gz |
SERVER-49400 Differenciate VectorClock persist behavior based on cluster role
Diffstat (limited to 'src/mongo/db/vector_clock_mongod_test.cpp')
-rw-r--r-- | src/mongo/db/vector_clock_mongod_test.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/mongo/db/vector_clock_mongod_test.cpp b/src/mongo/db/vector_clock_mongod_test.cpp index 6b8a9d663f0..d59d947bd90 100644 --- a/src/mongo/db/vector_clock_mongod_test.cpp +++ b/src/mongo/db/vector_clock_mongod_test.cpp @@ -33,6 +33,7 @@ #include "mongo/db/keys_collection_manager.h" #include "mongo/db/logical_time_validator.h" #include "mongo/db/persistent_task_store.h" +#include "mongo/db/repl/replication_coordinator_mock.h" #include "mongo/db/s/sharding_mongod_test_fixture.h" #include "mongo/db/vector_clock_document_gen.h" #include "mongo/db/vector_clock_mutable.h" @@ -84,6 +85,22 @@ private: std::shared_ptr<KeysCollectionManager> _keyManager; }; +class VectorClockMongoDTestPrimary : public VectorClockMongoDTest { +protected: + void setUp() override { + VectorClockMongoDTest::setUp(); + + serverGlobalParams.clusterRole = ClusterRole::ShardServer; + + auto replCoord = repl::ReplicationCoordinator::get(operationContext()); + ASSERT_OK(replCoord->setFollowerMode(repl::MemberState::RS_PRIMARY)); + } + + void tearDown() override { + VectorClockMongoDTest::tearDown(); + } +}; + TEST_F(VectorClockMongoDTest, TickClusterTime) { auto sc = getServiceContext(); auto vc = VectorClockMutable::get(sc); @@ -281,7 +298,7 @@ TEST_F(VectorClockMongoDTest, GossipInExternal) { ASSERT_EQ(afterTime3.topologyTime().asTimestamp(), Timestamp(0, 0)); } -TEST_F(VectorClockMongoDTest, PersistVectorClockDocument) { +TEST_F(VectorClockMongoDTestPrimary, PersistVectorClockDocument) { auto sc = getServiceContext(); auto opCtx = operationContext(); @@ -306,7 +323,7 @@ TEST_F(VectorClockMongoDTest, PersistVectorClockDocument) { ASSERT_EQUALS(store.count(opCtx, VectorClock::stateQuery()), 1); } -TEST_F(VectorClockMongoDTest, RecoverVectorClockDocument) { +TEST_F(VectorClockMongoDTestPrimary, RecoverVectorClockDocument) { auto sc = getServiceContext(); auto opCtx = operationContext(); const auto configTime = LogicalTime(Timestamp(3, 3)); @@ -335,7 +352,7 @@ TEST_F(VectorClockMongoDTest, RecoverVectorClockDocument) { ASSERT_EQUALS(actualTopologyTime, topologyTime); } -TEST_F(VectorClockMongoDTest, RecoverNotExistingVectorClockDocument) { +TEST_F(VectorClockMongoDTestPrimary, RecoverNotExistingVectorClockDocument) { auto sc = getServiceContext(); auto opCtx = operationContext(); auto vc = VectorClockMutable::get(sc); @@ -364,7 +381,7 @@ TEST_F(VectorClockMongoDTest, RecoverNotExistingVectorClockDocument) { ASSERT_EQUALS(actualTopologyTime, topologyTime); } -TEST_F(VectorClockMongoDTest, SubsequentPersistRecoverVectorClockDocument) { +TEST_F(VectorClockMongoDTestPrimary, SubsequentPersistRecoverVectorClockDocument) { auto sc = getServiceContext(); auto opCtx = operationContext(); auto vc = VectorClockMutable::get(sc); |