diff options
author | Wenbin Zhu <wenbin.zhu@mongodb.com> | 2021-08-11 18:44:26 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-08-11 19:00:00 +0000 |
commit | d21efd2cc4ac16693589f4d7da1cf229c4d08b8d (patch) | |
tree | 33563fdc9354a88aaaf1bc6f4324dfc6fdbcecac /src/mongo/db/repl/topology_coordinator_v1_test.cpp | |
parent | fb4606ea3efef560014284e99bf5db5755671f58 (diff) | |
download | mongo-d21efd2cc4ac16693589f4d7da1cf229c4d08b8d.tar.gz |
SERVER-57262 Relax vote constraint to allow voting for candidates with newer config.
(cherry picked from commit e7937256045a2a182c583c7aacaf168e02cf0d06)
Diffstat (limited to 'src/mongo/db/repl/topology_coordinator_v1_test.cpp')
-rw-r--r-- | src/mongo/db/repl/topology_coordinator_v1_test.cpp | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/mongo/db/repl/topology_coordinator_v1_test.cpp b/src/mongo/db/repl/topology_coordinator_v1_test.cpp index 1be2b970576..476adf62f90 100644 --- a/src/mongo/db/repl/topology_coordinator_v1_test.cpp +++ b/src/mongo/db/repl/topology_coordinator_v1_test.cpp @@ -3491,7 +3491,7 @@ public: TEST_F(ConfigTermAndVersionVoteTest, DataNodeDoesNotGrantVoteWhenConfigVersionIsLower) { auto response = testWithArbiter(false, 1, 2); ASSERT_EQUALS( - "candidate's config with {version: 1, term: 2} differs from mine with" + "candidate's config with {version: 1, term: 2} is older than mine with" " {version: 2, term: 2}", response.getReason()); } @@ -3499,7 +3499,7 @@ TEST_F(ConfigTermAndVersionVoteTest, DataNodeDoesNotGrantVoteWhenConfigVersionIs TEST_F(ConfigTermAndVersionVoteTest, ArbiterDoesNotGrantVoteWhenConfigVersionIsLower) { auto response = testWithArbiter(true, 1, 2); ASSERT_EQUALS( - "candidate's config with {version: 1, term: 2} differs from mine with" + "candidate's config with {version: 1, term: 2} is older than mine with" " {version: 2, term: 2}", response.getReason()); } @@ -3507,7 +3507,7 @@ TEST_F(ConfigTermAndVersionVoteTest, ArbiterDoesNotGrantVoteWhenConfigVersionIsL TEST_F(ConfigTermAndVersionVoteTest, DataNodeDoesNotGrantVoteWhenConfigTermIsLower) { auto response = testWithArbiter(false, 2, 1); ASSERT_EQUALS( - "candidate's config with {version: 2, term: 1} differs from mine with" + "candidate's config with {version: 2, term: 1} is older than mine with" " {version: 2, term: 2}", response.getReason()); } @@ -3515,7 +3515,7 @@ TEST_F(ConfigTermAndVersionVoteTest, DataNodeDoesNotGrantVoteWhenConfigTermIsLow TEST_F(ConfigTermAndVersionVoteTest, ArbiterDoesNotGrantVoteWhenConfigTermIsLower) { auto response = testWithArbiter(true, 2, 1); ASSERT_EQUALS( - "candidate's config with {version: 2, term: 1} differs from mine with" + "candidate's config with {version: 2, term: 1} is older than mine with" " {version: 2, term: 2}", response.getReason()); } @@ -3683,7 +3683,7 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantDryRunVoteWhenConfigVersionIsLower) { getTopoCoord().processReplSetRequestVotes(args, &response); ASSERT_EQUALS( - "candidate's config with {version: 0, term: 1} differs from mine with {version: 1, term: " + "candidate's config with {version: 0, term: 1} is older than mine with {version: 1, term: " "1}", response.getReason()); ASSERT_EQUALS(1, response.getTerm()); @@ -3738,7 +3738,7 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantDryRunVoteWhenTermIsStale) { ASSERT_FALSE(response.getVoteGranted()); } -TEST_F(TopoCoordTest, NodeDoesNotGrantVoteWhenTermIsHigherButConfigVersionIsLower) { +TEST_F(TopoCoordTest, NodeGrantsVoteWhenTermIsHigherButConfigVersionIsLower) { updateConfig(BSON("_id" << "rs0" << "version" << 2 << "term" << 1LL << "members" @@ -3769,11 +3769,7 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantVoteWhenTermIsHigherButConfigVersionIsLowe getTopoCoord().processReplSetRequestVotes(args, &response); // Candidates config(t, v) is (2, 1) and our config is (1, 2). Even though the candidate's // config version is lower, we grant our vote because the candidate's config term is higher. - ASSERT_FALSE(response.getVoteGranted()); - ASSERT_EQ( - "candidate's config with {version: 1, term: 2} differs from mine with {version: 2, term: " - "1}", - response.getReason()); + ASSERT_TRUE(response.getVoteGranted()); } TEST_F(TopoCoordTest, GrantDryRunVoteEvenWhenTermHasBeenSeen) { |