diff options
author | Vesselina Ratcheva <vesselina.ratcheva@10gen.com> | 2018-02-20 18:46:07 -0500 |
---|---|---|
committer | Vesselina Ratcheva <vesselina.ratcheva@10gen.com> | 2018-02-28 19:07:55 -0500 |
commit | 6168a6e7f5586ffc273888bec73b76c1184105bd (patch) | |
tree | 685e0ed7a677def78f10da144cc6b9caadadd31d /src/mongo/db/repl/topology_coordinator_v1_test.cpp | |
parent | e25af89eaa5fcfd3b5395b766eef4c7d93f44442 (diff) | |
download | mongo-6168a6e7f5586ffc273888bec73b76c1184105bd.tar.gz |
SERVER-33383 Prevent internal replSetStepDown from racing with stepdown via heartbeat
Diffstat (limited to 'src/mongo/db/repl/topology_coordinator_v1_test.cpp')
-rw-r--r-- | src/mongo/db/repl/topology_coordinator_v1_test.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/mongo/db/repl/topology_coordinator_v1_test.cpp b/src/mongo/db/repl/topology_coordinator_v1_test.cpp index e403b021400..010910cac91 100644 --- a/src/mongo/db/repl/topology_coordinator_v1_test.cpp +++ b/src/mongo/db/repl/topology_coordinator_v1_test.cpp @@ -1767,6 +1767,23 @@ TEST_F(TopoCoordTest, HeartbeatFrequencyShouldBeHalfElectionTimeoutWhenArbiter) ASSERT_EQUALS(expected, action.getNextHeartbeatStartDate()); } +TEST_F(TopoCoordTest, PrepareStepDownAttemptFailsIfNotLeader) { + updateConfig(BSON("_id" + << "rs0" + << "version" + << 5 + << "members" + << BSON_ARRAY(BSON("_id" << 0 << "host" + << "host1:27017")) + << "protocolVersion" + << 1), + 0); + getTopoCoord().changeMemberState_forTest(MemberState::RS_SECONDARY); + Status expectedStatus(ErrorCodes::NotMaster, "This node is not a primary. "); + + ASSERT_EQUALS(expectedStatus, getTopoCoord().prepareForStepDownAttempt()); +} + class PrepareHeartbeatResponseV1Test : public TopoCoordTest { public: virtual void setUp() { |