diff options
Diffstat (limited to 'src/mongo/db')
-rw-r--r-- | src/mongo/db/repl/check_quorum_for_config_change_test.cpp | 8 | ||||
-rw-r--r-- | src/mongo/db/repl/member_config.cpp | 22 | ||||
-rw-r--r-- | src/mongo/db/repl/member_config_test.cpp | 17 | ||||
-rw-r--r-- | src/mongo/db/repl/replica_set_config.cpp | 6 | ||||
-rw-r--r-- | src/mongo/db/repl/replica_set_config_test.cpp | 416 | ||||
-rw-r--r-- | src/mongo/db/repl/replication_coordinator_impl_test.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/repl/topology_coordinator_impl_test.cpp | 25 | ||||
-rw-r--r-- | src/mongo/db/repl/vote_requester_test.cpp | 62 |
8 files changed, 152 insertions, 408 deletions
diff --git a/src/mongo/db/repl/check_quorum_for_config_change_test.cpp b/src/mongo/db/repl/check_quorum_for_config_change_test.cpp index 475992e83fe..88904a9ff02 100644 --- a/src/mongo/db/repl/check_quorum_for_config_change_test.cpp +++ b/src/mongo/db/repl/check_quorum_for_config_change_test.cpp @@ -674,10 +674,10 @@ TEST_F(CheckQuorumForReconfig, QuorumCheckFailsDueToInsufficientVoters) { << "h3:1") << BSON("_id" << 4 << "host" << "h4:1" - << "votes" << 0) + << "votes" << 0 << "priority" << 0) << BSON("_id" << 5 << "host" << "h5:1" - << "votes" << 0)))); + << "votes" << 0 << "priority" << 0)))); const int myConfigIndex = 3; const BSONObj hbRequest = makeHeartbeatRequest(rsConfig, myConfigIndex); @@ -784,10 +784,10 @@ TEST_F(CheckQuorumForReconfig, QuorumCheckSucceedsWithAsSoonAsPossible) { << "h3:1") << BSON("_id" << 4 << "host" << "h4:1" - << "votes" << 0) + << "votes" << 0 << "priority" << 0) << BSON("_id" << 5 << "host" << "h5:1" - << "votes" << 0)))); + << "votes" << 0 << "priority" << 0)))); const int myConfigIndex = 3; const BSONObj hbRequest = makeHeartbeatRequest(rsConfig, myConfigIndex); diff --git a/src/mongo/db/repl/member_config.cpp b/src/mongo/db/repl/member_config.cpp index a6f8e311928..d8f3c1ed7bf 100644 --- a/src/mongo/db/repl/member_config.cpp +++ b/src/mongo/db/repl/member_config.cpp @@ -252,14 +252,20 @@ Status MemberConfig::validate() const { << durationCount<Seconds>(_slaveDelay) << " seconds is out of range"); } - if (_slaveDelay > Seconds(0) && _priority != 0) { - return Status(ErrorCodes::BadValue, "slaveDelay requires priority be zero"); - } - if (_hidden && _priority != 0) { - return Status(ErrorCodes::BadValue, "priority must be 0 when hidden=true"); - } - if (!_buildIndexes && _priority != 0) { - return Status(ErrorCodes::BadValue, "priority must be 0 when buildIndexes=false"); + // Check for additional electable requirements, when priority is non zero + if (_priority != 0) { + if (_votes == 0) { + return Status(ErrorCodes::BadValue, "priority must be 0 when non-voting (votes:0)"); + } + if (_slaveDelay > Seconds(0)) { + return Status(ErrorCodes::BadValue, "priority must be 0 when slaveDelay is used"); + } + if (_hidden) { + return Status(ErrorCodes::BadValue, "priority must be 0 when hidden=true"); + } + if (!_buildIndexes) { + return Status(ErrorCodes::BadValue, "priority must be 0 when buildIndexes=false"); + } } return Status::OK(); } diff --git a/src/mongo/db/repl/member_config_test.cpp b/src/mongo/db/repl/member_config_test.cpp index c53556f411d..b051451524c 100644 --- a/src/mongo/db/repl/member_config_test.cpp +++ b/src/mongo/db/repl/member_config_test.cpp @@ -177,7 +177,7 @@ TEST(MemberConfig, ParseVotes) { ASSERT_TRUE(mc.isVoter()); ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host" << "h" - << "votes" << 0), + << "votes" << 0 << "priority" << 0), &tagConfig)); ASSERT_FALSE(mc.isVoter()); @@ -291,7 +291,7 @@ TEST(MemberConfig, ValidateVotes) { ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host" << "h" - << "votes" << 0), + << "votes" << 0 << "priority" << 0), &tagConfig)); ASSERT_OK(mc.validate()); ASSERT_FALSE(mc.isVoter()); @@ -306,14 +306,14 @@ TEST(MemberConfig, ValidateVotes) { ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host" << "h" - << "votes" << 0.5), + << "votes" << 0.5 << "priority" << 0), &tagConfig)); ASSERT_OK(mc.validate()); ASSERT_FALSE(mc.isVoter()); ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host" << "h" - << "votes" << -0.5), + << "votes" << -0.5 << "priority" << 0), &tagConfig)); ASSERT_OK(mc.validate()); ASSERT_FALSE(mc.isVoter()); @@ -432,10 +432,11 @@ TEST(MemberConfig, ValidateArbiterVotesRelationship) { &tagConfig)); ASSERT_OK(mc.validate()); - ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host" - << "h" - << "votes" << 0 << "arbiterOnly" << false), - &tagConfig)); + ASSERT_OK( + mc.initialize(BSON("_id" << 0 << "host" + << "h" + << "votes" << 0 << "priority" << 0 << "arbiterOnly" << false), + &tagConfig)); ASSERT_OK(mc.validate()); ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host" << "h" diff --git a/src/mongo/db/repl/replica_set_config.cpp b/src/mongo/db/repl/replica_set_config.cpp index 1f394956f91..75a64383f80 100644 --- a/src/mongo/db/repl/replica_set_config.cpp +++ b/src/mongo/db/repl/replica_set_config.cpp @@ -117,9 +117,11 @@ Status ReplicaSetConfig::initialize(const BSONObj& cfg) { << typeName(memberElement.type())); } _members.resize(_members.size() + 1); - status = _members.back().initialize(memberElement.Obj(), &_tagConfig); + const auto& memberBSON = memberElement.Obj(); + status = _members.back().initialize(memberBSON, &_tagConfig); if (!status.isOK()) - return status; + return Status(ErrorCodes::InvalidReplicaSetConfig, + str::stream() << status.toString() << " for member:" << memberBSON); } // diff --git a/src/mongo/db/repl/replica_set_config_test.cpp b/src/mongo/db/repl/replica_set_config_test.cpp index f37a49ea541..236a007dda4 100644 --- a/src/mongo/db/repl/replica_set_config_test.cpp +++ b/src/mongo/db/repl/replica_set_config_test.cpp @@ -26,6 +26,7 @@ * it in the license file. */ +#include "mongo/bson/json.h" #include "mongo/bson/mutable/document.h" #include "mongo/bson/mutable/element.h" #include "mongo/db/jsobj.h" @@ -36,6 +37,23 @@ namespace mongo { namespace repl { namespace { +// Creates a bson document reprsenting a replica set config doc with the given members, and votes +BSONObj createConfigDoc(int members, int voters = ReplicaSetConfig::kMaxVotingMembers) { + str::stream configJson; + configJson << "{_id:'rs0', version:1, members:["; + for (int i = 0; i < members; ++i) { + configJson << "{_id:" << i << ", host:'node" << i << "'"; + if (i >= voters) { + configJson << ", votes:0, priority:0"; + } + configJson << "}"; + if (i != (members - 1)) + configJson << ","; + } + configJson << "]}"; + return fromjson(configJson); +} + TEST(ReplicaSetConfig, ParseMinimalConfigAndCheckDefaults) { ReplicaSetConfig config; ASSERT_OK(config.initialize(BSON("_id" @@ -96,10 +114,10 @@ TEST(ReplicaSetConfig, MajorityCalculationThreeVotersNoArbiters) { << "h3:1") << BSON("_id" << 4 << "host" << "h4:1" - << "votes" << 0) + << "votes" << 0 << "priority" << 0) << BSON("_id" << 5 << "host" << "h5:1" - << "votes" << 0))))); + << "votes" << 0 << "priority" << 0))))); ASSERT_OK(config.validate()); ASSERT_EQUALS(2, config.getWriteMajority()); @@ -129,31 +147,6 @@ TEST(ReplicaSetConfig, MajorityCalculationNearlyHalfArbiters) { ASSERT_EQUALS(3, config.getWriteMajority()); } -TEST(ReplicaSetConfig, MajorityCalculationNearlyHalfArbitersOthersNoVote) { - ReplicaSetConfig config; - ASSERT_OK( - config.initialize(BSON("_id" - << "mySet" - << "version" << 2 << "members" - << BSON_ARRAY(BSON("host" - << "node1:12345" - << "_id" << 0 << "votes" << 0) - << BSON("host" - << "node2:12345" - << "_id" << 1 << "votes" << 0) - << BSON("host" - << "node3:12345" - << "_id" << 2 << "votes" << 0) - << BSON("host" - << "node4:12345" - << "_id" << 3 << "arbiterOnly" << true) - << BSON("host" - << "node5:12345" - << "_id" << 4 << "arbiterOnly" << true))))); - ASSERT_OK(config.validate()); - ASSERT_EQUALS(0, config.getWriteMajority()); -} - TEST(ReplicaSetConfig, MajorityCalculationEvenNumberOfMembers) { ReplicaSetConfig config; ASSERT_OK(config.initialize(BSON("_id" @@ -180,20 +173,21 @@ TEST(ReplicaSetConfig, MajorityCalculationNearlyHalfSecondariesNoVotes) { config.initialize(BSON("_id" << "mySet" << "version" << 2 << "members" - << BSON_ARRAY(BSON("host" - << "node1:12345" - << "_id" << 0) - << BSON("host" - << "node2:12345" - << "_id" << 1 << "votes" << 0) - << BSON("host" - << "node3:12345" - << "_id" << 2 << "votes" << 0) - << BSON("host" - << "node4:12345" - << "_id" << 3) << BSON("host" - << "node5:12345" - << "_id" << 4))))); + << BSON_ARRAY( + BSON("host" + << "node1:12345" + << "_id" << 0) + << BSON("host" + << "node2:12345" + << "_id" << 1 << "votes" << 0 << "priority" << 0) + << BSON("host" + << "node3:12345" + << "_id" << 2 << "votes" << 0 << "priority" << 0) + << BSON("host" + << "node4:12345" + << "_id" << 3) << BSON("host" + << "node5:12345" + << "_id" << 4))))); ASSERT_OK(config.validate()); ASSERT_EQUALS(2, config.getWriteMajority()); } @@ -272,8 +266,7 @@ TEST(ReplicaSetConfig, ParseFailsWithBadMembers) { << BSON_ARRAY(BSON("_id" << 0 << "host" << "localhost:12345") << "localhost:23456")))); - ASSERT_EQUALS(ErrorCodes::NoSuchKey, - config.initialize(BSON("_id" + ASSERT_NOT_OK(config.initialize(BSON("_id" << "rs0" << "version" << 1 << "members" << BSON_ARRAY(BSON("host" @@ -350,15 +343,16 @@ TEST(ReplicaSetConfig, ParseFailsWithNoElectableNodes) { TEST(ReplicaSetConfig, ParseFailsWithTooFewVoters) { ReplicaSetConfig config; - const BSONObj configBsonNoVoters = BSON("_id" - << "rs0" - << "version" << 1 << "members" - << BSON_ARRAY(BSON("_id" << 0 << "host" - << "localhost:1" - << "votes" << 0) - << BSON("_id" << 1 << "host" - << "localhost:2" - << "votes" << 0))); + const BSONObj configBsonNoVoters = + BSON("_id" + << "rs0" + << "version" << 1 << "members" + << BSON_ARRAY(BSON("_id" << 0 << "host" + << "localhost:1" + << "votes" << 0 << "priority" << 0) + << BSON("_id" << 1 << "host" + << "localhost:2" + << "votes" << 0 << "priority" << 0))); ASSERT_OK(config.initialize(configBsonNoVoters)); ASSERT_EQUALS(ErrorCodes::BadValue, config.validate()); @@ -368,7 +362,8 @@ TEST(ReplicaSetConfig, ParseFailsWithTooFewVoters) { << "version" << 1 << "members" << BSON_ARRAY(BSON("_id" << 0 << "host" << "localhost:1" - << "votes" << 0) + << "votes" << 0 << "priority" + << 0) << BSON("_id" << 1 << "host" << "localhost:2" << "votes" << 1))); @@ -378,32 +373,10 @@ TEST(ReplicaSetConfig, ParseFailsWithTooFewVoters) { TEST(ReplicaSetConfig, ParseFailsWithTooManyVoters) { ReplicaSetConfig config; - namespace mmb = mutablebson; - mmb::Document configDoc; - mmb::Element configDocRoot = configDoc.root(); - ASSERT_OK(configDocRoot.appendString("_id", "rs0")); - ASSERT_OK(configDocRoot.appendInt("version", 1)); - mmb::Element membersArray = configDoc.makeElementArray("members"); - ASSERT_OK(configDocRoot.pushBack(membersArray)); - for (size_t i = 0; i < ReplicaSetConfig::kMaxVotingMembers + 1; ++i) { - mmb::Element memberElement = configDoc.makeElementObject(""); - ASSERT_OK(membersArray.pushBack(memberElement)); - ASSERT_OK(memberElement.appendInt("_id", i)); - ASSERT_OK( - memberElement.appendString("host", std::string(str::stream() << "localhost" << i + 1))); - ASSERT_OK(memberElement.appendInt("votes", 1)); - } - - const BSONObj configBsonTooManyVoters = configDoc.getObject(); - - membersArray.leftChild().findFirstChildNamed("votes").setValueInt(0); - const BSONObj configBsonMaxVoters = configDoc.getObject(); - - - ASSERT_OK(config.initialize(configBsonMaxVoters)); + ASSERT_OK(config.initialize(createConfigDoc(8, ReplicaSetConfig::kMaxVotingMembers))); ASSERT_OK(config.validate()); - ASSERT_OK(config.initialize(configBsonTooManyVoters)); - ASSERT_EQUALS(ErrorCodes::BadValue, config.validate()); + ASSERT_OK(config.initialize(createConfigDoc(8, ReplicaSetConfig::kMaxVotingMembers + 1))); + ASSERT_NOT_OK(config.validate()); } TEST(ReplicaSetConfig, ParseFailsWithDuplicateHost) { @@ -436,6 +409,7 @@ TEST(ReplicaSetConfig, ParseFailsWithTooManyNodes) { memberElement.appendString("host", std::string(str::stream() << "localhost" << i + 1))); if (i >= ReplicaSetConfig::kMaxVotingMembers) { ASSERT_OK(memberElement.appendInt("votes", 0)); + ASSERT_OK(memberElement.appendInt("priority", 0)); } } const BSONObj configBsonMaxNodes = configDoc.getObject(); @@ -446,6 +420,7 @@ TEST(ReplicaSetConfig, ParseFailsWithTooManyNodes) { ASSERT_OK(memberElement.appendString( "host", std::string(str::stream() << "localhost" << ReplicaSetConfig::kMaxMembers + 1))); ASSERT_OK(memberElement.appendInt("votes", 0)); + ASSERT_OK(memberElement.appendInt("priority", 0)); const BSONObj configBsonTooManyNodes = configDoc.getObject(); @@ -874,7 +849,7 @@ TEST(ReplicaSetConfig, toBSONRoundTripAbilityLarge) { << "true")) << BSON("_id" << 2 << "host" << "foo.com:3828" - << "priority" << 9 << "votes" << 0 << "tags" + << "votes" << 0 << "priority" << 0 << "tags" << BSON("coast" << "west" << "hdd" @@ -891,22 +866,21 @@ TEST(ReplicaSetConfig, toBSONRoundTripAbilityLarge) { TEST(ReplicaSetConfig, toBSONRoundTripAbilityInvalid) { ReplicaSetConfig configA; ReplicaSetConfig configB; - ASSERT_OK( - configA.initialize(BSON("_id" - << "" - << "version" << -3 << "members" - << BSON_ARRAY(BSON("_id" << 0 << "host" - << "localhost:12345" - << "arbiterOnly" << true << "votes" << 0) - << BSON("_id" << 0 << "host" - << "localhost:3828" - << "arbiterOnly" << false - << "buildIndexes" << false << "priority" - << 2) - << BSON("_id" << 2 << "host" - << "localhost:3828" - << "priority" << 9 << "votes" << 0)) - << "settings" << BSON("heartbeatTimeoutSecs" << -20)))); + ASSERT_OK(configA.initialize( + BSON("_id" + << "" + << "version" << -3 << "members" + << BSON_ARRAY(BSON("_id" << 0 << "host" + << "localhost:12345" + << "arbiterOnly" << true << "votes" << 0 << "priority" << 0) + << BSON("_id" << 0 << "host" + << "localhost:3828" + << "arbiterOnly" << false << "buildIndexes" << false + << "priority" << 2) + << BSON("_id" << 2 << "host" + << "localhost:3828" + << "votes" << 0 << "priority" << 0)) << "settings" + << BSON("heartbeatTimeoutSecs" << -20)))); ASSERT_OK(configB.initialize(configA.toBSON())); ASSERT_NOT_OK(configA.validate()); ASSERT_NOT_OK(configB.validate()); @@ -992,129 +966,8 @@ TEST(ReplicaSetConfig, CheckIfWriteConcernCanBeSatisfied) { TEST(ReplicaSetConfig, CheckMaximumNodesOkay) { ReplicaSetConfig configA; ReplicaSetConfig configB; - ASSERT_OK(configA.initialize( - BSON("_id" - << "rs0" - << "version" << 1 << "members" - << BSON_ARRAY(BSON("_id" << 0 << "host" - << "node0") - << BSON("_id" << 1 << "host" - << "node1") << BSON("_id" << 2 << "host" - << "node2") - << BSON("_id" << 3 << "host" - << "node3") << BSON("_id" << 4 << "host" - << "node4") - << BSON("_id" << 5 << "host" - << "node5") << BSON("_id" << 6 << "host" - << "node6") - << BSON("_id" << 7 << "host" - << "node7" - << "votes" << 0) << BSON("_id" << 8 << "host" - << "node8" - << "votes" << 0) - << BSON("_id" << 9 << "host" - << "node9" - << "votes" << 0) << BSON("_id" << 10 << "host" - << "node10" - << "votes" << 0) - << BSON("_id" << 11 << "host" - << "node11" - << "votes" << 0) << BSON("_id" << 12 << "host" - << "node12" - << "votes" << 0) - << BSON("_id" << 13 << "host" - << "node13" - << "votes" << 0) << BSON("_id" << 14 << "host" - << "node14" - << "votes" << 0) - << BSON("_id" << 15 << "host" - << "node15" - << "votes" << 0) << BSON("_id" << 16 << "host" - << "node16" - << "votes" << 0) - << BSON("_id" << 17 << "host" - << "node17" - << "votes" << 0) << BSON("_id" << 18 << "host" - << "node18" - << "votes" << 0) - << BSON("_id" << 19 << "host" - << "node19" - << "votes" << 0) << BSON("_id" << 20 << "host" - << "node20" - << "votes" << 0) - << BSON("_id" << 21 << "host" - << "node21" - << "votes" << 0) << BSON("_id" << 22 << "host" - << "node22" - << "votes" << 0) - << BSON("_id" << 23 << "host" - << "node23" - << "votes" << 0) << BSON("_id" << 24 << "host" - << "node24" - << "votes" << 0) - << BSON("_id" << 25 << "host" - << "node25" - << "votes" << 0) << BSON("_id" << 26 << "host" - << "node26" - << "votes" << 0) - << BSON("_id" << 27 << "host" - << "node27" - << "votes" << 0) << BSON("_id" << 28 << "host" - << "node28" - << "votes" << 0) - << BSON("_id" << 29 << "host" - << "node29" - << "votes" << 0) << BSON("_id" << 30 << "host" - << "node30" - << "votes" << 0) - << BSON("_id" << 31 << "host" - << "node31" - << "votes" << 0) << BSON("_id" << 32 << "host" - << "node32" - << "votes" << 0) - << BSON("_id" << 33 << "host" - << "node33" - << "votes" << 0) << BSON("_id" << 34 << "host" - << "node34" - << "votes" << 0) - << BSON("_id" << 35 << "host" - << "node35" - << "votes" << 0) << BSON("_id" << 36 << "host" - << "node36" - << "votes" << 0) - << BSON("_id" << 37 << "host" - << "node37" - << "votes" << 0) << BSON("_id" << 38 << "host" - << "node38" - << "votes" << 0) - << BSON("_id" << 39 << "host" - << "node39" - << "votes" << 0) << BSON("_id" << 40 << "host" - << "node40" - << "votes" << 0) - << BSON("_id" << 41 << "host" - << "node41" - << "votes" << 0) << BSON("_id" << 42 << "host" - << "node42" - << "votes" << 0) - << BSON("_id" << 43 << "host" - << "node43" - << "votes" << 0) << BSON("_id" << 44 << "host" - << "node44" - << "votes" << 0) - << BSON("_id" << 45 << "host" - << "node45" - << "votes" << 0) << BSON("_id" << 46 << "host" - << "node46" - << "votes" << 0) - << BSON("_id" << 47 << "host" - << "node47" - << "votes" << 0) << BSON("_id" << 48 << "host" - << "node48" - << "votes" << 0) - << BSON("_id" << 49 << "host" - << "node49" - << "votes" << 0))))); + const int memberCount = 50; + ASSERT_OK(configA.initialize(createConfigDoc(memberCount))); ASSERT_OK(configB.initialize(configA.toBSON())); ASSERT_OK(configA.validate()); ASSERT_OK(configB.validate()); @@ -1124,131 +977,8 @@ TEST(ReplicaSetConfig, CheckMaximumNodesOkay) { TEST(ReplicaSetConfig, CheckBeyondMaximumNodesFailsValidate) { ReplicaSetConfig configA; ReplicaSetConfig configB; - ASSERT_OK(configA.initialize( - BSON("_id" - << "rs0" - << "version" << 1 << "members" - << BSON_ARRAY(BSON("_id" << 0 << "host" - << "node0") - << BSON("_id" << 1 << "host" - << "node1") << BSON("_id" << 2 << "host" - << "node2") - << BSON("_id" << 3 << "host" - << "node3") << BSON("_id" << 4 << "host" - << "node4") - << BSON("_id" << 5 << "host" - << "node5") << BSON("_id" << 6 << "host" - << "node6") - << BSON("_id" << 7 << "host" - << "node7" - << "votes" << 0) << BSON("_id" << 8 << "host" - << "node8" - << "votes" << 0) - << BSON("_id" << 9 << "host" - << "node9" - << "votes" << 0) << BSON("_id" << 10 << "host" - << "node10" - << "votes" << 0) - << BSON("_id" << 11 << "host" - << "node11" - << "votes" << 0) << BSON("_id" << 12 << "host" - << "node12" - << "votes" << 0) - << BSON("_id" << 13 << "host" - << "node13" - << "votes" << 0) << BSON("_id" << 14 << "host" - << "node14" - << "votes" << 0) - << BSON("_id" << 15 << "host" - << "node15" - << "votes" << 0) << BSON("_id" << 16 << "host" - << "node16" - << "votes" << 0) - << BSON("_id" << 17 << "host" - << "node17" - << "votes" << 0) << BSON("_id" << 18 << "host" - << "node18" - << "votes" << 0) - << BSON("_id" << 19 << "host" - << "node19" - << "votes" << 0) << BSON("_id" << 20 << "host" - << "node20" - << "votes" << 0) - << BSON("_id" << 21 << "host" - << "node21" - << "votes" << 0) << BSON("_id" << 22 << "host" - << "node22" - << "votes" << 0) - << BSON("_id" << 23 << "host" - << "node23" - << "votes" << 0) << BSON("_id" << 24 << "host" - << "node24" - << "votes" << 0) - << BSON("_id" << 25 << "host" - << "node25" - << "votes" << 0) << BSON("_id" << 26 << "host" - << "node26" - << "votes" << 0) - << BSON("_id" << 27 << "host" - << "node27" - << "votes" << 0) << BSON("_id" << 28 << "host" - << "node28" - << "votes" << 0) - << BSON("_id" << 29 << "host" - << "node29" - << "votes" << 0) << BSON("_id" << 30 << "host" - << "node30" - << "votes" << 0) - << BSON("_id" << 31 << "host" - << "node31" - << "votes" << 0) << BSON("_id" << 32 << "host" - << "node32" - << "votes" << 0) - << BSON("_id" << 33 << "host" - << "node33" - << "votes" << 0) << BSON("_id" << 34 << "host" - << "node34" - << "votes" << 0) - << BSON("_id" << 35 << "host" - << "node35" - << "votes" << 0) << BSON("_id" << 36 << "host" - << "node36" - << "votes" << 0) - << BSON("_id" << 37 << "host" - << "node37" - << "votes" << 0) << BSON("_id" << 38 << "host" - << "node38" - << "votes" << 0) - << BSON("_id" << 39 << "host" - << "node39" - << "votes" << 0) << BSON("_id" << 40 << "host" - << "node40" - << "votes" << 0) - << BSON("_id" << 41 << "host" - << "node41" - << "votes" << 0) << BSON("_id" << 42 << "host" - << "node42" - << "votes" << 0) - << BSON("_id" << 43 << "host" - << "node43" - << "votes" << 0) << BSON("_id" << 44 << "host" - << "node44" - << "votes" << 0) - << BSON("_id" << 45 << "host" - << "node45" - << "votes" << 0) << BSON("_id" << 46 << "host" - << "node46" - << "votes" << 0) - << BSON("_id" << 47 << "host" - << "node47" - << "votes" << 0) << BSON("_id" << 48 << "host" - << "node48" - << "votes" << 0) - << BSON("_id" << 49 << "host" - << "node49" - << "votes" << 0) << BSON("_id" << 50 << "host" - << "node50" - << "votes" << 0))))); + const int memberCount = 51; + ASSERT_OK(configA.initialize(createConfigDoc(memberCount))); ASSERT_OK(configB.initialize(configA.toBSON())); ASSERT_NOT_OK(configA.validate()); ASSERT_NOT_OK(configB.validate()); diff --git a/src/mongo/db/repl/replication_coordinator_impl_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_test.cpp index 519170a1b95..078e34c9d71 100644 --- a/src/mongo/db/repl/replication_coordinator_impl_test.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl_test.cpp @@ -1977,7 +1977,7 @@ TEST_F(ReplCoordTest, AwaitReplicationMajority) { << "_id" << 2) << BSON("host" << "node4:12345" - << "_id" << 3 << "votes" << 0) + << "_id" << 3 << "votes" << 0 << "priority" << 0) << BSON("host" << "node5:12345" << "_id" << 4 << "arbiterOnly" << true))), @@ -2027,7 +2027,7 @@ TEST_F(ReplCoordTest, LastCommittedOpTime) { << "_id" << 2) << BSON("host" << "node4:12345" - << "_id" << 3 << "votes" << 0) + << "_id" << 3 << "votes" << 0 << "priority" << 0) << BSON("host" << "node5:12345" << "_id" << 4 << "arbiterOnly" << true))), diff --git a/src/mongo/db/repl/topology_coordinator_impl_test.cpp b/src/mongo/db/repl/topology_coordinator_impl_test.cpp index 9188fb2c0b2..c606e7cc21f 100644 --- a/src/mongo/db/repl/topology_coordinator_impl_test.cpp +++ b/src/mongo/db/repl/topology_coordinator_impl_test.cpp @@ -492,7 +492,7 @@ TEST_F(TopoCoordTest, ChooseSyncSourceWrtVoters) { updateConfig(fromjson( "{_id:'rs0', version:1, members:[" "{_id:10, host:'hself'}, " - "{_id:20, host:'h2', votes:0}, " + "{_id:20, host:'h2', votes:0, priority:0}, " "{_id:30, host:'h3'} " "]}"), 0); @@ -972,7 +972,7 @@ TEST_F(TopoCoordTest, PrepareSyncFromResponseVoters) { "{_id:'rs0', version:1, members:[" "{_id:0, host:'self'}," "{_id:1, host:'h1'}," - "{_id:2, host:'h2', votes:0}" + "{_id:2, host:'h2', votes:0, priority:0}" "]}"), 0); @@ -2918,19 +2918,22 @@ TEST_F(HeartbeatResponseTest, UpdateHeartbeatDataPrimaryDownMajorityOfVotersUp) << BSON_ARRAY(BSON("_id" << 0 << "host" << "host1:27017") << BSON("_id" << 1 << "host" - << "host2:27017") << BSON("_id" << 2 << "host" - << "host3:27017" - << "votes" << 0) + << "host2:27017") + << BSON("_id" << 2 << "host" + << "host3:27017" + << "votes" << 0 << "priority" << 0) << BSON("_id" << 3 << "host" << "host4:27017" - << "votes" << 0) << BSON("_id" << 4 << "host" - << "host5:27017" - << "votes" << 0) + << "votes" << 0 << "priority" << 0) + << BSON("_id" << 4 << "host" + << "host5:27017" + << "votes" << 0 << "priority" << 0) << BSON("_id" << 5 << "host" << "host6:27017" - << "votes" << 0) << BSON("_id" << 6 << "host" - << "host7:27017")) - << "settings" << BSON("heartbeatTimeoutSecs" << 5)), + << "votes" << 0 << "priority" << 0) + << BSON("_id" << 6 << "host" + << "host7:27017")) << "settings" + << BSON("heartbeatTimeoutSecs" << 5)), 0); setSelfMemberState(MemberState::RS_SECONDARY); diff --git a/src/mongo/db/repl/vote_requester_test.cpp b/src/mongo/db/repl/vote_requester_test.cpp index d169344c2e6..9b19060fc9d 100644 --- a/src/mongo/db/repl/vote_requester_test.cpp +++ b/src/mongo/db/repl/vote_requester_test.cpp @@ -58,21 +58,22 @@ class VoteRequesterTest : public mongo::unittest::Test { public: virtual void setUp() { ReplicaSetConfig config; - ASSERT_OK(config.initialize(BSON("_id" - << "rs0" - << "version" << 2 << "members" - << BSON_ARRAY(BSON("_id" << 0 << "host" - << "host0") - << BSON("_id" << 1 << "host" - << "host1") - << BSON("_id" << 2 << "host" - << "host2") - << BSON("_id" << 3 << "host" - << "host3" - << "votes" << 0) - << BSON("_id" << 4 << "host" - << "host4" - << "votes" << 0))))); + ASSERT_OK( + config.initialize(BSON("_id" + << "rs0" + << "version" << 2 << "members" + << BSON_ARRAY( + BSON("_id" << 0 << "host" + << "host0") + << BSON("_id" << 1 << "host" + << "host1") << BSON("_id" << 2 << "host" + << "host2") + << BSON("_id" << 3 << "host" + << "host3" + << "votes" << 0 << "priority" << 0) + << BSON("_id" << 4 << "host" + << "host4" + << "votes" << 0 << "priority" << 0))))); ASSERT_OK(config.validate()); long long candidateId = 0; long long term = 2; @@ -185,21 +186,22 @@ class VoteRequesterDryRunTest : public VoteRequesterTest { public: virtual void setUp() { ReplicaSetConfig config; - ASSERT_OK(config.initialize(BSON("_id" - << "rs0" - << "version" << 2 << "members" - << BSON_ARRAY(BSON("_id" << 0 << "host" - << "host0") - << BSON("_id" << 1 << "host" - << "host1") - << BSON("_id" << 2 << "host" - << "host2") - << BSON("_id" << 3 << "host" - << "host3" - << "votes" << 0) - << BSON("_id" << 4 << "host" - << "host4" - << "votes" << 0))))); + ASSERT_OK( + config.initialize(BSON("_id" + << "rs0" + << "version" << 2 << "members" + << BSON_ARRAY( + BSON("_id" << 0 << "host" + << "host0") + << BSON("_id" << 1 << "host" + << "host1") << BSON("_id" << 2 << "host" + << "host2") + << BSON("_id" << 3 << "host" + << "host3" + << "votes" << 0 << "priority" << 0) + << BSON("_id" << 4 << "host" + << "host4" + << "votes" << 0 << "priority" << 0))))); ASSERT_OK(config.validate()); long long candidateId = 0; long long term = 2; |