summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/replication_coordinator_impl_elect_v1_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/repl/replication_coordinator_impl_elect_v1_test.cpp')
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_elect_v1_test.cpp35
1 files changed, 15 insertions, 20 deletions
diff --git a/src/mongo/db/repl/replication_coordinator_impl_elect_v1_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_elect_v1_test.cpp
index f54883200ea..ed6c0febe18 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_elect_v1_test.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_elect_v1_test.cpp
@@ -374,9 +374,9 @@ TEST_F(ReplCoordTest, ElectionFailsWhenInsufficientVotesAreReceivedDuringDryRun)
<< false << "reason"
<< "don't like him much")));
voteRequests++;
- // Check that the node's election candidate metrics are set once it has called an
- // election.
- ASSERT_BSONOBJ_NE(
+
+ // Check that the node's election candidate metrics are not set if a dry run fails.
+ ASSERT_BSONOBJ_EQ(
BSONObj(),
ReplicationMetrics::get(getServiceContext()).getElectionCandidateMetricsBSON());
} else {
@@ -883,7 +883,7 @@ public:
}
void performSuccessfulTakeover(Date_t takeoverTime,
- TopologyCoordinator::StartElectionReason reason,
+ StartElectionReasonEnum reason,
const LastVote& lastVoteExpected) {
startCapturingLogMessages();
simulateSuccessfulV1ElectionAt(takeoverTime);
@@ -898,7 +898,7 @@ public:
ASSERT_EQ(lastVoteExpected.getCandidateIndex(), lastVote.getValue().getCandidateIndex());
ASSERT_EQ(lastVoteExpected.getTerm(), lastVote.getValue().getTerm());
- if (reason == TopologyCoordinator::StartElectionReason::kPriorityTakeover) {
+ if (reason == StartElectionReasonEnum::kPriorityTakeover) {
ASSERT_EQUALS(1,
countLogLinesContaining("Starting an election for a priority takeover"));
}
@@ -1448,9 +1448,8 @@ TEST_F(TakeoverTest, SuccessfulCatchupTakeover) {
ASSERT_EQUALS(1, countLogLinesContaining("Starting an election for a catchup takeover"));
LastVote lastVoteExpected = LastVote(replCoord->getTerm() + 1, 0);
- performSuccessfulTakeover(catchupTakeoverTime,
- TopologyCoordinator::StartElectionReason::kCatchupTakeover,
- lastVoteExpected);
+ performSuccessfulTakeover(
+ catchupTakeoverTime, StartElectionReasonEnum::kCatchupTakeover, lastVoteExpected);
// Check that the numCatchUpTakeoversCalled and the numCatchUpTakeoversSuccessful election
// metrics have been incremented, and that none of the metrics that track the number of
@@ -1707,9 +1706,8 @@ TEST_F(TakeoverTest, PrimaryCatchesUpBeforeHighPriorityNodeCatchupTakeover) {
config, now + longElectionTimeout, HostAndPort("node2", 12345), currentOptime);
LastVote lastVoteExpected = LastVote(replCoord->getTerm() + 1, 0);
- performSuccessfulTakeover(priorityTakeoverTime,
- TopologyCoordinator::StartElectionReason::kPriorityTakeover,
- lastVoteExpected);
+ performSuccessfulTakeover(
+ priorityTakeoverTime, StartElectionReasonEnum::kPriorityTakeover, lastVoteExpected);
}
TEST_F(TakeoverTest, SchedulesPriorityTakeoverIfNodeHasHigherPriorityThanCurrentPrimary) {
@@ -1801,9 +1799,8 @@ TEST_F(TakeoverTest, SuccessfulPriorityTakeover) {
config, now + halfElectionTimeout, HostAndPort("node2", 12345), myOptime);
LastVote lastVoteExpected = LastVote(replCoord->getTerm() + 1, 0);
- performSuccessfulTakeover(priorityTakeoverTime,
- TopologyCoordinator::StartElectionReason::kPriorityTakeover,
- lastVoteExpected);
+ performSuccessfulTakeover(
+ priorityTakeoverTime, StartElectionReasonEnum::kPriorityTakeover, lastVoteExpected);
// Check that the numPriorityTakeoversCalled and the numPriorityTakeoversSuccessful election
// metrics have been incremented, and that none of the metrics that track the number of
@@ -1892,9 +1889,8 @@ TEST_F(TakeoverTest, DontCallForPriorityTakeoverWhenLaggedSameSecond) {
Date_t() + Seconds(closeEnoughOpTime.getSecs()));
LastVote lastVoteExpected = LastVote(replCoord->getTerm() + 1, 0);
- performSuccessfulTakeover(priorityTakeoverTime,
- TopologyCoordinator::StartElectionReason::kPriorityTakeover,
- lastVoteExpected);
+ performSuccessfulTakeover(
+ priorityTakeoverTime, StartElectionReasonEnum::kPriorityTakeover, lastVoteExpected);
}
TEST_F(TakeoverTest, DontCallForPriorityTakeoverWhenLaggedDifferentSecond) {
@@ -1967,9 +1963,8 @@ TEST_F(TakeoverTest, DontCallForPriorityTakeoverWhenLaggedDifferentSecond) {
Date_t() + Seconds(closeEnoughOpTime.getSecs()));
LastVote lastVoteExpected = LastVote(replCoord->getTerm() + 1, 0);
- performSuccessfulTakeover(priorityTakeoverTime,
- TopologyCoordinator::StartElectionReason::kPriorityTakeover,
- lastVoteExpected);
+ performSuccessfulTakeover(
+ priorityTakeoverTime, StartElectionReasonEnum::kPriorityTakeover, lastVoteExpected);
}
TEST_F(ReplCoordTest, NodeCancelsElectionUponReceivingANewConfigDuringDryRun) {