Skip to content

Commit fed9947

Browse files
author
matt dannenberg
committed
SERVER-15062 more prepareElectResponse tests
1 parent 5ec8c6a commit fed9947

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/mongo/db/repl/topology_coordinator_impl_test.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1733,6 +1733,28 @@ namespace {
17331733
ASSERT_EQUALS(round, response2["round"].OID());
17341734
}
17351735

1736+
TEST_F(PrepareElectResponseTest, ElectResponseHighestPriorityOfLiveNodes) {
1737+
// Test trying to elect someone who isn't the highest priority node, but all higher nodes
1738+
// are down
1739+
ReplicationCoordinator::ReplSetElectArgs args;
1740+
args.set = "rs0";
1741+
args.round = round;
1742+
args.cfgver = 10;
1743+
args.whoid = 1;
1744+
1745+
downMember(HostAndPort("h3"), "rs0");
1746+
downMember(HostAndPort("h2"), "rs0");
1747+
1748+
BSONObjBuilder responseBuilder;
1749+
Status result = Status::OK();
1750+
startCapturingLogMessages();
1751+
getTopoCoord().prepareElectResponse(cbData, args, now++, &responseBuilder, &result);
1752+
stopCapturingLogMessages();
1753+
BSONObj response = responseBuilder.obj();
1754+
ASSERT_EQUALS(1, response["vote"].Int());
1755+
ASSERT_EQUALS(round, response["round"].OID());
1756+
}
1757+
17361758
TEST_F(PrepareElectResponseTest, ElectResponseValidVotes) {
17371759
// Test a valid vote
17381760
ReplicationCoordinator::ReplSetElectArgs args;

0 commit comments

Comments
 (0)