TEST_F(TopoCoordTest, ArbiterNotIncludedInMajorityReplicatedConfigChecks) { // Config with only one data-bearing node only needs one node to majority replicate config. updateConfig(BSON("_id" << "rs0" << "version" << 2 << "term" << 0 << "members" << BSON_ARRAY(BSON("_id" << 0 << "host" << "host0:27017") << BSON("_id" << 1 << "host" << "host1:27017" << "priority" << 0 << "votes" << 0) << BSON("_id" << 2 << "host" << "host2:27017" << "priority" << 0 << "votes" << 0) << BSON("_id" << 3 << "host" << "host3:27017" << "priority" << 0 << "votes" << 1) << BSON("_id" << 4 << "host" << "host4:27017" << "priority" << 0 << "votes" << 1))), 0); // makeSelfPrimary() doesn't actually conduct a true election, so the term will still be 0. makeSelfPrimary(); // Simulate a heartbeat to one of the other nodes. getTopoCoord().prepareHeartbeatRequestV1(now(), "rs0", HostAndPort("host1")); // Simulate heartbeat response from host1. This will call setUpValues, which will update the // memberData for host1. ReplSetHeartbeatResponse hb3; hb3.setConfigVersion(2); hb3.setConfigTerm(0); hb3.setState(MemberState::RS_SECONDARY); StatusWith hbResponse3 = StatusWith(hb3); now() += Milliseconds(1); getTopoCoord().processHeartbeatResponse( now(), Milliseconds(1), HostAndPort("host1"), hbResponse3); // Simulate a heartbeat to one of the other nodes. getTopoCoord().prepareHeartbeatRequestV1(now(), "rs0", HostAndPort("host2")); // Simulate heartbeat response from host1. This will call setUpValues, which will update the // memberData for host1. ReplSetHeartbeatResponse hb4; hb4.setConfigVersion(2); hb4.setConfigTerm(0); hb4.setState(MemberState::RS_SECONDARY); StatusWith hbResponse4 = StatusWith(hb4); now() += Milliseconds(1); getTopoCoord().processHeartbeatResponse( now(), Milliseconds(1), HostAndPort("host2"), hbResponse4); // Currently, only the primary has config 2 (the initial config). But, since arbiters do not // count towards the config majority, haveMajorityReplicatedConfig() should still return true. ASSERT_FALSE(getTopoCoord().haveMajorityReplicatedConfig()); }