summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorJason Rassi <rassi@10gen.com>2015-09-24 11:16:32 -0400
committerJason Rassi <rassi@10gen.com>2015-09-24 11:16:32 -0400
commit19d2885ec51768ab73eee0c7239d8eadc0c51d8d (patch)
treec4cb48ef7e76746a1e6638debea4c0530724d9f1 /src/mongo/db
parentb2a5ef9496ab5b26c8e51d92b4f3cdd0f2aba594 (diff)
downloadmongo-19d2885ec51768ab73eee0c7239d8eadc0c51d8d.tar.gz
Revert "SERVER-18498 New replica set configurations have protocolVersion=1 by default"
This reverts commit 2c1facf471cce8254e314755c3c7d2fbc753e5f4.
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl.cpp5
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_elect_test.cpp5
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_heartbeat_test.cpp41
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_heartbeat_v1_test.cpp4
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp18
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_test.cpp117
-rw-r--r--src/mongo/db/repl/replication_coordinator_test_fixture.cpp19
-rw-r--r--src/mongo/db/repl/replication_coordinator_test_fixture.h18
-rw-r--r--src/mongo/db/repl/topology_coordinator_impl_v1_test.cpp6
9 files changed, 95 insertions, 138 deletions
diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp
index 031558554c4..d6de5b44011 100644
--- a/src/mongo/db/repl/replication_coordinator_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl.cpp
@@ -1891,7 +1891,7 @@ Status ReplicationCoordinatorImpl::processReplSetReconfig(OperationContext* txn,
if (args.force) {
newConfigObj = incrementConfigVersionByRandom(newConfigObj);
}
- Status status = newConfig.initialize(newConfigObj, oldConfig.getProtocolVersion() == 1);
+ Status status = newConfig.initialize(newConfigObj);
if (!status.isOK()) {
error() << "replSetReconfig got " << status << " while parsing " << newConfigObj;
return Status(ErrorCodes::InvalidReplicaSetConfig, status.reason());
@@ -2003,10 +2003,11 @@ Status ReplicationCoordinatorImpl::processReplSetInitiate(OperationContext* txn,
}
ReplicaSetConfig newConfig;
- Status status = newConfig.initialize(configObj, true);
+ Status status = newConfig.initialize(configObj);
if (!status.isOK()) {
error() << "replSet initiate got " << status << " while parsing " << configObj;
return Status(ErrorCodes::InvalidReplicaSetConfig, status.reason());
+ ;
}
if (replEnabled && newConfig.getReplSetName() != _settings.ourSetName()) {
str::stream errmsg;
diff --git a/src/mongo/db/repl/replication_coordinator_impl_elect_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_elect_test.cpp
index e75ad1a675c..1eb90c747ac 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_elect_test.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_elect_test.cpp
@@ -54,15 +54,10 @@ using executor::RemoteCommandResponse;
class ReplCoordElectTest : public ReplCoordTest {
protected:
- void assertStartSuccess(const BSONObj& configDoc, const HostAndPort& selfHost);
void simulateEnoughHeartbeatsForElectability();
void simulateFreshEnoughForElectability();
};
-void ReplCoordElectTest::assertStartSuccess(const BSONObj& configDoc, const HostAndPort& selfHost) {
- ReplCoordTest::assertStartSuccess(addProtocolVersion(configDoc, 0), selfHost);
-}
-
void ReplCoordElectTest::simulateEnoughHeartbeatsForElectability() {
ReplicationCoordinatorImpl* replCoord = getReplCoord();
ReplicaSetConfig rsConfig = replCoord->getReplicaSetConfig_forTest();
diff --git a/src/mongo/db/repl/replication_coordinator_impl_heartbeat_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_heartbeat_test.cpp
index 0c630f772a5..fa9843b15ad 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_heartbeat_test.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_heartbeat_test.cpp
@@ -53,17 +53,12 @@ using executor::RemoteCommandResponse;
class ReplCoordHBTest : public ReplCoordTest {
protected:
- void assertStartSuccess(const BSONObj& configDoc, const HostAndPort& selfHost);
void assertMemberState(MemberState expected, std::string msg = "");
ReplSetHeartbeatResponse receiveHeartbeatFrom(const ReplicaSetConfig& rsConfig,
int sourceId,
const HostAndPort& source);
};
-void ReplCoordHBTest::assertStartSuccess(const BSONObj& configDoc, const HostAndPort& selfHost) {
- ReplCoordTest::assertStartSuccess(addProtocolVersion(configDoc, 0), selfHost);
-}
-
void ReplCoordHBTest::assertMemberState(const MemberState expected, std::string msg) {
const MemberState actual = getReplCoord()->getMemberState();
ASSERT(expected == actual) << "Expected coordinator to report state " << expected.toString()
@@ -88,15 +83,15 @@ ReplSetHeartbeatResponse ReplCoordHBTest::receiveHeartbeatFrom(const ReplicaSetC
TEST_F(ReplCoordHBTest, JoinExistingReplSet) {
logger::globalLogDomain()->setMinimumLoggedSeverity(logger::LogSeverity::Debug(3));
- ReplicaSetConfig rsConfig = assertMakeRSConfigV0(BSON("_id"
- << "mySet"
- << "version" << 3 << "members"
- << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "h1:1")
- << BSON("_id" << 2 << "host"
- << "h2:1")
- << BSON("_id" << 3 << "host"
- << "h3:1"))));
+ ReplicaSetConfig rsConfig =
+ assertMakeRSConfig(BSON("_id"
+ << "mySet"
+ << "version" << 3 << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "h1:1")
+ << BSON("_id" << 2 << "host"
+ << "h2:1") << BSON("_id" << 3 << "host"
+ << "h3:1"))));
init("mySet");
addSelf(HostAndPort("h2", 1));
const Date_t startDate = getNet()->now();
@@ -151,15 +146,15 @@ TEST_F(ReplCoordHBTest, DoNotJoinReplSetIfNotAMember) {
// Tests that a node in RS_STARTUP will not transition to RS_REMOVED if it receives a
// configuration that does not contain it.
logger::globalLogDomain()->setMinimumLoggedSeverity(logger::LogSeverity::Debug(3));
- ReplicaSetConfig rsConfig = assertMakeRSConfigV0(BSON("_id"
- << "mySet"
- << "version" << 3 << "members"
- << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "h1:1")
- << BSON("_id" << 2 << "host"
- << "h2:1")
- << BSON("_id" << 3 << "host"
- << "h3:1"))));
+ ReplicaSetConfig rsConfig =
+ assertMakeRSConfig(BSON("_id"
+ << "mySet"
+ << "version" << 3 << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "h1:1")
+ << BSON("_id" << 2 << "host"
+ << "h2:1") << BSON("_id" << 3 << "host"
+ << "h3:1"))));
init("mySet");
addSelf(HostAndPort("h4", 1));
const Date_t startDate = getNet()->now();
diff --git a/src/mongo/db/repl/replication_coordinator_impl_heartbeat_v1_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_heartbeat_v1_test.cpp
index 9fc73d5ec61..f7a70005a7f 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_heartbeat_v1_test.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_heartbeat_v1_test.cpp
@@ -94,7 +94,7 @@ TEST_F(ReplCoordHBV1Test, JoinExistingReplSet) {
<< BSON("_id" << 2 << "host"
<< "h2:1") << BSON("_id" << 3 << "host"
<< "h3:1"))
- << "protocolVersion" << 1));
+ << "settings" << BSON("protocolVersion" << 1)));
init("mySet");
addSelf(HostAndPort("h2", 1));
const Date_t startDate = getNet()->now();
@@ -157,7 +157,7 @@ TEST_F(ReplCoordHBV1Test, DoNotJoinReplSetIfNotAMember) {
<< BSON("_id" << 2 << "host"
<< "h2:1") << BSON("_id" << 3 << "host"
<< "h3:1"))
- << "protocolVersion" << 1));
+ << "settings" << BSON("protocolVersion" << 1)));
init("mySet");
addSelf(HostAndPort("h4", 1));
const Date_t startDate = getNet()->now();
diff --git a/src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp
index d75b2c847fa..e35a58eaae9 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp
@@ -100,7 +100,7 @@ TEST_F(ReplCoordTest, ReconfigWithUninitializableConfig) {
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastOptime(OpTime(Timestamp(100, 0), 0));
- simulateSuccessfulV1Election();
+ simulateSuccessfulElection();
BSONObjBuilder result;
ReplSetReconfigArgs args;
@@ -133,7 +133,7 @@ TEST_F(ReplCoordTest, ReconfigWithWrongReplSetName) {
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastOptime(OpTime(Timestamp(100, 0), 0));
- simulateSuccessfulV1Election();
+ simulateSuccessfulElection();
BSONObjBuilder result;
ReplSetReconfigArgs args;
@@ -164,7 +164,7 @@ TEST_F(ReplCoordTest, ReconfigValidateFails) {
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastOptime(OpTime(Timestamp(100, 0), 0));
- simulateSuccessfulV1Election();
+ simulateSuccessfulElection();
BSONObjBuilder result;
ReplSetReconfigArgs args;
@@ -227,7 +227,7 @@ TEST_F(ReplCoordTest, ReconfigQuorumCheckFails) {
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastOptime(OpTime(Timestamp(100, 0), 0));
- simulateSuccessfulV1Election();
+ simulateSuccessfulElection();
Status status(ErrorCodes::InternalError, "Not Set");
stdx::thread reconfigThread(stdx::bind(doReplSetReconfig, getReplCoord(), &status));
@@ -265,7 +265,7 @@ TEST_F(ReplCoordTest, ReconfigStoreLocalConfigDocumentFails) {
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastOptime(OpTime(Timestamp(100, 0), 0));
- simulateSuccessfulV1Election();
+ simulateSuccessfulElection();
Status status(ErrorCodes::InternalError, "Not Set");
getExternalState()->setStoreLocalConfigDocumentStatus(
@@ -290,7 +290,7 @@ TEST_F(ReplCoordTest, ReconfigWhileReconfiggingFails) {
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastOptime(OpTime(Timestamp(100, 0), 0));
- simulateSuccessfulV1Election();
+ simulateSuccessfulElection();
Status status(ErrorCodes::InternalError, "Not Set");
// first reconfig
@@ -367,7 +367,7 @@ TEST_F(ReplCoordTest, ReconfigSuccessful) {
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastOptime(OpTime(Timestamp(100, 0), 0));
- simulateSuccessfulV1Election();
+ simulateSuccessfulElection();
Status status(ErrorCodes::InternalError, "Not Set");
stdx::thread reconfigThread(stdx::bind(doReplSetReconfig, getReplCoord(), &status));
@@ -406,7 +406,7 @@ TEST_F(ReplCoordTest, ReconfigDuringHBReconfigFails) {
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastOptime(OpTime(Timestamp(100, 0), 0));
- simulateSuccessfulV1Election();
+ simulateSuccessfulElection();
ASSERT_TRUE(getReplCoord()->getMemberState().primary());
// set hbreconfig to hang while in progress
@@ -461,7 +461,7 @@ TEST_F(ReplCoordTest, HBReconfigDuringReconfigFails) {
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastOptime(OpTime(Timestamp(100, 0), 0));
- simulateSuccessfulV1Election();
+ simulateSuccessfulElection();
ASSERT_TRUE(getReplCoord()->getMemberState().primary());
// start reconfigThread
diff --git a/src/mongo/db/repl/replication_coordinator_impl_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_test.cpp
index fe2811a8127..cce2003c814 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_test.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_test.cpp
@@ -44,7 +44,6 @@
#include "mongo/db/repl/read_concern_args.h"
#include "mongo/db/repl/read_concern_response.h"
#include "mongo/db/repl/repl_set_heartbeat_args.h"
-#include "mongo/db/repl/repl_set_heartbeat_args_v1.h"
#include "mongo/db/repl/repl_settings.h"
#include "mongo/db/repl/replica_set_config.h"
#include "mongo/db/repl/replication_coordinator.h" // ReplSetReconfigArgs
@@ -92,18 +91,6 @@ struct OpTimeWithTermZero {
Timestamp timestamp;
};
-void runSingleNodeElection(ReplicationCoordinatorImpl* replCoord) {
- replCoord->setMyLastOptime(OpTime(Timestamp(1, 0), 0));
- ASSERT(replCoord->setFollowerMode(MemberState::RS_SECONDARY));
- replCoord->waitForElectionFinish_forTest();
-
- ASSERT(replCoord->isWaitingForApplierToDrain());
- ASSERT(replCoord->getMemberState().primary()) << replCoord->getMemberState().toString();
-
- OperationContextReplMock txn;
- replCoord->signalDrainComplete(&txn);
-}
-
TEST_F(ReplCoordTest, StartupWithValidLocalConfig) {
assertStartSuccess(BSON("_id"
<< "mySet"
@@ -694,7 +681,7 @@ TEST_F(ReplCoordTest, AwaitReplicationReplSetBaseCases) {
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastOptime(OpTimeWithTermZero(100, 0));
- simulateSuccessfulV1Election();
+ simulateSuccessfulElection();
statusAndDur = getReplCoord()->awaitReplication(&txn, time, writeConcern);
ASSERT_OK(statusAndDur.status);
@@ -721,7 +708,7 @@ TEST_F(ReplCoordTest, AwaitReplicationNumberOfNodesNonBlocking) {
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastOptime(OpTimeWithTermZero(100, 0));
- simulateSuccessfulV1Election();
+ simulateSuccessfulElection();
OpTimeWithTermZero time1(100, 1);
OpTimeWithTermZero time2(100, 2);
@@ -809,7 +796,7 @@ TEST_F(ReplCoordTest, AwaitReplicationNamedModesNonBlocking) {
HostAndPort("node0"));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastOptime(OpTime(Timestamp(100, 0), 0));
- simulateSuccessfulV1Election();
+ simulateSuccessfulElection();
OpTime time1(Timestamp(100, 1), 1);
OpTime time2(Timestamp(100, 2), 1);
@@ -977,7 +964,7 @@ TEST_F(ReplCoordTest, AwaitReplicationNumberOfNodesBlocking) {
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastOptime(OpTimeWithTermZero(100, 0));
- simulateSuccessfulV1Election();
+ simulateSuccessfulElection();
ReplicationAwaiter awaiter(getReplCoord(), &txn);
@@ -1033,7 +1020,7 @@ TEST_F(ReplCoordTest, AwaitReplicationTimeout) {
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastOptime(OpTimeWithTermZero(100, 0));
- simulateSuccessfulV1Election();
+ simulateSuccessfulElection();
ReplicationAwaiter awaiter(getReplCoord(), &txn);
@@ -1071,7 +1058,7 @@ TEST_F(ReplCoordTest, AwaitReplicationShutdown) {
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastOptime(OpTimeWithTermZero(100, 0));
- simulateSuccessfulV1Election();
+ simulateSuccessfulElection();
ReplicationAwaiter awaiter(getReplCoord(), &txn);
@@ -1112,7 +1099,7 @@ TEST_F(ReplCoordTest, AwaitReplicationStepDown) {
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastOptime(OpTimeWithTermZero(100, 0));
- simulateSuccessfulV1Election();
+ simulateSuccessfulElection();
ReplicationAwaiter awaiter(getReplCoord(), &txn);
@@ -1150,7 +1137,7 @@ TEST_F(ReplCoordTest, AwaitReplicationInterrupt) {
HostAndPort("node1"));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastOptime(OpTimeWithTermZero(100, 0));
- simulateSuccessfulV1Election();
+ simulateSuccessfulElection();
ReplicationAwaiter awaiter(getReplCoord(), &txn);
@@ -1270,7 +1257,7 @@ TEST_F(StepDownTest, StepDownTimeoutAcquiringGlobalLock) {
ASSERT_OK(getReplCoord()->setLastOptime_forTest(1, 1, optime1));
ASSERT_OK(getReplCoord()->setLastOptime_forTest(1, 2, optime1));
- simulateSuccessfulV1Election();
+ simulateSuccessfulElection();
// Make sure stepDown cannot grab the global shared lock
Lock::GlobalWrite lk(txn.lockState());
@@ -1288,7 +1275,7 @@ TEST_F(StepDownTest, StepDownNoWaiting) {
ASSERT_OK(getReplCoord()->setLastOptime_forTest(1, 1, optime1));
ASSERT_OK(getReplCoord()->setLastOptime_forTest(1, 2, optime1));
- simulateSuccessfulV1Election();
+ simulateSuccessfulElection();
enterNetwork();
getNet()->runUntil(getNet()->now() + Seconds(2));
@@ -1296,7 +1283,7 @@ TEST_F(StepDownTest, StepDownNoWaiting) {
NetworkInterfaceMock::NetworkOperationIterator noi = getNet()->getNextReadyRequest();
RemoteCommandRequest request = noi->getRequest();
log() << request.target.toString() << " processing " << request.cmdObj;
- ReplSetHeartbeatArgsV1 hbArgs;
+ ReplSetHeartbeatArgs hbArgs;
if (hbArgs.initialize(request.cmdObj).isOK()) {
ReplSetHeartbeatResponse hbResp;
hbResp.setSetName(hbArgs.getSetName());
@@ -1334,7 +1321,9 @@ TEST_F(ReplCoordTest, StepDownAndBackUpSingleNode) {
<< "test1:1234"))),
HostAndPort("test1", 1234));
OperationContextReplMock txn;
- runSingleNodeElection(getReplCoord());
+ getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY);
+
+ ASSERT_TRUE(getReplCoord()->getMemberState().primary());
ASSERT_OK(getReplCoord()->stepDown(&txn, true, Milliseconds(0), Milliseconds(1000)));
getNet()->enterNetwork(); // Must do this before inspecting the topocoord
Date_t stepdownUntil = getNet()->now() + Seconds(1);
@@ -1430,7 +1419,7 @@ TEST_F(StepDownTest, StepDownNotCaughtUp) {
runner.setWaitTime(Milliseconds(0));
runner.setStepDownTime(Milliseconds(1000));
- simulateSuccessfulV1Election();
+ simulateSuccessfulElection();
runner.start(&txn);
Status status = runner.getResult();
@@ -1471,7 +1460,7 @@ TEST_F(StepDownTest, StepDownCatchUp) {
runner.setWaitTime(Milliseconds(10000));
runner.setStepDownTime(Milliseconds(60000));
- simulateSuccessfulV1Election();
+ simulateSuccessfulElection();
runner.start(&txn);
@@ -1482,7 +1471,7 @@ TEST_F(StepDownTest, StepDownCatchUp) {
NetworkInterfaceMock::NetworkOperationIterator noi = getNet()->getNextReadyRequest();
RemoteCommandRequest request = noi->getRequest();
log() << request.target.toString() << " processing " << request.cmdObj;
- ReplSetHeartbeatArgsV1 hbArgs;
+ ReplSetHeartbeatArgs hbArgs;
if (hbArgs.initialize(request.cmdObj).isOK()) {
ReplSetHeartbeatResponse hbResp;
hbResp.setSetName(hbArgs.getSetName());
@@ -1520,7 +1509,7 @@ TEST_F(StepDownTest, InterruptStepDown) {
runner.setWaitTime(Milliseconds(10000));
runner.setStepDownTime(Milliseconds(60000));
- simulateSuccessfulV1Election();
+ simulateSuccessfulElection();
ASSERT_TRUE(getReplCoord()->getMemberState().primary());
runner.start(&txn);
@@ -1603,14 +1592,13 @@ TEST_F(ReplCoordTest, TestPrepareReplSetUpdatePositionCommand) {
memberIds.insert(memberId);
if (memberId == 0) {
// TODO(siyuan) Update when we change replSetUpdatePosition format
- ASSERT_EQUALS(optime1.timestamp, entry["optime"]["ts"].timestamp());
+ ASSERT_EQUALS(optime1.timestamp, entry["optime"].timestamp());
} else if (memberId == 1) {
- ASSERT_EQUALS(optime2.timestamp, entry["optime"]["ts"].timestamp());
+ ASSERT_EQUALS(optime2.timestamp, entry["optime"].timestamp());
} else {
ASSERT_EQUALS(2, memberId);
- ASSERT_EQUALS(optime3.timestamp, entry["optime"]["ts"].timestamp());
+ ASSERT_EQUALS(optime3.timestamp, entry["optime"].timestamp());
}
- ASSERT_EQUALS(0, entry["optime"]["t"].Number());
}
ASSERT_EQUALS(3U, memberIds.size()); // Make sure we saw all 3 nodes
}
@@ -1928,7 +1916,7 @@ TEST_F(ReplCoordTest, UpdatePositionWithConfigVersionAndMemberIdTest) {
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastOptime(OpTimeWithTermZero(100, 0));
- simulateSuccessfulV1Election();
+ simulateSuccessfulElection();
OpTimeWithTermZero time1(100, 1);
OpTimeWithTermZero time2(100, 2);
@@ -2028,7 +2016,7 @@ TEST_F(ReplCoordTest, AwaitReplicationReconfigSimple) {
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastOptime(OpTimeWithTermZero(100, 2));
- simulateSuccessfulV1Election();
+ simulateSuccessfulElection();
OpTimeWithTermZero time(100, 2);
@@ -2090,7 +2078,7 @@ TEST_F(ReplCoordTest, AwaitReplicationReconfigNodeCountExceedsNumberOfNodes) {
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastOptime(OpTimeWithTermZero(100, 2));
- simulateSuccessfulV1Election();
+ simulateSuccessfulElection();
OpTimeWithTermZero time(100, 2);
@@ -2139,8 +2127,8 @@ TEST_F(ReplCoordTest, AwaitReplicationReconfigToSmallerMajority) {
<< "_id" << 4))),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
- getReplCoord()->setMyLastOptime(OpTimeWithTermZero(100, 1));
- simulateSuccessfulV1Election();
+ getReplCoord()->setMyLastOptime(OpTime(Timestamp(100, 1), 0));
+ simulateSuccessfulElection();
OpTime time(Timestamp(100, 2), 1);
@@ -2205,7 +2193,7 @@ TEST_F(ReplCoordTest, AwaitReplicationMajority) {
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
OpTime time(Timestamp(100, 0), 1);
getReplCoord()->setMyLastOptime(time);
- simulateSuccessfulV1Election();
+ simulateSuccessfulElection();
WriteConcernOptions majorityWriteConcern;
majorityWriteConcern.wTimeout = WriteConcernOptions::kNoWaiting;
@@ -2256,7 +2244,7 @@ TEST_F(ReplCoordTest, LastCommittedOpTime) {
OpTime zero(Timestamp(0, 0), 0);
OpTime time(Timestamp(100, 0), 1);
getReplCoord()->setMyLastOptime(time);
- simulateSuccessfulV1Election();
+ simulateSuccessfulElection();
ASSERT_EQUALS(zero, getReplCoord()->getLastCommittedOpTime());
ASSERT_OK(getReplCoord()->setLastOptime_forTest(2, 1, time));
@@ -2401,7 +2389,7 @@ TEST_F(ReplCoordTest, ReadAfterCommittedWhileShutdown) {
<< "node1:12345"
<< "_id" << 0))),
HostAndPort("node1", 12345));
- runSingleNodeElection(getReplCoord());
+ getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY);
getReplCoord()->setMyLastOptime(OpTime(Timestamp(10, 0), 0));
@@ -2422,7 +2410,7 @@ TEST_F(ReplCoordTest, ReadAfterCommittedInterrupted) {
<< "node1:12345"
<< "_id" << 0))),
HostAndPort("node1", 12345));
- runSingleNodeElection(getReplCoord());
+ getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY);
getReplCoord()->setMyLastOptime(OpTime(Timestamp(10, 0), 0));
@@ -2443,12 +2431,12 @@ TEST_F(ReplCoordTest, ReadAfterCommittedGreaterOpTime) {
<< "node1:12345"
<< "_id" << 0))),
HostAndPort("node1", 12345));
- runSingleNodeElection(getReplCoord());
+ getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY);
- getReplCoord()->setMyLastOptime(OpTime(Timestamp(100, 0), 1));
- getReplCoord()->onSnapshotCreate(OpTime(Timestamp(100, 0), 1), SnapshotName(1));
+ getReplCoord()->setMyLastOptime(OpTime(Timestamp(100, 0), 0));
+ getReplCoord()->onSnapshotCreate(OpTime(Timestamp(100, 0), 0), SnapshotName(1));
auto result = getReplCoord()->waitUntilOpTime(
- &txn, ReadConcernArgs(OpTime(Timestamp(50, 0), 1), ReadConcernLevel::kMajorityReadConcern));
+ &txn, ReadConcernArgs(OpTime(Timestamp(50, 0), 0), ReadConcernLevel::kMajorityReadConcern));
ASSERT_TRUE(result.didWait());
ASSERT_OK(result.getStatus());
@@ -2462,8 +2450,10 @@ TEST_F(ReplCoordTest, ReadAfterCommittedEqualOpTime) {
<< "node1:12345"
<< "_id" << 0))),
HostAndPort("node1", 12345));
- runSingleNodeElection(getReplCoord());
- OpTime time(Timestamp(100, 0), 1);
+ getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY);
+
+
+ OpTime time(Timestamp(100, 0), 0);
getReplCoord()->setMyLastOptime(time);
getReplCoord()->onSnapshotCreate(time, SnapshotName(1));
auto result = getReplCoord()->waitUntilOpTime(
@@ -2481,9 +2471,10 @@ TEST_F(ReplCoordTest, ReadAfterCommittedDeferredGreaterOpTime) {
<< "node1:12345"
<< "_id" << 0))),
HostAndPort("node1", 12345));
- runSingleNodeElection(getReplCoord());
- getReplCoord()->setMyLastOptime(OpTime(Timestamp(0, 0), 1));
- OpTime committedOpTime(Timestamp(200, 0), 1);
+ getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY);
+
+ getReplCoord()->setMyLastOptime(OpTime(Timestamp(0, 0), 0));
+ OpTime committedOpTime(Timestamp(200, 0), 0);
auto pseudoLogOp =
stdx::async(stdx::launch::async,
[this, &committedOpTime]() {
@@ -2494,7 +2485,7 @@ TEST_F(ReplCoordTest, ReadAfterCommittedDeferredGreaterOpTime) {
auto result = getReplCoord()->waitUntilOpTime(
&txn,
- ReadConcernArgs(OpTime(Timestamp(100, 0), 1), ReadConcernLevel::kMajorityReadConcern));
+ ReadConcernArgs(OpTime(Timestamp(100, 0), 0), ReadConcernLevel::kMajorityReadConcern));
pseudoLogOp.get();
ASSERT_TRUE(result.didWait());
@@ -2509,10 +2500,11 @@ TEST_F(ReplCoordTest, ReadAfterCommittedDeferredEqualOpTime) {
<< "node1:12345"
<< "_id" << 0))),
HostAndPort("node1", 12345));
- runSingleNodeElection(getReplCoord());
- getReplCoord()->setMyLastOptime(OpTime(Timestamp(0, 0), 1));
+ getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY);
+
+ getReplCoord()->setMyLastOptime(OpTime(Timestamp(0, 0), 0));
- OpTime opTimeToWait(Timestamp(100, 0), 1);
+ OpTime opTimeToWait(Timestamp(100, 0), 0);
auto pseudoLogOp =
stdx::async(stdx::launch::async,
@@ -2711,13 +2703,12 @@ TEST_F(ReplCoordTest, CancelAndRescheduleElectionTimeout) {
TEST_F(ReplCoordTest, CancelAndRescheduleElectionTimeoutWhenNotProtocolVersion1) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "protocolVersion" << 0 << "version" << 2 << "members"
- << BSON_ARRAY(BSON("host"
- << "node1:12345"
- << "_id" << 0)
- << BSON("host"
- << "node2:12345"
- << "_id" << 1))),
+ << "version" << 2 << "members" << BSON_ARRAY(BSON("host"
+ << "node1:12345"
+ << "_id" << 0)
+ << BSON("host"
+ << "node2:12345"
+ << "_id" << 1))),
HostAndPort("node1", 12345));
ReplicationCoordinatorImpl* replCoord = getReplCoord();
ASSERT_TRUE(replCoord->setFollowerMode(MemberState::RS_SECONDARY));
@@ -2923,7 +2914,7 @@ TEST_F(ReplCoordTest, SnapshotCommitting) {
<< "test1:1234"))),
HostAndPort("test1", 1234));
OperationContextReplMock txn;
- runSingleNodeElection(getReplCoord());
+ getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY);
OpTime time1(Timestamp(100, 1), 1);
OpTime time2(Timestamp(100, 2), 1);
diff --git a/src/mongo/db/repl/replication_coordinator_test_fixture.cpp b/src/mongo/db/repl/replication_coordinator_test_fixture.cpp
index 738626eabdc..7f0b3799217 100644
--- a/src/mongo/db/repl/replication_coordinator_test_fixture.cpp
+++ b/src/mongo/db/repl/replication_coordinator_test_fixture.cpp
@@ -61,18 +61,6 @@ ReplicaSetConfig ReplCoordTest::assertMakeRSConfig(const BSONObj& configBson) {
return config;
}
-ReplicaSetConfig ReplCoordTest::assertMakeRSConfigV0(const BSONObj& configBson) {
- return assertMakeRSConfig(addProtocolVersion(configBson, 0));
-}
-
-BSONObj ReplCoordTest::addProtocolVersion(const BSONObj& configDoc, int protocolVersion) {
- BSONObjBuilder builder;
- builder << "protocolVersion" << protocolVersion;
- builder.appendElementsUnique(configDoc);
- return builder.obj();
-}
-
-
void ReplCoordTest::setUp() {
_settings.replSet = "mySet/node1:12345,node2:54321";
}
@@ -161,12 +149,7 @@ void ReplCoordTest::start(const HostAndPort& selfHost) {
}
void ReplCoordTest::assertStartSuccess(const BSONObj& configDoc, const HostAndPort& selfHost) {
- // Set default protocol version to 1.
- if (!configDoc.hasField("protocolVersion")) {
- start(addProtocolVersion(configDoc, 1), selfHost);
- } else {
- start(configDoc, selfHost);
- }
+ start(configDoc, selfHost);
ASSERT_NE(MemberState::RS_STARTUP, getReplCoord()->getMemberState().s);
}
diff --git a/src/mongo/db/repl/replication_coordinator_test_fixture.h b/src/mongo/db/repl/replication_coordinator_test_fixture.h
index a4023857091..7d64c936fd0 100644
--- a/src/mongo/db/repl/replication_coordinator_test_fixture.h
+++ b/src/mongo/db/repl/replication_coordinator_test_fixture.h
@@ -67,24 +67,12 @@ public:
* Constructs a ReplicaSetConfig from the given BSON, or raises a test failure exception.
*/
static ReplicaSetConfig assertMakeRSConfig(const BSONObj& configBSON);
- static ReplicaSetConfig assertMakeRSConfigV0(const BSONObj& configBson);
-
- /**
- * Adds { protocolVersion: 0 or 1 } to the config.
- */
- static BSONObj addProtocolVersion(const BSONObj& configDoc, int protocolVersion);
protected:
virtual void setUp();
virtual void tearDown();
/**
- * Asserts that calling start(configDoc, selfHost) successfully initiates the
- * ReplicationCoordinator under test.
- */
- virtual void assertStartSuccess(const BSONObj& configDoc, const HostAndPort& selfHost);
-
- /**
* Gets the network mock.
*/
executor::NetworkInterfaceMock* getNet() {
@@ -196,6 +184,12 @@ protected:
void simulateSuccessfulV1Election();
/**
+ * Asserts that calling start(configDoc, selfHost) successfully initiates the
+ * ReplicationCoordinator under test.
+ */
+ void assertStartSuccess(const BSONObj& configDoc, const HostAndPort& selfHost);
+
+ /**
* Shuts down the objects under test.
*/
void shutdown();
diff --git a/src/mongo/db/repl/topology_coordinator_impl_v1_test.cpp b/src/mongo/db/repl/topology_coordinator_impl_v1_test.cpp
index 0b0e87e7a70..63f0c80532e 100644
--- a/src/mongo/db/repl/topology_coordinator_impl_v1_test.cpp
+++ b/src/mongo/db/repl/topology_coordinator_impl_v1_test.cpp
@@ -2307,14 +2307,12 @@ TEST_F(HeartbeatResponseTestV1, ShouldRespondNegativelyToPV0ElectionCommands) {
ASSERT_EQUALS("replset: incompatible replset protocol version: 1", status.reason());
ASSERT_TRUE(responseBuilder.obj().isEmpty());
- BSONObjBuilder electResponseBuilder;
ReplicationCoordinator::ReplSetElectArgs electArgs;
status = internalErrorStatus;
- getTopoCoord().prepareElectResponse(
- electArgs, Date_t(), OpTime(), &electResponseBuilder, &status);
+ getTopoCoord().prepareElectResponse(electArgs, Date_t(), OpTime(), &responseBuilder, &status);
ASSERT_EQUALS(ErrorCodes::BadValue, status);
ASSERT_EQUALS("replset: incompatible replset protocol version: 1", status.reason());
- ASSERT_TRUE(electResponseBuilder.obj().isEmpty());
+ ASSERT_TRUE(responseBuilder.obj().isEmpty());
}
TEST_F(HeartbeatResponseTestV1, ShouldChangeSyncSourceFresherMemberIsDown) {