summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/repl')
-rw-r--r--src/mongo/db/repl/applier_test.cpp64
-rw-r--r--src/mongo/db/repl/base_cloner_test_fixture.cpp5
-rw-r--r--src/mongo/db/repl/base_cloner_test_fixture.h2
-rw-r--r--src/mongo/db/repl/bgsync.cpp13
-rw-r--r--src/mongo/db/repl/check_quorum_for_config_change_test.cpp247
-rw-r--r--src/mongo/db/repl/collection_cloner.cpp4
-rw-r--r--src/mongo/db/repl/collection_cloner.h2
-rw-r--r--src/mongo/db/repl/collection_cloner_test.cpp12
-rw-r--r--src/mongo/db/repl/data_replicator.cpp4
-rw-r--r--src/mongo/db/repl/data_replicator.h4
-rw-r--r--src/mongo/db/repl/data_replicator_test.cpp387
-rw-r--r--src/mongo/db/repl/database_cloner.cpp32
-rw-r--r--src/mongo/db/repl/database_cloner.h2
-rw-r--r--src/mongo/db/repl/database_cloner_test.cpp115
-rw-r--r--src/mongo/db/repl/database_task.h2
-rw-r--r--src/mongo/db/repl/elect_cmd_runner_test.cpp41
-rw-r--r--src/mongo/db/repl/freshness_checker_test.cpp284
-rw-r--r--src/mongo/db/repl/freshness_scanner.cpp5
-rw-r--r--src/mongo/db/repl/freshness_scanner_test.cpp39
-rw-r--r--src/mongo/db/repl/is_master_response.cpp27
-rw-r--r--src/mongo/db/repl/isself.cpp6
-rw-r--r--src/mongo/db/repl/master_slave.cpp4
-rw-r--r--src/mongo/db/repl/member_config_test.cpp181
-rw-r--r--src/mongo/db/repl/old_update_position_args.cpp6
-rw-r--r--src/mongo/db/repl/oplog.cpp87
-rw-r--r--src/mongo/db/repl/oplog.h2
-rw-r--r--src/mongo/db/repl/oplog_fetcher.cpp41
-rw-r--r--src/mongo/db/repl/oplog_fetcher_test.cpp21
-rw-r--r--src/mongo/db/repl/oplog_interface_local.cpp4
-rw-r--r--src/mongo/db/repl/oplog_interface_mock.h2
-rw-r--r--src/mongo/db/repl/optime_extract_test.cpp3
-rw-r--r--src/mongo/db/repl/read_concern_args.cpp3
-rw-r--r--src/mongo/db/repl/read_concern_args_test.cpp116
-rw-r--r--src/mongo/db/repl/repl_set_heartbeat_response.cpp18
-rw-r--r--src/mongo/db/repl/repl_set_heartbeat_response_test.cpp12
-rw-r--r--src/mongo/db/repl/repl_set_html_summary.cpp2
-rw-r--r--src/mongo/db/repl/repl_settings.h2
-rw-r--r--src/mongo/db/repl/replica_set_config.cpp86
-rw-r--r--src/mongo/db/repl/replica_set_config_checks.cpp46
-rw-r--r--src/mongo/db/repl/replica_set_config_checks_test.cpp414
-rw-r--r--src/mongo/db/repl/replica_set_config_test.cpp1236
-rw-r--r--src/mongo/db/repl/replication_coordinator_external_state_impl.cpp19
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl.cpp74
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl.h2
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_elect.cpp4
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_elect_test.cpp176
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_elect_v1_test.cpp286
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp16
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_heartbeat_test.cpp24
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_heartbeat_v1_test.cpp133
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp114
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_test.cpp1711
-rw-r--r--src/mongo/db/repl/replication_coordinator_mock.cpp2
-rw-r--r--src/mongo/db/repl/replication_coordinator_test_fixture.cpp36
-rw-r--r--src/mongo/db/repl/replication_executor.cpp4
-rw-r--r--src/mongo/db/repl/replication_executor_test.cpp111
-rw-r--r--src/mongo/db/repl/replication_executor_test_fixture.h2
-rw-r--r--src/mongo/db/repl/replset_commands.cpp11
-rw-r--r--src/mongo/db/repl/replset_web_handler.cpp2
-rw-r--r--src/mongo/db/repl/reporter_test.cpp20
-rw-r--r--src/mongo/db/repl/resync.cpp2
-rw-r--r--src/mongo/db/repl/roll_back_local_operations_test.cpp10
-rw-r--r--src/mongo/db/repl/rollback_checker.cpp94
-rw-r--r--src/mongo/db/repl/rollback_source_impl.cpp2
-rw-r--r--src/mongo/db/repl/rs_initialsync.cpp7
-rw-r--r--src/mongo/db/repl/rs_rollback.cpp38
-rw-r--r--src/mongo/db/repl/rs_rollback_test.cpp95
-rw-r--r--src/mongo/db/repl/rs_sync.cpp2
-rw-r--r--src/mongo/db/repl/rs_sync.h2
-rw-r--r--src/mongo/db/repl/storage_interface_impl.cpp6
-rw-r--r--src/mongo/db/repl/sync_source_feedback.cpp38
-rw-r--r--src/mongo/db/repl/sync_tail.cpp9
-rw-r--r--src/mongo/db/repl/sync_tail_test.cpp76
-rw-r--r--src/mongo/db/repl/task_runner.cpp2
-rw-r--r--src/mongo/db/repl/topology_coordinator.h2
-rw-r--r--src/mongo/db/repl/topology_coordinator_impl.cpp32
-rw-r--r--src/mongo/db/repl/topology_coordinator_impl_test.cpp1584
-rw-r--r--src/mongo/db/repl/topology_coordinator_impl_v1_test.cpp1456
-rw-r--r--src/mongo/db/repl/update_position_args.cpp2
-rw-r--r--src/mongo/db/repl/vote_requester_test.cpp80
80 files changed, 6257 insertions, 3612 deletions
diff --git a/src/mongo/db/repl/applier_test.cpp b/src/mongo/db/repl/applier_test.cpp
index 2b49a92dc19..8ef0bf4db30 100644
--- a/src/mongo/db/repl/applier_test.cpp
+++ b/src/mongo/db/repl/applier_test.cpp
@@ -304,13 +304,16 @@ TEST_F(ApplierTest, ApplyOperationSuccessful) {
Applier::Operations operationsToApply{
OplogEntry(BSON("op"
<< "a"
- << "ts" << Timestamp(Seconds(123), 0))),
+ << "ts"
+ << Timestamp(Seconds(123), 0))),
OplogEntry(BSON("op"
<< "b"
- << "ts" << Timestamp(Seconds(456), 0))),
+ << "ts"
+ << Timestamp(Seconds(456), 0))),
OplogEntry(BSON("op"
<< "c"
- << "ts" << Timestamp(Seconds(789), 0))),
+ << "ts"
+ << Timestamp(Seconds(789), 0))),
};
stdx::mutex mutex;
StatusWith<Timestamp> result = getDetectableErrorStatus();
@@ -352,13 +355,16 @@ void ApplierTest::_testApplyOperationFailed(size_t opIndex, stdx::function<Statu
Applier::Operations operationsToApply{
OplogEntry(BSON("op"
<< "a"
- << "ts" << Timestamp(Seconds(123), 0))),
+ << "ts"
+ << Timestamp(Seconds(123), 0))),
OplogEntry(BSON("op"
<< "b"
- << "ts" << Timestamp(Seconds(456), 0))),
+ << "ts"
+ << Timestamp(Seconds(456), 0))),
OplogEntry(BSON("op"
<< "c"
- << "ts" << Timestamp(Seconds(789), 0))),
+ << "ts"
+ << Timestamp(Seconds(789), 0))),
};
stdx::mutex mutex;
StatusWith<Timestamp> result = getDetectableErrorStatus();
@@ -403,12 +409,11 @@ TEST_F(ApplierTest, ApplyOperationFailedOnFirstOperation) {
}
TEST_F(ApplierTest, ApplyOperationThrowsExceptionOnFirstOperation) {
- _testApplyOperationFailed(0U,
- []() {
- uasserted(ErrorCodes::OperationFailed, "");
- MONGO_UNREACHABLE;
- return Status(ErrorCodes::InternalError, "unreachable");
- });
+ _testApplyOperationFailed(0U, []() {
+ uasserted(ErrorCodes::OperationFailed, "");
+ MONGO_UNREACHABLE;
+ return Status(ErrorCodes::InternalError, "unreachable");
+ });
}
TEST_F(ApplierTest, ApplyOperationFailedOnSecondOperation) {
@@ -416,12 +421,11 @@ TEST_F(ApplierTest, ApplyOperationFailedOnSecondOperation) {
}
TEST_F(ApplierTest, ApplyOperationThrowsExceptionOnSecondOperation) {
- _testApplyOperationFailed(1U,
- []() {
- uasserted(ErrorCodes::OperationFailed, "");
- MONGO_UNREACHABLE;
- return Status(ErrorCodes::InternalError, "unreachable");
- });
+ _testApplyOperationFailed(1U, []() {
+ uasserted(ErrorCodes::OperationFailed, "");
+ MONGO_UNREACHABLE;
+ return Status(ErrorCodes::InternalError, "unreachable");
+ });
}
TEST_F(ApplierTest, ApplyOperationFailedOnLastOperation) {
@@ -429,12 +433,11 @@ TEST_F(ApplierTest, ApplyOperationFailedOnLastOperation) {
}
TEST_F(ApplierTest, ApplyOperationThrowsExceptionOnLastOperation) {
- _testApplyOperationFailed(2U,
- []() {
- uasserted(ErrorCodes::OperationFailed, "");
- MONGO_UNREACHABLE;
- return Status(ErrorCodes::InternalError, "unreachable");
- });
+ _testApplyOperationFailed(2U, []() {
+ uasserted(ErrorCodes::OperationFailed, "");
+ MONGO_UNREACHABLE;
+ return Status(ErrorCodes::InternalError, "unreachable");
+ });
}
class ApplyUntilAndPauseTest : public ApplierTest {};
@@ -454,8 +457,8 @@ TEST_F(ApplyUntilAndPauseTest, NoOperationsInRange) {
auto result = applyUntilAndPause(
&getReplExecutor(),
{
- OplogEntry(BSON("ts" << Timestamp(Seconds(456), 0))),
- OplogEntry(BSON("ts" << Timestamp(Seconds(789), 0))),
+ OplogEntry(BSON("ts" << Timestamp(Seconds(456), 0))),
+ OplogEntry(BSON("ts" << Timestamp(Seconds(789), 0))),
},
[](OperationContext* txn, const OplogEntry& operation) { return Status::OK(); },
Timestamp(Seconds(123), 0),
@@ -594,13 +597,16 @@ void _testApplyUntilAndPauseDiscardOperations(ReplicationExecutor* executor,
Applier::Operations operationsToApply{
OplogEntry(BSON("op"
<< "a"
- << "ts" << Timestamp(Seconds(123), 0))),
+ << "ts"
+ << Timestamp(Seconds(123), 0))),
OplogEntry(BSON("op"
<< "b"
- << "ts" << Timestamp(Seconds(456), 0))),
+ << "ts"
+ << Timestamp(Seconds(456), 0))),
OplogEntry(BSON("op"
<< "c"
- << "ts" << Timestamp(Seconds(789), 0))),
+ << "ts"
+ << Timestamp(Seconds(789), 0))),
};
stdx::mutex mutex;
StatusWith<Timestamp> completionResult = ApplyUntilAndPauseTest::getDetectableErrorStatus();
diff --git a/src/mongo/db/repl/base_cloner_test_fixture.cpp b/src/mongo/db/repl/base_cloner_test_fixture.cpp
index ea57b00133a..90c845c62f0 100644
--- a/src/mongo/db/repl/base_cloner_test_fixture.cpp
+++ b/src/mongo/db/repl/base_cloner_test_fixture.cpp
@@ -32,8 +32,8 @@
#include <memory>
-#include "mongo/stdx/thread.h"
#include "mongo/db/jsobj.h"
+#include "mongo/stdx/thread.h"
namespace mongo {
namespace repl {
@@ -45,7 +45,8 @@ const HostAndPort BaseClonerTest::target("localhost", -1);
const NamespaceString BaseClonerTest::nss("db.coll");
const BSONObj BaseClonerTest::idIndexSpec = BSON("v" << 1 << "key" << BSON("_id" << 1) << "name"
<< "_id_"
- << "ns" << nss.ns());
+ << "ns"
+ << nss.ns());
// static
BSONObj BaseClonerTest::createCursorResponse(CursorId cursorId,
diff --git a/src/mongo/db/repl/base_cloner_test_fixture.h b/src/mongo/db/repl/base_cloner_test_fixture.h
index cab5c517916..1451adb4960 100644
--- a/src/mongo/db/repl/base_cloner_test_fixture.h
+++ b/src/mongo/db/repl/base_cloner_test_fixture.h
@@ -38,8 +38,8 @@
#include "mongo/db/repl/collection_cloner.h"
#include "mongo/db/repl/replication_executor_test_fixture.h"
#include "mongo/executor/network_interface_mock.h"
-#include "mongo/stdx/mutex.h"
#include "mongo/stdx/condition_variable.h"
+#include "mongo/stdx/mutex.h"
#include "mongo/util/net/hostandport.h"
namespace mongo {
diff --git a/src/mongo/db/repl/bgsync.cpp b/src/mongo/db/repl/bgsync.cpp
index c5a5b08a0e7..fb6e689a019 100644
--- a/src/mongo/db/repl/bgsync.cpp
+++ b/src/mongo/db/repl/bgsync.cpp
@@ -304,8 +304,8 @@ void BackgroundSync::_produce(
log() << "Our newest OpTime : " << lastOpTimeFetched;
log() << "Earliest OpTime available is " << syncSourceResp.earliestOpTimeSeen;
log() << "See http://dochub.mongodb.org/core/resyncingaverystalereplicasetmember";
- StorageInterface::get(txn)
- ->setMinValid(txn, {lastOpTimeFetched, syncSourceResp.earliestOpTimeSeen});
+ StorageInterface::get(txn)->setMinValid(
+ txn, {lastOpTimeFetched, syncSourceResp.earliestOpTimeSeen});
auto status = _replCoord->setMaintenanceMode(true);
if (!status.isOK()) {
warning() << "Failed to transition into maintenance mode.";
@@ -439,10 +439,11 @@ void BackgroundSync::_produce(
if (!boundaries.start.isNull() || boundaries.end > lastApplied) {
fassertNoTrace(18750,
Status(ErrorCodes::UnrecoverableRollbackError,
- str::stream()
- << "need to rollback, but in inconsistent state. "
- << "minvalid: " << boundaries.end.toString()
- << " > our last optime: " << lastApplied.toString()));
+ str::stream() << "need to rollback, but in inconsistent state. "
+ << "minvalid: "
+ << boundaries.end.toString()
+ << " > our last optime: "
+ << lastApplied.toString()));
}
_rollback(txn, source, getConnection);
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 b8da58e4372..86527def28a 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
@@ -46,18 +46,18 @@
#include "mongo/unittest/unittest.h"
#include "mongo/util/net/hostandport.h"
-#define ASSERT_REASON_CONTAINS(STATUS, PATTERN) \
- do { \
- const mongo::Status s_ = (STATUS); \
- ASSERT_FALSE(s_.reason().find(PATTERN) == std::string::npos) \
- << #STATUS ".reason() == " << s_.reason(); \
+#define ASSERT_REASON_CONTAINS(STATUS, PATTERN) \
+ do { \
+ const mongo::Status s_ = (STATUS); \
+ ASSERT_FALSE(s_.reason().find(PATTERN) == std::string::npos) << #STATUS ".reason() == " \
+ << s_.reason(); \
} while (false)
-#define ASSERT_NOT_REASON_CONTAINS(STATUS, PATTERN) \
- do { \
- const mongo::Status s_ = (STATUS); \
- ASSERT_TRUE(s_.reason().find(PATTERN) == std::string::npos) \
- << #STATUS ".reason() == " << s_.reason(); \
+#define ASSERT_NOT_REASON_CONTAINS(STATUS, PATTERN) \
+ do { \
+ const mongo::Status s_ = (STATUS); \
+ ASSERT_TRUE(s_.reason().find(PATTERN) == std::string::npos) << #STATUS ".reason() == " \
+ << s_.reason(); \
} while (false)
namespace mongo {
@@ -155,7 +155,9 @@ ReplicaSetConfig assertMakeRSConfig(const BSONObj& configBson) {
TEST_F(CheckQuorumForInitiate, ValidSingleNodeSet) {
ReplicaSetConfig config = assertMakeRSConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1"))));
startQuorumCheck(config, 0);
@@ -166,7 +168,9 @@ TEST_F(CheckQuorumForInitiate, QuorumCheckCanceledByShutdown) {
_executor->shutdown();
ReplicaSetConfig config = assertMakeRSConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1"))));
startQuorumCheck(config, 0);
@@ -177,18 +181,21 @@ TEST_F(CheckQuorumForInitiate, QuorumCheckFailedDueToSeveralDownNodes) {
// In this test, "we" are host "h3:1". All other nodes time out on
// their heartbeat request, and so the quorum check for initiate
// will fail because some members were unavailable.
- ReplicaSetConfig config =
- assertMakeRSConfig(BSON("_id"
- << "rs0"
- << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "h1:1")
- << BSON("_id" << 2 << "host"
- << "h2:1") << BSON("_id" << 3 << "host"
- << "h3:1")
- << BSON("_id" << 4 << "host"
- << "h4:1") << BSON("_id" << 5 << "host"
- << "h5:1"))));
+ ReplicaSetConfig config = assertMakeRSConfig(BSON("_id"
+ << "rs0"
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "h1:1")
+ << BSON("_id" << 2 << "host"
+ << "h2:1")
+ << BSON("_id" << 3 << "host"
+ << "h3:1")
+ << BSON("_id" << 4 << "host"
+ << "h4:1")
+ << BSON("_id" << 5 << "host"
+ << "h5:1"))));
startQuorumCheck(config, 2);
_net->enterNetwork();
const Date_t startDate = _net->now();
@@ -231,15 +238,19 @@ TEST_F(CheckQuorumForInitiate, QuorumCheckSuccessForFiveNodes) {
const ReplicaSetConfig rsConfig =
assertMakeRSConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1:1")
<< BSON("_id" << 2 << "host"
- << "h2:1") << BSON("_id" << 3 << "host"
- << "h3:1")
+ << "h2:1")
+ << BSON("_id" << 3 << "host"
+ << "h3:1")
<< BSON("_id" << 4 << "host"
- << "h4:1") << BSON("_id" << 5 << "host"
- << "h5:1"))));
+ << "h4:1")
+ << BSON("_id" << 5 << "host"
+ << "h5:1"))));
const int myConfigIndex = 2;
const BSONObj hbRequest = makeHeartbeatRequest(rsConfig, myConfigIndex);
@@ -274,18 +285,25 @@ TEST_F(CheckQuorumForInitiate, QuorumCheckFailedDueToOneDownNode) {
const ReplicaSetConfig rsConfig =
assertMakeRSConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1:1")
<< BSON("_id" << 2 << "host"
<< "h2:1"
- << "priority" << 0 << "votes" << 0)
+ << "priority"
+ << 0
+ << "votes"
+ << 0)
<< BSON("_id" << 3 << "host"
- << "h3:1") << BSON("_id" << 4 << "host"
- << "h4:1")
+ << "h3:1")
+ << BSON("_id" << 4 << "host"
+ << "h4:1")
<< BSON("_id" << 5 << "host"
- << "h5:1") << BSON("_id" << 6 << "host"
- << "h6:1"))));
+ << "h5:1")
+ << BSON("_id" << 6 << "host"
+ << "h6:1"))));
const int myConfigIndex = 2;
const BSONObj hbRequest = makeHeartbeatRequest(rsConfig, myConfigIndex);
@@ -334,15 +352,19 @@ TEST_F(CheckQuorumForInitiate, QuorumCheckFailedDueToSetNameMismatch) {
const ReplicaSetConfig rsConfig =
assertMakeRSConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1:1")
<< BSON("_id" << 2 << "host"
- << "h2:1") << BSON("_id" << 3 << "host"
- << "h3:1")
+ << "h2:1")
+ << BSON("_id" << 3 << "host"
+ << "h3:1")
<< BSON("_id" << 4 << "host"
- << "h4:1") << BSON("_id" << 5 << "host"
- << "h5:1"))));
+ << "h4:1")
+ << BSON("_id" << 5 << "host"
+ << "h5:1"))));
const int myConfigIndex = 2;
const BSONObj hbRequest = makeHeartbeatRequest(rsConfig, myConfigIndex);
@@ -392,16 +414,21 @@ TEST_F(CheckQuorumForInitiate, QuorumCheckFailedDueToSetIdMismatch) {
const ReplicaSetConfig rsConfig =
assertMakeRSConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1:1")
<< BSON("_id" << 2 << "host"
- << "h2:1") << BSON("_id" << 3 << "host"
- << "h3:1")
+ << "h2:1")
+ << BSON("_id" << 3 << "host"
+ << "h3:1")
<< BSON("_id" << 4 << "host"
- << "h4:1") << BSON("_id" << 5 << "host"
- << "h5:1"))
- << "settings" << BSON("replicaSetId" << replicaSetId)));
+ << "h4:1")
+ << BSON("_id" << 5 << "host"
+ << "h5:1"))
+ << "settings"
+ << BSON("replicaSetId" << replicaSetId)));
const int myConfigIndex = 2;
const BSONObj hbRequest = makeHeartbeatRequest(rsConfig, myConfigIndex);
@@ -449,8 +476,10 @@ TEST_F(CheckQuorumForInitiate, QuorumCheckFailedDueToSetIdMismatch) {
ASSERT_EQUALS(ErrorCodes::NewReplicaSetConfigurationIncompatible, status);
ASSERT_REASON_CONTAINS(status,
str::stream() << "Our replica set ID of " << replicaSetId
- << " did not match that of " << incompatibleHost.toString()
- << ", which is " << unexpectedId);
+ << " did not match that of "
+ << incompatibleHost.toString()
+ << ", which is "
+ << unexpectedId);
ASSERT_NOT_REASON_CONTAINS(status, "h1:1");
ASSERT_NOT_REASON_CONTAINS(status, "h2:1");
ASSERT_NOT_REASON_CONTAINS(status, "h3:1");
@@ -466,15 +495,19 @@ TEST_F(CheckQuorumForInitiate, QuorumCheckFailedDueToInitializedNode) {
const ReplicaSetConfig rsConfig =
assertMakeRSConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1:1")
<< BSON("_id" << 2 << "host"
- << "h2:1") << BSON("_id" << 3 << "host"
- << "h3:1")
+ << "h2:1")
+ << BSON("_id" << 3 << "host"
+ << "h3:1")
<< BSON("_id" << 4 << "host"
- << "h4:1") << BSON("_id" << 5 << "host"
- << "h5:1"))));
+ << "h4:1")
+ << BSON("_id" << 5 << "host"
+ << "h5:1"))));
const int myConfigIndex = 2;
const BSONObj hbRequest = makeHeartbeatRequest(rsConfig, myConfigIndex);
@@ -495,7 +528,8 @@ TEST_F(CheckQuorumForInitiate, QuorumCheckFailedDueToInitializedNode) {
startDate + Milliseconds(10),
ResponseStatus(RemoteCommandResponse(BSON("ok" << 0 << "set"
<< "rs0"
- << "v" << 1),
+ << "v"
+ << 1),
BSONObj(),
Milliseconds(8))));
} else {
@@ -527,15 +561,19 @@ TEST_F(CheckQuorumForInitiate, QuorumCheckFailedDueToInitializedNodeOnlyOneRespo
const ReplicaSetConfig rsConfig =
assertMakeRSConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1:1")
<< BSON("_id" << 2 << "host"
- << "h2:1") << BSON("_id" << 3 << "host"
- << "h3:1")
+ << "h2:1")
+ << BSON("_id" << 3 << "host"
+ << "h3:1")
<< BSON("_id" << 4 << "host"
- << "h4:1") << BSON("_id" << 5 << "host"
- << "h5:1"))));
+ << "h4:1")
+ << BSON("_id" << 5 << "host"
+ << "h5:1"))));
const int myConfigIndex = 2;
const BSONObj hbRequest = makeHeartbeatRequest(rsConfig, myConfigIndex);
@@ -556,7 +594,8 @@ TEST_F(CheckQuorumForInitiate, QuorumCheckFailedDueToInitializedNodeOnlyOneRespo
startDate + Milliseconds(10),
ResponseStatus(RemoteCommandResponse(BSON("ok" << 0 << "set"
<< "rs0"
- << "v" << 1),
+ << "v"
+ << 1),
BSONObj(),
Milliseconds(8))));
} else {
@@ -583,15 +622,19 @@ TEST_F(CheckQuorumForInitiate, QuorumCheckFailedDueToNodeWithData) {
const ReplicaSetConfig rsConfig =
assertMakeRSConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1:1")
<< BSON("_id" << 2 << "host"
- << "h2:1") << BSON("_id" << 3 << "host"
- << "h3:1")
+ << "h2:1")
+ << BSON("_id" << 3 << "host"
+ << "h3:1")
<< BSON("_id" << 4 << "host"
- << "h4:1") << BSON("_id" << 5 << "host"
- << "h5:1"))));
+ << "h4:1")
+ << BSON("_id" << 5 << "host"
+ << "h5:1"))));
const int myConfigIndex = 2;
const BSONObj hbRequest = makeHeartbeatRequest(rsConfig, myConfigIndex);
@@ -637,12 +680,15 @@ TEST_F(CheckQuorumForReconfig, QuorumCheckVetoedDueToHigherConfigVersion) {
const ReplicaSetConfig rsConfig =
assertMakeRSConfig(BSON("_id"
<< "rs0"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1:1")
<< BSON("_id" << 2 << "host"
- << "h2:1") << BSON("_id" << 3 << "host"
- << "h3:1"))));
+ << "h2:1")
+ << BSON("_id" << 3 << "host"
+ << "h3:1"))));
const int myConfigIndex = 2;
const BSONObj hbRequest = makeHeartbeatRequest(rsConfig, myConfigIndex);
@@ -663,7 +709,8 @@ TEST_F(CheckQuorumForReconfig, QuorumCheckVetoedDueToHigherConfigVersion) {
startDate + Milliseconds(10),
ResponseStatus(RemoteCommandResponse(BSON("ok" << 0 << "set"
<< "rs0"
- << "v" << 5),
+ << "v"
+ << 5),
BSONObj(),
Milliseconds(8))));
} else {
@@ -688,12 +735,15 @@ TEST_F(CheckQuorumForReconfig, QuorumCheckVetoedDueToIncompatibleSetName) {
const ReplicaSetConfig rsConfig =
assertMakeRSConfig(BSON("_id"
<< "rs0"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1:1")
<< BSON("_id" << 2 << "host"
- << "h2:1") << BSON("_id" << 3 << "host"
- << "h3:1"))));
+ << "h2:1")
+ << BSON("_id" << 3 << "host"
+ << "h3:1"))));
const int myConfigIndex = 2;
const BSONObj hbRequest = makeHeartbeatRequest(rsConfig, myConfigIndex);
@@ -740,18 +790,27 @@ TEST_F(CheckQuorumForReconfig, QuorumCheckFailsDueToInsufficientVoters) {
const ReplicaSetConfig rsConfig =
assertMakeRSConfig(BSON("_id"
<< "rs0"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1:1")
<< BSON("_id" << 2 << "host"
- << "h2:1") << BSON("_id" << 3 << "host"
- << "h3:1")
+ << "h2:1")
+ << BSON("_id" << 3 << "host"
+ << "h3:1")
<< BSON("_id" << 4 << "host"
<< "h4:1"
- << "votes" << 0 << "priority" << 0)
+ << "votes"
+ << 0
+ << "priority"
+ << 0)
<< BSON("_id" << 5 << "host"
<< "h5:1"
- << "votes" << 0 << "priority" << 0))));
+ << "votes"
+ << 0
+ << "priority"
+ << 0))));
const int myConfigIndex = 3;
const BSONObj hbRequest = makeHeartbeatRequest(rsConfig, myConfigIndex);
@@ -797,18 +856,23 @@ TEST_F(CheckQuorumForReconfig, QuorumCheckFailsDueToNoElectableNodeResponding) {
const ReplicaSetConfig rsConfig =
assertMakeRSConfig(BSON("_id"
<< "rs0"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1:1")
<< BSON("_id" << 2 << "host"
- << "h2:1") << BSON("_id" << 3 << "host"
- << "h3:1")
+ << "h2:1")
+ << BSON("_id" << 3 << "host"
+ << "h3:1")
<< BSON("_id" << 4 << "host"
<< "h4:1"
- << "priority" << 0)
+ << "priority"
+ << 0)
<< BSON("_id" << 5 << "host"
<< "h5:1"
- << "priority" << 0))));
+ << "priority"
+ << 0))));
const int myConfigIndex = 3;
const BSONObj hbRequest = makeHeartbeatRequest(rsConfig, myConfigIndex);
@@ -850,18 +914,27 @@ TEST_F(CheckQuorumForReconfig, QuorumCheckSucceedsWithAsSoonAsPossible) {
const ReplicaSetConfig rsConfig =
assertMakeRSConfig(BSON("_id"
<< "rs0"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1:1")
<< BSON("_id" << 2 << "host"
- << "h2:1") << BSON("_id" << 3 << "host"
- << "h3:1")
+ << "h2:1")
+ << BSON("_id" << 3 << "host"
+ << "h3:1")
<< BSON("_id" << 4 << "host"
<< "h4:1"
- << "votes" << 0 << "priority" << 0)
+ << "votes"
+ << 0
+ << "priority"
+ << 0)
<< BSON("_id" << 5 << "host"
<< "h5:1"
- << "votes" << 0 << "priority" << 0))));
+ << "votes"
+ << 0
+ << "priority"
+ << 0))));
const int myConfigIndex = 3;
const BSONObj hbRequest = makeHeartbeatRequest(rsConfig, myConfigIndex);
diff --git a/src/mongo/db/repl/collection_cloner.cpp b/src/mongo/db/repl/collection_cloner.cpp
index 95c2fd66baf..ceae2886956 100644
--- a/src/mongo/db/repl/collection_cloner.cpp
+++ b/src/mongo/db/repl/collection_cloner.cpp
@@ -107,8 +107,8 @@ std::string CollectionCloner::getDiagnosticString() const {
output << " active: " << _active;
output << " listIndexes fetcher: " << _listIndexesFetcher.getDiagnosticString();
output << " find fetcher: " << _findFetcher.getDiagnosticString();
- output << " database worked callback handle: " << (_dbWorkCallbackHandle.isValid() ? "valid"
- : "invalid");
+ output << " database worked callback handle: "
+ << (_dbWorkCallbackHandle.isValid() ? "valid" : "invalid");
return output;
}
diff --git a/src/mongo/db/repl/collection_cloner.h b/src/mongo/db/repl/collection_cloner.h
index cf69d7f44ef..a7d9000bbfb 100644
--- a/src/mongo/db/repl/collection_cloner.h
+++ b/src/mongo/db/repl/collection_cloner.h
@@ -40,8 +40,8 @@
#include "mongo/db/namespace_string.h"
#include "mongo/db/repl/base_cloner.h"
#include "mongo/db/repl/replication_executor.h"
-#include "mongo/stdx/functional.h"
#include "mongo/stdx/condition_variable.h"
+#include "mongo/stdx/functional.h"
#include "mongo/stdx/mutex.h"
#include "mongo/util/net/hostandport.h"
diff --git a/src/mongo/db/repl/collection_cloner_test.cpp b/src/mongo/db/repl/collection_cloner_test.cpp
index 5ac2c71c992..c0320dc16b6 100644
--- a/src/mongo/db/repl/collection_cloner_test.cpp
+++ b/src/mongo/db/repl/collection_cloner_test.cpp
@@ -140,7 +140,8 @@ TEST_F(CollectionClonerTest, RemoteCollectionMissing) {
processNetworkResponse(BSON("ok" << 0 << "errmsg"
<< ""
- << "code" << ErrorCodes::NamespaceNotFound));
+ << "code"
+ << ErrorCodes::NamespaceNotFound));
ASSERT_EQUALS(ErrorCodes::NamespaceNotFound, getStatus().code());
ASSERT_FALSE(collectionCloner->isActive());
@@ -238,10 +239,12 @@ TEST_F(CollectionClonerTest, BeginCollection) {
const std::vector<BSONObj> specs = {idIndexSpec,
BSON("v" << 1 << "key" << BSON("a" << 1) << "name"
<< "a_1"
- << "ns" << nss.ns()),
+ << "ns"
+ << nss.ns()),
BSON("v" << 1 << "key" << BSON("b" << 1) << "name"
<< "b_1"
- << "ns" << nss.ns())};
+ << "ns"
+ << nss.ns())};
processNetworkResponse(createListIndexesResponse(1, BSON_ARRAY(specs[0] << specs[1])));
@@ -329,7 +332,8 @@ TEST_F(CollectionClonerTest, FindCommandFailed) {
processNetworkResponse(BSON("ok" << 0 << "errmsg"
<< ""
- << "code" << ErrorCodes::CursorNotFound));
+ << "code"
+ << ErrorCodes::CursorNotFound));
ASSERT_EQUALS(ErrorCodes::CursorNotFound, getStatus().code());
ASSERT_FALSE(collectionCloner->isActive());
diff --git a/src/mongo/db/repl/data_replicator.cpp b/src/mongo/db/repl/data_replicator.cpp
index f09013af383..ff99eb594b2 100644
--- a/src/mongo/db/repl/data_replicator.cpp
+++ b/src/mongo/db/repl/data_replicator.cpp
@@ -775,8 +775,8 @@ void DataReplicator::_onDataClonerFinish(const Status& status) {
return;
}
- BSONObj query = BSON("find" << _opts.remoteOplogNS.coll() << "sort" << BSON("$natural" << -1)
- << "limit" << 1);
+ BSONObj query = BSON(
+ "find" << _opts.remoteOplogNS.coll() << "sort" << BSON("$natural" << -1) << "limit" << 1);
TimestampStatus timestampStatus(ErrorCodes::BadValue, "");
_tmpFetcher = stdx::make_unique<Fetcher>(
diff --git a/src/mongo/db/repl/data_replicator.h b/src/mongo/db/repl/data_replicator.h
index e1c491ebd4d..bde976acd9c 100644
--- a/src/mongo/db/repl/data_replicator.h
+++ b/src/mongo/db/repl/data_replicator.h
@@ -37,10 +37,10 @@
#include "mongo/bson/bsonobj.h"
#include "mongo/bson/timestamp.h"
#include "mongo/db/namespace_string.h"
-#include "mongo/db/repl/multiapplier.h"
#include "mongo/db/repl/collection_cloner.h"
-#include "mongo/db/repl/database_cloner.h"
#include "mongo/db/repl/data_replicator_external_state.h"
+#include "mongo/db/repl/database_cloner.h"
+#include "mongo/db/repl/multiapplier.h"
#include "mongo/db/repl/oplog_fetcher.h"
#include "mongo/db/repl/optime.h"
#include "mongo/db/repl/replication_executor.h"
diff --git a/src/mongo/db/repl/data_replicator_test.cpp b/src/mongo/db/repl/data_replicator_test.cpp
index 300100d4726..43e42f7cc5e 100644
--- a/src/mongo/db/repl/data_replicator_test.cpp
+++ b/src/mongo/db/repl/data_replicator_test.cpp
@@ -40,18 +40,18 @@
#include "mongo/db/repl/data_replicator_external_state_mock.h"
#include "mongo/db/repl/member_state.h"
#include "mongo/db/repl/optime.h"
-#include "mongo/db/repl/update_position_args.h"
-#include "mongo/db/repl/replication_executor_test_fixture.h"
#include "mongo/db/repl/replication_executor.h"
+#include "mongo/db/repl/replication_executor_test_fixture.h"
#include "mongo/db/repl/reporter.h"
#include "mongo/db/repl/storage_interface.h"
#include "mongo/db/repl/storage_interface_mock.h"
-#include "mongo/db/repl/sync_source_selector.h"
#include "mongo/db/repl/sync_source_resolver.h"
+#include "mongo/db/repl/sync_source_selector.h"
+#include "mongo/db/repl/update_position_args.h"
#include "mongo/executor/network_interface_mock.h"
#include "mongo/stdx/mutex.h"
-#include "mongo/util/fail_point_service.h"
#include "mongo/util/concurrency/thread_name.h"
+#include "mongo/util/fail_point_service.h"
#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
@@ -105,8 +105,9 @@ public:
* clear/reset state
*/
void reset() {
- _rollbackFn = [](OperationContext*, const OpTime&, const HostAndPort&)
- -> Status { return Status::OK(); };
+ _rollbackFn = [](OperationContext*, const OpTime&, const HostAndPort&) -> Status {
+ return Status::OK();
+ };
_setMyLastOptime = [this](const OpTime& opTime) { _myLastOpTime = opTime; };
_myLastOpTime = OpTime();
_memberState = MemberState::RS_UNKNOWN;
@@ -198,7 +199,7 @@ protected:
options.prepareReplSetUpdatePositionCommandFn =
[](ReplicationCoordinator::ReplSetUpdatePositionCommandStyle commandStyle)
- -> StatusWith<BSONObj> { return BSON(UpdatePositionArgs::kCommandFieldName << 1); };
+ -> StatusWith<BSONObj> { return BSON(UpdatePositionArgs::kCommandFieldName << 1); };
options.getMyLastOptime = [this]() { return _myLastOpTime; };
options.setMyLastOptime = [this](const OpTime& opTime) { _setMyLastOptime(opTime); };
options.setFollowerMode = [this](const MemberState& state) {
@@ -209,13 +210,17 @@ protected:
options.syncSourceSelector = this;
options.getReplSetConfig = []() {
ReplicaSetConfig config;
- ASSERT_OK(
- config.initialize(BSON("_id"
- << "myset"
- << "version" << 1 << "protocolVersion" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "localhost:12345")) << "settings"
- << BSON("electionTimeoutMillis" << 10000))));
+ ASSERT_OK(config.initialize(BSON("_id"
+ << "myset"
+ << "version"
+ << 1
+ << "protocolVersion"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "localhost:12345"))
+ << "settings"
+ << BSON("electionTimeoutMillis" << 10000))));
return config;
};
@@ -333,10 +338,9 @@ protected:
_storage.beginCollectionFn = _beginCollectionFn;
_storage.insertDocumentsFn = _insertCollectionFn;
- _storage.insertMissingDocFn =
- [&](OperationContext* txn, const NamespaceString& nss, const BSONObj& doc) {
- return Status::OK();
- };
+ _storage.insertMissingDocFn = [&](OperationContext* txn,
+ const NamespaceString& nss,
+ const BSONObj& doc) { return Status::OK(); };
dr->_setInitialSyncStorageInterface(&_storage);
_isbr.reset(new InitialSyncBackgroundRunner(dr));
@@ -366,11 +370,15 @@ protected:
const long long cursorId = cmdElem.numberLong();
if (isGetMore && cursorId == 1LL) {
// process getmore requests from the oplog fetcher
- auto respBSON = fromjson(str::stream()
- << "{ok:1, cursor:{id:NumberLong(1), ns:'local.oplog.rs'"
- " , nextBatch:[{ts:Timestamp(" << ++c
- << ",1), h:1, ns:'test.a', v:" << OplogEntry::kOplogVersion
- << ", op:'u', o2:{_id:" << c << "}, o:{$set:{a:1}}}]}}");
+ auto respBSON =
+ fromjson(str::stream() << "{ok:1, cursor:{id:NumberLong(1), ns:'local.oplog.rs'"
+ " , nextBatch:[{ts:Timestamp("
+ << ++c
+ << ",1), h:1, ns:'test.a', v:"
+ << OplogEntry::kOplogVersion
+ << ", op:'u', o2:{_id:"
+ << c
+ << "}, o:{$set:{a:1}}}]}}");
net->scheduleResponse(
noi,
net->now(),
@@ -446,47 +454,50 @@ TEST_F(InitialSyncTest, Complete) {
*
*/
- const std::vector<BSONObj> responses = {
- // get rollback id
- fromjson(str::stream() << "{ok: 1, rbid:1}"),
- // get latest oplog ts
- fromjson(
- str::stream() << "{ok:1, cursor:{id:NumberLong(0), ns:'local.oplog.rs', firstBatch:["
- "{ts:Timestamp(1,1), h:1, ns:'a.a', v:" << OplogEntry::kOplogVersion
- << ", op:'i', o:{_id:1, a:1}}]}}"),
- // oplog fetcher find
- fromjson(
- str::stream() << "{ok:1, cursor:{id:NumberLong(1), ns:'local.oplog.rs', firstBatch:["
- "{ts:Timestamp(1,1), h:1, ns:'a.a', v:" << OplogEntry::kOplogVersion
- << ", op:'i', o:{_id:1, a:1}}]}}"),
- // Clone Start
- // listDatabases
- fromjson("{ok:1, databases:[{name:'a'}]}"),
- // listCollections for "a"
- fromjson(
- "{ok:1, cursor:{id:NumberLong(0), ns:'a.$cmd.listCollections', firstBatch:["
- "{name:'a', options:{}} "
- "]}}"),
- // listIndexes:a
- fromjson(str::stream()
- << "{ok:1, cursor:{id:NumberLong(0), ns:'a.$cmd.listIndexes.a', firstBatch:["
- "{v:" << OplogEntry::kOplogVersion
- << ", key:{_id:1}, name:'_id_', ns:'a.a'}]}}"),
- // find:a
- fromjson(
- "{ok:1, cursor:{id:NumberLong(0), ns:'a.a', firstBatch:["
- "{_id:1, a:1} "
- "]}}"),
- // Clone Done
- // get latest oplog ts
- fromjson(
- str::stream() << "{ok:1, cursor:{id:NumberLong(0), ns:'local.oplog.rs', firstBatch:["
- "{ts:Timestamp(2,2), h:1, ns:'b.c', v:" << OplogEntry::kOplogVersion
- << ", op:'i', o:{_id:1, c:1}}]}}"),
- // Applier starts ...
- // check for rollback
- fromjson(str::stream() << "{ok: 1, rbid:1}"),
- };
+ const std::vector<BSONObj> responses =
+ {
+ // get rollback id
+ fromjson(str::stream() << "{ok: 1, rbid:1}"),
+ // get latest oplog ts
+ fromjson(str::stream()
+ << "{ok:1, cursor:{id:NumberLong(0), ns:'local.oplog.rs', firstBatch:["
+ "{ts:Timestamp(1,1), h:1, ns:'a.a', v:"
+ << OplogEntry::kOplogVersion
+ << ", op:'i', o:{_id:1, a:1}}]}}"),
+ // oplog fetcher find
+ fromjson(str::stream()
+ << "{ok:1, cursor:{id:NumberLong(1), ns:'local.oplog.rs', firstBatch:["
+ "{ts:Timestamp(1,1), h:1, ns:'a.a', v:"
+ << OplogEntry::kOplogVersion
+ << ", op:'i', o:{_id:1, a:1}}]}}"),
+ // Clone Start
+ // listDatabases
+ fromjson("{ok:1, databases:[{name:'a'}]}"),
+ // listCollections for "a"
+ fromjson("{ok:1, cursor:{id:NumberLong(0), ns:'a.$cmd.listCollections', firstBatch:["
+ "{name:'a', options:{}} "
+ "]}}"),
+ // listIndexes:a
+ fromjson(str::stream()
+ << "{ok:1, cursor:{id:NumberLong(0), ns:'a.$cmd.listIndexes.a', firstBatch:["
+ "{v:"
+ << OplogEntry::kOplogVersion
+ << ", key:{_id:1}, name:'_id_', ns:'a.a'}]}}"),
+ // find:a
+ fromjson("{ok:1, cursor:{id:NumberLong(0), ns:'a.a', firstBatch:["
+ "{_id:1, a:1} "
+ "]}}"),
+ // Clone Done
+ // get latest oplog ts
+ fromjson(str::stream()
+ << "{ok:1, cursor:{id:NumberLong(0), ns:'local.oplog.rs', firstBatch:["
+ "{ts:Timestamp(2,2), h:1, ns:'b.c', v:"
+ << OplogEntry::kOplogVersion
+ << ", op:'i', o:{_id:1, c:1}}]}}"),
+ // Applier starts ...
+ // check for rollback
+ fromjson(str::stream() << "{ok: 1, rbid:1}"),
+ };
// Initial sync flag should not be set before starting.
ASSERT_FALSE(StorageInterface::get(getGlobalServiceContext())
@@ -516,58 +527,61 @@ TEST_F(InitialSyncTest, Complete) {
TEST_F(InitialSyncTest, MissingDocOnMultiApplyCompletes) {
DataReplicatorOptions opts;
int applyCounter{0};
- getExternalState()->multiApplyFn =
- [&](OperationContext*, const MultiApplier::Operations& ops, MultiApplier::ApplyOperationFn)
- -> StatusWith<OpTime> {
- if (++applyCounter == 1) {
- return Status(ErrorCodes::NoMatchingDocument, "failed: missing doc.");
- }
- return ops.back().getOpTime();
- };
-
- const std::vector<BSONObj> responses = {
- // get rollback id
- fromjson(str::stream() << "{ok: 1, rbid:1}"),
- // get latest oplog ts
- fromjson(
- str::stream() << "{ok:1, cursor:{id:NumberLong(0), ns:'local.oplog.rs', firstBatch:["
- "{ts:Timestamp(1,1), h:1, ns:'a.a', v:" << OplogEntry::kOplogVersion
- << ", op:'i', o:{_id:1, a:1}}]}}"),
- // oplog fetcher find
- fromjson(
- str::stream() << "{ok:1, cursor:{id:NumberLong(1), ns:'local.oplog.rs', firstBatch:["
- "{ts:Timestamp(1,1), h:1, ns:'a.a', v:" << OplogEntry::kOplogVersion
- << ", op:'u', o2:{_id:1}, o:{$set:{a:1}}}]}}"),
- // Clone Start
- // listDatabases
- fromjson("{ok:1, databases:[{name:'a'}]}"),
- // listCollections for "a"
- fromjson(
- "{ok:1, cursor:{id:NumberLong(0), ns:'a.$cmd.listCollections', firstBatch:["
- "{name:'a', options:{}} "
- "]}}"),
- // listIndexes:a
- fromjson(str::stream()
- << "{ok:1, cursor:{id:NumberLong(0), ns:'a.$cmd.listIndexes.a', firstBatch:["
- "{v:" << OplogEntry::kOplogVersion
- << ", key:{_id:1}, name:'_id_', ns:'a.a'}]}}"),
- // find:a -- empty
- fromjson("{ok:1, cursor:{id:NumberLong(0), ns:'a.a', firstBatch:[]}}"),
- // Clone Done
- // get latest oplog ts
- fromjson(
- str::stream() << "{ok:1, cursor:{id:NumberLong(0), ns:'local.oplog.rs', firstBatch:["
- "{ts:Timestamp(2,2), h:1, ns:'b.c', v:" << OplogEntry::kOplogVersion
- << ", op:'i', o:{_id:1, c:1}}]}}"),
- // Applier starts ...
- // missing doc fetch -- find:a {_id:1}
- fromjson(
- "{ok:1, cursor:{id:NumberLong(0), ns:'a.a', firstBatch:["
- "{_id:1, a:1} "
- "]}}"),
- // check for rollback
- fromjson(str::stream() << "{ok: 1, rbid:1}"),
+ getExternalState()->multiApplyFn = [&](OperationContext*,
+ const MultiApplier::Operations& ops,
+ MultiApplier::ApplyOperationFn) -> StatusWith<OpTime> {
+ if (++applyCounter == 1) {
+ return Status(ErrorCodes::NoMatchingDocument, "failed: missing doc.");
+ }
+ return ops.back().getOpTime();
};
+
+ const std::vector<BSONObj> responses =
+ {
+ // get rollback id
+ fromjson(str::stream() << "{ok: 1, rbid:1}"),
+ // get latest oplog ts
+ fromjson(str::stream()
+ << "{ok:1, cursor:{id:NumberLong(0), ns:'local.oplog.rs', firstBatch:["
+ "{ts:Timestamp(1,1), h:1, ns:'a.a', v:"
+ << OplogEntry::kOplogVersion
+ << ", op:'i', o:{_id:1, a:1}}]}}"),
+ // oplog fetcher find
+ fromjson(str::stream()
+ << "{ok:1, cursor:{id:NumberLong(1), ns:'local.oplog.rs', firstBatch:["
+ "{ts:Timestamp(1,1), h:1, ns:'a.a', v:"
+ << OplogEntry::kOplogVersion
+ << ", op:'u', o2:{_id:1}, o:{$set:{a:1}}}]}}"),
+ // Clone Start
+ // listDatabases
+ fromjson("{ok:1, databases:[{name:'a'}]}"),
+ // listCollections for "a"
+ fromjson("{ok:1, cursor:{id:NumberLong(0), ns:'a.$cmd.listCollections', firstBatch:["
+ "{name:'a', options:{}} "
+ "]}}"),
+ // listIndexes:a
+ fromjson(str::stream()
+ << "{ok:1, cursor:{id:NumberLong(0), ns:'a.$cmd.listIndexes.a', firstBatch:["
+ "{v:"
+ << OplogEntry::kOplogVersion
+ << ", key:{_id:1}, name:'_id_', ns:'a.a'}]}}"),
+ // find:a -- empty
+ fromjson("{ok:1, cursor:{id:NumberLong(0), ns:'a.a', firstBatch:[]}}"),
+ // Clone Done
+ // get latest oplog ts
+ fromjson(str::stream()
+ << "{ok:1, cursor:{id:NumberLong(0), ns:'local.oplog.rs', firstBatch:["
+ "{ts:Timestamp(2,2), h:1, ns:'b.c', v:"
+ << OplogEntry::kOplogVersion
+ << ", op:'i', o:{_id:1, c:1}}]}}"),
+ // Applier starts ...
+ // missing doc fetch -- find:a {_id:1}
+ fromjson("{ok:1, cursor:{id:NumberLong(0), ns:'a.a', firstBatch:["
+ "{_id:1, a:1} "
+ "]}}"),
+ // check for rollback
+ fromjson(str::stream() << "{ok: 1, rbid:1}"),
+ };
startSync();
setResponses(responses);
playResponses(true);
@@ -581,7 +595,9 @@ TEST_F(InitialSyncTest, Failpoint) {
BSONObj configObj = BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -611,12 +627,14 @@ TEST_F(InitialSyncTest, FailsOnClone) {
// get latest oplog ts
fromjson(
str::stream() << "{ok:1, cursor:{id:NumberLong(0), ns:'local.oplog.rs', firstBatch:["
- "{ts:Timestamp(1,1), h:1, ns:'a.a', v:" << OplogEntry::kOplogVersion
+ "{ts:Timestamp(1,1), h:1, ns:'a.a', v:"
+ << OplogEntry::kOplogVersion
<< ", op:'i', o:{_id:1, a:1}}]}}"),
// oplog fetcher find
fromjson(
str::stream() << "{ok:1, cursor:{id:NumberLong(1), ns:'local.oplog.rs', firstBatch:["
- "{ts:Timestamp(1,1), h:1, ns:'a.a', v:" << OplogEntry::kOplogVersion
+ "{ts:Timestamp(1,1), h:1, ns:'a.a', v:"
+ << OplogEntry::kOplogVersion
<< ", op:'i', o:{_id:1, a:1}}]}}"),
// Clone Start
// listDatabases
@@ -631,47 +649,50 @@ TEST_F(InitialSyncTest, FailsOnClone) {
}
TEST_F(InitialSyncTest, FailOnRollback) {
- const std::vector<BSONObj> responses = {
- // get rollback id
- fromjson(str::stream() << "{ok: 1, rbid:1}"),
- // get latest oplog ts
- fromjson(
- str::stream() << "{ok:1, cursor:{id:NumberLong(0), ns:'local.oplog.rs', firstBatch:["
- "{ts:Timestamp(1,1), h:1, ns:'a.a', v:" << OplogEntry::kOplogVersion
- << ", op:'i', o:{_id:1, a:1}}]}}"),
- // oplog fetcher find
- fromjson(
- str::stream() << "{ok:1, cursor:{id:NumberLong(1), ns:'local.oplog.rs', firstBatch:["
- "{ts:Timestamp(1,1), h:1, ns:'a.a', v:" << OplogEntry::kOplogVersion
- << ", op:'i', o:{_id:1, a:1}}]}}"),
- // Clone Start
- // listDatabases
- fromjson("{ok:1, databases:[{name:'a'}]}"),
- // listCollections for "a"
- fromjson(
- "{ok:1, cursor:{id:NumberLong(0), ns:'a.$cmd.listCollections', firstBatch:["
- "{name:'a', options:{}} "
- "]}}"),
- // listIndexes:a
- fromjson(str::stream()
- << "{ok:1, cursor:{id:NumberLong(0), ns:'a.$cmd.listIndexes.a', firstBatch:["
- "{v:" << OplogEntry::kOplogVersion
- << ", key:{_id:1}, name:'_id_', ns:'a.a'}]}}"),
- // find:a
- fromjson(
- "{ok:1, cursor:{id:NumberLong(0), ns:'a.a', firstBatch:["
- "{_id:1, a:1} "
- "]}}"),
- // Clone Done
- // get latest oplog ts
- fromjson(
- str::stream() << "{ok:1, cursor:{id:NumberLong(0), ns:'local.oplog.rs', firstBatch:["
- "{ts:Timestamp(2,2), h:1, ns:'b.c', v:" << OplogEntry::kOplogVersion
- << ", op:'i', o:{_id:1, c:1}}]}}"),
- // Applier starts ...
- // check for rollback
- fromjson(str::stream() << "{ok: 1, rbid:2}"),
- };
+ const std::vector<BSONObj> responses =
+ {
+ // get rollback id
+ fromjson(str::stream() << "{ok: 1, rbid:1}"),
+ // get latest oplog ts
+ fromjson(str::stream()
+ << "{ok:1, cursor:{id:NumberLong(0), ns:'local.oplog.rs', firstBatch:["
+ "{ts:Timestamp(1,1), h:1, ns:'a.a', v:"
+ << OplogEntry::kOplogVersion
+ << ", op:'i', o:{_id:1, a:1}}]}}"),
+ // oplog fetcher find
+ fromjson(str::stream()
+ << "{ok:1, cursor:{id:NumberLong(1), ns:'local.oplog.rs', firstBatch:["
+ "{ts:Timestamp(1,1), h:1, ns:'a.a', v:"
+ << OplogEntry::kOplogVersion
+ << ", op:'i', o:{_id:1, a:1}}]}}"),
+ // Clone Start
+ // listDatabases
+ fromjson("{ok:1, databases:[{name:'a'}]}"),
+ // listCollections for "a"
+ fromjson("{ok:1, cursor:{id:NumberLong(0), ns:'a.$cmd.listCollections', firstBatch:["
+ "{name:'a', options:{}} "
+ "]}}"),
+ // listIndexes:a
+ fromjson(str::stream()
+ << "{ok:1, cursor:{id:NumberLong(0), ns:'a.$cmd.listIndexes.a', firstBatch:["
+ "{v:"
+ << OplogEntry::kOplogVersion
+ << ", key:{_id:1}, name:'_id_', ns:'a.a'}]}}"),
+ // find:a
+ fromjson("{ok:1, cursor:{id:NumberLong(0), ns:'a.a', firstBatch:["
+ "{_id:1, a:1} "
+ "]}}"),
+ // Clone Done
+ // get latest oplog ts
+ fromjson(str::stream()
+ << "{ok:1, cursor:{id:NumberLong(0), ns:'local.oplog.rs', firstBatch:["
+ "{ts:Timestamp(2,2), h:1, ns:'b.c', v:"
+ << OplogEntry::kOplogVersion
+ << ", op:'i', o:{_id:1, c:1}}]}}"),
+ // Applier starts ...
+ // check for rollback
+ fromjson(str::stream() << "{ok: 1, rbid:2}"),
+ };
startSync();
setResponses({responses});
@@ -984,26 +1005,30 @@ TEST_F(SteadyStateTest, RollbackTwoSyncSourcesSecondRollbackSucceeds) {
TEST_F(SteadyStateTest, PauseDataReplicator) {
auto lastOperationApplied = BSON("op"
<< "a"
- << "v" << OplogEntry::kOplogVersion << "ts"
+ << "v"
+ << OplogEntry::kOplogVersion
+ << "ts"
<< Timestamp(Seconds(123), 0));
auto operationToApply = BSON("op"
<< "a"
- << "v" << OplogEntry::kOplogVersion << "ts"
+ << "v"
+ << OplogEntry::kOplogVersion
+ << "ts"
<< Timestamp(Seconds(456), 0));
stdx::mutex mutex;
unittest::Barrier barrier(2U);
Timestamp lastTimestampApplied;
BSONObj operationApplied;
- getExternalState()->multiApplyFn =
- [&](OperationContext*, const MultiApplier::Operations& ops, MultiApplier::ApplyOperationFn)
- -> StatusWith<OpTime> {
- stdx::lock_guard<stdx::mutex> lock(mutex);
- operationApplied = ops.back().raw;
- barrier.countDownAndWait();
- return ops.back().getOpTime();
- };
+ getExternalState()->multiApplyFn = [&](OperationContext*,
+ const MultiApplier::Operations& ops,
+ MultiApplier::ApplyOperationFn) -> StatusWith<OpTime> {
+ stdx::lock_guard<stdx::mutex> lock(mutex);
+ operationApplied = ops.back().raw;
+ barrier.countDownAndWait();
+ return ops.back().getOpTime();
+ };
DataReplicatorOptions::SetMyLastOptimeFn oldSetMyLastOptime = _setMyLastOptime;
_setMyLastOptime = [&](const OpTime& opTime) {
oldSetMyLastOptime(opTime);
@@ -1076,26 +1101,30 @@ TEST_F(SteadyStateTest, PauseDataReplicator) {
TEST_F(SteadyStateTest, ApplyOneOperation) {
auto lastOperationApplied = BSON("op"
<< "a"
- << "v" << OplogEntry::kOplogVersion << "ts"
+ << "v"
+ << OplogEntry::kOplogVersion
+ << "ts"
<< Timestamp(Seconds(123), 0));
auto operationToApply = BSON("op"
<< "a"
- << "v" << OplogEntry::kOplogVersion << "ts"
+ << "v"
+ << OplogEntry::kOplogVersion
+ << "ts"
<< Timestamp(Seconds(456), 0));
stdx::mutex mutex;
unittest::Barrier barrier(2U);
Timestamp lastTimestampApplied;
BSONObj operationApplied;
- getExternalState()->multiApplyFn =
- [&](OperationContext*, const MultiApplier::Operations& ops, MultiApplier::ApplyOperationFn)
- -> StatusWith<OpTime> {
- stdx::lock_guard<stdx::mutex> lock(mutex);
- operationApplied = ops.back().raw;
- barrier.countDownAndWait();
- return ops.back().getOpTime();
- };
+ getExternalState()->multiApplyFn = [&](OperationContext*,
+ const MultiApplier::Operations& ops,
+ MultiApplier::ApplyOperationFn) -> StatusWith<OpTime> {
+ stdx::lock_guard<stdx::mutex> lock(mutex);
+ operationApplied = ops.back().raw;
+ barrier.countDownAndWait();
+ return ops.back().getOpTime();
+ };
DataReplicatorOptions::SetMyLastOptimeFn oldSetMyLastOptime = _setMyLastOptime;
_setMyLastOptime = [&](const OpTime& opTime) {
oldSetMyLastOptime(opTime);
diff --git a/src/mongo/db/repl/database_cloner.cpp b/src/mongo/db/repl/database_cloner.cpp
index da4d3c33887..37e53a97776 100644
--- a/src/mongo/db/repl/database_cloner.cpp
+++ b/src/mongo/db/repl/database_cloner.cpp
@@ -219,16 +219,17 @@ void DatabaseCloner::_listCollectionsCallback(const StatusWith<Fetcher::QueryRes
for (auto&& info : _collectionInfos) {
BSONElement nameElement = info.getField(kNameFieldName);
if (nameElement.eoo()) {
- _finishCallback(Status(ErrorCodes::FailedToParse,
- str::stream() << "collection info must contain '"
- << kNameFieldName << "' "
- << "field : " << info));
+ _finishCallback(
+ Status(ErrorCodes::FailedToParse,
+ str::stream() << "collection info must contain '" << kNameFieldName << "' "
+ << "field : "
+ << info));
return;
}
if (nameElement.type() != mongo::String) {
- _finishCallback(Status(ErrorCodes::TypeMismatch,
- str::stream() << "'" << kNameFieldName
- << "' field must be a string: " << info));
+ _finishCallback(Status(
+ ErrorCodes::TypeMismatch,
+ str::stream() << "'" << kNameFieldName << "' field must be a string: " << info));
return;
}
const std::string collectionName = nameElement.String();
@@ -236,22 +237,27 @@ void DatabaseCloner::_listCollectionsCallback(const StatusWith<Fetcher::QueryRes
_finishCallback(Status(ErrorCodes::DuplicateKey,
str::stream()
<< "collection info contains duplicate collection name "
- << "'" << collectionName << "': " << info));
+ << "'"
+ << collectionName
+ << "': "
+ << info));
return;
}
BSONElement optionsElement = info.getField(kOptionsFieldName);
if (optionsElement.eoo()) {
- _finishCallback(Status(ErrorCodes::FailedToParse,
- str::stream() << "collection info must contain '"
- << kOptionsFieldName << "' "
- << "field : " << info));
+ _finishCallback(Status(
+ ErrorCodes::FailedToParse,
+ str::stream() << "collection info must contain '" << kOptionsFieldName << "' "
+ << "field : "
+ << info));
return;
}
if (!optionsElement.isABSONObj()) {
_finishCallback(Status(ErrorCodes::TypeMismatch,
str::stream() << "'" << kOptionsFieldName
- << "' field must be an object: " << info));
+ << "' field must be an object: "
+ << info));
return;
}
const BSONObj optionsObj = optionsElement.Obj();
diff --git a/src/mongo/db/repl/database_cloner.h b/src/mongo/db/repl/database_cloner.h
index 954f816cdaa..79dcf1529e2 100644
--- a/src/mongo/db/repl/database_cloner.h
+++ b/src/mongo/db/repl/database_cloner.h
@@ -37,8 +37,8 @@
#include "mongo/bson/bsonobj.h"
#include "mongo/client/fetcher.h"
#include "mongo/db/namespace_string.h"
-#include "mongo/db/repl/collection_cloner.h"
#include "mongo/db/repl/base_cloner.h"
+#include "mongo/db/repl/collection_cloner.h"
#include "mongo/db/repl/replication_executor.h"
#include "mongo/stdx/condition_variable.h"
#include "mongo/stdx/mutex.h"
diff --git a/src/mongo/db/repl/database_cloner_test.cpp b/src/mongo/db/repl/database_cloner_test.cpp
index d5494d80345..78d70018ae3 100644
--- a/src/mongo/db/repl/database_cloner_test.cpp
+++ b/src/mongo/db/repl/database_cloner_test.cpp
@@ -190,7 +190,8 @@ TEST_F(DatabaseClonerTest, InvalidListCollectionsFilter) {
processNetworkResponse(BSON("ok" << 0 << "errmsg"
<< "unknown operator"
- << "code" << ErrorCodes::BadValue));
+ << "code"
+ << ErrorCodes::BadValue));
ASSERT_EQUALS(ErrorCodes::BadValue, getStatus().code());
ASSERT_FALSE(databaseCloner->isActive());
@@ -214,8 +215,9 @@ TEST_F(DatabaseClonerTest, ListCollectionsReturnedNoCollections) {
}
TEST_F(DatabaseClonerTest, ListCollectionsPredicate) {
- DatabaseCloner::ListCollectionsPredicateFn pred =
- [](const BSONObj& info) { return info["name"].String() != "b"; };
+ DatabaseCloner::ListCollectionsPredicateFn pred = [](const BSONObj& info) {
+ return info["name"].String() != "b";
+ };
databaseCloner.reset(new DatabaseCloner(
&getReplExecutor(),
target,
@@ -232,13 +234,16 @@ TEST_F(DatabaseClonerTest, ListCollectionsPredicate) {
const std::vector<BSONObj> sourceInfos = {BSON("name"
<< "a"
- << "options" << BSONObj()),
+ << "options"
+ << BSONObj()),
BSON("name"
<< "b"
- << "options" << BSONObj()),
+ << "options"
+ << BSONObj()),
BSON("name"
<< "c"
- << "options" << BSONObj())};
+ << "options"
+ << BSONObj())};
processNetworkResponse(createListCollectionsResponse(
0, BSON_ARRAY(sourceInfos[0] << sourceInfos[1] << sourceInfos[2])));
@@ -256,10 +261,12 @@ TEST_F(DatabaseClonerTest, ListCollectionsMultipleBatches) {
const std::vector<BSONObj> sourceInfos = {BSON("name"
<< "a"
- << "options" << BSONObj()),
+ << "options"
+ << BSONObj()),
BSON("name"
<< "b"
- << "options" << BSONObj())};
+ << "options"
+ << BSONObj())};
processNetworkResponse(createListCollectionsResponse(1, BSON_ARRAY(sourceInfos[0])));
ASSERT_EQUALS(getDetectableErrorStatus(), getStatus());
@@ -305,11 +312,11 @@ TEST_F(DatabaseClonerTest, CollectionInfoNameNotAString) {
TEST_F(DatabaseClonerTest, CollectionInfoNameEmpty) {
ASSERT_OK(databaseCloner->start());
- processNetworkResponse(
- createListCollectionsResponse(0,
- BSON_ARRAY(BSON("name"
- << ""
- << "options" << BSONObj()))));
+ processNetworkResponse(createListCollectionsResponse(0,
+ BSON_ARRAY(BSON("name"
+ << ""
+ << "options"
+ << BSONObj()))));
ASSERT_EQUALS(ErrorCodes::BadValue, getStatus().code());
ASSERT_STRING_CONTAINS(getStatus().reason(), "invalid collection namespace: db.");
ASSERT_FALSE(databaseCloner->isActive());
@@ -317,14 +324,15 @@ TEST_F(DatabaseClonerTest, CollectionInfoNameEmpty) {
TEST_F(DatabaseClonerTest, CollectionInfoNameDuplicate) {
ASSERT_OK(databaseCloner->start());
- processNetworkResponse(
- createListCollectionsResponse(0,
- BSON_ARRAY(BSON("name"
- << "a"
- << "options" << BSONObj())
- << BSON("name"
- << "a"
- << "options" << BSONObj()))));
+ processNetworkResponse(createListCollectionsResponse(0,
+ BSON_ARRAY(BSON("name"
+ << "a"
+ << "options"
+ << BSONObj())
+ << BSON("name"
+ << "a"
+ << "options"
+ << BSONObj()))));
ASSERT_EQUALS(ErrorCodes::DuplicateKey, getStatus().code());
ASSERT_STRING_CONTAINS(getStatus().reason(), "duplicate collection name 'a'");
ASSERT_FALSE(databaseCloner->isActive());
@@ -345,7 +353,8 @@ TEST_F(DatabaseClonerTest, CollectionInfoOptionsNotAnObject) {
processNetworkResponse(createListCollectionsResponse(0,
BSON_ARRAY(BSON("name"
<< "a"
- << "options" << 123))));
+ << "options"
+ << 123))));
ASSERT_EQUALS(ErrorCodes::TypeMismatch, getStatus().code());
ASSERT_STRING_CONTAINS(getStatus().reason(), "'options' field must be an object");
ASSERT_FALSE(databaseCloner->isActive());
@@ -355,11 +364,11 @@ TEST_F(DatabaseClonerTest, InvalidCollectionOptions) {
ASSERT_OK(databaseCloner->start());
processNetworkResponse(
- createListCollectionsResponse(
- 0,
- BSON_ARRAY(BSON("name"
- << "a"
- << "options" << BSON("storageEngine" << 1)))));
+ createListCollectionsResponse(0,
+ BSON_ARRAY(BSON("name"
+ << "a"
+ << "options"
+ << BSON("storageEngine" << 1)))));
ASSERT_EQUALS(ErrorCodes::BadValue, getStatus().code());
ASSERT_FALSE(databaseCloner->isActive());
@@ -380,11 +389,11 @@ TEST_F(DatabaseClonerTest, ListCollectionsReturnsEmptyCollectionName) {
stdx::bind(&DatabaseClonerTest::setStatus, this, stdx::placeholders::_1)));
ASSERT_OK(databaseCloner->start());
- processNetworkResponse(
- createListCollectionsResponse(0,
- BSON_ARRAY(BSON("name"
- << ""
- << "options" << BSONObj()))));
+ processNetworkResponse(createListCollectionsResponse(0,
+ BSON_ARRAY(BSON("name"
+ << ""
+ << "options"
+ << BSONObj()))));
ASSERT_EQUALS(ErrorCodes::BadValue, getStatus().code());
ASSERT_STRING_CONTAINS(getStatus().reason(), "invalid collection namespace: db.");
@@ -397,11 +406,11 @@ TEST_F(DatabaseClonerTest, StartFirstCollectionClonerFailed) {
databaseCloner->setStartCollectionClonerFn(
[](CollectionCloner& cloner) { return Status(ErrorCodes::OperationFailed, ""); });
- processNetworkResponse(
- createListCollectionsResponse(0,
- BSON_ARRAY(BSON("name"
- << "a"
- << "options" << BSONObj()))));
+ processNetworkResponse(createListCollectionsResponse(0,
+ BSON_ARRAY(BSON("name"
+ << "a"
+ << "options"
+ << BSONObj()))));
ASSERT_EQUALS(ErrorCodes::OperationFailed, getStatus().code());
ASSERT_FALSE(databaseCloner->isActive());
@@ -424,14 +433,15 @@ TEST_F(DatabaseClonerTest, StartSecondCollectionClonerFailed) {
return cloner.start();
});
- processNetworkResponse(
- createListCollectionsResponse(0,
- BSON_ARRAY(BSON("name"
- << "a"
- << "options" << BSONObj())
- << BSON("name"
- << "b"
- << "options" << BSONObj()))));
+ processNetworkResponse(createListCollectionsResponse(0,
+ BSON_ARRAY(BSON("name"
+ << "a"
+ << "options"
+ << BSONObj())
+ << BSON("name"
+ << "b"
+ << "options"
+ << BSONObj()))));
processNetworkResponse(createListIndexesResponse(0, BSON_ARRAY(idIndexSpec)));
processNetworkResponse(createCursorResponse(0, BSONArray()));
@@ -452,10 +462,12 @@ TEST_F(DatabaseClonerTest, FirstCollectionListIndexesFailed) {
const std::vector<BSONObj> sourceInfos = {BSON("name"
<< "a"
- << "options" << BSONObj()),
+ << "options"
+ << BSONObj()),
BSON("name"
<< "b"
- << "options" << BSONObj())};
+ << "options"
+ << BSONObj())};
processNetworkResponse(
createListCollectionsResponse(0, BSON_ARRAY(sourceInfos[0] << sourceInfos[1])));
@@ -466,7 +478,8 @@ TEST_F(DatabaseClonerTest, FirstCollectionListIndexesFailed) {
// This affects the order of the network responses.
processNetworkResponse(BSON("ok" << 0 << "errmsg"
<< ""
- << "code" << ErrorCodes::NamespaceNotFound));
+ << "code"
+ << ErrorCodes::NamespaceNotFound));
processNetworkResponse(createListIndexesResponse(0, BSON_ARRAY(idIndexSpec)));
processNetworkResponse(createCursorResponse(0, BSONArray()));
@@ -497,10 +510,12 @@ TEST_F(DatabaseClonerTest, CreateCollections) {
const std::vector<BSONObj> sourceInfos = {BSON("name"
<< "a"
- << "options" << BSONObj()),
+ << "options"
+ << BSONObj()),
BSON("name"
<< "b"
- << "options" << BSONObj())};
+ << "options"
+ << BSONObj())};
processNetworkResponse(
createListCollectionsResponse(0, BSON_ARRAY(sourceInfos[0] << sourceInfos[1])));
diff --git a/src/mongo/db/repl/database_task.h b/src/mongo/db/repl/database_task.h
index 29f10f2902c..bde2df64c09 100644
--- a/src/mongo/db/repl/database_task.h
+++ b/src/mongo/db/repl/database_task.h
@@ -31,8 +31,8 @@
#include <string>
#include "mongo/db/concurrency/lock_manager_defs.h"
-#include "mongo/db/repl/task_runner.h"
#include "mongo/db/namespace_string.h"
+#include "mongo/db/repl/task_runner.h"
namespace mongo {
diff --git a/src/mongo/db/repl/elect_cmd_runner_test.cpp b/src/mongo/db/repl/elect_cmd_runner_test.cpp
index 1b4a82902c2..c92f931cf34 100644
--- a/src/mongo/db/repl/elect_cmd_runner_test.cpp
+++ b/src/mongo/db/repl/elect_cmd_runner_test.cpp
@@ -99,9 +99,13 @@ ReplicaSetConfig assertMakeRSConfig(const BSONObj& configBson) {
const BSONObj makeElectRequest(const ReplicaSetConfig& rsConfig, int selfIndex) {
const MemberConfig& myConfig = rsConfig.getMemberAt(selfIndex);
return BSON("replSetElect" << 1 << "set" << rsConfig.getReplSetName() << "who"
- << myConfig.getHostAndPort().toString() << "whoid"
- << myConfig.getId() << "cfgver" << rsConfig.getConfigVersion()
- << "round" << 380865962699346850ll);
+ << myConfig.getHostAndPort().toString()
+ << "whoid"
+ << myConfig.getId()
+ << "cfgver"
+ << rsConfig.getConfigVersion()
+ << "round"
+ << 380865962699346850ll);
}
BSONObj stripRound(const BSONObj& orig) {
@@ -158,7 +162,9 @@ TEST_F(ElectCmdRunnerTest, OneNode) {
// Only one node in the config.
const ReplicaSetConfig config = assertMakeRSConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1"))));
@@ -174,7 +180,9 @@ TEST_F(ElectCmdRunnerTest, TwoNodes) {
const ReplicaSetConfig config =
assertMakeRSConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h0")
<< BSON("_id" << 2 << "host"
@@ -210,7 +218,9 @@ TEST_F(ElectCmdRunnerTest, ShuttingDown) {
// Two nodes, we are node h1. Shutdown happens while we're scheduling remote commands.
ReplicaSetConfig config = assertMakeRSConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h0")
<< BSON("_id" << 2 << "host"
@@ -307,26 +317,33 @@ protected:
BSONObj threeNodesTwoArbitersConfig() {
return BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host0")
<< BSON("_id" << 1 << "host"
<< "host1"
- << "arbiterOnly" << true)
+ << "arbiterOnly"
+ << true)
<< BSON("_id" << 2 << "host"
<< "host2"
- << "arbiterOnly" << true)));
+ << "arbiterOnly"
+ << true)));
}
BSONObj basicThreeNodeConfig() {
return BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host0")
<< BSON("_id" << 1 << "host"
- << "host1") << BSON("_id" << 2 << "host"
- << "host2")));
+ << "host1")
+ << BSON("_id" << 2 << "host"
+ << "host2")));
}
private:
diff --git a/src/mongo/db/repl/freshness_checker_test.cpp b/src/mongo/db/repl/freshness_checker_test.cpp
index 45fde9ef816..2d0917254ec 100644
--- a/src/mongo/db/repl/freshness_checker_test.cpp
+++ b/src/mongo/db/repl/freshness_checker_test.cpp
@@ -121,9 +121,13 @@ const BSONObj makeFreshRequest(const ReplicaSetConfig& rsConfig,
int selfIndex) {
const MemberConfig& myConfig = rsConfig.getMemberAt(selfIndex);
return BSON("replSetFresh" << 1 << "set" << rsConfig.getReplSetName() << "opTime"
- << Date_t::fromMillisSinceEpoch(lastOpTimeApplied.asLL()) << "who"
- << myConfig.getHostAndPort().toString() << "cfgver"
- << rsConfig.getConfigVersion() << "id" << myConfig.getId());
+ << Date_t::fromMillisSinceEpoch(lastOpTimeApplied.asLL())
+ << "who"
+ << myConfig.getHostAndPort().toString()
+ << "cfgver"
+ << rsConfig.getConfigVersion()
+ << "id"
+ << myConfig.getId());
}
// This is necessary because the run method must be scheduled in the Replication Executor
@@ -159,7 +163,9 @@ TEST_F(FreshnessCheckerTest, TwoNodes) {
// Two nodes, we are node h1. We are freshest, but we tie with h2.
ReplicaSetConfig config = assertMakeRSConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h0")
<< BSON("_id" << 2 << "host"
@@ -177,16 +183,19 @@ TEST_F(FreshnessCheckerTest, TwoNodes) {
ASSERT_EQUALS("admin", noi->getRequest().dbname);
ASSERT_EQUALS(freshRequest, noi->getRequest().cmdObj);
ASSERT_EQUALS(HostAndPort("h1"), noi->getRequest().target);
- _net->scheduleResponse(noi,
- startDate + Milliseconds(10),
- ResponseStatus(RemoteCommandResponse(
- BSON("ok" << 1 << "id" << 2 << "set"
- << "rs0"
- << "who"
- << "h1"
- << "cfgver" << 1 << "opTime" << Date_t()),
- BSONObj(),
- Milliseconds(8))));
+ _net->scheduleResponse(
+ noi,
+ startDate + Milliseconds(10),
+ ResponseStatus(RemoteCommandResponse(BSON("ok" << 1 << "id" << 2 << "set"
+ << "rs0"
+ << "who"
+ << "h1"
+ << "cfgver"
+ << 1
+ << "opTime"
+ << Date_t()),
+ BSONObj(),
+ Milliseconds(8))));
}
_net->runUntil(startDate + Milliseconds(10));
_net->exitNetwork();
@@ -199,7 +208,9 @@ TEST_F(FreshnessCheckerTest, ShuttingDown) {
// Two nodes, we are node h1. Shutdown happens while we're scheduling remote commands.
ReplicaSetConfig config = assertMakeRSConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h0")
<< BSON("_id" << 2 << "host"
@@ -222,7 +233,9 @@ TEST_F(FreshnessCheckerTest, ElectNotElectingSelfWeAreNotFreshest) {
startCapturingLogMessages();
ReplicaSetConfig config = assertMakeRSConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h0")
<< BSON("_id" << 2 << "host"
@@ -248,8 +261,12 @@ TEST_F(FreshnessCheckerTest, ElectNotElectingSelfWeAreNotFreshest) {
<< "rs0"
<< "who"
<< "h1"
- << "cfgver" << 1 << "fresher" << true
- << "opTime" << Date_t()),
+ << "cfgver"
+ << 1
+ << "fresher"
+ << true
+ << "opTime"
+ << Date_t()),
BSONObj(),
Milliseconds(8))));
}
@@ -268,7 +285,9 @@ TEST_F(FreshnessCheckerTest, ElectNotElectingSelfWeAreNotFreshestOpTime) {
startCapturingLogMessages();
ReplicaSetConfig config = assertMakeRSConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h0")
<< BSON("_id" << 2 << "host"
@@ -295,7 +314,9 @@ TEST_F(FreshnessCheckerTest, ElectNotElectingSelfWeAreNotFreshestOpTime) {
<< "rs0"
<< "who"
<< "h1"
- << "cfgver" << 1 << "opTime"
+ << "cfgver"
+ << 1
+ << "opTime"
<< Date_t::fromMillisSinceEpoch(Timestamp(10, 0).asLL())),
BSONObj(),
Milliseconds(8))));
@@ -314,7 +335,9 @@ TEST_F(FreshnessCheckerTest, ElectWrongTypeInFreshnessResponse) {
startCapturingLogMessages();
ReplicaSetConfig config = assertMakeRSConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h0")
<< BSON("_id" << 2 << "host"
@@ -340,7 +363,10 @@ TEST_F(FreshnessCheckerTest, ElectWrongTypeInFreshnessResponse) {
<< "rs0"
<< "who"
<< "h1"
- << "cfgver" << 1 << "opTime" << 3),
+ << "cfgver"
+ << 1
+ << "opTime"
+ << 3),
BSONObj(),
Milliseconds(8))));
}
@@ -353,9 +379,8 @@ TEST_F(FreshnessCheckerTest, ElectWrongTypeInFreshnessResponse) {
ASSERT_EQUALS(shouldAbortElection(), FreshnessChecker::FresherNodeFound);
ASSERT_EQUALS(1,
- countLogLinesContaining(
- "wrong type for opTime argument in replSetFresh "
- "response: int"));
+ countLogLinesContaining("wrong type for opTime argument in replSetFresh "
+ "response: int"));
}
TEST_F(FreshnessCheckerTest, ElectVetoed) {
@@ -363,7 +388,9 @@ TEST_F(FreshnessCheckerTest, ElectVetoed) {
startCapturingLogMessages();
ReplicaSetConfig config = assertMakeRSConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h0")
<< BSON("_id" << 2 << "host"
@@ -390,9 +417,14 @@ TEST_F(FreshnessCheckerTest, ElectVetoed) {
<< "rs0"
<< "who"
<< "h1"
- << "cfgver" << 1 << "veto" << true << "errmsg"
+ << "cfgver"
+ << 1
+ << "veto"
+ << true
+ << "errmsg"
<< "I'd rather you didn't"
- << "opTime" << Date_t::fromMillisSinceEpoch(Timestamp(0, 0).asLL())),
+ << "opTime"
+ << Date_t::fromMillisSinceEpoch(Timestamp(0, 0).asLL())),
BSONObj(),
Milliseconds(8))));
}
@@ -405,9 +437,8 @@ TEST_F(FreshnessCheckerTest, ElectVetoed) {
ASSERT_EQUALS(shouldAbortElection(), FreshnessChecker::FresherNodeFound);
ASSERT_EQUALS(1,
- countLogLinesContaining(
- "not electing self, h1:27017 would veto with "
- "'I'd rather you didn't'"));
+ countLogLinesContaining("not electing self, h1:27017 would veto with "
+ "'I'd rather you didn't'"));
}
int findIdForMember(const ReplicaSetConfig& rsConfig, const HostAndPort& host) {
@@ -419,18 +450,21 @@ int findIdForMember(const ReplicaSetConfig& rsConfig, const HostAndPort& host) {
TEST_F(FreshnessCheckerTest, ElectNotElectingSelfWeAreNotFreshestManyNodes) {
// one other responds as fresher than us
startCapturingLogMessages();
- ReplicaSetConfig config =
- assertMakeRSConfig(BSON("_id"
- << "rs0"
- << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "h0")
- << BSON("_id" << 2 << "host"
- << "h1") << BSON("_id" << 3 << "host"
- << "h2")
- << BSON("_id" << 4 << "host"
- << "h3") << BSON("_id" << 5 << "host"
- << "h4"))));
+ ReplicaSetConfig config = assertMakeRSConfig(BSON("_id"
+ << "rs0"
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "h0")
+ << BSON("_id" << 2 << "host"
+ << "h1")
+ << BSON("_id" << 3 << "host"
+ << "h2")
+ << BSON("_id" << 4 << "host"
+ << "h3")
+ << BSON("_id" << 5 << "host"
+ << "h4"))));
std::vector<HostAndPort> hosts;
for (ReplicaSetConfig::MemberIterator mem = ++config.membersBegin(); mem != config.membersEnd();
@@ -475,18 +509,21 @@ TEST_F(FreshnessCheckerTest, ElectNotElectingSelfWeAreNotFreshestManyNodes) {
TEST_F(FreshnessCheckerTest, ElectNotElectingSelfWeAreNotFreshestOpTimeManyNodes) {
// one other responds with a later optime than ours
startCapturingLogMessages();
- ReplicaSetConfig config =
- assertMakeRSConfig(BSON("_id"
- << "rs0"
- << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "h0")
- << BSON("_id" << 2 << "host"
- << "h1") << BSON("_id" << 3 << "host"
- << "h2")
- << BSON("_id" << 4 << "host"
- << "h3") << BSON("_id" << 5 << "host"
- << "h4"))));
+ ReplicaSetConfig config = assertMakeRSConfig(BSON("_id"
+ << "rs0"
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "h0")
+ << BSON("_id" << 2 << "host"
+ << "h1")
+ << BSON("_id" << 3 << "host"
+ << "h2")
+ << BSON("_id" << 4 << "host"
+ << "h3")
+ << BSON("_id" << 5 << "host"
+ << "h4"))));
std::vector<HostAndPort> hosts;
for (ReplicaSetConfig::MemberIterator mem = config.membersBegin(); mem != config.membersEnd();
@@ -545,18 +582,21 @@ TEST_F(FreshnessCheckerTest, ElectNotElectingSelfWeAreNotFreshestOpTimeManyNodes
TEST_F(FreshnessCheckerTest, ElectWrongTypeInFreshnessResponseManyNodes) {
// one other responds with "opTime" field of non-Date value, causing not freshest
startCapturingLogMessages();
- ReplicaSetConfig config =
- assertMakeRSConfig(BSON("_id"
- << "rs0"
- << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "h0")
- << BSON("_id" << 2 << "host"
- << "h1") << BSON("_id" << 3 << "host"
- << "h2")
- << BSON("_id" << 4 << "host"
- << "h3") << BSON("_id" << 5 << "host"
- << "h4"))));
+ ReplicaSetConfig config = assertMakeRSConfig(BSON("_id"
+ << "rs0"
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "h0")
+ << BSON("_id" << 2 << "host"
+ << "h1")
+ << BSON("_id" << 3 << "host"
+ << "h2")
+ << BSON("_id" << 4 << "host"
+ << "h3")
+ << BSON("_id" << 5 << "host"
+ << "h4"))));
std::vector<HostAndPort> hosts;
for (ReplicaSetConfig::MemberIterator mem = ++config.membersBegin(); mem != config.membersEnd();
@@ -597,26 +637,28 @@ TEST_F(FreshnessCheckerTest, ElectWrongTypeInFreshnessResponseManyNodes) {
stopCapturingLogMessages();
ASSERT_EQUALS(shouldAbortElection(), FreshnessChecker::FresherNodeFound);
ASSERT_EQUALS(1,
- countLogLinesContaining(
- "wrong type for opTime argument in replSetFresh "
- "response: int"));
+ countLogLinesContaining("wrong type for opTime argument in replSetFresh "
+ "response: int"));
}
TEST_F(FreshnessCheckerTest, ElectVetoedManyNodes) {
// one other responds with veto
startCapturingLogMessages();
- ReplicaSetConfig config =
- assertMakeRSConfig(BSON("_id"
- << "rs0"
- << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "h0")
- << BSON("_id" << 2 << "host"
- << "h1") << BSON("_id" << 3 << "host"
- << "h2")
- << BSON("_id" << 4 << "host"
- << "h3") << BSON("_id" << 5 << "host"
- << "h4"))));
+ ReplicaSetConfig config = assertMakeRSConfig(BSON("_id"
+ << "rs0"
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "h0")
+ << BSON("_id" << 2 << "host"
+ << "h1")
+ << BSON("_id" << 3 << "host"
+ << "h2")
+ << BSON("_id" << 4 << "host"
+ << "h3")
+ << BSON("_id" << 5 << "host"
+ << "h4"))));
std::vector<HostAndPort> hosts;
for (ReplicaSetConfig::MemberIterator mem = ++config.membersBegin(); mem != config.membersEnd();
@@ -657,26 +699,28 @@ TEST_F(FreshnessCheckerTest, ElectVetoedManyNodes) {
stopCapturingLogMessages();
ASSERT_EQUALS(shouldAbortElection(), FreshnessChecker::FresherNodeFound);
ASSERT_EQUALS(1,
- countLogLinesContaining(
- "not electing self, h1:27017 would veto with "
- "'I'd rather you didn't'"));
+ countLogLinesContaining("not electing self, h1:27017 would veto with "
+ "'I'd rather you didn't'"));
}
TEST_F(FreshnessCheckerTest, ElectVetoedAndTiedFreshnessManyNodes) {
// one other responds with veto and another responds with tie
startCapturingLogMessages();
- ReplicaSetConfig config =
- assertMakeRSConfig(BSON("_id"
- << "rs0"
- << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "h0")
- << BSON("_id" << 2 << "host"
- << "h1") << BSON("_id" << 3 << "host"
- << "h2")
- << BSON("_id" << 4 << "host"
- << "h3") << BSON("_id" << 5 << "host"
- << "h4"))));
+ ReplicaSetConfig config = assertMakeRSConfig(BSON("_id"
+ << "rs0"
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "h0")
+ << BSON("_id" << 2 << "host"
+ << "h1")
+ << BSON("_id" << 3 << "host"
+ << "h2")
+ << BSON("_id" << 4 << "host"
+ << "h3")
+ << BSON("_id" << 5 << "host"
+ << "h4"))));
std::vector<HostAndPort> hosts;
for (ReplicaSetConfig::MemberIterator mem = config.membersBegin(); mem != config.membersEnd();
@@ -726,9 +770,8 @@ TEST_F(FreshnessCheckerTest, ElectVetoedAndTiedFreshnessManyNodes) {
_net->runUntil(startDate + Milliseconds(10));
ASSERT_EQUALS(startDate + Milliseconds(10), _net->now());
ASSERT_EQUALS(0,
- countLogLinesContaining(
- "not electing self, h4:27017 would veto with '"
- "errmsg: \"I'd rather you didn't\"'"));
+ countLogLinesContaining("not electing self, h4:27017 would veto with '"
+ "errmsg: \"I'd rather you didn't\"'"));
_net->runUntil(startDate + Milliseconds(20));
ASSERT_EQUALS(startDate + Milliseconds(20), _net->now());
_net->exitNetwork();
@@ -736,24 +779,26 @@ TEST_F(FreshnessCheckerTest, ElectVetoedAndTiedFreshnessManyNodes) {
stopCapturingLogMessages();
ASSERT_EQUALS(shouldAbortElection(), FreshnessChecker::FresherNodeFound);
ASSERT_EQUALS(1,
- countLogLinesContaining(
- "not electing self, h4:27017 would veto with "
- "'I'd rather you didn't'"));
+ countLogLinesContaining("not electing self, h4:27017 would veto with "
+ "'I'd rather you didn't'"));
}
TEST_F(FreshnessCheckerTest, ElectManyNodesNotAllRespond) {
- ReplicaSetConfig config =
- assertMakeRSConfig(BSON("_id"
- << "rs0"
- << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "h0")
- << BSON("_id" << 2 << "host"
- << "h1") << BSON("_id" << 3 << "host"
- << "h2")
- << BSON("_id" << 4 << "host"
- << "h3") << BSON("_id" << 5 << "host"
- << "h4"))));
+ ReplicaSetConfig config = assertMakeRSConfig(BSON("_id"
+ << "rs0"
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "h0")
+ << BSON("_id" << 2 << "host"
+ << "h1")
+ << BSON("_id" << 3 << "host"
+ << "h2")
+ << BSON("_id" << 4 << "host"
+ << "h3")
+ << BSON("_id" << 5 << "host"
+ << "h4"))));
std::vector<HostAndPort> hosts;
for (ReplicaSetConfig::MemberIterator mem = ++config.membersBegin(); mem != config.membersEnd();
@@ -806,12 +851,15 @@ public:
ReplicaSetConfig config;
config.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host0")
<< BSON("_id" << 1 << "host"
- << "host1") << BSON("_id" << 2 << "host"
- << "host2"))));
+ << "host1")
+ << BSON("_id" << 2 << "host"
+ << "host2"))));
std::vector<HostAndPort> hosts;
for (ReplicaSetConfig::MemberIterator mem = ++config.membersBegin();
diff --git a/src/mongo/db/repl/freshness_scanner.cpp b/src/mongo/db/repl/freshness_scanner.cpp
index ed4f160ee8f..fcba850e021 100644
--- a/src/mongo/db/repl/freshness_scanner.cpp
+++ b/src/mongo/db/repl/freshness_scanner.cpp
@@ -86,8 +86,9 @@ void FreshnessScanner::Algorithm::processResponse(const RemoteCommandRequest& re
int index = _rsConfig.findMemberIndexByHostAndPort(request.target);
FreshnessInfo freshnessInfo{index, lastOpTime};
- auto cmp =
- [](const FreshnessInfo& a, const FreshnessInfo& b) { return a.opTime > b.opTime; };
+ auto cmp = [](const FreshnessInfo& a, const FreshnessInfo& b) {
+ return a.opTime > b.opTime;
+ };
auto iter =
std::upper_bound(_freshnessInfos.begin(), _freshnessInfos.end(), freshnessInfo, cmp);
_freshnessInfos.insert(iter, freshnessInfo);
diff --git a/src/mongo/db/repl/freshness_scanner_test.cpp b/src/mongo/db/repl/freshness_scanner_test.cpp
index 5096b4ce9f2..53314298b5b 100644
--- a/src/mongo/db/repl/freshness_scanner_test.cpp
+++ b/src/mongo/db/repl/freshness_scanner_test.cpp
@@ -58,22 +58,29 @@ public:
}
virtual void setUp() {
- ASSERT_OK(
- _config.initialize(BSON("_id"
- << "rs0"
- << "version" << 1 << "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.initialize(BSON("_id"
+ << "rs0"
+ << "version"
+ << 1
+ << "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());
_net = new NetworkInterfaceMock;
diff --git a/src/mongo/db/repl/is_master_response.cpp b/src/mongo/db/repl/is_master_response.cpp
index efd8bd5466e..78fe98e45de 100644
--- a/src/mongo/db/repl/is_master_response.cpp
+++ b/src/mongo/db/repl/is_master_response.cpp
@@ -219,7 +219,8 @@ Status IsMasterResponse::initialize(const BSONObj& doc) {
str::stream() << "Found \"" << kIsReplicaSetFieldName
<< "\" field which should indicate that no valid config "
"is loaded, but we didn't also have an \""
- << kInfoFieldName << "\" field as we expected");
+ << kInfoFieldName
+ << "\" field as we expected");
}
}
@@ -246,7 +247,8 @@ Status IsMasterResponse::initialize(const BSONObj& doc) {
return Status(ErrorCodes::TypeMismatch,
str::stream() << "Elements in \"" << kHostsFieldName
<< "\" array of isMaster response must be of type "
- << typeName(String) << " but found type "
+ << typeName(String)
+ << " but found type "
<< typeName(hostElement.type()));
}
_hosts.push_back(HostAndPort(hostElement.String()));
@@ -266,7 +268,8 @@ Status IsMasterResponse::initialize(const BSONObj& doc) {
return Status(ErrorCodes::TypeMismatch,
str::stream() << "Elements in \"" << kPassivesFieldName
<< "\" array of isMaster response must be of type "
- << typeName(String) << " but found type "
+ << typeName(String)
+ << " but found type "
<< typeName(passiveElement.type()));
}
_passives.push_back(HostAndPort(passiveElement.String()));
@@ -286,7 +289,8 @@ Status IsMasterResponse::initialize(const BSONObj& doc) {
return Status(ErrorCodes::TypeMismatch,
str::stream() << "Elements in \"" << kArbitersFieldName
<< "\" array of isMaster response must be of type "
- << typeName(String) << " but found type "
+ << typeName(String)
+ << " but found type "
<< typeName(arbiterElement.type()));
}
_arbiters.push_back(HostAndPort(arbiterElement.String()));
@@ -359,7 +363,8 @@ Status IsMasterResponse::initialize(const BSONObj& doc) {
str::stream() << "Elements in \"" << kTagsFieldName
<< "\" obj "
"of isMaster response must be of type "
- << typeName(String) << " but found type "
+ << typeName(String)
+ << " but found type "
<< typeName(tagsElement.type()));
}
_tags[tagElement.fieldNameStringData().toString()] = tagElement.String();
@@ -391,7 +396,8 @@ Status IsMasterResponse::initialize(const BSONObj& doc) {
str::stream() << "Elements in \"" << kLastWriteOpTimeFieldName
<< "\" obj "
"of isMaster response must be of type "
- << typeName(Object) << " but found type "
+ << typeName(Object)
+ << " but found type "
<< typeName(lastWriteOpTimeElement.type()));
}
auto lastWriteOpTime = OpTime::parseFromOplogEntry(lastWriteOpTimeElement.Obj());
@@ -411,7 +417,8 @@ Status IsMasterResponse::initialize(const BSONObj& doc) {
str::stream() << "Elements in \"" << kLastWriteDateFieldName
<< "\" obj "
"of isMaster response must be of type "
- << typeName(Date) << " but found type "
+ << typeName(Date)
+ << " but found type "
<< typeName(lastWriteDateElement.type()));
}
if (_lastWrite) {
@@ -431,7 +438,8 @@ Status IsMasterResponse::initialize(const BSONObj& doc) {
str::stream() << "Elements in \"" << kLastMajorityWriteOpTimeFieldName
<< "\" obj "
"of isMaster response must be of type "
- << typeName(Object) << " but found type "
+ << typeName(Object)
+ << " but found type "
<< typeName(lastMajorityWriteOpTimeElement.type()));
}
auto lastMajorityWriteOpTime =
@@ -452,7 +460,8 @@ Status IsMasterResponse::initialize(const BSONObj& doc) {
str::stream() << "Elements in \"" << kLastMajorityWriteDateFieldName
<< "\" obj "
"of isMaster response must be of type "
- << typeName(Date) << " but found type "
+ << typeName(Date)
+ << " but found type "
<< typeName(lastMajorityWriteDateElement.type()));
}
if (_lastMajorityWrite) {
diff --git a/src/mongo/db/repl/isself.cpp b/src/mongo/db/repl/isself.cpp
index 87cba6fe03b..50be2827f35 100644
--- a/src/mongo/db/repl/isself.cpp
+++ b/src/mongo/db/repl/isself.cpp
@@ -37,15 +37,15 @@
#include "mongo/base/init.h"
#include "mongo/bson/util/builder.h"
#include "mongo/client/dbclientinterface.h"
-#include "mongo/db/commands.h"
#include "mongo/db/auth/action_set.h"
#include "mongo/db/auth/action_type.h"
#include "mongo/db/auth/authorization_manager.h"
#include "mongo/db/auth/authorization_manager_global.h"
#include "mongo/db/auth/internal_user_auth.h"
#include "mongo/db/auth/privilege.h"
-#include "mongo/util/scopeguard.h"
+#include "mongo/db/commands.h"
#include "mongo/util/log.h"
+#include "mongo/util/scopeguard.h"
#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun) || \
defined(__OpenBSD__)
@@ -66,11 +66,11 @@
#endif
#elif defined(_WIN32)
+#include <Ws2tcpip.h>
#include <boost/asio/detail/socket_ops.hpp>
#include <boost/system/error_code.hpp>
#include <iphlpapi.h>
#include <winsock2.h>
-#include <Ws2tcpip.h>
#endif // defined(_WIN32)
namespace mongo {
diff --git a/src/mongo/db/repl/master_slave.cpp b/src/mongo/db/repl/master_slave.cpp
index a368b4b91c6..d7695947687 100644
--- a/src/mongo/db/repl/master_slave.cpp
+++ b/src/mongo/db/repl/master_slave.cpp
@@ -975,8 +975,8 @@ int ReplSource::_sync_pullOpLog(OperationContext* txn, int& nApplied) {
<< ((nextOpTime < syncedTo) ? "<??" : ">") << " syncedTo "
<< syncedTo.toStringLong() << '\n'
<< "time diff: " << (nextOpTime.getSecs() - syncedTo.getSecs()) << "sec\n"
- << "tailing: " << tailing << '\n' << "data too stale, halting replication"
- << endl;
+ << "tailing: " << tailing << '\n'
+ << "data too stale, halting replication" << endl;
replInfo = replAllDead = "data too stale halted replication";
verify(syncedTo < nextOpTime);
throw SyncException();
diff --git a/src/mongo/db/repl/member_config_test.cpp b/src/mongo/db/repl/member_config_test.cpp
index b051451524c..eda31743ba7 100644
--- a/src/mongo/db/repl/member_config_test.cpp
+++ b/src/mongo/db/repl/member_config_test.cpp
@@ -62,7 +62,8 @@ TEST(MemberConfig, ParseFailsWithIllegalFieldName) {
ASSERT_EQUALS(ErrorCodes::BadValue,
mc.initialize(BSON("_id" << 0 << "host"
<< "localhost"
- << "frim" << 1),
+ << "frim"
+ << 1),
&tagConfig));
}
@@ -121,12 +122,14 @@ TEST(MemberConfig, ParseArbiterOnly) {
MemberConfig mc;
ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "arbiterOnly" << 1.0),
+ << "arbiterOnly"
+ << 1.0),
&tagConfig));
ASSERT_TRUE(mc.isArbiter());
ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "arbiterOnly" << false),
+ << "arbiterOnly"
+ << false),
&tagConfig));
ASSERT_TRUE(!mc.isArbiter());
}
@@ -136,12 +139,14 @@ TEST(MemberConfig, ParseHidden) {
MemberConfig mc;
ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "hidden" << 1.0),
+ << "hidden"
+ << 1.0),
&tagConfig));
ASSERT_TRUE(mc.isHidden());
ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "hidden" << false),
+ << "hidden"
+ << false),
&tagConfig));
ASSERT_TRUE(!mc.isHidden());
ASSERT_EQUALS(ErrorCodes::TypeMismatch,
@@ -157,12 +162,14 @@ TEST(MemberConfig, ParseBuildIndexes) {
MemberConfig mc;
ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "buildIndexes" << 1.0),
+ << "buildIndexes"
+ << 1.0),
&tagConfig));
ASSERT_TRUE(mc.shouldBuildIndexes());
ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "buildIndexes" << false),
+ << "buildIndexes"
+ << false),
&tagConfig));
ASSERT_TRUE(!mc.shouldBuildIndexes());
}
@@ -172,40 +179,49 @@ TEST(MemberConfig, ParseVotes) {
MemberConfig mc;
ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "votes" << 1.0),
+ << "votes"
+ << 1.0),
&tagConfig));
ASSERT_TRUE(mc.isVoter());
ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "votes" << 0 << "priority" << 0),
+ << "votes"
+ << 0
+ << "priority"
+ << 0),
&tagConfig));
ASSERT_FALSE(mc.isVoter());
// For backwards compatibility, truncate 1.X to 1, and 0.X to 0 (and -0.X to 0).
ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "votes" << 1.5),
+ << "votes"
+ << 1.5),
&tagConfig));
ASSERT_TRUE(mc.isVoter());
ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "votes" << 0.5),
+ << "votes"
+ << 0.5),
&tagConfig));
ASSERT_FALSE(mc.isVoter());
ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "votes" << -0.5),
+ << "votes"
+ << -0.5),
&tagConfig));
ASSERT_FALSE(mc.isVoter());
ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "votes" << 2),
+ << "votes"
+ << 2),
&tagConfig));
ASSERT_EQUALS(ErrorCodes::TypeMismatch,
mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "votes" << Date_t::fromMillisSinceEpoch(2)),
+ << "votes"
+ << Date_t::fromMillisSinceEpoch(2)),
&tagConfig));
}
@@ -214,24 +230,28 @@ TEST(MemberConfig, ParsePriority) {
MemberConfig mc;
ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "priority" << 1),
+ << "priority"
+ << 1),
&tagConfig));
ASSERT_EQUALS(1.0, mc.getPriority());
ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "priority" << 0),
+ << "priority"
+ << 0),
&tagConfig));
ASSERT_EQUALS(0.0, mc.getPriority());
ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "priority" << 100.8),
+ << "priority"
+ << 100.8),
&tagConfig));
ASSERT_EQUALS(100.8, mc.getPriority());
ASSERT_EQUALS(ErrorCodes::TypeMismatch,
mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "priority" << Date_t::fromMillisSinceEpoch(2)),
+ << "priority"
+ << Date_t::fromMillisSinceEpoch(2)),
&tagConfig));
}
@@ -240,7 +260,8 @@ TEST(MemberConfig, ParseSlaveDelay) {
MemberConfig mc;
ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "slaveDelay" << 100),
+ << "slaveDelay"
+ << 100),
&tagConfig));
ASSERT_EQUALS(Seconds(100), mc.getSlaveDelay());
}
@@ -250,10 +271,11 @@ TEST(MemberConfig, ParseTags) {
MemberConfig mc;
ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "tags" << BSON("k1"
- << "v1"
- << "k2"
- << "v2")),
+ << "tags"
+ << BSON("k1"
+ << "v1"
+ << "k2"
+ << "v2")),
&tagConfig));
ASSERT_EQUALS(5U, mc.getNumTags());
ASSERT_EQUALS(5, std::distance(mc.tagsBegin(), mc.tagsEnd()));
@@ -284,14 +306,18 @@ TEST(MemberConfig, ValidateVotes) {
ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "votes" << 1.0),
+ << "votes"
+ << 1.0),
&tagConfig));
ASSERT_OK(mc.validate());
ASSERT_TRUE(mc.isVoter());
ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "votes" << 0 << "priority" << 0),
+ << "votes"
+ << 0
+ << "priority"
+ << 0),
&tagConfig));
ASSERT_OK(mc.validate());
ASSERT_FALSE(mc.isVoter());
@@ -299,21 +325,28 @@ TEST(MemberConfig, ValidateVotes) {
// For backwards compatibility, truncate 1.X to 1, and 0.X to 0 (and -0.X to 0).
ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "votes" << 1.5),
+ << "votes"
+ << 1.5),
&tagConfig));
ASSERT_OK(mc.validate());
ASSERT_TRUE(mc.isVoter());
ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "votes" << 0.5 << "priority" << 0),
+ << "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 << "priority" << 0),
+ << "votes"
+ << -0.5
+ << "priority"
+ << 0),
&tagConfig));
ASSERT_OK(mc.validate());
ASSERT_FALSE(mc.isVoter());
@@ -321,13 +354,15 @@ TEST(MemberConfig, ValidateVotes) {
// Invalid values
ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "votes" << 2),
+ << "votes"
+ << 2),
&tagConfig));
ASSERT_EQUALS(ErrorCodes::BadValue, mc.validate());
ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "votes" << -1),
+ << "votes"
+ << -1),
&tagConfig));
ASSERT_EQUALS(ErrorCodes::BadValue, mc.validate());
}
@@ -337,22 +372,26 @@ TEST(MemberConfig, ValidatePriorityRanges) {
MemberConfig mc;
ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "priority" << 0),
+ << "priority"
+ << 0),
&tagConfig));
ASSERT_OK(mc.validate());
ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "priority" << 1000),
+ << "priority"
+ << 1000),
&tagConfig));
ASSERT_OK(mc.validate());
ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "priority" << -1),
+ << "priority"
+ << -1),
&tagConfig));
ASSERT_EQUALS(ErrorCodes::BadValue, mc.validate());
ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "priority" << 1001),
+ << "priority"
+ << 1001),
&tagConfig));
ASSERT_EQUALS(ErrorCodes::BadValue, mc.validate());
}
@@ -362,22 +401,34 @@ TEST(MemberConfig, ValidateSlaveDelays) {
MemberConfig mc;
ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "priority" << 0 << "slaveDelay" << 0),
+ << "priority"
+ << 0
+ << "slaveDelay"
+ << 0),
&tagConfig));
ASSERT_OK(mc.validate());
ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "priority" << 0 << "slaveDelay" << 3600 * 10),
+ << "priority"
+ << 0
+ << "slaveDelay"
+ << 3600 * 10),
&tagConfig));
ASSERT_OK(mc.validate());
ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "priority" << 0 << "slaveDelay" << -1),
+ << "priority"
+ << 0
+ << "slaveDelay"
+ << -1),
&tagConfig));
ASSERT_EQUALS(ErrorCodes::BadValue, mc.validate());
ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "priority" << 0 << "slaveDelay" << 3600 * 24 * 400),
+ << "priority"
+ << 0
+ << "slaveDelay"
+ << 3600 * 24 * 400),
&tagConfig));
ASSERT_EQUALS(ErrorCodes::BadValue, mc.validate());
}
@@ -387,7 +438,10 @@ TEST(MemberConfig, ValidatePriorityAndSlaveDelayRelationship) {
MemberConfig mc;
ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "priority" << 1 << "slaveDelay" << 60),
+ << "priority"
+ << 1
+ << "slaveDelay"
+ << 60),
&tagConfig));
ASSERT_EQUALS(ErrorCodes::BadValue, mc.validate());
}
@@ -397,12 +451,18 @@ TEST(MemberConfig, ValidatePriorityAndHiddenRelationship) {
MemberConfig mc;
ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "priority" << 1 << "hidden" << true),
+ << "priority"
+ << 1
+ << "hidden"
+ << true),
&tagConfig));
ASSERT_EQUALS(ErrorCodes::BadValue, mc.validate());
ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "priority" << 1 << "hidden" << false),
+ << "priority"
+ << 1
+ << "hidden"
+ << false),
&tagConfig));
ASSERT_OK(mc.validate());
}
@@ -412,13 +472,19 @@ TEST(MemberConfig, ValidatePriorityAndBuildIndexesRelationship) {
MemberConfig mc;
ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "priority" << 1 << "buildIndexes" << false),
+ << "priority"
+ << 1
+ << "buildIndexes"
+ << false),
&tagConfig));
ASSERT_EQUALS(ErrorCodes::BadValue, mc.validate());
ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "priority" << 1 << "buildIndexes" << true),
+ << "priority"
+ << 1
+ << "buildIndexes"
+ << true),
&tagConfig));
ASSERT_OK(mc.validate());
}
@@ -428,25 +494,38 @@ TEST(MemberConfig, ValidateArbiterVotesRelationship) {
MemberConfig mc;
ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "votes" << 1 << "arbiterOnly" << true),
+ << "votes"
+ << 1
+ << "arbiterOnly"
+ << true),
&tagConfig));
ASSERT_OK(mc.validate());
- ASSERT_OK(
- mc.initialize(BSON("_id" << 0 << "host"
- << "h"
- << "votes" << 0 << "priority" << 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"
- << "votes" << 1 << "arbiterOnly" << false),
+ << "votes"
+ << 1
+ << "arbiterOnly"
+ << false),
&tagConfig));
ASSERT_OK(mc.validate());
ASSERT_OK(mc.initialize(BSON("_id" << 0 << "host"
<< "h"
- << "votes" << 0 << "arbiterOnly" << true),
+ << "votes"
+ << 0
+ << "arbiterOnly"
+ << true),
&tagConfig));
ASSERT_EQUALS(ErrorCodes::BadValue, mc.validate());
}
diff --git a/src/mongo/db/repl/old_update_position_args.cpp b/src/mongo/db/repl/old_update_position_args.cpp
index 67575d7e280..92ffd74db79 100644
--- a/src/mongo/db/repl/old_update_position_args.cpp
+++ b/src/mongo/db/repl/old_update_position_args.cpp
@@ -141,8 +141,10 @@ BSONObj OldUpdatePositionArgs::toBSON() const {
++update) {
updateArray.append(BSON(kMemberRIDFieldName << update->rid << kOpTimeFieldName
<< update->ts.getTimestamp()
- << kConfigVersionFieldName << update->cfgver
- << kMemberIdFieldName << update->memberId));
+ << kConfigVersionFieldName
+ << update->cfgver
+ << kMemberIdFieldName
+ << update->memberId));
}
updateArray.doneFast();
}
diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp
index 0d66d00aad6..2a9e7e0b40c 100644
--- a/src/mongo/db/repl/oplog.cpp
+++ b/src/mongo/db/repl/oplog.cpp
@@ -431,7 +431,7 @@ void logOps(OperationContext* txn,
txn, opstr, nss, begin[i], NULL, fromMigrate, slots[i].opTime, slots[i].hash));
}
- std::unique_ptr<DocWriter const* []> basePtrs(new DocWriter const* [count]);
+ std::unique_ptr<DocWriter const* []> basePtrs(new DocWriter const*[count]);
for (size_t i = 0; i < count; i++) {
basePtrs[i] = &writers[i];
}
@@ -605,72 +605,73 @@ struct ApplyOpMetadata {
std::map<std::string, ApplyOpMetadata> opsMap = {
{"create",
- {[](OperationContext* txn, const char* ns, BSONObj& cmd)
- -> Status { return createCollection(txn, NamespaceString(ns).db().toString(), cmd); },
- {ErrorCodes::NamespaceExists}}},
- {"collMod",
{[](OperationContext* txn, const char* ns, BSONObj& cmd) -> Status {
+ return createCollection(txn, NamespaceString(ns).db().toString(), cmd);
+ },
+ {ErrorCodes::NamespaceExists}}},
+ {"collMod", {[](OperationContext* txn, const char* ns, BSONObj& cmd) -> Status {
BSONObjBuilder resultWeDontCareAbout;
return collMod(txn, parseNs(ns, cmd), cmd, &resultWeDontCareAbout);
}}},
{"dropDatabase",
- {[](OperationContext* txn, const char* ns, BSONObj& cmd)
- -> Status { return dropDatabase(txn, NamespaceString(ns).db().toString()); },
+ {[](OperationContext* txn, const char* ns, BSONObj& cmd) -> Status {
+ return dropDatabase(txn, NamespaceString(ns).db().toString());
+ },
{ErrorCodes::NamespaceNotFound}}},
{"drop",
{[](OperationContext* txn, const char* ns, BSONObj& cmd) -> Status {
- BSONObjBuilder resultWeDontCareAbout;
- return dropCollection(txn, parseNs(ns, cmd), resultWeDontCareAbout);
- },
+ BSONObjBuilder resultWeDontCareAbout;
+ return dropCollection(txn, parseNs(ns, cmd), resultWeDontCareAbout);
+ },
// IllegalOperation is necessary because in 3.0 we replicate drops of system.profile
// TODO(dannenberg) remove IllegalOperation once we no longer need 3.0 compatibility
{ErrorCodes::NamespaceNotFound, ErrorCodes::IllegalOperation}}},
// deleteIndex(es) is deprecated but still works as of April 10, 2015
{"deleteIndex",
{[](OperationContext* txn, const char* ns, BSONObj& cmd) -> Status {
- BSONObjBuilder resultWeDontCareAbout;
- return dropIndexes(txn, parseNs(ns, cmd), cmd, &resultWeDontCareAbout);
- },
+ BSONObjBuilder resultWeDontCareAbout;
+ return dropIndexes(txn, parseNs(ns, cmd), cmd, &resultWeDontCareAbout);
+ },
{ErrorCodes::NamespaceNotFound, ErrorCodes::IndexNotFound}}},
{"deleteIndexes",
{[](OperationContext* txn, const char* ns, BSONObj& cmd) -> Status {
- BSONObjBuilder resultWeDontCareAbout;
- return dropIndexes(txn, parseNs(ns, cmd), cmd, &resultWeDontCareAbout);
- },
+ BSONObjBuilder resultWeDontCareAbout;
+ return dropIndexes(txn, parseNs(ns, cmd), cmd, &resultWeDontCareAbout);
+ },
{ErrorCodes::NamespaceNotFound, ErrorCodes::IndexNotFound}}},
{"dropIndex",
{[](OperationContext* txn, const char* ns, BSONObj& cmd) -> Status {
- BSONObjBuilder resultWeDontCareAbout;
- return dropIndexes(txn, parseNs(ns, cmd), cmd, &resultWeDontCareAbout);
- },
+ BSONObjBuilder resultWeDontCareAbout;
+ return dropIndexes(txn, parseNs(ns, cmd), cmd, &resultWeDontCareAbout);
+ },
{ErrorCodes::NamespaceNotFound, ErrorCodes::IndexNotFound}}},
{"dropIndexes",
{[](OperationContext* txn, const char* ns, BSONObj& cmd) -> Status {
- BSONObjBuilder resultWeDontCareAbout;
- return dropIndexes(txn, parseNs(ns, cmd), cmd, &resultWeDontCareAbout);
- },
+ BSONObjBuilder resultWeDontCareAbout;
+ return dropIndexes(txn, parseNs(ns, cmd), cmd, &resultWeDontCareAbout);
+ },
{ErrorCodes::NamespaceNotFound, ErrorCodes::IndexNotFound}}},
{"renameCollection",
{[](OperationContext* txn, const char* ns, BSONObj& cmd) -> Status {
- return renameCollection(txn,
- NamespaceString(cmd.firstElement().valuestrsafe()),
- NamespaceString(cmd["to"].valuestrsafe()),
- cmd["dropTarget"].trueValue(),
- cmd["stayTemp"].trueValue());
- },
+ return renameCollection(txn,
+ NamespaceString(cmd.firstElement().valuestrsafe()),
+ NamespaceString(cmd["to"].valuestrsafe()),
+ cmd["dropTarget"].trueValue(),
+ cmd["stayTemp"].trueValue());
+ },
{ErrorCodes::NamespaceNotFound, ErrorCodes::NamespaceExists}}},
{"applyOps",
{[](OperationContext* txn, const char* ns, BSONObj& cmd) -> Status {
- BSONObjBuilder resultWeDontCareAbout;
- return applyOps(txn, nsToDatabase(ns), cmd, &resultWeDontCareAbout);
- },
+ BSONObjBuilder resultWeDontCareAbout;
+ return applyOps(txn, nsToDatabase(ns), cmd, &resultWeDontCareAbout);
+ },
{ErrorCodes::UnknownError}}},
- {"convertToCapped",
- {[](OperationContext* txn, const char* ns, BSONObj& cmd)
- -> Status { return convertToCapped(txn, parseNs(ns, cmd), cmd["size"].number()); }}},
- {"emptycapped",
- {[](OperationContext* txn, const char* ns, BSONObj& cmd)
- -> Status { return emptyCapped(txn, parseNs(ns, cmd)); }}},
+ {"convertToCapped", {[](OperationContext* txn, const char* ns, BSONObj& cmd) -> Status {
+ return convertToCapped(txn, parseNs(ns, cmd), cmd["size"].number());
+ }}},
+ {"emptycapped", {[](OperationContext* txn, const char* ns, BSONObj& cmd) -> Status {
+ return emptyCapped(txn, parseNs(ns, cmd));
+ }}},
};
} // namespace
@@ -742,7 +743,9 @@ Status applyOperation_inlock(OperationContext* txn,
indexNss.isValid());
uassert(ErrorCodes::InvalidNamespace,
str::stream() << "Database name mismatch for database ("
- << nsToDatabaseSubstring(ns) << ") while creating index: " << op,
+ << nsToDatabaseSubstring(ns)
+ << ") while creating index: "
+ << op,
nsToDatabaseSubstring(ns) == indexNss.db());
opCounters->gotInsert();
@@ -773,10 +776,10 @@ Status applyOperation_inlock(OperationContext* txn,
}
return Status::OK();
}
- uassert(
- ErrorCodes::NamespaceNotFound,
- str::stream() << "Failed to apply insert due to missing collection: " << op.toString(),
- collection);
+ uassert(ErrorCodes::NamespaceNotFound,
+ str::stream() << "Failed to apply insert due to missing collection: "
+ << op.toString(),
+ collection);
if (fieldO.type() == Array) {
// Batched inserts.
diff --git a/src/mongo/db/repl/oplog.h b/src/mongo/db/repl/oplog.h
index d009083c709..c04fdd85579 100644
--- a/src/mongo/db/repl/oplog.h
+++ b/src/mongo/db/repl/oplog.h
@@ -32,8 +32,8 @@
#include <deque>
#include <string>
-#include "mongo/base/status.h"
#include "mongo/base/disallow_copying.h"
+#include "mongo/base/status.h"
#include "mongo/db/repl/optime.h"
#include "mongo/db/repl/replication_coordinator.h"
#include "mongo/stdx/functional.h"
diff --git a/src/mongo/db/repl/oplog_fetcher.cpp b/src/mongo/db/repl/oplog_fetcher.cpp
index ec02d16ce1a..f43e53817f7 100644
--- a/src/mongo/db/repl/oplog_fetcher.cpp
+++ b/src/mongo/db/repl/oplog_fetcher.cpp
@@ -127,17 +127,26 @@ Status checkRemoteOplogStart(const Fetcher::Documents& documents, OpTimeWithHash
if (!opTimeResult.isOK()) {
return Status(ErrorCodes::OplogStartMissing,
str::stream() << "our last op time fetched: " << lastFetched.opTime.toString()
- << " (hash: " << lastFetched.value << ")"
+ << " (hash: "
+ << lastFetched.value
+ << ")"
<< ". failed to parse optime from first oplog on source: "
- << o.toString() << ": " << opTimeResult.getStatus().toString());
+ << o.toString()
+ << ": "
+ << opTimeResult.getStatus().toString());
}
auto opTime = opTimeResult.getValue();
long long hash = o["h"].numberLong();
if (opTime != lastFetched.opTime || hash != lastFetched.value) {
return Status(ErrorCodes::OplogStartMissing,
str::stream() << "our last op time fetched: " << lastFetched.opTime.toString()
- << ". source's GTE: " << opTime.toString() << " hashes: ("
- << lastFetched.value << "/" << hash << ")");
+ << ". source's GTE: "
+ << opTime.toString()
+ << " hashes: ("
+ << lastFetched.value
+ << "/"
+ << hash
+ << ")");
}
return Status::OK();
}
@@ -149,7 +158,8 @@ StatusWith<OplogFetcher::DocumentsInfo> OplogFetcher::validateDocuments(
if (first && documents.empty()) {
return Status(ErrorCodes::OplogStartMissing,
str::stream() << "The first batch of oplog entries is empty, but expected at "
- "least 1 document matching ts: " << lastTS.toString());
+ "least 1 document matching ts: "
+ << lastTS.toString());
}
DocumentsInfo info;
@@ -178,8 +188,11 @@ StatusWith<OplogFetcher::DocumentsInfo> OplogFetcher::validateDocuments(
if (lastTS >= docTS) {
return Status(ErrorCodes::OplogOutOfOrder,
str::stream() << "Out of order entries in oplog. lastTS: "
- << lastTS.toString() << " outOfOrderTS:" << docTS.toString()
- << " at count:" << info.networkDocumentCount);
+ << lastTS.toString()
+ << " outOfOrderTS:"
+ << docTS.toString()
+ << " at count:"
+ << info.networkDocumentCount);
}
lastTS = docTS;
}
@@ -348,12 +361,14 @@ void OplogFetcher::_callback(const Fetcher::QueryResponseStatus& result,
if (_dataReplicatorExternalState->shouldStopFetching(_fetcher.getSource(), metadata)) {
_onShutdown(Status(ErrorCodes::InvalidSyncSource,
- str::stream()
- << "sync source " << _fetcher.getSource().toString()
- << " (last optime: " << metadata.getLastOpVisible().toString()
- << "; sync source index: " << metadata.getSyncSourceIndex()
- << "; primary index: " << metadata.getPrimaryIndex()
- << ") is no longer valid"),
+ str::stream() << "sync source " << _fetcher.getSource().toString()
+ << " (last optime: "
+ << metadata.getLastOpVisible().toString()
+ << "; sync source index: "
+ << metadata.getSyncSourceIndex()
+ << "; primary index: "
+ << metadata.getPrimaryIndex()
+ << ") is no longer valid"),
opTimeWithHash);
return;
}
diff --git a/src/mongo/db/repl/oplog_fetcher_test.cpp b/src/mongo/db/repl/oplog_fetcher_test.cpp
index 49875369842..6ec6ab36bc4 100644
--- a/src/mongo/db/repl/oplog_fetcher_test.cpp
+++ b/src/mongo/db/repl/oplog_fetcher_test.cpp
@@ -316,7 +316,8 @@ TEST_F(
_createConfig(true),
dataReplicatorExternalState.get(),
enqueueDocumentsFn,
- [](Status, OpTimeWithHash) {}).getCommandObject_forTest();
+ [](Status, OpTimeWithHash) {})
+ .getCommandObject_forTest();
ASSERT_EQUALS(mongo::BSONType::Object, cmdObj["filter"].type());
ASSERT_EQUALS(BSON("ts" << BSON("$gte" << lastFetched.opTime.getTimestamp())),
cmdObj["filter"].Obj());
@@ -335,7 +336,8 @@ TEST_F(
_createConfig(true),
dataReplicatorExternalState.get(),
enqueueDocumentsFn,
- [](Status, OpTimeWithHash) {}).getCommandObject_forTest();
+ [](Status, OpTimeWithHash) {})
+ .getCommandObject_forTest();
ASSERT_EQUALS(mongo::BSONType::Object, cmdObj["filter"].type());
ASSERT_EQUALS(BSON("ts" << BSON("$gte" << lastFetched.opTime.getTimestamp())),
cmdObj["filter"].Obj());
@@ -351,7 +353,8 @@ TEST_F(OplogFetcherTest, MetadataObjectContainsReplSetMetadataFieldUnderProtocol
_createConfig(true),
dataReplicatorExternalState.get(),
enqueueDocumentsFn,
- [](Status, OpTimeWithHash) {}).getMetadataObject_forTest();
+ [](Status, OpTimeWithHash) {})
+ .getMetadataObject_forTest();
ASSERT_EQUALS(1, metadataObj.nFields());
ASSERT_EQUALS(1, metadataObj[rpc::kReplSetMetadataFieldName].numberInt());
}
@@ -364,7 +367,8 @@ TEST_F(OplogFetcherTest, MetadataObjectIsEmptyUnderProtocolVersion0) {
_createConfig(false),
dataReplicatorExternalState.get(),
enqueueDocumentsFn,
- [](Status, OpTimeWithHash) {}).getMetadataObject_forTest();
+ [](Status, OpTimeWithHash) {})
+ .getMetadataObject_forTest();
ASSERT_EQUALS(BSONObj(), metadataObj);
}
@@ -377,7 +381,8 @@ TEST_F(OplogFetcherTest, RemoteCommandTimeoutShouldEqualElectionTimeout) {
config,
dataReplicatorExternalState.get(),
enqueueDocumentsFn,
- [](Status, OpTimeWithHash) {}).getRemoteCommandTimeout_forTest();
+ [](Status, OpTimeWithHash) {})
+ .getRemoteCommandTimeout_forTest();
ASSERT_EQUALS(config.getElectionTimeoutPeriod(), timeout);
}
@@ -390,7 +395,8 @@ TEST_F(OplogFetcherTest, AwaitDataTimeoutShouldEqualHalfElectionTimeoutUnderProt
config,
dataReplicatorExternalState.get(),
enqueueDocumentsFn,
- [](Status, OpTimeWithHash) {}).getAwaitDataTimeout_forTest();
+ [](Status, OpTimeWithHash) {})
+ .getAwaitDataTimeout_forTest();
ASSERT_EQUALS(config.getElectionTimeoutPeriod() / 2, timeout);
}
@@ -402,7 +408,8 @@ TEST_F(OplogFetcherTest, AwaitDataTimeoutShouldBeAConstantUnderProtocolVersion0)
_createConfig(false),
dataReplicatorExternalState.get(),
enqueueDocumentsFn,
- [](Status, OpTimeWithHash) {}).getAwaitDataTimeout_forTest();
+ [](Status, OpTimeWithHash) {})
+ .getAwaitDataTimeout_forTest();
ASSERT_EQUALS(OplogFetcher::kDefaultProtocolZeroAwaitDataTimeout, timeout);
}
diff --git a/src/mongo/db/repl/oplog_interface_local.cpp b/src/mongo/db/repl/oplog_interface_local.cpp
index 43a74b15d54..88aa50436ee 100644
--- a/src/mongo/db/repl/oplog_interface_local.cpp
+++ b/src/mongo/db/repl/oplog_interface_local.cpp
@@ -91,8 +91,8 @@ OplogInterfaceLocal::OplogInterfaceLocal(OperationContext* txn, const std::strin
std::string OplogInterfaceLocal::toString() const {
return str::stream() << "LocalOplogInterface: "
- "operation context: " << _txn->getOpID()
- << "; collection: " << _collectionName;
+ "operation context: "
+ << _txn->getOpID() << "; collection: " << _collectionName;
}
std::unique_ptr<OplogInterface::Iterator> OplogInterfaceLocal::makeIterator() const {
diff --git a/src/mongo/db/repl/oplog_interface_mock.h b/src/mongo/db/repl/oplog_interface_mock.h
index 524ab3c8d2f..7c1b32c506f 100644
--- a/src/mongo/db/repl/oplog_interface_mock.h
+++ b/src/mongo/db/repl/oplog_interface_mock.h
@@ -28,8 +28,8 @@
#pragma once
-#include <initializer_list>
#include "mongo/db/repl/oplog_interface.h"
+#include <initializer_list>
namespace mongo {
namespace repl {
diff --git a/src/mongo/db/repl/optime_extract_test.cpp b/src/mongo/db/repl/optime_extract_test.cpp
index ef1d82dff7d..5f5f5800e24 100644
--- a/src/mongo/db/repl/optime_extract_test.cpp
+++ b/src/mongo/db/repl/optime_extract_test.cpp
@@ -49,7 +49,8 @@ TEST(ExtractBSON, ExtractOpTimeField) {
// Missing timestamp field.
obj = BSON("a" << BSON("ts"
<< "notATimestamp"
- << "t" << 2));
+ << "t"
+ << 2));
ASSERT_EQUALS(ErrorCodes::TypeMismatch, bsonExtractOpTimeField(obj, "a", &opTime));
// Wrong typed timestamp field.
obj = BSON("a" << BSON("t" << 2));
diff --git a/src/mongo/db/repl/read_concern_args.cpp b/src/mongo/db/repl/read_concern_args.cpp
index 097bdc78655..79c9d7b65b4 100644
--- a/src/mongo/db/repl/read_concern_args.cpp
+++ b/src/mongo/db/repl/read_concern_args.cpp
@@ -125,7 +125,8 @@ Status ReadConcernArgs::initialize(const BSONElement& readConcernElem) {
} else {
return Status(ErrorCodes::InvalidOptions,
str::stream() << "Unrecognized option in " << kReadConcernFieldName
- << ": " << fieldName);
+ << ": "
+ << fieldName);
}
}
diff --git a/src/mongo/db/repl/read_concern_args_test.cpp b/src/mongo/db/repl/read_concern_args_test.cpp
index 57364f07d14..75843f5a945 100644
--- a/src/mongo/db/repl/read_concern_args_test.cpp
+++ b/src/mongo/db/repl/read_concern_args_test.cpp
@@ -38,12 +38,13 @@ namespace {
TEST(ReadAfterParse, ReadAfterOnly) {
ReadConcernArgs readAfterOpTime;
- ASSERT_OK(readAfterOpTime.initialize(BSON("find"
- << "test" << ReadConcernArgs::kReadConcernFieldName
- << BSON(ReadConcernArgs::kAfterOpTimeFieldName
- << BSON(OpTime::kTimestampFieldName
- << Timestamp(20, 30)
- << OpTime::kTermFieldName << 2)))));
+ ASSERT_OK(readAfterOpTime.initialize(BSON(
+ "find"
+ << "test"
+ << ReadConcernArgs::kReadConcernFieldName
+ << BSON(ReadConcernArgs::kAfterOpTimeFieldName
+ << BSON(OpTime::kTimestampFieldName << Timestamp(20, 30) << OpTime::kTermFieldName
+ << 2)))));
ASSERT_EQ(Timestamp(20, 30), readAfterOpTime.getOpTime().getTimestamp());
ASSERT_EQ(2, readAfterOpTime.getOpTime().getTerm());
@@ -54,7 +55,8 @@ TEST(ReadAfterParse, ReadCommitLevelOnly) {
ReadConcernArgs readAfterOpTime;
ASSERT_OK(
readAfterOpTime.initialize(BSON("find"
- << "test" << ReadConcernArgs::kReadConcernFieldName
+ << "test"
+ << ReadConcernArgs::kReadConcernFieldName
<< BSON(ReadConcernArgs::kLevelFieldName << "majority"))));
ASSERT_TRUE(readAfterOpTime.getOpTime().isNull());
@@ -63,13 +65,15 @@ TEST(ReadAfterParse, ReadCommitLevelOnly) {
TEST(ReadAfterParse, ReadCommittedFullSpecification) {
ReadConcernArgs readAfterOpTime;
- ASSERT_OK(readAfterOpTime.initialize(
- BSON("find"
- << "test" << ReadConcernArgs::kReadConcernFieldName
- << BSON(ReadConcernArgs::kAfterOpTimeFieldName
- << BSON(OpTime::kTimestampFieldName << Timestamp(20, 30)
- << OpTime::kTermFieldName << 2)
- << ReadConcernArgs::kLevelFieldName << "majority"))));
+ ASSERT_OK(readAfterOpTime.initialize(BSON(
+ "find"
+ << "test"
+ << ReadConcernArgs::kReadConcernFieldName
+ << BSON(ReadConcernArgs::kAfterOpTimeFieldName
+ << BSON(OpTime::kTimestampFieldName << Timestamp(20, 30) << OpTime::kTermFieldName
+ << 2)
+ << ReadConcernArgs::kLevelFieldName
+ << "majority"))));
ASSERT_EQ(Timestamp(20, 30), readAfterOpTime.getOpTime().getTimestamp());
ASSERT_EQ(2, readAfterOpTime.getOpTime().getTerm());
@@ -87,24 +91,26 @@ TEST(ReadAfterParse, Empty) {
TEST(ReadAfterParse, BadRootType) {
ReadConcernArgs readAfterOpTime;
- ASSERT_NOT_OK(
- readAfterOpTime.initialize(BSON("find"
- << "test" << ReadConcernArgs::kReadConcernFieldName
- << "x")));
+ ASSERT_NOT_OK(readAfterOpTime.initialize(BSON("find"
+ << "test"
+ << ReadConcernArgs::kReadConcernFieldName
+ << "x")));
}
TEST(ReadAfterParse, BadOpTimeType) {
ReadConcernArgs readAfterOpTime;
ASSERT_NOT_OK(
readAfterOpTime.initialize(BSON("find"
- << "test" << ReadConcernArgs::kReadConcernFieldName
+ << "test"
+ << ReadConcernArgs::kReadConcernFieldName
<< BSON(ReadConcernArgs::kAfterOpTimeFieldName << 2))));
}
TEST(ReadAfterParse, OpTimeNotNeededForValidReadConcern) {
ReadConcernArgs readAfterOpTime;
ASSERT_OK(readAfterOpTime.initialize(BSON("find"
- << "test" << ReadConcernArgs::kReadConcernFieldName
+ << "test"
+ << ReadConcernArgs::kReadConcernFieldName
<< BSONObj())));
}
@@ -112,47 +118,49 @@ TEST(ReadAfterParse, NoOpTimeTS) {
ReadConcernArgs readAfterOpTime;
ASSERT_NOT_OK(
readAfterOpTime.initialize(BSON("find"
- << "test" << ReadConcernArgs::kReadConcernFieldName
+ << "test"
+ << ReadConcernArgs::kReadConcernFieldName
<< BSON(ReadConcernArgs::kAfterOpTimeFieldName
<< BSON(OpTime::kTimestampFieldName << 2)))));
}
TEST(ReadAfterParse, NoOpTimeTerm) {
ReadConcernArgs readAfterOpTime;
- ASSERT_NOT_OK(
- readAfterOpTime.initialize(BSON("find"
- << "test" << ReadConcernArgs::kReadConcernFieldName
- << BSON(ReadConcernArgs::kAfterOpTimeFieldName
- << BSON(OpTime::kTermFieldName << 2)))));
+ ASSERT_NOT_OK(readAfterOpTime.initialize(BSON("find"
+ << "test"
+ << ReadConcernArgs::kReadConcernFieldName
+ << BSON(ReadConcernArgs::kAfterOpTimeFieldName
+ << BSON(OpTime::kTermFieldName << 2)))));
}
TEST(ReadAfterParse, BadOpTimeTSType) {
ReadConcernArgs readAfterOpTime;
- ASSERT_NOT_OK(
- readAfterOpTime.initialize(BSON("find"
- << "test" << ReadConcernArgs::kReadConcernFieldName
- << BSON(ReadConcernArgs::kAfterOpTimeFieldName
- << BSON(OpTime::kTimestampFieldName
- << BSON("x" << 1) << OpTime::kTermFieldName
- << 2)))));
+ ASSERT_NOT_OK(readAfterOpTime.initialize(
+ BSON("find"
+ << "test"
+ << ReadConcernArgs::kReadConcernFieldName
+ << BSON(ReadConcernArgs::kAfterOpTimeFieldName
+ << BSON(OpTime::kTimestampFieldName << BSON("x" << 1) << OpTime::kTermFieldName
+ << 2)))));
}
TEST(ReadAfterParse, BadOpTimeTermType) {
ReadConcernArgs readAfterOpTime;
- ASSERT_NOT_OK(
- readAfterOpTime.initialize(BSON("find"
- << "test" << ReadConcernArgs::kReadConcernFieldName
- << BSON(ReadConcernArgs::kAfterOpTimeFieldName
- << BSON(OpTime::kTimestampFieldName
- << Timestamp(1, 0) << OpTime::kTermFieldName
- << "y")))));
+ ASSERT_NOT_OK(readAfterOpTime.initialize(BSON(
+ "find"
+ << "test"
+ << ReadConcernArgs::kReadConcernFieldName
+ << BSON(ReadConcernArgs::kAfterOpTimeFieldName
+ << BSON(OpTime::kTimestampFieldName << Timestamp(1, 0) << OpTime::kTermFieldName
+ << "y")))));
}
TEST(ReadAfterParse, BadLevelType) {
ReadConcernArgs readAfterOpTime;
ASSERT_EQ(ErrorCodes::TypeMismatch,
readAfterOpTime.initialize(BSON("find"
- << "test" << ReadConcernArgs::kReadConcernFieldName
+ << "test"
+ << ReadConcernArgs::kReadConcernFieldName
<< BSON(ReadConcernArgs::kLevelFieldName << 7))));
}
@@ -160,7 +168,8 @@ TEST(ReadAfterParse, BadLevelValue) {
ReadConcernArgs readAfterOpTime;
ASSERT_EQ(ErrorCodes::FailedToParse,
readAfterOpTime.initialize(BSON("find"
- << "test" << ReadConcernArgs::kReadConcernFieldName
+ << "test"
+ << ReadConcernArgs::kReadConcernFieldName
<< BSON(ReadConcernArgs::kLevelFieldName
<< "seven is not a real level"))));
}
@@ -169,7 +178,8 @@ TEST(ReadAfterParse, BadOption) {
ReadConcernArgs readAfterOpTime;
ASSERT_EQ(ErrorCodes::InvalidOptions,
readAfterOpTime.initialize(BSON("find"
- << "test" << ReadConcernArgs::kReadConcernFieldName
+ << "test"
+ << ReadConcernArgs::kReadConcernFieldName
<< BSON("asdf" << 1))));
}
@@ -188,10 +198,10 @@ TEST(ReadAfterSerialize, ReadAfterOnly) {
ReadConcernArgs readAfterOpTime(OpTime(Timestamp(20, 30), 2), boost::none);
readAfterOpTime.appendInfo(&builder);
- BSONObj expectedObj(BSON(ReadConcernArgs::kReadConcernFieldName
- << BSON(ReadConcernArgs::kAfterOpTimeFieldName << BSON(
- OpTime::kTimestampFieldName
- << Timestamp(20, 30) << OpTime::kTermFieldName << 2))));
+ BSONObj expectedObj(BSON(
+ ReadConcernArgs::kReadConcernFieldName << BSON(
+ ReadConcernArgs::kAfterOpTimeFieldName << BSON(
+ OpTime::kTimestampFieldName << Timestamp(20, 30) << OpTime::kTermFieldName << 2))));
ASSERT_EQ(expectedObj, builder.done());
}
@@ -213,11 +223,13 @@ TEST(ReadAfterSerialize, FullSpecification) {
ReadConcernLevel::kMajorityReadConcern);
readAfterOpTime.appendInfo(&builder);
- BSONObj expectedObj(BSON(ReadConcernArgs::kReadConcernFieldName << BSON(
- ReadConcernArgs::kLevelFieldName
- << "majority" << ReadConcernArgs::kAfterOpTimeFieldName
- << BSON(OpTime::kTimestampFieldName
- << Timestamp(20, 30) << OpTime::kTermFieldName << 2))));
+ BSONObj expectedObj(BSON(
+ ReadConcernArgs::kReadConcernFieldName
+ << BSON(ReadConcernArgs::kLevelFieldName
+ << "majority"
+ << ReadConcernArgs::kAfterOpTimeFieldName
+ << BSON(OpTime::kTimestampFieldName << Timestamp(20, 30) << OpTime::kTermFieldName
+ << 2))));
ASSERT_EQ(expectedObj, builder.done());
}
diff --git a/src/mongo/db/repl/repl_set_heartbeat_response.cpp b/src/mongo/db/repl/repl_set_heartbeat_response.cpp
index f7388355c98..032ef5e3b1d 100644
--- a/src/mongo/db/repl/repl_set_heartbeat_response.cpp
+++ b/src/mongo/db/repl/repl_set_heartbeat_response.cpp
@@ -261,18 +261,18 @@ Status ReplSetHeartbeatResponse::initialize(const BSONObj& doc, long long term)
if (memberStateElement.eoo()) {
_stateSet = false;
} else if (memberStateElement.type() != NumberInt && memberStateElement.type() != NumberLong) {
- return Status(ErrorCodes::TypeMismatch,
- str::stream()
- << "Expected \"" << kMemberStateFieldName
+ return Status(
+ ErrorCodes::TypeMismatch,
+ str::stream() << "Expected \"" << kMemberStateFieldName
<< "\" field in response to replSetHeartbeat "
"command to have type NumberInt or NumberLong, but found type "
<< typeName(memberStateElement.type()));
} else {
long long stateInt = memberStateElement.numberLong();
if (stateInt < 0 || stateInt > MemberState::RS_MAX) {
- return Status(ErrorCodes::BadValue,
- str::stream()
- << "Value for \"" << kMemberStateFieldName
+ return Status(
+ ErrorCodes::BadValue,
+ str::stream() << "Value for \"" << kMemberStateFieldName
<< "\" in response to replSetHeartbeat is "
"out of range; legal values are non-negative and no more than "
<< MemberState::RS_MAX);
@@ -312,7 +312,8 @@ Status ReplSetHeartbeatResponse::initialize(const BSONObj& doc, long long term)
return Status(ErrorCodes::TypeMismatch,
str::stream() << "Expected \"" << kHbMessageFieldName
<< "\" field in response to replSetHeartbeat to have "
- "type String, but found " << typeName(hbMsgElement.type()));
+ "type String, but found "
+ << typeName(hbMsgElement.type()));
} else {
_hbmsg = hbMsgElement.String();
}
@@ -339,7 +340,8 @@ Status ReplSetHeartbeatResponse::initialize(const BSONObj& doc, long long term)
return Status(ErrorCodes::TypeMismatch,
str::stream() << "Expected \"" << kConfigFieldName
<< "\" in response to replSetHeartbeat to have type "
- "Object, but found " << typeName(rsConfigElement.type()));
+ "Object, but found "
+ << typeName(rsConfigElement.type()));
}
_configSet = true;
diff --git a/src/mongo/db/repl/repl_set_heartbeat_response_test.cpp b/src/mongo/db/repl/repl_set_heartbeat_response_test.cpp
index 87634a155a5..80548c1aacf 100644
--- a/src/mongo/db/repl/repl_set_heartbeat_response_test.cpp
+++ b/src/mongo/db/repl/repl_set_heartbeat_response_test.cpp
@@ -713,7 +713,8 @@ TEST(ReplSetHeartbeatResponse, InitializeHeartbeatMeessageWrongType) {
ReplSetHeartbeatResponse hbResponse;
BSONObj initializerObj =
BSON("ok" << 1.0 << "v" << 2 << // needs a version to get this far in initialize()
- "hbmsg" << 4);
+ "hbmsg"
+ << 4);
Status result = hbResponse.initialize(initializerObj, 0);
ASSERT_EQUALS(ErrorCodes::TypeMismatch, result);
ASSERT_EQUALS(
@@ -726,7 +727,8 @@ TEST(ReplSetHeartbeatResponse, InitializeSyncingToWrongType) {
ReplSetHeartbeatResponse hbResponse;
BSONObj initializerObj =
BSON("ok" << 1.0 << "v" << 2 << // needs a version to get this far in initialize()
- "syncingTo" << 4);
+ "syncingTo"
+ << 4);
Status result = hbResponse.initialize(initializerObj, 0);
ASSERT_EQUALS(ErrorCodes::TypeMismatch, result);
ASSERT_EQUALS(
@@ -739,7 +741,8 @@ TEST(ReplSetHeartbeatResponse, InitializeConfigWrongType) {
ReplSetHeartbeatResponse hbResponse;
BSONObj initializerObj =
BSON("ok" << 1.0 << "v" << 2 << // needs a version to get this far in initialize()
- "config" << 4);
+ "config"
+ << 4);
Status result = hbResponse.initialize(initializerObj, 0);
ASSERT_EQUALS(ErrorCodes::TypeMismatch, result);
ASSERT_EQUALS(
@@ -752,7 +755,8 @@ TEST(ReplSetHeartbeatResponse, InitializeBadConfig) {
ReplSetHeartbeatResponse hbResponse;
BSONObj initializerObj =
BSON("ok" << 1.0 << "v" << 2 << // needs a version to get this far in initialize()
- "config" << BSON("illegalFieldName" << 2));
+ "config"
+ << BSON("illegalFieldName" << 2));
Status result = hbResponse.initialize(initializerObj, 0);
ASSERT_EQUALS(ErrorCodes::BadValue, result);
ASSERT_EQUALS("Unexpected field illegalFieldName in replica set configuration",
diff --git a/src/mongo/db/repl/repl_set_html_summary.cpp b/src/mongo/db/repl/repl_set_html_summary.cpp
index 218dff908fd..14c2ff81b7d 100644
--- a/src/mongo/db/repl/repl_set_html_summary.cpp
+++ b/src/mongo/db/repl/repl_set_html_summary.cpp
@@ -32,8 +32,8 @@
#include "mongo/db/repl/repl_set_html_summary.h"
-#include <string>
#include <sstream>
+#include <string>
#include "mongo/util/mongoutils/html.h"
#include "mongo/util/mongoutils/str.h"
diff --git a/src/mongo/db/repl/repl_settings.h b/src/mongo/db/repl/repl_settings.h
index 36705f1ce74..b7c6918d75d 100644
--- a/src/mongo/db/repl/repl_settings.h
+++ b/src/mongo/db/repl/repl_settings.h
@@ -32,8 +32,8 @@
#include <string>
#include "mongo/db/jsobj.h"
-#include "mongo/util/concurrency/mutex.h"
#include "mongo/db/repl/bgsync.h"
+#include "mongo/util/concurrency/mutex.h"
namespace mongo {
namespace repl {
diff --git a/src/mongo/db/repl/replica_set_config.cpp b/src/mongo/db/repl/replica_set_config.cpp
index 8f619f6a5d9..b3d0d8f4fc8 100644
--- a/src/mongo/db/repl/replica_set_config.cpp
+++ b/src/mongo/db/repl/replica_set_config.cpp
@@ -128,7 +128,8 @@ Status ReplicaSetConfig::_initialize(const BSONObj& cfg,
if (memberElement.type() != Object) {
return Status(ErrorCodes::TypeMismatch,
str::stream() << "Expected type of " << kMembersFieldName << "."
- << memberElement.fieldName() << " to be Object, but found "
+ << memberElement.fieldName()
+ << " to be Object, but found "
<< typeName(memberElement.type()));
}
_members.resize(_members.size() + 1);
@@ -200,7 +201,8 @@ Status ReplicaSetConfig::_initialize(const BSONObj& cfg,
str::stream() << "replica set configuration cannot contain '"
<< kReplicaSetIdFieldName
<< "' "
- "field when called from replSetInitiate: " << cfg);
+ "field when called from replSetInitiate: "
+ << cfg);
}
_replicaSetId = OID::gen();
} else if (!_replicaSetId.isSet()) {
@@ -312,8 +314,10 @@ Status ReplicaSetConfig::_parseSettingsSubdocument(const BSONObj& settings) {
if (modeElement.type() != Object) {
return Status(ErrorCodes::TypeMismatch,
str::stream() << "Expected " << kSettingsFieldName << '.'
- << kGetLastErrorModesFieldName << '.'
- << modeElement.fieldName() << " to be an Object, not "
+ << kGetLastErrorModesFieldName
+ << '.'
+ << modeElement.fieldName()
+ << " to be an Object, not "
<< typeName(modeElement.type()));
}
ReplicaSetTagPattern pattern = _tagConfig.makePattern();
@@ -321,20 +325,26 @@ Status ReplicaSetConfig::_parseSettingsSubdocument(const BSONObj& settings) {
const BSONElement constraintElement = constraintIter.next();
if (!constraintElement.isNumber()) {
return Status(ErrorCodes::TypeMismatch,
- str::stream()
- << "Expected " << kSettingsFieldName << '.'
- << kGetLastErrorModesFieldName << '.' << modeElement.fieldName()
- << '.' << constraintElement.fieldName() << " to be a number, not "
- << typeName(constraintElement.type()));
+ str::stream() << "Expected " << kSettingsFieldName << '.'
+ << kGetLastErrorModesFieldName
+ << '.'
+ << modeElement.fieldName()
+ << '.'
+ << constraintElement.fieldName()
+ << " to be a number, not "
+ << typeName(constraintElement.type()));
}
const int minCount = constraintElement.numberInt();
if (minCount <= 0) {
return Status(ErrorCodes::BadValue,
str::stream() << "Value of " << kSettingsFieldName << '.'
- << kGetLastErrorModesFieldName << '.'
- << modeElement.fieldName() << '.'
+ << kGetLastErrorModesFieldName
+ << '.'
+ << modeElement.fieldName()
+ << '.'
<< constraintElement.fieldName()
- << " must be positive, but found " << minCount);
+ << " must be positive, but found "
+ << minCount);
}
status = _tagConfig.addTagCountConstraintToPattern(
&pattern, constraintElement.fieldNameStringData(), minCount);
@@ -370,7 +380,8 @@ Status ReplicaSetConfig::validate() const {
if (_replSetName.empty()) {
return Status(ErrorCodes::BadValue,
str::stream() << "Replica set configuration must have non-empty "
- << kIdFieldName << " field");
+ << kIdFieldName
+ << " field");
}
if (_heartbeatInterval < Milliseconds(0)) {
return Status(ErrorCodes::BadValue,
@@ -413,22 +424,41 @@ Status ReplicaSetConfig::validate() const {
const MemberConfig& memberJ = _members[j];
if (memberI.getId() == memberJ.getId()) {
return Status(ErrorCodes::BadValue,
- str::stream()
- << "Found two member configurations with same "
- << MemberConfig::kIdFieldName << " field, " << kMembersFieldName
- << "." << i << "." << MemberConfig::kIdFieldName
- << " == " << kMembersFieldName << "." << j << "."
- << MemberConfig::kIdFieldName << " == " << memberI.getId());
+ str::stream() << "Found two member configurations with same "
+ << MemberConfig::kIdFieldName
+ << " field, "
+ << kMembersFieldName
+ << "."
+ << i
+ << "."
+ << MemberConfig::kIdFieldName
+ << " == "
+ << kMembersFieldName
+ << "."
+ << j
+ << "."
+ << MemberConfig::kIdFieldName
+ << " == "
+ << memberI.getId());
}
if (memberI.getHostAndPort() == memberJ.getHostAndPort()) {
return Status(ErrorCodes::BadValue,
str::stream() << "Found two member configurations with same "
- << MemberConfig::kHostFieldName << " field, "
- << kMembersFieldName << "." << i << "."
<< MemberConfig::kHostFieldName
- << " == " << kMembersFieldName << "." << j << "."
+ << " field, "
+ << kMembersFieldName
+ << "."
+ << i
+ << "."
+ << MemberConfig::kHostFieldName
+ << " == "
+ << kMembersFieldName
+ << "."
+ << j
+ << "."
<< MemberConfig::kHostFieldName
- << " == " << memberI.getHostAndPort().toString());
+ << " == "
+ << memberI.getHostAndPort().toString());
}
}
}
@@ -438,7 +468,9 @@ Status ReplicaSetConfig::validate() const {
ErrorCodes::BadValue,
str::stream()
<< "Either all host names in a replica set configuration must be localhost "
- "references, or none must be; found " << localhostCount << " out of "
+ "references, or none must be; found "
+ << localhostCount
+ << " out of "
<< _members.size());
}
@@ -474,7 +506,8 @@ Status ReplicaSetConfig::validate() const {
if (_protocolVersion != 0 && _protocolVersion != 1) {
return Status(ErrorCodes::BadValue,
str::stream() << kProtocolVersionFieldName << " field value of "
- << _protocolVersion << " is not 1 or 0");
+ << _protocolVersion
+ << " is not 1 or 0");
}
if (_configServer) {
@@ -546,7 +579,8 @@ Status ReplicaSetConfig::checkIfWriteConcernCanBeSatisfied(
// write concern mode.
return Status(ErrorCodes::CannotSatisfyWriteConcern,
str::stream() << "Not enough nodes match write concern mode \""
- << writeConcern.wMode << "\"");
+ << writeConcern.wMode
+ << "\"");
} else {
int nodesRemaining = writeConcern.wNumNodes;
for (size_t j = 0; j < _members.size(); ++j) {
diff --git a/src/mongo/db/repl/replica_set_config_checks.cpp b/src/mongo/db/repl/replica_set_config_checks.cpp
index 6539bd08e3f..a45985d3cb4 100644
--- a/src/mongo/db/repl/replica_set_config_checks.cpp
+++ b/src/mongo/db/repl/replica_set_config_checks.cpp
@@ -60,8 +60,10 @@ StatusWith<int> findSelfInConfig(ReplicationCoordinatorExternalState* externalSt
if (meConfigs.empty()) {
return StatusWith<int>(ErrorCodes::NodeNotFound,
str::stream() << "No host described in new configuration "
- << newConfig.getConfigVersion() << " for replica set "
- << newConfig.getReplSetName() << " maps to this node");
+ << newConfig.getConfigVersion()
+ << " for replica set "
+ << newConfig.getReplSetName()
+ << " maps to this node");
}
if (meConfigs.size() > 1) {
str::stream message;
@@ -90,9 +92,11 @@ Status checkElectable(const ReplicaSetConfig& newConfig, int configIndex) {
if (!myConfig.isElectable()) {
return Status(ErrorCodes::NodeNotElectable,
str::stream() << "This node, " << myConfig.getHostAndPort().toString()
- << ", with _id " << myConfig.getId()
+ << ", with _id "
+ << myConfig.getId()
<< " is not electable under the new configuration version "
- << newConfig.getConfigVersion() << " for replica set "
+ << newConfig.getConfigVersion()
+ << " for replica set "
<< newConfig.getReplSetName());
}
return Status::OK();
@@ -138,22 +142,28 @@ Status validateOldAndNewConfigsCompatible(const ReplicaSetConfig& oldConfig,
return Status(ErrorCodes::NewReplicaSetConfigurationIncompatible,
str::stream()
<< "New replica set configuration version must be greater than old, but "
- << newConfig.getConfigVersion() << " is not greater than "
- << oldConfig.getConfigVersion() << " for replica set "
+ << newConfig.getConfigVersion()
+ << " is not greater than "
+ << oldConfig.getConfigVersion()
+ << " for replica set "
<< newConfig.getReplSetName());
}
if (oldConfig.getReplSetName() != newConfig.getReplSetName()) {
return Status(ErrorCodes::NewReplicaSetConfigurationIncompatible,
str::stream() << "New and old configurations differ in replica set name; "
- "old was " << oldConfig.getReplSetName() << ", and new is "
+ "old was "
+ << oldConfig.getReplSetName()
+ << ", and new is "
<< newConfig.getReplSetName());
}
if (oldConfig.getReplicaSetId() != newConfig.getReplicaSetId()) {
return Status(ErrorCodes::NewReplicaSetConfigurationIncompatible,
str::stream() << "New and old configurations differ in replica set ID; "
- "old was " << oldConfig.getReplicaSetId() << ", and new is "
+ "old was "
+ << oldConfig.getReplicaSetId()
+ << ", and new is "
<< newConfig.getReplicaSetId());
}
@@ -185,14 +195,18 @@ Status validateOldAndNewConfigsCompatible(const ReplicaSetConfig& oldConfig,
}
if (hostsEqual && !idsEqual) {
return Status(ErrorCodes::NewReplicaSetConfigurationIncompatible,
- str::stream()
- << "New and old configurations both have members with "
- << MemberConfig::kHostFieldName << " of "
- << mOld->getHostAndPort().toString()
- << " but in the new configuration the "
- << MemberConfig::kIdFieldName << " field is " << mNew->getId()
- << " and in the old configuration it is " << mOld->getId()
- << " for replica set " << newConfig.getReplSetName());
+ str::stream() << "New and old configurations both have members with "
+ << MemberConfig::kHostFieldName
+ << " of "
+ << mOld->getHostAndPort().toString()
+ << " but in the new configuration the "
+ << MemberConfig::kIdFieldName
+ << " field is "
+ << mNew->getId()
+ << " and in the old configuration it is "
+ << mOld->getId()
+ << " for replica set "
+ << newConfig.getReplSetName());
}
// At this point, the _id and host fields are equal, so we're looking at the old and
// new configurations for the same member node.
diff --git a/src/mongo/db/repl/replica_set_config_checks_test.cpp b/src/mongo/db/repl/replica_set_config_checks_test.cpp
index ab43959d37d..394d6535dbd 100644
--- a/src/mongo/db/repl/replica_set_config_checks_test.cpp
+++ b/src/mongo/db/repl/replica_set_config_checks_test.cpp
@@ -48,7 +48,9 @@ TEST(ValidateConfigForInitiate, VersionMustBe1) {
ReplicaSetConfig config;
ASSERT_OK(config.initializeForInitiate(BSON("_id"
<< "rs0"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1")))));
ASSERT_EQUALS(ErrorCodes::NewReplicaSetConfigurationIncompatible,
@@ -59,7 +61,9 @@ TEST(ValidateConfigForInitiate, MustFindSelf) {
ReplicaSetConfig config;
ASSERT_OK(config.initializeForInitiate(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1")
<< BSON("_id" << 2 << "host"
@@ -85,12 +89,15 @@ TEST(ValidateConfigForInitiate, SelfMustBeElectable) {
ReplicaSetConfig config;
ASSERT_OK(config.initializeForInitiate(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1")
<< BSON("_id" << 2 << "host"
<< "h2"
- << "priority" << 0)
+ << "priority"
+ << 0)
<< BSON("_id" << 3 << "host"
<< "h3")))));
ReplicationCoordinatorExternalStateMock presentOnceExternalState;
@@ -108,25 +115,29 @@ TEST(ValidateConfigForReconfig, NewConfigVersionNumberMustBeHigherThanOld) {
ReplicaSetConfig newConfig;
// Two configurations, identical except for version.
- ASSERT_OK(
- oldConfig.initialize(BSON("_id"
- << "rs0"
- << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "h1")
- << BSON("_id" << 2 << "host"
- << "h2") << BSON("_id" << 3 << "host"
- << "h3")))));
+ ASSERT_OK(oldConfig.initialize(BSON("_id"
+ << "rs0"
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "h1")
+ << BSON("_id" << 2 << "host"
+ << "h2")
+ << BSON("_id" << 3 << "host"
+ << "h3")))));
- ASSERT_OK(
- newConfig.initialize(BSON("_id"
- << "rs0"
- << "version" << 3 << "members"
- << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "h1")
- << BSON("_id" << 2 << "host"
- << "h2") << BSON("_id" << 3 << "host"
- << "h3")))));
+ ASSERT_OK(newConfig.initialize(BSON("_id"
+ << "rs0"
+ << "version"
+ << 3
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "h1")
+ << BSON("_id" << 2 << "host"
+ << "h2")
+ << BSON("_id" << 3 << "host"
+ << "h3")))));
ASSERT_OK(oldConfig.validate());
ASSERT_OK(newConfig.validate());
@@ -162,25 +173,29 @@ TEST(ValidateConfigForReconfig, NewConfigMustNotChangeSetName) {
ReplicaSetConfig newConfig;
// Two configurations, compatible except for set name.
- ASSERT_OK(
- oldConfig.initialize(BSON("_id"
- << "rs0"
- << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "h1")
- << BSON("_id" << 2 << "host"
- << "h2") << BSON("_id" << 3 << "host"
- << "h3")))));
+ ASSERT_OK(oldConfig.initialize(BSON("_id"
+ << "rs0"
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "h1")
+ << BSON("_id" << 2 << "host"
+ << "h2")
+ << BSON("_id" << 3 << "host"
+ << "h3")))));
- ASSERT_OK(
- newConfig.initialize(BSON("_id"
- << "rs1"
- << "version" << 3 << "members"
- << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "h1")
- << BSON("_id" << 2 << "host"
- << "h2") << BSON("_id" << 3 << "host"
- << "h3")))));
+ ASSERT_OK(newConfig.initialize(BSON("_id"
+ << "rs1"
+ << "version"
+ << 3
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "h1")
+ << BSON("_id" << 2 << "host"
+ << "h2")
+ << BSON("_id" << 3 << "host"
+ << "h3")))));
ASSERT_OK(oldConfig.validate());
ASSERT_OK(newConfig.validate());
@@ -201,27 +216,33 @@ TEST(ValidateConfigForReconfig, NewConfigMustNotChangeSetId) {
ReplicaSetConfig newConfig;
// Two configurations, compatible except for set ID.
- ASSERT_OK(
- oldConfig.initialize(BSON("_id"
- << "rs0"
- << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "h1")
- << BSON("_id" << 2 << "host"
- << "h2") << BSON("_id" << 3 << "host"
- << "h3"))
- << "settings" << BSON("replicaSetId" << OID::gen()))));
+ ASSERT_OK(oldConfig.initialize(BSON("_id"
+ << "rs0"
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "h1")
+ << BSON("_id" << 2 << "host"
+ << "h2")
+ << BSON("_id" << 3 << "host"
+ << "h3"))
+ << "settings"
+ << BSON("replicaSetId" << OID::gen()))));
- ASSERT_OK(
- newConfig.initialize(BSON("_id"
- << "rs0"
- << "version" << 3 << "members"
- << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "h1")
- << BSON("_id" << 2 << "host"
- << "h2") << BSON("_id" << 3 << "host"
- << "h3"))
- << "settings" << BSON("replicaSetId" << OID::gen()))));
+ ASSERT_OK(newConfig.initialize(BSON("_id"
+ << "rs0"
+ << "version"
+ << 3
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "h1")
+ << BSON("_id" << 2 << "host"
+ << "h2")
+ << BSON("_id" << 3 << "host"
+ << "h3"))
+ << "settings"
+ << BSON("replicaSetId" << OID::gen()))));
ASSERT_OK(oldConfig.validate());
ASSERT_OK(newConfig.validate());
@@ -248,40 +269,51 @@ TEST(ValidateConfigForReconfig, NewConfigMustNotFlipBuildIndexesFlag) {
// The third, compatible with the first.
ASSERT_OK(oldConfig.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1")
<< BSON("_id" << 2 << "host"
<< "h2"
- << "buildIndexes" << false
- << "priority" << 0)
+ << "buildIndexes"
+ << false
+ << "priority"
+ << 0)
<< BSON("_id" << 3 << "host"
<< "h3")))));
ASSERT_OK(newConfig.initialize(BSON("_id"
<< "rs0"
- << "version" << 3 << "members"
+ << "version"
+ << 3
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1")
<< BSON("_id" << 2 << "host"
<< "h2"
- << "buildIndexes" << true
- << "priority" << 0)
+ << "buildIndexes"
+ << true
+ << "priority"
+ << 0)
<< BSON("_id" << 3 << "host"
<< "h3")))));
- ASSERT_OK(
- oldConfigRefresh.initialize(BSON("_id"
- << "rs0"
- << "version" << 2 << "members"
- << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "h1")
- << BSON("_id" << 2 << "host"
- << "h2"
- << "buildIndexes" << false
- << "priority" << 0)
- << BSON("_id" << 3 << "host"
- << "h3")))));
+ ASSERT_OK(oldConfigRefresh.initialize(BSON("_id"
+ << "rs0"
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "h1")
+ << BSON("_id" << 2 << "host"
+ << "h2"
+ << "buildIndexes"
+ << false
+ << "priority"
+ << 0)
+ << BSON("_id" << 3 << "host"
+ << "h3")))));
ASSERT_OK(oldConfig.validate());
ASSERT_OK(newConfig.validate());
@@ -310,37 +342,45 @@ TEST(ValidateConfigForReconfig, NewConfigMustNotFlipArbiterFlag) {
// The third, compatible with the first.
ASSERT_OK(oldConfig.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1")
<< BSON("_id" << 2 << "host"
<< "h2"
- << "arbiterOnly" << false)
+ << "arbiterOnly"
+ << false)
<< BSON("_id" << 3 << "host"
<< "h3")))));
ASSERT_OK(newConfig.initialize(BSON("_id"
<< "rs0"
- << "version" << 3 << "members"
+ << "version"
+ << 3
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1")
<< BSON("_id" << 2 << "host"
<< "h2"
- << "arbiterOnly" << true)
+ << "arbiterOnly"
+ << true)
<< BSON("_id" << 3 << "host"
<< "h3")))));
- ASSERT_OK(
- oldConfigRefresh.initialize(BSON("_id"
- << "rs0"
- << "version" << 2 << "members"
- << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "h1")
- << BSON("_id" << 2 << "host"
- << "h2"
- << "arbiterOnly" << false)
- << BSON("_id" << 3 << "host"
- << "h3")))));
+ ASSERT_OK(oldConfigRefresh.initialize(BSON("_id"
+ << "rs0"
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "h1")
+ << BSON("_id" << 2 << "host"
+ << "h2"
+ << "arbiterOnly"
+ << false)
+ << BSON("_id" << 3 << "host"
+ << "h3")))));
ASSERT_OK(oldConfig.validate());
ASSERT_OK(newConfig.validate());
@@ -369,15 +409,17 @@ TEST(ValidateConfigForReconfig, HostAndIdRemappingRestricted) {
ReplicaSetConfig illegalNewConfigReusingHost;
ReplicaSetConfig illegalNewConfigReusingId;
- ASSERT_OK(
- oldConfig.initialize(BSON("_id"
- << "rs0"
- << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "h1")
- << BSON("_id" << 2 << "host"
- << "h2") << BSON("_id" << 3 << "host"
- << "h3")))));
+ ASSERT_OK(oldConfig.initialize(BSON("_id"
+ << "rs0"
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "h1")
+ << BSON("_id" << 2 << "host"
+ << "h2")
+ << BSON("_id" << 3 << "host"
+ << "h3")))));
ASSERT_OK(oldConfig.validate());
//
@@ -387,7 +429,9 @@ TEST(ValidateConfigForReconfig, HostAndIdRemappingRestricted) {
ASSERT_OK(
legalNewConfigWithNewHostAndId.initialize(BSON("_id"
<< "rs0"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1")
<< BSON("_id" << 4 << "host"
@@ -395,8 +439,9 @@ TEST(ValidateConfigForReconfig, HostAndIdRemappingRestricted) {
<< BSON("_id" << 3 << "host"
<< "h3")))));
ASSERT_OK(legalNewConfigWithNewHostAndId.validate());
- ASSERT_OK(validateConfigForReconfig(
- &externalState, oldConfig, legalNewConfigWithNewHostAndId, false).getStatus());
+ ASSERT_OK(
+ validateConfigForReconfig(&externalState, oldConfig, legalNewConfigWithNewHostAndId, false)
+ .getStatus());
//
// Here, the new config is invalid because we've reused host name "h2" with
@@ -404,7 +449,9 @@ TEST(ValidateConfigForReconfig, HostAndIdRemappingRestricted) {
//
ASSERT_OK(illegalNewConfigReusingHost.initialize(BSON("_id"
<< "rs0"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1")
<< BSON("_id" << 4 << "host"
@@ -412,20 +459,24 @@ TEST(ValidateConfigForReconfig, HostAndIdRemappingRestricted) {
<< BSON("_id" << 3 << "host"
<< "h3")))));
ASSERT_OK(illegalNewConfigReusingHost.validate());
- ASSERT_EQUALS(ErrorCodes::NewReplicaSetConfigurationIncompatible,
- validateConfigForReconfig(
- &externalState, oldConfig, illegalNewConfigReusingHost, false).getStatus());
+ ASSERT_EQUALS(
+ ErrorCodes::NewReplicaSetConfigurationIncompatible,
+ validateConfigForReconfig(&externalState, oldConfig, illegalNewConfigReusingHost, false)
+ .getStatus());
// Forced reconfigs also do not allow this.
- ASSERT_EQUALS(ErrorCodes::NewReplicaSetConfigurationIncompatible,
- validateConfigForReconfig(
- &externalState, oldConfig, illegalNewConfigReusingHost, true).getStatus());
+ ASSERT_EQUALS(
+ ErrorCodes::NewReplicaSetConfigurationIncompatible,
+ validateConfigForReconfig(&externalState, oldConfig, illegalNewConfigReusingHost, true)
+ .getStatus());
//
// Here, the new config is valid, because all we've changed is the name of
// the host representing _id 2.
//
ASSERT_OK(illegalNewConfigReusingId.initialize(BSON("_id"
<< "rs0"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1")
<< BSON("_id" << 2 << "host"
@@ -441,26 +492,30 @@ TEST(ValidateConfigForReconfig, MustFindSelf) {
// Old and new config are same except for version change; this is just testing that we can
// find ourself in the new config.
ReplicaSetConfig oldConfig;
- ASSERT_OK(
- oldConfig.initialize(BSON("_id"
- << "rs0"
- << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "h1")
- << BSON("_id" << 2 << "host"
- << "h2") << BSON("_id" << 3 << "host"
- << "h3")))));
+ ASSERT_OK(oldConfig.initialize(BSON("_id"
+ << "rs0"
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "h1")
+ << BSON("_id" << 2 << "host"
+ << "h2")
+ << BSON("_id" << 3 << "host"
+ << "h3")))));
ReplicaSetConfig newConfig;
- ASSERT_OK(
- newConfig.initialize(BSON("_id"
- << "rs0"
- << "version" << 2 << "members"
- << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "h1")
- << BSON("_id" << 2 << "host"
- << "h2") << BSON("_id" << 3 << "host"
- << "h3")))));
+ ASSERT_OK(newConfig.initialize(BSON("_id"
+ << "rs0"
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "h1")
+ << BSON("_id" << 2 << "host"
+ << "h2")
+ << BSON("_id" << 3 << "host"
+ << "h3")))));
ReplicationCoordinatorExternalStateMock notPresentExternalState;
ReplicationCoordinatorExternalStateMock presentOnceExternalState;
presentOnceExternalState.addSelf(HostAndPort("h2"));
@@ -472,9 +527,10 @@ TEST(ValidateConfigForReconfig, MustFindSelf) {
ASSERT_EQUALS(ErrorCodes::NodeNotFound,
validateConfigForReconfig(&notPresentExternalState, oldConfig, newConfig, false)
.getStatus());
- ASSERT_EQUALS(ErrorCodes::DuplicateKey,
- validateConfigForReconfig(
- &presentThriceExternalState, oldConfig, newConfig, false).getStatus());
+ ASSERT_EQUALS(
+ ErrorCodes::DuplicateKey,
+ validateConfigForReconfig(&presentThriceExternalState, oldConfig, newConfig, false)
+ .getStatus());
ASSERT_EQUALS(1,
unittest::assertGet(validateConfigForReconfig(
&presentOnceExternalState, oldConfig, newConfig, false)));
@@ -494,25 +550,30 @@ TEST(ValidateConfigForReconfig, SelfMustEndElectable) {
// Old and new config are same except for version change and the electability of one node;
// this is just testing that we must be electable in the new config.
ReplicaSetConfig oldConfig;
- ASSERT_OK(
- oldConfig.initialize(BSON("_id"
- << "rs0"
- << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "h1")
- << BSON("_id" << 2 << "host"
- << "h2") << BSON("_id" << 3 << "host"
- << "h3")))));
+ ASSERT_OK(oldConfig.initialize(BSON("_id"
+ << "rs0"
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "h1")
+ << BSON("_id" << 2 << "host"
+ << "h2")
+ << BSON("_id" << 3 << "host"
+ << "h3")))));
ReplicaSetConfig newConfig;
ASSERT_OK(newConfig.initialize(BSON("_id"
<< "rs0"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1")
<< BSON("_id" << 2 << "host"
<< "h2"
- << "priority" << 0)
+ << "priority"
+ << 0)
<< BSON("_id" << 3 << "host"
<< "h3")))));
ReplicationCoordinatorExternalStateMock presentOnceExternalState;
@@ -533,7 +594,9 @@ TEST(ValidateConfigForInitiate, NewConfigInvalid) {
ReplicaSetConfig newConfig;
ASSERT_OK(newConfig.initializeForInitiate(BSON("_id"
<< "rs0"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "h2")
<< BSON("_id" << 0 << "host"
@@ -552,14 +615,18 @@ TEST(ValidateConfigForReconfig, NewConfigInvalid) {
ReplicaSetConfig oldConfig;
ASSERT_OK(oldConfig.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "h2")))));
ReplicaSetConfig newConfig;
ASSERT_OK(newConfig.initialize(BSON("_id"
<< "rs0"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "h2")
<< BSON("_id" << 0 << "host"
@@ -583,14 +650,18 @@ TEST(ValidateConfigForStartUp, NewConfigInvalid) {
ReplicaSetConfig oldConfig;
ASSERT_OK(oldConfig.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "h2")))));
ReplicaSetConfig newConfig;
ASSERT_OK(newConfig.initialize(BSON("_id"
<< "rs0"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "h2")
<< BSON("_id" << 0 << "host"
@@ -610,7 +681,9 @@ TEST(ValidateConfigForStartUp, OldAndNewConfigIncompatible) {
ReplicaSetConfig oldConfig;
ASSERT_OK(oldConfig.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "h2")
<< BSON("_id" << 1 << "host"
@@ -620,7 +693,9 @@ TEST(ValidateConfigForStartUp, OldAndNewConfigIncompatible) {
ReplicaSetConfig newConfig;
ASSERT_OK(newConfig.initialize(BSON("_id"
<< "rs0"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 2 << "host"
<< "h2")
<< BSON("_id" << 1 << "host"
@@ -640,7 +715,9 @@ TEST(ValidateConfigForStartUp, OldAndNewConfigCompatible) {
ReplicaSetConfig oldConfig;
ASSERT_OK(oldConfig.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "h2")
<< BSON("_id" << 1 << "host"
@@ -650,10 +727,13 @@ TEST(ValidateConfigForStartUp, OldAndNewConfigCompatible) {
ReplicaSetConfig newConfig;
ASSERT_OK(newConfig.initialize(BSON("_id"
<< "rs0"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "h2"
- << "priority" << 3)
+ << "priority"
+ << 3)
<< BSON("_id" << 1 << "host"
<< "h3")))));
@@ -670,7 +750,9 @@ TEST(ValidateConfigForHeartbeatReconfig, NewConfigInvalid) {
ReplicaSetConfig newConfig;
ASSERT_OK(newConfig.initialize(BSON("_id"
<< "rs0"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "h2")
<< BSON("_id" << 0 << "host"
@@ -689,7 +771,9 @@ TEST(ValidateConfigForHeartbeatReconfig, NewConfigValid) {
ReplicaSetConfig newConfig;
ASSERT_OK(newConfig.initialize(BSON("_id"
<< "rs0"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "h2")
<< BSON("_id" << 1 << "host"
@@ -706,7 +790,9 @@ TEST(ValidateForReconfig, ForceStillNeedsValidConfig) {
ReplicaSetConfig oldConfig;
ASSERT_OK(oldConfig.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "h2")
<< BSON("_id" << 1 << "host"
@@ -716,7 +802,9 @@ TEST(ValidateForReconfig, ForceStillNeedsValidConfig) {
ReplicaSetConfig newConfig;
ASSERT_OK(newConfig.initialize(BSON("_id"
<< "rs0"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "h2")
<< BSON("_id" << 0 << "host"
@@ -735,7 +823,9 @@ TEST(ValidateForReconfig, ForceStillNeedsSelfPresent) {
ReplicaSetConfig oldConfig;
ASSERT_OK(oldConfig.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "h2")
<< BSON("_id" << 1 << "host"
@@ -745,7 +835,9 @@ TEST(ValidateForReconfig, ForceStillNeedsSelfPresent) {
ReplicaSetConfig newConfig;
ASSERT_OK(newConfig.initialize(BSON("_id"
<< "rs0"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h3")
<< BSON("_id" << 2 << "host"
diff --git a/src/mongo/db/repl/replica_set_config_test.cpp b/src/mongo/db/repl/replica_set_config_test.cpp
index 100ca89383f..6e5bb69b40b 100644
--- a/src/mongo/db/repl/replica_set_config_test.cpp
+++ b/src/mongo/db/repl/replica_set_config_test.cpp
@@ -34,8 +34,8 @@
#include "mongo/db/jsobj.h"
#include "mongo/db/repl/replica_set_config.h"
#include "mongo/db/server_options.h"
-#include "mongo/util/scopeguard.h"
#include "mongo/unittest/unittest.h"
+#include "mongo/util/scopeguard.h"
namespace mongo {
namespace repl {
@@ -62,7 +62,9 @@ TEST(ReplicaSetConfig, ParseMinimalConfigAndCheckDefaults) {
ReplicaSetConfig config;
ASSERT_OK(config.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345")))));
ASSERT_OK(config.validate());
@@ -88,20 +90,32 @@ TEST(ReplicaSetConfig, ParseMinimalConfigAndCheckDefaults) {
TEST(ReplicaSetConfig, ParseLargeConfigAndCheckAccessors) {
ReplicaSetConfig config;
- ASSERT_OK(config.initialize(BSON(
- "_id"
- << "rs0"
- << "version" << 1234 << "members" << BSON_ARRAY(BSON("_id" << 234 << "host"
- << "localhost:12345"
- << "tags" << BSON("NYC"
- << "NY")))
- << "protocolVersion" << 1 << "settings"
- << BSON("getLastErrorDefaults" << BSON("w"
- << "majority") << "getLastErrorModes"
- << BSON("eastCoast" << BSON("NYC" << 1)) << "chainingAllowed"
- << false << "heartbeatIntervalMillis" << 5000
- << "heartbeatTimeoutSecs" << 120 << "electionTimeoutMillis"
- << 10))));
+ ASSERT_OK(config.initialize(BSON("_id"
+ << "rs0"
+ << "version"
+ << 1234
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 234 << "host"
+ << "localhost:12345"
+ << "tags"
+ << BSON("NYC"
+ << "NY")))
+ << "protocolVersion"
+ << 1
+ << "settings"
+ << BSON("getLastErrorDefaults"
+ << BSON("w"
+ << "majority")
+ << "getLastErrorModes"
+ << BSON("eastCoast" << BSON("NYC" << 1))
+ << "chainingAllowed"
+ << false
+ << "heartbeatIntervalMillis"
+ << 5000
+ << "heartbeatTimeoutSecs"
+ << 120
+ << "electionTimeoutMillis"
+ << 10))));
ASSERT_OK(config.validate());
ASSERT_EQUALS("rs0", config.getReplSetName());
ASSERT_EQUALS(1234, config.getConfigVersion());
@@ -123,44 +137,57 @@ TEST(ReplicaSetConfig, ParseLargeConfigAndCheckAccessors) {
TEST(ReplicaSetConfig, GetConnectionStringFiltersHiddenNodes) {
ReplicaSetConfig config;
- ASSERT_OK(
- config.initialize(BSON("_id"
- << "rs0"
- << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "localhost:11111")
- << BSON("_id" << 1 << "host"
- << "localhost:22222"
- << "arbiterOnly" << true)
- << BSON("_id" << 2 << "host"
- << "localhost:33333"
- << "hidden" << true << "priority" << 0)
- << BSON("_id" << 3 << "host"
- << "localhost:44444")))));
+ ASSERT_OK(config.initialize(BSON("_id"
+ << "rs0"
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "localhost:11111")
+ << BSON("_id" << 1 << "host"
+ << "localhost:22222"
+ << "arbiterOnly"
+ << true)
+ << BSON("_id" << 2 << "host"
+ << "localhost:33333"
+ << "hidden"
+ << true
+ << "priority"
+ << 0)
+ << BSON("_id" << 3 << "host"
+ << "localhost:44444")))));
ASSERT_OK(config.validate());
- ASSERT_EQUALS(
- ConnectionString::forReplicaSet(
- "rs0", {HostAndPort{"localhost:11111"}, HostAndPort{"localhost:44444"}}).toString(),
- config.getConnectionString().toString());
+ ASSERT_EQUALS(ConnectionString::forReplicaSet(
+ "rs0", {HostAndPort{"localhost:11111"}, HostAndPort{"localhost:44444"}})
+ .toString(),
+ config.getConnectionString().toString());
}
TEST(ReplicaSetConfig, MajorityCalculationThreeVotersNoArbiters) {
ReplicaSetConfig config;
- ASSERT_OK(
- config.initialize(BSON("_id"
- << "rs0"
- << "version" << 2 << "members"
- << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "h1:1")
- << BSON("_id" << 2 << "host"
- << "h2:1") << BSON("_id" << 3 << "host"
- << "h3:1")
- << BSON("_id" << 4 << "host"
- << "h4:1"
- << "votes" << 0 << "priority" << 0)
- << BSON("_id" << 5 << "host"
- << "h5:1"
- << "votes" << 0 << "priority" << 0)))));
+ ASSERT_OK(config.initialize(BSON("_id"
+ << "rs0"
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "h1:1")
+ << BSON("_id" << 2 << "host"
+ << "h2:1")
+ << BSON("_id" << 3 << "host"
+ << "h3:1")
+ << BSON("_id" << 4 << "host"
+ << "h4:1"
+ << "votes"
+ << 0
+ << "priority"
+ << 0)
+ << BSON("_id" << 5 << "host"
+ << "h5:1"
+ << "votes"
+ << 0
+ << "priority"
+ << 0)))));
ASSERT_OK(config.validate());
ASSERT_EQUALS(2, config.getWriteMajority());
@@ -168,24 +195,35 @@ TEST(ReplicaSetConfig, MajorityCalculationThreeVotersNoArbiters) {
TEST(ReplicaSetConfig, MajorityCalculationNearlyHalfArbiters) {
ReplicaSetConfig config;
- ASSERT_OK(
- config.initialize(BSON("_id"
- << "mySet"
- << "version" << 2 << "members"
- << BSON_ARRAY(BSON("host"
- << "node1:12345"
- << "_id" << 0)
- << BSON("host"
- << "node2:12345"
- << "_id" << 1) << BSON("host"
- << "node3:12345"
- << "_id" << 2)
- << BSON("host"
- << "node4:12345"
- << "_id" << 3 << "arbiterOnly" << true)
- << BSON("host"
- << "node5:12345"
- << "_id" << 4 << "arbiterOnly" << true)))));
+ ASSERT_OK(config.initialize(BSON("_id"
+ << "mySet"
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("host"
+ << "node1:12345"
+ << "_id"
+ << 0)
+ << BSON("host"
+ << "node2:12345"
+ << "_id"
+ << 1)
+ << BSON("host"
+ << "node3:12345"
+ << "_id"
+ << 2)
+ << BSON("host"
+ << "node4:12345"
+ << "_id"
+ << 3
+ << "arbiterOnly"
+ << true)
+ << BSON("host"
+ << "node5:12345"
+ << "_id"
+ << 4
+ << "arbiterOnly"
+ << true)))));
ASSERT_OK(config.validate());
ASSERT_EQUALS(3, config.getWriteMajority());
}
@@ -194,43 +232,64 @@ TEST(ReplicaSetConfig, MajorityCalculationEvenNumberOfMembers) {
ReplicaSetConfig config;
ASSERT_OK(config.initialize(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id" << 0)
+ << "_id"
+ << 0)
<< BSON("host"
<< "node2:12345"
- << "_id" << 1) << BSON("host"
- << "node3:12345"
- << "_id" << 2)
+ << "_id"
+ << 1)
+ << BSON("host"
+ << "node3:12345"
+ << "_id"
+ << 2)
<< BSON("host"
<< "node4:12345"
- << "_id" << 3)))));
+ << "_id"
+ << 3)))));
ASSERT_OK(config.validate());
ASSERT_EQUALS(3, config.getWriteMajority());
}
TEST(ReplicaSetConfig, MajorityCalculationNearlyHalfSecondariesNoVotes) {
ReplicaSetConfig config;
- ASSERT_OK(
- config.initialize(BSON("_id"
- << "mySet"
- << "version" << 2 << "members"
- << 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.initialize(BSON("_id"
+ << "mySet"
+ << "version"
+ << 2
+ << "members"
+ << 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());
}
@@ -253,7 +312,9 @@ TEST(ReplicaSetConfig, ParseFailsWithBadOrMissingIdField) {
// Empty repl set name parses, but does not validate.
ASSERT_OK(config.initialize(BSON("_id"
<< ""
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345")))));
@@ -263,40 +324,44 @@ TEST(ReplicaSetConfig, ParseFailsWithBadOrMissingIdField) {
TEST(ReplicaSetConfig, ParseFailsWithBadOrMissingVersionField) {
ReplicaSetConfig config;
// Config version field must be present.
- ASSERT_EQUALS(
- ErrorCodes::NoSuchKey,
- config.initialize(BSON("_id"
- << "rs0"
- << "members" << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "localhost:12345")))));
- ASSERT_EQUALS(
- ErrorCodes::TypeMismatch,
- config.initialize(BSON("_id"
- << "rs0"
- << "version"
- << "1"
- << "members" << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "localhost:12345")))));
+ ASSERT_EQUALS(ErrorCodes::NoSuchKey,
+ config.initialize(BSON("_id"
+ << "rs0"
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "localhost:12345")))));
+ ASSERT_EQUALS(ErrorCodes::TypeMismatch,
+ config.initialize(BSON("_id"
+ << "rs0"
+ << "version"
+ << "1"
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "localhost:12345")))));
ASSERT_OK(config.initialize(BSON("_id"
<< "rs0"
- << "version" << 1.0 << "members"
+ << "version"
+ << 1.0
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345")))));
ASSERT_OK(config.validate());
ASSERT_OK(config.initialize(BSON("_id"
<< "rs0"
- << "version" << 0.0 << "members"
+ << "version"
+ << 0.0
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345")))));
ASSERT_EQUALS(ErrorCodes::BadValue, config.validate());
- ASSERT_OK(
- config.initialize(BSON("_id"
- << "rs0"
- << "version"
- << static_cast<long long>(std::numeric_limits<int>::max()) + 1
- << "members" << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "localhost:12345")))));
+ ASSERT_OK(config.initialize(BSON("_id"
+ << "rs0"
+ << "version"
+ << static_cast<long long>(std::numeric_limits<int>::max()) + 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "localhost:12345")))));
ASSERT_EQUALS(ErrorCodes::BadValue, config.validate());
}
@@ -305,13 +370,17 @@ TEST(ReplicaSetConfig, ParseFailsWithBadMembers) {
ASSERT_EQUALS(ErrorCodes::TypeMismatch,
config.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345")
<< "localhost:23456"))));
ASSERT_NOT_OK(config.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("host"
<< "localhost:12345")))));
}
@@ -320,7 +389,9 @@ TEST(ReplicaSetConfig, ParseFailsWithLocalNonLocalHostMix) {
ReplicaSetConfig config;
ASSERT_OK(config.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost")
<< BSON("_id" << 1 << "host"
@@ -332,10 +403,13 @@ TEST(ReplicaSetConfig, ParseFailsWithNoElectableNodes) {
ReplicaSetConfig config;
const BSONObj configBsonNoElectableNodes = BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:1"
- << "priority" << 0)
+ << "priority"
+ << 0)
<< BSON("_id" << 1 << "host"
<< "localhost:2"
<< "priority"
@@ -344,38 +418,51 @@ TEST(ReplicaSetConfig, ParseFailsWithNoElectableNodes) {
ASSERT_OK(config.initialize(configBsonNoElectableNodes));
ASSERT_EQUALS(ErrorCodes::BadValue, config.validate());
- const BSONObj configBsonNoElectableNodesOneArbiter =
- BSON("_id"
- << "rs0"
- << "version" << 1 << "members" << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "localhost:1"
- << "arbiterOnly" << 1)
- << BSON("_id" << 1 << "host"
- << "localhost:2"
- << "priority" << 0)));
+ const BSONObj configBsonNoElectableNodesOneArbiter = BSON("_id"
+ << "rs0"
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(
+ BSON("_id" << 0 << "host"
+ << "localhost:1"
+ << "arbiterOnly"
+ << 1)
+ << BSON("_id" << 1 << "host"
+ << "localhost:2"
+ << "priority"
+ << 0)));
ASSERT_OK(config.initialize(configBsonNoElectableNodesOneArbiter));
ASSERT_EQUALS(ErrorCodes::BadValue, config.validate());
- const BSONObj configBsonNoElectableNodesTwoArbiters =
- BSON("_id"
- << "rs0"
- << "version" << 1 << "members" << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "localhost:1"
- << "arbiterOnly" << 1)
- << BSON("_id" << 1 << "host"
- << "localhost:2"
- << "arbiterOnly" << 1)));
+ const BSONObj configBsonNoElectableNodesTwoArbiters = BSON("_id"
+ << "rs0"
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(
+ BSON("_id" << 0 << "host"
+ << "localhost:1"
+ << "arbiterOnly"
+ << 1)
+ << BSON("_id" << 1 << "host"
+ << "localhost:2"
+ << "arbiterOnly"
+ << 1)));
ASSERT_OK(config.initialize(configBsonNoElectableNodesOneArbiter));
ASSERT_EQUALS(ErrorCodes::BadValue, config.validate());
const BSONObj configBsonOneElectableNode = BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:1"
- << "priority" << 0)
+ << "priority"
+ << 0)
<< BSON("_id" << 1 << "host"
<< "localhost:2"
<< "priority"
@@ -386,30 +473,42 @@ 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 << "priority" << 0)
- << BSON("_id" << 1 << "host"
- << "localhost:2"
- << "votes" << 0 << "priority" << 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());
const BSONObj configBsonOneVoter = BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:1"
- << "votes" << 0 << "priority"
+ << "votes"
+ << 0
+ << "priority"
<< 0)
<< BSON("_id" << 1 << "host"
<< "localhost:2"
- << "votes" << 1)));
+ << "votes"
+ << 1)));
ASSERT_OK(config.initialize(configBsonOneVoter));
ASSERT_OK(config.validate());
}
@@ -426,7 +525,9 @@ TEST(ReplicaSetConfig, ParseFailsWithDuplicateHost) {
ReplicaSetConfig config;
const BSONObj configBson = BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:1")
<< BSON("_id" << 1 << "host"
@@ -477,7 +578,9 @@ TEST(ReplicaSetConfig, ParseFailsWithUnexpectedField) {
ReplicaSetConfig config;
Status status = config.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "unexpectedfield"
+ << "version"
+ << 1
+ << "unexpectedfield"
<< "value"));
ASSERT_EQUALS(ErrorCodes::BadValue, status);
}
@@ -486,7 +589,9 @@ TEST(ReplicaSetConfig, ParseFailsWithNonArrayMembersField) {
ReplicaSetConfig config;
Status status = config.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< "value"));
ASSERT_EQUALS(ErrorCodes::TypeMismatch, status);
}
@@ -495,11 +600,14 @@ TEST(ReplicaSetConfig, ParseFailsWithNonNumericHeartbeatIntervalMillisField) {
ReplicaSetConfig config;
Status status = config.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"))
- << "settings" << BSON("heartbeatIntervalMillis"
- << "no")));
+ << "settings"
+ << BSON("heartbeatIntervalMillis"
+ << "no")));
ASSERT_EQUALS(ErrorCodes::TypeMismatch, status);
ASSERT_FALSE(config.isInitialized());
@@ -512,11 +620,14 @@ TEST(ReplicaSetConfig, ParseFailsWithNonNumericElectionTimeoutMillisField) {
ReplicaSetConfig config;
Status status = config.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"))
- << "settings" << BSON("electionTimeoutMillis"
- << "no")));
+ << "settings"
+ << BSON("electionTimeoutMillis"
+ << "no")));
ASSERT_EQUALS(ErrorCodes::TypeMismatch, status);
}
@@ -524,11 +635,14 @@ TEST(ReplicaSetConfig, ParseFailsWithNonNumericHeartbeatTimeoutSecsField) {
ReplicaSetConfig config;
Status status = config.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"))
- << "settings" << BSON("heartbeatTimeoutSecs"
- << "no")));
+ << "settings"
+ << BSON("heartbeatTimeoutSecs"
+ << "no")));
ASSERT_EQUALS(ErrorCodes::TypeMismatch, status);
}
@@ -536,48 +650,57 @@ TEST(ReplicaSetConfig, ParseFailsWithNonBoolChainingAllowedField) {
ReplicaSetConfig config;
Status status = config.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"))
- << "settings" << BSON("chainingAllowed"
- << "no")));
+ << "settings"
+ << BSON("chainingAllowed"
+ << "no")));
ASSERT_EQUALS(ErrorCodes::TypeMismatch, status);
}
TEST(ReplicaSetConfig, ParseFailsWithNonBoolConfigServerField) {
ReplicaSetConfig config;
- Status status =
- config.initialize(BSON("_id"
- << "rs0"
- << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "localhost:12345")) << "configsvr"
- << "no"));
+ Status status = config.initialize(BSON("_id"
+ << "rs0"
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "localhost:12345"))
+ << "configsvr"
+ << "no"));
ASSERT_EQUALS(ErrorCodes::TypeMismatch, status);
}
TEST(ReplicaSetConfig, ParseFailsWithNonObjectSettingsField) {
ReplicaSetConfig config;
- Status status =
- config.initialize(BSON("_id"
- << "rs0"
- << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "localhost:12345")) << "settings"
- << "none"));
+ Status status = config.initialize(BSON("_id"
+ << "rs0"
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "localhost:12345"))
+ << "settings"
+ << "none"));
ASSERT_EQUALS(ErrorCodes::TypeMismatch, status);
}
TEST(ReplicaSetConfig, ParseFailsWithGetLastErrorDefaultsFieldUnparseable) {
ReplicaSetConfig config;
- Status status =
- config.initialize(BSON("_id"
- << "rs0"
- << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "localhost:12345")) << "settings"
- << BSON("getLastErrorDefaults" << BSON("fsync"
- << "seven"))));
+ Status status = config.initialize(BSON("_id"
+ << "rs0"
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "localhost:12345"))
+ << "settings"
+ << BSON("getLastErrorDefaults" << BSON("fsync"
+ << "seven"))));
ASSERT_EQUALS(ErrorCodes::FailedToParse, status);
}
@@ -585,11 +708,14 @@ TEST(ReplicaSetConfig, ParseFailsWithNonObjectGetLastErrorDefaultsField) {
ReplicaSetConfig config;
Status status = config.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"))
- << "settings" << BSON("getLastErrorDefaults"
- << "no")));
+ << "settings"
+ << BSON("getLastErrorDefaults"
+ << "no")));
ASSERT_EQUALS(ErrorCodes::TypeMismatch, status);
}
@@ -597,41 +723,50 @@ TEST(ReplicaSetConfig, ParseFailsWithNonObjectGetLastErrorModesField) {
ReplicaSetConfig config;
Status status = config.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"))
- << "settings" << BSON("getLastErrorModes"
- << "no")));
+ << "settings"
+ << BSON("getLastErrorModes"
+ << "no")));
ASSERT_EQUALS(ErrorCodes::TypeMismatch, status);
}
TEST(ReplicaSetConfig, ParseFailsWithDuplicateGetLastErrorModesField) {
ReplicaSetConfig config;
- Status status =
- config.initialize(BSON("_id"
- << "rs0"
- << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "localhost:12345"
- << "tags" << BSON("tag"
- << "yes"))) << "settings"
- << BSON("getLastErrorModes"
- << BSON("one" << BSON("tag" << 1) << "one"
- << BSON("tag" << 1)))));
+ Status status = config.initialize(BSON("_id"
+ << "rs0"
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "localhost:12345"
+ << "tags"
+ << BSON("tag"
+ << "yes")))
+ << "settings"
+ << BSON("getLastErrorModes"
+ << BSON("one" << BSON("tag" << 1) << "one"
+ << BSON("tag" << 1)))));
ASSERT_EQUALS(ErrorCodes::DuplicateKey, status);
}
TEST(ReplicaSetConfig, ParseFailsWithNonObjectGetLastErrorModesEntryField) {
ReplicaSetConfig config;
- Status status =
- config.initialize(BSON("_id"
- << "rs0"
- << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "localhost:12345"
- << "tags" << BSON("tag"
- << "yes"))) << "settings"
- << BSON("getLastErrorModes" << BSON("one" << 1))));
+ Status status = config.initialize(BSON("_id"
+ << "rs0"
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "localhost:12345"
+ << "tags"
+ << BSON("tag"
+ << "yes")))
+ << "settings"
+ << BSON("getLastErrorModes" << BSON("one" << 1))));
ASSERT_EQUALS(ErrorCodes::TypeMismatch, status);
}
@@ -640,11 +775,15 @@ TEST(ReplicaSetConfig, ParseFailsWithNonNumericGetLastErrorModesConstraintValue)
Status status =
config.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"
- << "tags" << BSON("tag"
- << "yes"))) << "settings"
+ << "tags"
+ << BSON("tag"
+ << "yes")))
+ << "settings"
<< BSON("getLastErrorModes" << BSON("one" << BSON("tag"
<< "no")))));
ASSERT_EQUALS(ErrorCodes::TypeMismatch, status);
@@ -655,11 +794,15 @@ TEST(ReplicaSetConfig, ParseFailsWithNegativeGetLastErrorModesConstraintValue) {
Status status =
config.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"
- << "tags" << BSON("tag"
- << "yes"))) << "settings"
+ << "tags"
+ << BSON("tag"
+ << "yes")))
+ << "settings"
<< BSON("getLastErrorModes" << BSON("one" << BSON("tag" << -1)))));
ASSERT_EQUALS(ErrorCodes::BadValue, status);
}
@@ -669,11 +812,15 @@ TEST(ReplicaSetConfig, ParseFailsWithNonExistentGetLastErrorModesConstraintTag)
Status status =
config.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"
- << "tags" << BSON("tag"
- << "yes"))) << "settings"
+ << "tags"
+ << BSON("tag"
+ << "yes")))
+ << "settings"
<< BSON("getLastErrorModes" << BSON("one" << BSON("tag2" << 1)))));
ASSERT_EQUALS(ErrorCodes::NoSuchKey, status);
}
@@ -682,7 +829,11 @@ TEST(ReplicaSetConfig, ValidateFailsWithBadProtocolVersion) {
ReplicaSetConfig config;
Status status = config.initialize(BSON("_id"
<< "rs0"
- << "protocolVersion" << 3 << "version" << 1 << "members"
+ << "protocolVersion"
+ << 3
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345")
<< BSON("_id" << 1 << "host"
@@ -697,7 +848,9 @@ TEST(ReplicaSetConfig, ValidateFailsWithDuplicateMemberId) {
ReplicaSetConfig config;
Status status = config.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345")
<< BSON("_id" << 0 << "host"
@@ -712,10 +865,13 @@ TEST(ReplicaSetConfig, ValidateFailsWithInvalidMember) {
ReplicaSetConfig config;
Status status = config.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"
- << "hidden" << true))));
+ << "hidden"
+ << true))));
ASSERT_OK(status);
status = config.validate();
@@ -726,18 +882,24 @@ TEST(ReplicaSetConfig, ChainingAllowedField) {
ReplicaSetConfig config;
ASSERT_OK(config.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
- << "localhost:12345")) << "settings"
+ << "localhost:12345"))
+ << "settings"
<< BSON("chainingAllowed" << true))));
ASSERT_OK(config.validate());
ASSERT_TRUE(config.isChainingAllowed());
ASSERT_OK(config.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
- << "localhost:12345")) << "settings"
+ << "localhost:12345"))
+ << "settings"
<< BSON("chainingAllowed" << false))));
ASSERT_OK(config.validate());
ASSERT_FALSE(config.isChainingAllowed());
@@ -745,18 +907,27 @@ TEST(ReplicaSetConfig, ChainingAllowedField) {
TEST(ReplicaSetConfig, ConfigServerField) {
ReplicaSetConfig config;
- ASSERT_OK(
- config.initialize(BSON("_id"
- << "rs0"
- << "protocolVersion" << 1 << "version" << 1 << "configsvr" << true
- << "members" << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "localhost:12345")))));
+ ASSERT_OK(config.initialize(BSON("_id"
+ << "rs0"
+ << "protocolVersion"
+ << 1
+ << "version"
+ << 1
+ << "configsvr"
+ << true
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "localhost:12345")))));
ASSERT_TRUE(config.isConfigServer());
ReplicaSetConfig config2;
ASSERT_OK(config2.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "configsvr" << false << "members"
+ << "version"
+ << 1
+ << "configsvr"
+ << false
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345")))));
ASSERT_FALSE(config2.isConfigServer());
@@ -779,18 +950,25 @@ TEST(ReplicaSetConfig, ConfigServerFieldDefaults) {
ReplicaSetConfig config;
ASSERT_OK(config.initialize(BSON("_id"
<< "rs0"
- << "protocolVersion" << 1 << "version" << 1 << "members"
+ << "protocolVersion"
+ << 1
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345")))));
ASSERT_FALSE(config.isConfigServer());
ReplicaSetConfig config2;
- ASSERT_OK(
- config2.initializeForInitiate(BSON("_id"
- << "rs0"
- << "protocolVersion" << 1 << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "localhost:12345")))));
+ ASSERT_OK(config2.initializeForInitiate(BSON("_id"
+ << "rs0"
+ << "protocolVersion"
+ << 1
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "localhost:12345")))));
ASSERT_FALSE(config2.isConfigServer());
serverGlobalParams.clusterRole = ClusterRole::ConfigServer;
@@ -799,18 +977,25 @@ TEST(ReplicaSetConfig, ConfigServerFieldDefaults) {
ReplicaSetConfig config3;
ASSERT_OK(config3.initialize(BSON("_id"
<< "rs0"
- << "protocolVersion" << 1 << "version" << 1 << "members"
+ << "protocolVersion"
+ << 1
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345")))));
ASSERT_FALSE(config3.isConfigServer());
ReplicaSetConfig config4;
- ASSERT_OK(
- config4.initializeForInitiate(BSON("_id"
- << "rs0"
- << "protocolVersion" << 1 << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "localhost:12345")))));
+ ASSERT_OK(config4.initializeForInitiate(BSON("_id"
+ << "rs0"
+ << "protocolVersion"
+ << 1
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "localhost:12345")))));
ASSERT_TRUE(config4.isConfigServer());
}
@@ -818,18 +1003,24 @@ TEST(ReplicaSetConfig, HeartbeatIntervalField) {
ReplicaSetConfig config;
ASSERT_OK(config.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
- << "localhost:12345")) << "settings"
+ << "localhost:12345"))
+ << "settings"
<< BSON("heartbeatIntervalMillis" << 5000))));
ASSERT_OK(config.validate());
ASSERT_EQUALS(Seconds(5), config.getHeartbeatInterval());
ASSERT_OK(config.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
- << "localhost:12345")) << "settings"
+ << "localhost:12345"))
+ << "settings"
<< BSON("heartbeatIntervalMillis" << -5000))));
ASSERT_EQUALS(ErrorCodes::BadValue, config.validate());
}
@@ -838,19 +1029,25 @@ TEST(ReplicaSetConfig, ElectionTimeoutField) {
ReplicaSetConfig config;
ASSERT_OK(config.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
- << "localhost:12345")) << "settings"
+ << "localhost:12345"))
+ << "settings"
<< BSON("electionTimeoutMillis" << 20))));
ASSERT_OK(config.validate());
ASSERT_EQUALS(Milliseconds(20), config.getElectionTimeoutPeriod());
auto status = config.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"))
- << "settings" << BSON("electionTimeoutMillis" << -20)));
+ << "settings"
+ << BSON("electionTimeoutMillis" << -20)));
ASSERT_EQUALS(ErrorCodes::BadValue, status);
ASSERT_STRING_CONTAINS(status.reason(), "election timeout must be greater than 0");
}
@@ -859,19 +1056,25 @@ TEST(ReplicaSetConfig, HeartbeatTimeoutField) {
ReplicaSetConfig config;
ASSERT_OK(config.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
- << "localhost:12345")) << "settings"
+ << "localhost:12345"))
+ << "settings"
<< BSON("heartbeatTimeoutSecs" << 20))));
ASSERT_OK(config.validate());
ASSERT_EQUALS(Seconds(20), config.getHeartbeatTimeoutPeriod());
auto status = config.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"))
- << "settings" << BSON("heartbeatTimeoutSecs" << -20)));
+ << "settings"
+ << BSON("heartbeatTimeoutSecs" << -20)));
ASSERT_EQUALS(ErrorCodes::BadValue, status);
ASSERT_STRING_CONTAINS(status.reason(), "heartbeat timeout must be greater than 0");
}
@@ -880,9 +1083,12 @@ TEST(ReplicaSetConfig, GleDefaultField) {
ReplicaSetConfig config;
ASSERT_OK(config.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
- << "localhost:12345")) << "settings"
+ << "localhost:12345"))
+ << "settings"
<< BSON("getLastErrorDefaults" << BSON("w"
<< "majority")))));
ASSERT_OK(config.validate());
@@ -890,32 +1096,43 @@ TEST(ReplicaSetConfig, GleDefaultField) {
ASSERT_OK(config.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
- << "localhost:12345")) << "settings"
+ << "localhost:12345"))
+ << "settings"
<< BSON("getLastErrorDefaults" << BSON("w"
<< "frim")))));
ASSERT_EQUALS(ErrorCodes::BadValue, config.validate());
ASSERT_OK(config.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
- << "localhost:12345")) << "settings"
+ << "localhost:12345"))
+ << "settings"
<< BSON("getLastErrorDefaults" << BSON("w" << 0)))));
ASSERT_EQUALS(ErrorCodes::BadValue, config.validate());
- ASSERT_OK(config.initialize(BSON("_id"
- << "rs0"
- << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "localhost:12345"
- << "tags" << BSON("a"
- << "v")))
- << "settings" << BSON("getLastErrorDefaults"
- << BSON("w"
- << "frim") << "getLastErrorModes"
- << BSON("frim" << BSON("a" << 1))))));
+ ASSERT_OK(
+ config.initialize(BSON("_id"
+ << "rs0"
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "localhost:12345"
+ << "tags"
+ << BSON("a"
+ << "v")))
+ << "settings"
+ << BSON("getLastErrorDefaults" << BSON("w"
+ << "frim")
+ << "getLastErrorModes"
+ << BSON("frim" << BSON("a" << 1))))));
ASSERT_OK(config.validate());
ASSERT_EQUALS("frim", config.getDefaultWriteConcern().wMode);
ASSERT_OK(config.findCustomWriteMode("frim").getStatus());
@@ -992,14 +1209,17 @@ bool operator==(const ReplicaSetConfig& a, const ReplicaSetConfig& b) {
TEST(ReplicaSetConfig, toBSONRoundTripAbility) {
ReplicaSetConfig configA;
ReplicaSetConfig configB;
- ASSERT_OK(configA.initialize(BSON("_id"
- << "rs0"
- << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "localhost:12345")) << "settings"
- << BSON("heartbeatIntervalMillis"
- << 5000 << "heartbeatTimeoutSecs" << 20
- << "replicaSetId" << OID::gen()))));
+ ASSERT_OK(configA.initialize(BSON(
+ "_id"
+ << "rs0"
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "localhost:12345"))
+ << "settings"
+ << BSON("heartbeatIntervalMillis" << 5000 << "heartbeatTimeoutSecs" << 20 << "replicaSetId"
+ << OID::gen()))));
ASSERT_OK(configB.initialize(configA.toBSON()));
ASSERT_TRUE(configA == configB);
}
@@ -1007,35 +1227,66 @@ TEST(ReplicaSetConfig, toBSONRoundTripAbility) {
TEST(ReplicaSetConfig, toBSONRoundTripAbilityLarge) {
ReplicaSetConfig configA;
ReplicaSetConfig configB;
- ASSERT_OK(configA.initialize(BSON(
- "_id"
- << "asdf"
- << "version" << 9 << "writeConcernMajorityJournalDefault" << true << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "localhost:12345"
- << "arbiterOnly" << true << "votes" << 1)
- << BSON("_id" << 3 << "host"
- << "localhost:3828"
- << "arbiterOnly" << false << "hidden" << true << "buildIndexes"
- << false << "priority" << 0 << "slaveDelay" << 17 << "votes"
- << 0 << "tags" << BSON("coast"
- << "east"
- << "ssd"
- << "true"))
- << BSON("_id" << 2 << "host"
- << "foo.com:3828"
- << "votes" << 0 << "priority" << 0 << "tags"
- << BSON("coast"
- << "west"
- << "hdd"
- << "true"))) << "protocolVersion" << 0 << "settings"
-
- << BSON("heartbeatIntervalMillis"
- << 5000 << "heartbeatTimeoutSecs" << 20 << "electionTimeoutMillis" << 4
- << "chainingAllowd" << true << "getLastErrorDefaults" << BSON("w"
- << "majority")
- << "getLastErrorModes" << BSON("disks" << BSON("ssd" << 1 << "hdd" << 1) << "coasts"
- << BSON("coast" << 2))))));
+ ASSERT_OK(configA.initialize(
+ BSON("_id"
+ << "asdf"
+ << "version"
+ << 9
+ << "writeConcernMajorityJournalDefault"
+ << true
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "localhost:12345"
+ << "arbiterOnly"
+ << true
+ << "votes"
+ << 1)
+ << BSON("_id" << 3 << "host"
+ << "localhost:3828"
+ << "arbiterOnly"
+ << false
+ << "hidden"
+ << true
+ << "buildIndexes"
+ << false
+ << "priority"
+ << 0
+ << "slaveDelay"
+ << 17
+ << "votes"
+ << 0
+ << "tags"
+ << BSON("coast"
+ << "east"
+ << "ssd"
+ << "true"))
+ << BSON("_id" << 2 << "host"
+ << "foo.com:3828"
+ << "votes"
+ << 0
+ << "priority"
+ << 0
+ << "tags"
+ << BSON("coast"
+ << "west"
+ << "hdd"
+ << "true")))
+ << "protocolVersion"
+ << 0
+ << "settings"
+
+ << BSON("heartbeatIntervalMillis" << 5000 << "heartbeatTimeoutSecs" << 20
+ << "electionTimeoutMillis"
+ << 4
+ << "chainingAllowd"
+ << true
+ << "getLastErrorDefaults"
+ << BSON("w"
+ << "majority")
+ << "getLastErrorModes"
+ << BSON("disks" << BSON("ssd" << 1 << "hdd" << 1)
+ << "coasts"
+ << BSON("coast" << 2))))));
BSONObj configObjA = configA.toBSON();
// Ensure a protocolVersion does not show up if it is 0 to maintain cross version compatibility.
ASSERT_FALSE(configObjA.hasField("protocolVersion"));
@@ -1046,22 +1297,39 @@ 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 << "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("heartbeatIntervalMillis" << -5000 << "heartbeatTimeoutSecs" << 20
- << "electionTimeoutMillis" << 2))));
+ 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("heartbeatIntervalMillis" << -5000 << "heartbeatTimeoutSecs"
+ << 20
+ << "electionTimeoutMillis"
+ << 2))));
ASSERT_OK(configB.initialize(configA.toBSON()));
ASSERT_NOT_OK(configA.validate());
ASSERT_NOT_OK(configB.validate());
@@ -1070,46 +1338,57 @@ TEST(ReplicaSetConfig, toBSONRoundTripAbilityInvalid) {
TEST(ReplicaSetConfig, CheckIfWriteConcernCanBeSatisfied) {
ReplicaSetConfig configA;
- ASSERT_OK(configA.initialize(BSON(
- "_id"
- << "rs0"
- << "version" << 1 << "members" << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "node0"
- << "tags" << BSON("dc"
- << "NA"
- << "rack"
- << "rackNA1"))
- << BSON("_id" << 1 << "host"
- << "node1"
- << "tags" << BSON("dc"
- << "NA"
- << "rack"
- << "rackNA2"))
- << BSON("_id" << 2 << "host"
- << "node2"
- << "tags" << BSON("dc"
- << "NA"
- << "rack"
- << "rackNA3"))
- << BSON("_id" << 3 << "host"
- << "node3"
- << "tags" << BSON("dc"
- << "EU"
- << "rack"
- << "rackEU1"))
- << BSON("_id" << 4 << "host"
- << "node4"
- << "tags" << BSON("dc"
- << "EU"
- << "rack"
- << "rackEU2"))
- << BSON("_id" << 5 << "host"
- << "node5"
- << "arbiterOnly" << true))
- << "settings" << BSON("getLastErrorModes"
- << BSON("valid" << BSON("dc" << 2 << "rack" << 3)
- << "invalidNotEnoughValues" << BSON("dc" << 3)
- << "invalidNotEnoughNodes" << BSON("rack" << 6))))));
+ ASSERT_OK(configA.initialize(BSON("_id"
+ << "rs0"
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "node0"
+ << "tags"
+ << BSON("dc"
+ << "NA"
+ << "rack"
+ << "rackNA1"))
+ << BSON("_id" << 1 << "host"
+ << "node1"
+ << "tags"
+ << BSON("dc"
+ << "NA"
+ << "rack"
+ << "rackNA2"))
+ << BSON("_id" << 2 << "host"
+ << "node2"
+ << "tags"
+ << BSON("dc"
+ << "NA"
+ << "rack"
+ << "rackNA3"))
+ << BSON("_id" << 3 << "host"
+ << "node3"
+ << "tags"
+ << BSON("dc"
+ << "EU"
+ << "rack"
+ << "rackEU1"))
+ << BSON("_id" << 4 << "host"
+ << "node4"
+ << "tags"
+ << BSON("dc"
+ << "EU"
+ << "rack"
+ << "rackEU2"))
+ << BSON("_id" << 5 << "host"
+ << "node5"
+ << "arbiterOnly"
+ << true))
+ << "settings"
+ << BSON("getLastErrorModes"
+ << BSON("valid" << BSON("dc" << 2 << "rack" << 3)
+ << "invalidNotEnoughValues"
+ << BSON("dc" << 3)
+ << "invalidNotEnoughNodes"
+ << BSON("rack" << 6))))));
WriteConcernOptions validNumberWC;
validNumberWC.wNumNodes = 5;
@@ -1170,13 +1449,19 @@ TEST(ReplicaSetConfig, CheckConfigServerCantBeProtocolVersion0) {
ReplicaSetConfig configA;
ASSERT_OK(configA.initialize(BSON("_id"
<< "rs0"
- << "protocolVersion" << 0 << "version" << 1 << "configsvr"
- << true << "members"
+ << "protocolVersion"
+ << 0
+ << "version"
+ << 1
+ << "configsvr"
+ << true
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345")
<< BSON("_id" << 1 << "host"
<< "localhost:54321"
- << "arbiterOnly" << true)))));
+ << "arbiterOnly"
+ << true)))));
Status status = configA.validate();
ASSERT_EQUALS(ErrorCodes::BadValue, status);
ASSERT_STRING_CONTAINS(status.reason(), "cannot run in protocolVersion 0");
@@ -1186,13 +1471,19 @@ TEST(ReplicaSetConfig, CheckConfigServerCantHaveArbiters) {
ReplicaSetConfig configA;
ASSERT_OK(configA.initialize(BSON("_id"
<< "rs0"
- << "protocolVersion" << 1 << "version" << 1 << "configsvr"
- << true << "members"
+ << "protocolVersion"
+ << 1
+ << "version"
+ << 1
+ << "configsvr"
+ << true
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345")
<< BSON("_id" << 1 << "host"
<< "localhost:54321"
- << "arbiterOnly" << true)))));
+ << "arbiterOnly"
+ << true)))));
Status status = configA.validate();
ASSERT_EQUALS(ErrorCodes::BadValue, status);
ASSERT_STRING_CONTAINS(status.reason(), "Arbiters are not allowed");
@@ -1202,14 +1493,21 @@ TEST(ReplicaSetConfig, CheckConfigServerMustBuildIndexes) {
ReplicaSetConfig configA;
ASSERT_OK(configA.initialize(BSON("_id"
<< "rs0"
- << "protocolVersion" << 1 << "version" << 1 << "configsvr"
- << true << "members"
+ << "protocolVersion"
+ << 1
+ << "version"
+ << 1
+ << "configsvr"
+ << true
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345")
<< BSON("_id" << 1 << "host"
<< "localhost:54321"
- << "priority" << 0
- << "buildIndexes" << false)))));
+ << "priority"
+ << 0
+ << "buildIndexes"
+ << false)))));
Status status = configA.validate();
ASSERT_EQUALS(ErrorCodes::BadValue, status);
ASSERT_STRING_CONTAINS(status.reason(), "must build indexes");
@@ -1217,16 +1515,23 @@ TEST(ReplicaSetConfig, CheckConfigServerMustBuildIndexes) {
TEST(ReplicaSetConfig, CheckConfigServerCantHaveSlaveDelay) {
ReplicaSetConfig configA;
- ASSERT_OK(
- configA.initialize(BSON("_id"
- << "rs0"
- << "protocolVersion" << 1 << "version" << 1 << "configsvr" << true
- << "members" << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "localhost:12345")
- << BSON("_id" << 1 << "host"
- << "localhost:54321"
- << "priority" << 0
- << "slaveDelay" << 3)))));
+ ASSERT_OK(configA.initialize(BSON("_id"
+ << "rs0"
+ << "protocolVersion"
+ << 1
+ << "version"
+ << 1
+ << "configsvr"
+ << true
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "localhost:12345")
+ << BSON("_id" << 1 << "host"
+ << "localhost:54321"
+ << "priority"
+ << 0
+ << "slaveDelay"
+ << 3)))));
Status status = configA.validate();
ASSERT_EQUALS(ErrorCodes::BadValue, status);
ASSERT_STRING_CONTAINS(status.reason(), "cannot have a non-zero slaveDelay");
@@ -1236,15 +1541,21 @@ TEST(ReplicaSetConfig, CheckConfigServerMustHaveTrueForWriteConcernMajorityJourn
serverGlobalParams.clusterRole = ClusterRole::ConfigServer;
ON_BLOCK_EXIT([&] { serverGlobalParams.clusterRole = ClusterRole::None; });
ReplicaSetConfig configA;
- ASSERT_OK(
- configA.initialize(BSON("_id"
- << "rs0"
- << "protocolVersion" << 1 << "version" << 1 << "configsvr" << true
- << "members" << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "localhost:12345")
- << BSON("_id" << 1 << "host"
- << "localhost:54321"))
- << "writeConcernMajorityJournalDefault" << false)));
+ ASSERT_OK(configA.initialize(BSON("_id"
+ << "rs0"
+ << "protocolVersion"
+ << 1
+ << "version"
+ << 1
+ << "configsvr"
+ << true
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "localhost:12345")
+ << BSON("_id" << 1 << "host"
+ << "localhost:54321"))
+ << "writeConcernMajorityJournalDefault"
+ << false)));
Status status = configA.validate();
ASSERT_EQUALS(ErrorCodes::BadValue, status);
ASSERT_STRING_CONTAINS(status.reason(), " must be true in replica set configurations being ");
@@ -1254,22 +1565,30 @@ TEST(ReplicaSetConfig, GetPriorityTakeoverDelay) {
ReplicaSetConfig configA;
ASSERT_OK(configA.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"
- << "priority" << 1)
+ << "priority"
+ << 1)
<< BSON("_id" << 1 << "host"
<< "localhost:54321"
- << "priority" << 2)
+ << "priority"
+ << 2)
<< BSON("_id" << 2 << "host"
<< "localhost:5321"
- << "priority" << 3)
+ << "priority"
+ << 3)
<< BSON("_id" << 3 << "host"
<< "localhost:5421"
- << "priority" << 4)
+ << "priority"
+ << 4)
<< BSON("_id" << 4 << "host"
<< "localhost:5431"
- << "priority" << 5)) << "settings"
+ << "priority"
+ << 5))
+ << "settings"
<< BSON("electionTimeoutMillis" << 1000))));
ASSERT_OK(configA.validate());
ASSERT_EQUALS(Milliseconds(5000), configA.getPriorityTakeoverDelay(0));
@@ -1281,22 +1600,30 @@ TEST(ReplicaSetConfig, GetPriorityTakeoverDelay) {
ReplicaSetConfig configB;
ASSERT_OK(configB.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"
- << "priority" << 1)
+ << "priority"
+ << 1)
<< BSON("_id" << 1 << "host"
<< "localhost:54321"
- << "priority" << 2)
+ << "priority"
+ << 2)
<< BSON("_id" << 2 << "host"
<< "localhost:5321"
- << "priority" << 2)
+ << "priority"
+ << 2)
<< BSON("_id" << 3 << "host"
<< "localhost:5421"
- << "priority" << 3)
+ << "priority"
+ << 3)
<< BSON("_id" << 4 << "host"
<< "localhost:5431"
- << "priority" << 3)) << "settings"
+ << "priority"
+ << 3))
+ << "settings"
<< BSON("electionTimeoutMillis" << 1000))));
ASSERT_OK(configB.validate());
ASSERT_EQUALS(Milliseconds(5000), configB.getPriorityTakeoverDelay(0));
@@ -1311,7 +1638,9 @@ TEST(ReplicaSetConfig, ConfirmDefaultValuesOfAndAbilityToSetWriteConcernMajority
ReplicaSetConfig config;
ASSERT_OK(config.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345")))));
ASSERT_OK(config.validate());
@@ -1321,10 +1650,13 @@ TEST(ReplicaSetConfig, ConfirmDefaultValuesOfAndAbilityToSetWriteConcernMajority
// Should be able to set it true in PV0.
ASSERT_OK(config.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"))
- << "writeConcernMajorityJournalDefault" << true)));
+ << "writeConcernMajorityJournalDefault"
+ << true)));
ASSERT_OK(config.validate());
ASSERT_TRUE(config.getWriteConcernMajorityShouldJournal());
ASSERT_TRUE(config.toBSON().hasField("writeConcernMajorityJournalDefault"));
@@ -1332,7 +1664,11 @@ TEST(ReplicaSetConfig, ConfirmDefaultValuesOfAndAbilityToSetWriteConcernMajority
// PV1, should default to true.
ASSERT_OK(config.initialize(BSON("_id"
<< "rs0"
- << "protocolVersion" << 1 << "version" << 1 << "members"
+ << "protocolVersion"
+ << 1
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345")))));
ASSERT_OK(config.validate());
@@ -1342,10 +1678,15 @@ TEST(ReplicaSetConfig, ConfirmDefaultValuesOfAndAbilityToSetWriteConcernMajority
// Should be able to set it false in PV1.
ASSERT_OK(config.initialize(BSON("_id"
<< "rs0"
- << "protocolVersion" << 1 << "version" << 1 << "members"
+ << "protocolVersion"
+ << 1
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"))
- << "writeConcernMajorityJournalDefault" << false)));
+ << "writeConcernMajorityJournalDefault"
+ << false)));
ASSERT_OK(config.validate());
ASSERT_FALSE(config.getWriteConcernMajorityShouldJournal());
ASSERT_TRUE(config.toBSON().hasField("writeConcernMajorityJournalDefault"));
@@ -1360,10 +1701,13 @@ TEST(ReplicaSetConfig, ReplSetId) {
auto status =
ReplicaSetConfig().initializeForInitiate(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"
- << "priority" << 1))
+ << "priority"
+ << 1))
<< "settings"
<< BSON("replicaSetId" << OID::gen())));
ASSERT_EQUALS(ErrorCodes::InvalidReplicaSetConfig, status);
@@ -1377,10 +1721,13 @@ TEST(ReplicaSetConfig, ReplSetId) {
ASSERT_OK(
configInitiate.initializeForInitiate(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"
- << "priority" << 1)))));
+ << "priority"
+ << 1)))));
ASSERT_OK(configInitiate.validate());
ASSERT_TRUE(configInitiate.hasReplicaSetId());
OID replicaSetId = configInitiate.getReplicaSetId();
@@ -1389,11 +1736,15 @@ TEST(ReplicaSetConfig, ReplSetId) {
ReplicaSetConfig configLocal;
ASSERT_OK(configLocal.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"
- << "priority" << 1))
- << "settings" << BSON("replicaSetId" << replicaSetId))));
+ << "priority"
+ << 1))
+ << "settings"
+ << BSON("replicaSetId" << replicaSetId))));
ASSERT_OK(configLocal.validate());
ASSERT_TRUE(configLocal.hasReplicaSetId());
ASSERT_EQUALS(replicaSetId, configLocal.getReplicaSetId());
@@ -1402,10 +1753,13 @@ TEST(ReplicaSetConfig, ReplSetId) {
OID defaultReplicaSetId = OID::gen();
ASSERT_OK(configLocal.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"
- << "priority" << 1))),
+ << "priority"
+ << 1))),
true,
defaultReplicaSetId));
ASSERT_OK(configLocal.validate());
@@ -1415,10 +1769,14 @@ TEST(ReplicaSetConfig, ReplSetId) {
// 'replicaSetId' field cannot be null.
status = configLocal.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"
- << "priority" << 1)) << "settings"
+ << "priority"
+ << 1))
+ << "settings"
<< BSON("replicaSetId" << OID())));
ASSERT_EQUALS(ErrorCodes::BadValue, status);
ASSERT_STRING_CONTAINS(status.reason(), "replicaSetId field value cannot be null");
@@ -1426,10 +1784,14 @@ TEST(ReplicaSetConfig, ReplSetId) {
// 'replicaSetId' field must be an OID.
status = configLocal.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"
- << "priority" << 1)) << "settings"
+ << "priority"
+ << 1))
+ << "settings"
<< BSON("replicaSetId" << 12345)));
ASSERT_EQUALS(ErrorCodes::TypeMismatch, status);
ASSERT_STRING_CONTAINS(status.reason(),
diff --git a/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp b/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp
index e705fd17c9d..292f0ef9ae4 100644
--- a/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp
@@ -53,18 +53,18 @@
#include "mongo/db/repl/oplog.h"
#include "mongo/db/repl/repl_settings.h"
#include "mongo/db/repl/replication_coordinator_global.h"
-#include "mongo/db/repl/rs_sync.h"
#include "mongo/db/repl/rs_initialsync.h"
+#include "mongo/db/repl/rs_sync.h"
#include "mongo/db/repl/snapshot_thread.h"
#include "mongo/db/repl/storage_interface.h"
-#include "mongo/db/server_parameters.h"
-#include "mongo/db/service_context.h"
#include "mongo/db/s/sharding_state.h"
#include "mongo/db/s/sharding_state_recovery.h"
+#include "mongo/db/server_parameters.h"
+#include "mongo/db/service_context.h"
#include "mongo/db/storage/storage_engine.h"
#include "mongo/executor/network_interface.h"
-#include "mongo/s/grid.h"
#include "mongo/s/client/shard_registry.h"
+#include "mongo/s/grid.h"
#include "mongo/stdx/functional.h"
#include "mongo/stdx/memory.h"
#include "mongo/stdx/thread.h"
@@ -350,12 +350,15 @@ StatusWith<OpTime> ReplicationCoordinatorExternalStateImpl::loadLastOpTime(Opera
if (tsElement.eoo()) {
return StatusWith<OpTime>(ErrorCodes::NoSuchKey,
str::stream() << "Most recent entry in " << rsOplogName
- << " missing \"" << tsFieldName << "\" field");
+ << " missing \""
+ << tsFieldName
+ << "\" field");
}
if (tsElement.type() != bsonTimestamp) {
return StatusWith<OpTime>(ErrorCodes::TypeMismatch,
str::stream() << "Expected type of \"" << tsFieldName
- << "\" in most recent " << rsOplogName
+ << "\" in most recent "
+ << rsOplogName
<< " entry to have type Timestamp, but found "
<< typeName(tsElement.type()));
}
@@ -410,8 +413,8 @@ void ReplicationCoordinatorExternalStateImpl::updateShardIdentityConfigString(
if (ShardingState::get(txn)->enabled()) {
const auto configsvrConnStr =
Grid::get(txn)->shardRegistry()->getConfigShard()->getConnString();
- auto status = ShardingState::get(txn)
- ->updateShardIdentityConfigString(txn, configsvrConnStr.toString());
+ auto status = ShardingState::get(txn)->updateShardIdentityConfigString(
+ txn, configsvrConnStr.toString());
if (!status.isOK()) {
warning() << "error encountered while trying to update config connection string to "
<< configsvrConnStr << causedBy(status);
diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp
index c33326031b7..8b89de49f60 100644
--- a/src/mongo/db/repl/replication_coordinator_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl.cpp
@@ -203,18 +203,21 @@ ReplicationCoordinator::Mode getReplicationModeFromSettings(const ReplSettings&
DataReplicatorOptions createDataReplicatorOptions(ReplicationCoordinator* replCoord) {
DataReplicatorOptions options;
- options.rollbackFn =
- [](OperationContext*, const OpTime&, const HostAndPort&) -> Status { return Status::OK(); };
+ options.rollbackFn = [](OperationContext*, const OpTime&, const HostAndPort&) -> Status {
+ return Status::OK();
+ };
options.prepareReplSetUpdatePositionCommandFn =
[replCoord](ReplicationCoordinator::ReplSetUpdatePositionCommandStyle commandStyle)
- -> StatusWith<BSONObj> {
- return replCoord->prepareReplSetUpdatePositionCommand(commandStyle);
- };
+ -> StatusWith<BSONObj> {
+ return replCoord->prepareReplSetUpdatePositionCommand(commandStyle);
+ };
options.getMyLastOptime = [replCoord]() { return replCoord->getMyLastAppliedOpTime(); };
- options.setMyLastOptime =
- [replCoord](const OpTime& opTime) { replCoord->setMyLastAppliedOpTime(opTime); };
- options.setFollowerMode =
- [replCoord](const MemberState& newState) { return replCoord->setFollowerMode(newState); };
+ options.setMyLastOptime = [replCoord](const OpTime& opTime) {
+ replCoord->setMyLastAppliedOpTime(opTime);
+ };
+ options.setFollowerMode = [replCoord](const MemberState& newState) {
+ return replCoord->setFollowerMode(newState);
+ };
options.getSlaveDelay = [replCoord]() { return replCoord->getSlaveDelaySecs(); };
options.syncSourceSelector = replCoord;
options.replBatchLimitBytes = dur::UncommittedBytesLimit;
@@ -367,8 +370,8 @@ bool ReplicationCoordinatorImpl::_startLoadLocalConfig(OperationContext* txn) {
if (!status.isOK()) {
error() << "Locally stored replica set configuration does not parse; See "
"http://www.mongodb.org/dochub/core/recover-replica-set-from-invalid-config "
- "for information on how to recover from this. Got \"" << status
- << "\" while parsing " << cfg.getValue();
+ "for information on how to recover from this. Got \""
+ << status << "\" while parsing " << cfg.getValue();
fassertFailedNoTrace(28545);
}
@@ -417,8 +420,8 @@ void ReplicationCoordinatorImpl::_finishLoadLocalConfig(
} else {
error() << "Locally stored replica set configuration is invalid; See "
"http://www.mongodb.org/dochub/core/recover-replica-set-from-invalid-config"
- " for information on how to recover from this. Got \"" << myIndex.getStatus()
- << "\" while validating " << localConfig.toBSON();
+ " for information on how to recover from this. Got \""
+ << myIndex.getStatus() << "\" while validating " << localConfig.toBSON();
fassertFailedNoTrace(28544);
}
}
@@ -603,7 +606,8 @@ Status ReplicationCoordinatorImpl::waitForMemberState(MemberState expectedState,
if (!_memberStateChange.wait_for(lk, timeout.toSystemDuration(), pred)) {
return Status(ErrorCodes::ExceededTimeLimit,
str::stream() << "Timed out waiting for state to become "
- << expectedState.toString() << ". Current state is "
+ << expectedState.toString()
+ << ". Current state is "
<< _memberState.toString());
}
return Status::OK();
@@ -835,7 +839,8 @@ void ReplicationCoordinatorImpl::_updateSlaveInfoDurableOpTime_inlock(SlaveInfo*
if (slaveInfo->lastAppliedOpTime < opTime) {
log() << "Durable progress (" << opTime << ") is ahead of the applied progress ("
<< slaveInfo->lastAppliedOpTime << ". This is likely due to a "
- "rollback. slaveInfo: " << slaveInfo->toString();
+ "rollback. slaveInfo: "
+ << slaveInfo->toString();
return;
}
slaveInfo->lastDurableOpTime = opTime;
@@ -1009,9 +1014,9 @@ void ReplicationCoordinatorImpl::_setMyLastDurableOpTime_inlock(const OpTime& op
// lastAppliedOpTime cannot be behind lastDurableOpTime.
if (mySlaveInfo->lastAppliedOpTime < opTime) {
log() << "My durable progress (" << opTime << ") is ahead of my applied progress ("
- << mySlaveInfo->lastAppliedOpTime
- << ". This is likely due to a "
- "rollback. slaveInfo: " << mySlaveInfo->toString();
+ << mySlaveInfo->lastAppliedOpTime << ". This is likely due to a "
+ "rollback. slaveInfo: "
+ << mySlaveInfo->toString();
return;
}
_updateSlaveInfoDurableOpTime_inlock(mySlaveInfo, opTime);
@@ -2927,21 +2932,24 @@ SyncSourceResolverResponse ReplicationCoordinatorImpl::selectSyncSource(
// Candidate found.
Status queryStatus(ErrorCodes::NotYetInitialized, "not mutated");
BSONObj firstObjFound;
- auto work =
- [&firstObjFound, &queryStatus](const StatusWith<Fetcher::QueryResponse>& queryResult,
- NextAction* nextActiion,
- BSONObjBuilder* bob) {
- queryStatus = queryResult.getStatus();
- if (queryResult.isOK() && !queryResult.getValue().documents.empty()) {
- firstObjFound = queryResult.getValue().documents.front();
- }
- };
+ auto work = [&firstObjFound,
+ &queryStatus](const StatusWith<Fetcher::QueryResponse>& queryResult,
+ NextAction* nextActiion,
+ BSONObjBuilder* bob) {
+ queryStatus = queryResult.getStatus();
+ if (queryResult.isOK() && !queryResult.getValue().documents.empty()) {
+ firstObjFound = queryResult.getValue().documents.front();
+ }
+ };
Fetcher candidateProber(&_replExecutor,
candidate,
"local",
BSON("find"
<< "oplog.rs"
- << "limit" << 1 << "sort" << BSON("$natural" << 1)),
+ << "limit"
+ << 1
+ << "sort"
+ << BSON("$natural" << 1)),
work,
rpc::ServerSelectionMetadata(true, boost::none).toBSON(),
Milliseconds(30000));
@@ -3414,8 +3422,9 @@ void ReplicationCoordinatorImpl::_resetElectionInfoOnProtocolVersionUpgrade(
}
CallbackHandle ReplicationCoordinatorImpl::_scheduleWork(const CallbackFn& work) {
- auto scheduleFn =
- [this](const CallbackFn& workWrapped) { return _replExecutor.scheduleWork(workWrapped); };
+ auto scheduleFn = [this](const CallbackFn& workWrapped) {
+ return _replExecutor.scheduleWork(workWrapped);
+ };
return _wrapAndScheduleWork(scheduleFn, work);
}
@@ -3440,8 +3449,9 @@ void ReplicationCoordinatorImpl::_scheduleWorkAtAndWaitForCompletion(Date_t when
}
CallbackHandle ReplicationCoordinatorImpl::_scheduleDBWork(const CallbackFn& work) {
- auto scheduleFn =
- [this](const CallbackFn& workWrapped) { return _replExecutor.scheduleDBWork(workWrapped); };
+ auto scheduleFn = [this](const CallbackFn& workWrapped) {
+ return _replExecutor.scheduleDBWork(workWrapped);
+ };
return _wrapAndScheduleWork(scheduleFn, work);
}
diff --git a/src/mongo/db/repl/replication_coordinator_impl.h b/src/mongo/db/repl/replication_coordinator_impl.h
index 53f0ffde4c3..61fda88b59a 100644
--- a/src/mongo/db/repl/replication_coordinator_impl.h
+++ b/src/mongo/db/repl/replication_coordinator_impl.h
@@ -28,9 +28,9 @@
#pragma once
-#include <vector>
#include <memory>
#include <utility>
+#include <vector>
#include "mongo/base/status.h"
#include "mongo/bson/timestamp.h"
diff --git a/src/mongo/db/repl/replication_coordinator_impl_elect.cpp b/src/mongo/db/repl/replication_coordinator_impl_elect.cpp
index a70c8963af8..494b8f7a0d6 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_elect.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_elect.cpp
@@ -31,10 +31,10 @@
#include "mongo/platform/basic.h"
#include "mongo/base/disallow_copying.h"
-#include "mongo/db/repl/replication_coordinator_impl.h"
-#include "mongo/db/repl/topology_coordinator_impl.h"
#include "mongo/db/repl/elect_cmd_runner.h"
#include "mongo/db/repl/freshness_checker.h"
+#include "mongo/db/repl/replication_coordinator_impl.h"
+#include "mongo/db/repl/topology_coordinator_impl.h"
#include "mongo/util/log.h"
#include "mongo/util/scopeguard.h"
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 a414ac0aabb..e3779fd3dee 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_elect_test.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_elect_test.cpp
@@ -77,7 +77,8 @@ void ReplCoordElectTest::simulateFreshEnoughForElectability() {
net->now(),
makeResponseStatus(BSON("ok" << 1 << "fresher" << false << "opTime"
<< Date_t::fromMillisSinceEpoch(Timestamp(0, 0).asLL())
- << "veto" << false)));
+ << "veto"
+ << false)));
} else {
error() << "Black holing unexpected request to " << request.target << ": "
<< request.cmdObj;
@@ -95,7 +96,9 @@ TEST_F(ReplCoordElectTest, StartElectionDoesNotStartAnElectionWhenNodeHasNoOplog
startCapturingLogMessages();
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -112,16 +115,22 @@ TEST_F(ReplCoordElectTest, StartElectionDoesNotStartAnElectionWhenNodeHasNoOplog
* vote(s) to win.
*/
TEST_F(ReplCoordElectTest, ElectionSucceedsWhenNodeIsTheOnlyElectableNode) {
- assertStartSuccess(
- BSON("_id"
- << "mySet"
- << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "node1:12345")
- << BSON("_id" << 2 << "host"
- << "node2:12345"
- << "votes" << 0 << "hidden" << true << "priority" << 0))),
- HostAndPort("node1", 12345));
+ assertStartSuccess(BSON("_id"
+ << "mySet"
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "node1:12345")
+ << BSON("_id" << 2 << "host"
+ << "node2:12345"
+ << "votes"
+ << 0
+ << "hidden"
+ << true
+ << "priority"
+ << 0))),
+ HostAndPort("node1", 12345));
getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY);
// Fake OpTime from initiate, or a write op.
@@ -166,7 +175,9 @@ TEST_F(ReplCoordElectTest, ElectionSucceedsWhenNodeIsTheOnlyNode) {
startCapturingLogMessages();
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345"))),
HostAndPort("node1", 12345));
@@ -197,7 +208,9 @@ TEST_F(ReplCoordElectTest, ElectionSucceedsWhenNodeIsTheOnlyNode) {
TEST_F(ReplCoordElectTest, ElectionSucceedsWhenAllNodesVoteYea) {
BSONObj configObj = BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -221,7 +234,9 @@ TEST_F(ReplCoordElectTest, ElectionFailsWhenOneNodeVotesNay) {
startCapturingLogMessages();
BSONObj configObj = BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -266,7 +281,9 @@ TEST_F(ReplCoordElectTest, VotesWithStringValuesAreNotCountedAsYeas) {
startCapturingLogMessages();
BSONObj configObj = BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -298,7 +315,8 @@ TEST_F(ReplCoordElectTest, VotesWithStringValuesAreNotCountedAsYeas) {
net->now(),
makeResponseStatus(BSON("ok" << 1 << "vote"
<< "yea"
- << "round" << OID())));
+ << "round"
+ << OID())));
}
net->runReadyNetworkOperations();
}
@@ -311,7 +329,9 @@ TEST_F(ReplCoordElectTest, VotesWithStringValuesAreNotCountedAsYeas) {
TEST_F(ReplCoordElectTest, ElectionsAbortWhenNodeTransitionsToRollbackState) {
BSONObj configObj = BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -344,19 +364,22 @@ TEST_F(ReplCoordElectTest, NodeWillNotStandForElectionDuringHeartbeatReconfig) {
// start up, receive reconfig via heartbeat while at the same time, become candidate.
// candidate state should be cleared.
OperationContextNoop txn;
- assertStartSuccess(
- BSON("_id"
- << "mySet"
- << "version" << 2 << "members"
- << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "node1:12345")
- << BSON("_id" << 2 << "host"
- << "node2:12345") << BSON("_id" << 3 << "host"
- << "node3:12345")
- << BSON("_id" << 4 << "host"
- << "node4:12345") << BSON("_id" << 5 << "host"
- << "node5:12345"))),
- HostAndPort("node1", 12345));
+ assertStartSuccess(BSON("_id"
+ << "mySet"
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "node1:12345")
+ << BSON("_id" << 2 << "host"
+ << "node2:12345")
+ << BSON("_id" << 3 << "host"
+ << "node3:12345")
+ << BSON("_id" << 4 << "host"
+ << "node4:12345")
+ << BSON("_id" << 5 << "host"
+ << "node5:12345"))),
+ HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastAppliedOpTime(OpTime(Timestamp(100, 0), 0));
@@ -370,7 +393,9 @@ TEST_F(ReplCoordElectTest, NodeWillNotStandForElectionDuringHeartbeatReconfig) {
ReplicaSetConfig config;
config.initialize(BSON("_id"
<< "mySet"
- << "version" << 3 << "members"
+ << "version"
+ << 3
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -428,19 +453,21 @@ TEST_F(ReplCoordElectTest, NodeWillNotStandForElectionDuringHeartbeatReconfig) {
stopCapturingLogMessages();
// ensure node does not stand for election
ASSERT_EQUALS(1,
- countLogLinesContaining(
- "Not standing for election; processing "
- "a configuration change"));
+ countLogLinesContaining("Not standing for election; processing "
+ "a configuration change"));
getExternalState()->setStoreLocalConfigDocumentToHang(false);
}
TEST_F(ReplCoordElectTest, StepsDownRemoteIfNodeHasHigherPriorityThanCurrentPrimary) {
BSONObj configObj = BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345"
- << "priority" << 2)
+ << "priority"
+ << 2)
<< BSON("_id" << 2 << "host"
<< "node2:12345")
<< BSON("_id" << 3 << "host"
@@ -501,23 +528,27 @@ TEST_F(ReplCoordElectTest, StepsDownRemoteIfNodeHasHigherPriorityThanCurrentPrim
net->exitNetwork();
ASSERT_EQUALS(1,
countLogLinesContaining(str::stream() << "stepdown of primary("
- << target.toString() << ") succeeded"));
+ << target.toString()
+ << ") succeeded"));
}
TEST_F(ReplCoordElectTest, NodeCancelsElectionUponReceivingANewConfigDuringFreshnessCheckingPhase) {
// Start up and become electable.
OperationContextNoop txn;
- assertStartSuccess(
- BSON("_id"
- << "mySet"
- << "version" << 2 << "members"
- << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "node1:12345")
- << BSON("_id" << 3 << "host"
- << "node3:12345") << BSON("_id" << 2 << "host"
- << "node2:12345"))
- << "settings" << BSON("heartbeatIntervalMillis" << 100)),
- HostAndPort("node1", 12345));
+ assertStartSuccess(BSON("_id"
+ << "mySet"
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "node1:12345")
+ << BSON("_id" << 3 << "host"
+ << "node3:12345")
+ << BSON("_id" << 2 << "host"
+ << "node2:12345"))
+ << "settings"
+ << BSON("heartbeatIntervalMillis" << 100)),
+ HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastAppliedOpTime(OpTime(Timestamp(100, 0), 0));
getReplCoord()->setMyLastDurableOpTime(OpTime(Timestamp(100, 0), 0));
@@ -542,10 +573,13 @@ TEST_F(ReplCoordElectTest, NodeCancelsElectionUponReceivingANewConfigDuringFresh
ReplicationCoordinatorImpl::ReplSetReconfigArgs config = {
BSON("_id"
<< "mySet"
- << "version" << 4 << "members" << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "node1:12345")
- << BSON("_id" << 2 << "host"
- << "node2:12345"))),
+ << "version"
+ << 4
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "node1:12345")
+ << BSON("_id" << 2 << "host"
+ << "node2:12345"))),
true};
BSONObjBuilder result;
@@ -560,17 +594,20 @@ TEST_F(ReplCoordElectTest, NodeCancelsElectionUponReceivingANewConfigDuringFresh
TEST_F(ReplCoordElectTest, NodeCancelsElectionUponReceivingANewConfigDuringElectionPhase) {
// Start up and become electable.
OperationContextNoop txn;
- assertStartSuccess(
- BSON("_id"
- << "mySet"
- << "version" << 2 << "members"
- << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "node1:12345")
- << BSON("_id" << 3 << "host"
- << "node3:12345") << BSON("_id" << 2 << "host"
- << "node2:12345"))
- << "settings" << BSON("heartbeatIntervalMillis" << 100)),
- HostAndPort("node1", 12345));
+ assertStartSuccess(BSON("_id"
+ << "mySet"
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "node1:12345")
+ << BSON("_id" << 3 << "host"
+ << "node3:12345")
+ << BSON("_id" << 2 << "host"
+ << "node2:12345"))
+ << "settings"
+ << BSON("heartbeatIntervalMillis" << 100)),
+ HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastAppliedOpTime(OpTime(Timestamp(100, 0), 0));
getReplCoord()->setMyLastDurableOpTime(OpTime(Timestamp(100, 0), 0));
@@ -582,10 +619,13 @@ TEST_F(ReplCoordElectTest, NodeCancelsElectionUponReceivingANewConfigDuringElect
ReplicationCoordinatorImpl::ReplSetReconfigArgs config = {
BSON("_id"
<< "mySet"
- << "version" << 4 << "members" << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "node1:12345")
- << BSON("_id" << 2 << "host"
- << "node2:12345"))),
+ << "version"
+ << 4
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "node1:12345")
+ << BSON("_id" << 2 << "host"
+ << "node2:12345"))),
true};
BSONObjBuilder result;
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 beaf238fcef..100f44d4156 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
@@ -53,17 +53,24 @@ using executor::RemoteCommandRequest;
using executor::RemoteCommandResponse;
TEST_F(ReplCoordTest, ElectionSucceedsWhenNodeIsTheOnlyElectableNode) {
- assertStartSuccess(
- BSON("_id"
- << "mySet"
- << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "node1:12345")
- << BSON("_id" << 2 << "host"
- << "node2:12345"
- << "votes" << 0 << "hidden" << true << "priority" << 0))
- << "protocolVersion" << 1),
- HostAndPort("node1", 12345));
+ assertStartSuccess(BSON("_id"
+ << "mySet"
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "node1:12345")
+ << BSON("_id" << 2 << "host"
+ << "node2:12345"
+ << "votes"
+ << 0
+ << "hidden"
+ << true
+ << "priority"
+ << 0))
+ << "protocolVersion"
+ << 1),
+ HostAndPort("node1", 12345));
getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY);
@@ -117,11 +124,14 @@ TEST_F(ReplCoordTest, ElectionSucceedsWhenNodeIsTheOnlyElectableNode) {
TEST_F(ReplCoordTest, StartElectionDoesNotStartAnElectionWhenNodeIsRecovering) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
- << "node2:12345")) << "protocolVersion"
+ << "node2:12345"))
+ << "protocolVersion"
<< 1),
HostAndPort("node1", 12345));
@@ -142,9 +152,13 @@ TEST_F(ReplCoordTest, ElectionSucceedsWhenNodeIsTheOnlyNode) {
startCapturingLogMessages();
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
- << "node1:12345")) << "protocolVersion" << 1),
+ << "node1:12345"))
+ << "protocolVersion"
+ << 1),
HostAndPort("node1", 12345));
getReplCoord()->setMyLastAppliedOpTime(OpTime(Timestamp(10, 0), 0));
@@ -172,13 +186,16 @@ TEST_F(ReplCoordTest, ElectionSucceedsWhenNodeIsTheOnlyNode) {
TEST_F(ReplCoordTest, ElectionSucceedsWhenAllNodesVoteYea) {
BSONObj configObj = BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
<< "node2:12345")
<< BSON("_id" << 3 << "host"
- << "node3:12345")) << "protocolVersion"
+ << "node3:12345"))
+ << "protocolVersion"
<< 1);
assertStartSuccess(configObj, HostAndPort("node1", 12345));
OperationContextNoop txn;
@@ -202,20 +219,25 @@ TEST_F(ReplCoordTest, ElectionSucceedsWhenAllNodesVoteYea) {
TEST_F(ReplCoordTest, ElectionSucceedsWhenMaxSevenNodesVoteYea) {
BSONObj configObj = BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
- << BSON_ARRAY(
- BSON("_id" << 1 << "host"
- << "node1:12345")
- << BSON("_id" << 2 << "host"
- << "node2:12345") << BSON("_id" << 3 << "host"
- << "node3:12345")
- << BSON("_id" << 4 << "host"
- << "node4:12345") << BSON("_id" << 5 << "host"
- << "node5:12345")
- << BSON("_id" << 6 << "host"
- << "node6:12345") << BSON("_id" << 7 << "host"
- << "node7:12345"))
- << "protocolVersion" << 1);
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "node1:12345")
+ << BSON("_id" << 2 << "host"
+ << "node2:12345")
+ << BSON("_id" << 3 << "host"
+ << "node3:12345")
+ << BSON("_id" << 4 << "host"
+ << "node4:12345")
+ << BSON("_id" << 5 << "host"
+ << "node5:12345")
+ << BSON("_id" << 6 << "host"
+ << "node6:12345")
+ << BSON("_id" << 7 << "host"
+ << "node7:12345"))
+ << "protocolVersion"
+ << 1);
assertStartSuccess(configObj, HostAndPort("node1", 12345));
OperationContextNoop txn;
getReplCoord()->setMyLastAppliedOpTime(OpTime(Timestamp(100, 1), 0));
@@ -239,13 +261,16 @@ TEST_F(ReplCoordTest, ElectionFailsWhenInsufficientVotesAreReceivedDuringDryRun)
startCapturingLogMessages();
BSONObj configObj = BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
<< "node2:12345")
<< BSON("_id" << 3 << "host"
- << "node3:12345")) << "protocolVersion"
+ << "node3:12345"))
+ << "protocolVersion"
<< 1);
assertStartSuccess(configObj, HostAndPort("node1", 12345));
ReplicaSetConfig config = assertMakeRSConfig(configObj);
@@ -278,9 +303,9 @@ TEST_F(ReplCoordTest, ElectionFailsWhenInsufficientVotesAreReceivedDuringDryRun)
} else {
net->scheduleResponse(noi,
net->now(),
- makeResponseStatus(BSON("ok" << 1 << "term" << 0 << "voteGranted"
- << false << "reason"
- << "don't like him much")));
+ makeResponseStatus(BSON(
+ "ok" << 1 << "term" << 0 << "voteGranted" << false << "reason"
+ << "don't like him much")));
voteRequests++;
}
net->runReadyNetworkOperations();
@@ -295,13 +320,16 @@ TEST_F(ReplCoordTest, ElectionFailsWhenDryRunResponseContainsANewerTerm) {
startCapturingLogMessages();
BSONObj configObj = BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
<< "node2:12345")
<< BSON("_id" << 3 << "host"
- << "node3:12345")) << "protocolVersion"
+ << "node3:12345"))
+ << "protocolVersion"
<< 1);
assertStartSuccess(configObj, HostAndPort("node1", 12345));
ReplicaSetConfig config = assertMakeRSConfig(configObj);
@@ -336,7 +364,9 @@ TEST_F(ReplCoordTest, ElectionFailsWhenDryRunResponseContainsANewerTerm) {
noi,
net->now(),
makeResponseStatus(BSON("ok" << 1 << "term" << request.cmdObj["term"].Long() + 1
- << "voteGranted" << false << "reason"
+ << "voteGranted"
+ << false
+ << "reason"
<< "quit living in the past")));
voteRequests++;
}
@@ -353,20 +383,24 @@ TEST_F(ReplCoordTest, NodeWillNotStandForElectionDuringHeartbeatReconfig) {
// start up, receive reconfig via heartbeat while at the same time, become candidate.
// candidate state should be cleared.
OperationContextNoop txn;
- assertStartSuccess(
- BSON("_id"
- << "mySet"
- << "version" << 2 << "members"
- << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "node1:12345")
- << BSON("_id" << 2 << "host"
- << "node2:12345") << BSON("_id" << 3 << "host"
- << "node3:12345")
- << BSON("_id" << 4 << "host"
- << "node4:12345") << BSON("_id" << 5 << "host"
- << "node5:12345"))
- << "protocolVersion" << 1),
- HostAndPort("node1", 12345));
+ assertStartSuccess(BSON("_id"
+ << "mySet"
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "node1:12345")
+ << BSON("_id" << 2 << "host"
+ << "node2:12345")
+ << BSON("_id" << 3 << "host"
+ << "node3:12345")
+ << BSON("_id" << 4 << "host"
+ << "node4:12345")
+ << BSON("_id" << 5 << "host"
+ << "node5:12345"))
+ << "protocolVersion"
+ << 1),
+ HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastAppliedOpTime(OpTime(Timestamp(100, 0), 0));
getReplCoord()->setMyLastDurableOpTime(OpTime(Timestamp(100, 0), 0));
@@ -381,11 +415,14 @@ TEST_F(ReplCoordTest, NodeWillNotStandForElectionDuringHeartbeatReconfig) {
ReplicaSetConfig config;
config.initialize(BSON("_id"
<< "mySet"
- << "version" << 3 << "members"
+ << "version"
+ << 3
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
- << "node2:12345")) << "protocolVersion"
+ << "node2:12345"))
+ << "protocolVersion"
<< 1));
hbResp2.setConfig(config);
hbResp2.setConfigVersion(3);
@@ -451,9 +488,8 @@ TEST_F(ReplCoordTest, NodeWillNotStandForElectionDuringHeartbeatReconfig) {
stopCapturingLogMessages();
// ensure node does not stand for election
ASSERT_EQUALS(1,
- countLogLinesContaining(
- "Not standing for election; processing "
- "a configuration change"));
+ countLogLinesContaining("Not standing for election; processing "
+ "a configuration change"));
getExternalState()->setStoreLocalConfigDocumentToHang(false);
}
@@ -461,13 +497,16 @@ TEST_F(ReplCoordTest, ElectionFailsWhenInsufficientVotesAreReceivedDuringRequest
startCapturingLogMessages();
BSONObj configObj = BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
<< "node2:12345")
<< BSON("_id" << 3 << "host"
- << "node3:12345")) << "protocolVersion"
+ << "node3:12345"))
+ << "protocolVersion"
<< 1);
assertStartSuccess(configObj, HostAndPort("node1", 12345));
ReplicaSetConfig config = assertMakeRSConfig(configObj);
@@ -492,9 +531,9 @@ TEST_F(ReplCoordTest, ElectionFailsWhenInsufficientVotesAreReceivedDuringRequest
} else {
net->scheduleResponse(noi,
net->now(),
- makeResponseStatus(BSON("ok" << 1 << "term" << 1 << "voteGranted"
- << false << "reason"
- << "don't like him much")));
+ makeResponseStatus(BSON(
+ "ok" << 1 << "term" << 1 << "voteGranted" << false << "reason"
+ << "don't like him much")));
}
net->runReadyNetworkOperations();
}
@@ -509,13 +548,16 @@ TEST_F(ReplCoordTest, ElectionFailsWhenInsufficientVotesAreReceivedDuringRequest
TEST_F(ReplCoordTest, ElectionsAbortWhenNodeTransitionsToRollbackState) {
BSONObj configObj = BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
<< "node2:12345")
<< BSON("_id" << 3 << "host"
- << "node3:12345")) << "protocolVersion"
+ << "node3:12345"))
+ << "protocolVersion"
<< 1);
assertStartSuccess(configObj, HostAndPort("node1", 12345));
ReplicaSetConfig config = assertMakeRSConfig(configObj);
@@ -544,13 +586,16 @@ TEST_F(ReplCoordTest, ElectionFailsWhenVoteRequestResponseContainsANewerTerm) {
startCapturingLogMessages();
BSONObj configObj = BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
<< "node2:12345")
<< BSON("_id" << 3 << "host"
- << "node3:12345")) << "protocolVersion"
+ << "node3:12345"))
+ << "protocolVersion"
<< 1);
assertStartSuccess(configObj, HostAndPort("node1", 12345));
ReplicaSetConfig config = assertMakeRSConfig(configObj);
@@ -577,7 +622,9 @@ TEST_F(ReplCoordTest, ElectionFailsWhenVoteRequestResponseContainsANewerTerm) {
noi,
net->now(),
makeResponseStatus(BSON("ok" << 1 << "term" << request.cmdObj["term"].Long() + 1
- << "voteGranted" << false << "reason"
+ << "voteGranted"
+ << false
+ << "reason"
<< "quit living in the past")));
}
net->runReadyNetworkOperations();
@@ -594,13 +641,16 @@ TEST_F(ReplCoordTest, ElectionFailsWhenTermChangesDuringDryRun) {
startCapturingLogMessages();
BSONObj configObj = BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
<< "node2:12345")
<< BSON("_id" << 3 << "host"
- << "node3:12345")) << "protocolVersion"
+ << "node3:12345"))
+ << "protocolVersion"
<< 1);
assertStartSuccess(configObj, HostAndPort("node1", 12345));
@@ -631,13 +681,16 @@ TEST_F(ReplCoordTest, ElectionFailsWhenTermChangesDuringActualElection) {
startCapturingLogMessages();
BSONObj configObj = BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
<< "node2:12345")
<< BSON("_id" << 3 << "host"
- << "node3:12345")) << "protocolVersion"
+ << "node3:12345"))
+ << "protocolVersion"
<< 1);
assertStartSuccess(configObj, HostAndPort("node1", 12345));
ReplicaSetConfig config = assertMakeRSConfig(configObj);
@@ -665,9 +718,10 @@ TEST_F(ReplCoordTest, ElectionFailsWhenTermChangesDuringActualElection) {
net->scheduleResponse(
noi,
net->now(),
- makeResponseStatus(BSON("ok" << 1 << "term" << request.cmdObj["term"].Long()
- << "voteGranted" << true << "reason"
- << "")));
+ makeResponseStatus(BSON(
+ "ok" << 1 << "term" << request.cmdObj["term"].Long() << "voteGranted" << true
+ << "reason"
+ << "")));
}
net->runReadyNetworkOperations();
}
@@ -682,14 +736,18 @@ TEST_F(ReplCoordTest, SchedulesPriorityTakeoverIfNodeHasHigherPriorityThanCurren
startCapturingLogMessages();
BSONObj configObj = BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345"
- << "priority" << 2)
+ << "priority"
+ << 2)
<< BSON("_id" << 2 << "host"
<< "node2:12345")
<< BSON("_id" << 3 << "host"
- << "node3:12345")) << "protocolVersion"
+ << "node3:12345"))
+ << "protocolVersion"
<< 1);
assertStartSuccess(configObj, HostAndPort("node1", 12345));
ReplicaSetConfig config = assertMakeRSConfig(configObj);
@@ -746,17 +804,20 @@ TEST_F(ReplCoordTest, SchedulesPriorityTakeoverIfNodeHasHigherPriorityThanCurren
TEST_F(ReplCoordTest, NodeCancelsElectionUponReceivingANewConfigDuringDryRun) {
// Start up and become electable.
OperationContextNoop txn;
- assertStartSuccess(
- BSON("_id"
- << "mySet"
- << "version" << 2 << "members"
- << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "node1:12345")
- << BSON("_id" << 3 << "host"
- << "node3:12345") << BSON("_id" << 2 << "host"
- << "node2:12345"))
- << "settings" << BSON("heartbeatIntervalMillis" << 100)),
- HostAndPort("node1", 12345));
+ assertStartSuccess(BSON("_id"
+ << "mySet"
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "node1:12345")
+ << BSON("_id" << 3 << "host"
+ << "node3:12345")
+ << BSON("_id" << 2 << "host"
+ << "node2:12345"))
+ << "settings"
+ << BSON("heartbeatIntervalMillis" << 100)),
+ HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastAppliedOpTime(OpTime(Timestamp(100, 0), 0));
getReplCoord()->setMyLastDurableOpTime(OpTime(Timestamp(100, 0), 0));
@@ -779,10 +840,13 @@ TEST_F(ReplCoordTest, NodeCancelsElectionUponReceivingANewConfigDuringDryRun) {
ReplicationCoordinatorImpl::ReplSetReconfigArgs config = {
BSON("_id"
<< "mySet"
- << "version" << 4 << "members" << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "node1:12345")
- << BSON("_id" << 2 << "host"
- << "node2:12345"))),
+ << "version"
+ << 4
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "node1:12345")
+ << BSON("_id" << 2 << "host"
+ << "node2:12345"))),
true};
BSONObjBuilder result;
@@ -797,17 +861,20 @@ TEST_F(ReplCoordTest, NodeCancelsElectionUponReceivingANewConfigDuringDryRun) {
TEST_F(ReplCoordTest, NodeCancelsElectionUponReceivingANewConfigDuringVotePhase) {
// Start up and become electable.
OperationContextNoop txn;
- assertStartSuccess(
- BSON("_id"
- << "mySet"
- << "version" << 2 << "members"
- << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "node1:12345")
- << BSON("_id" << 3 << "host"
- << "node3:12345") << BSON("_id" << 2 << "host"
- << "node2:12345"))
- << "settings" << BSON("heartbeatIntervalMillis" << 100)),
- HostAndPort("node1", 12345));
+ assertStartSuccess(BSON("_id"
+ << "mySet"
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "node1:12345")
+ << BSON("_id" << 3 << "host"
+ << "node3:12345")
+ << BSON("_id" << 2 << "host"
+ << "node2:12345"))
+ << "settings"
+ << BSON("heartbeatIntervalMillis" << 100)),
+ HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastAppliedOpTime(OpTime(Timestamp(100, 0), 0));
getReplCoord()->setMyLastDurableOpTime(OpTime(Timestamp(100, 0), 0));
@@ -819,10 +886,13 @@ TEST_F(ReplCoordTest, NodeCancelsElectionUponReceivingANewConfigDuringVotePhase)
ReplicationCoordinatorImpl::ReplSetReconfigArgs config = {
BSON("_id"
<< "mySet"
- << "version" << 4 << "members" << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "node1:12345")
- << BSON("_id" << 2 << "host"
- << "node2:12345"))),
+ << "version"
+ << 4
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "node1:12345")
+ << BSON("_id" << 2 << "host"
+ << "node2:12345"))),
true};
BSONObjBuilder result;
diff --git a/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp b/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp
index d9b9297bfb7..4c8945ac064 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp
@@ -146,11 +146,11 @@ void ReplicationCoordinatorImpl::_handleHeartbeatResponse(
if (replMetadata.isOK() && _rsConfig.isInitialized() && _rsConfig.hasReplicaSetId() &&
replMetadata.getValue().getReplicaSetId().isSet() &&
_rsConfig.getReplicaSetId() != replMetadata.getValue().getReplicaSetId()) {
- responseStatus =
- Status(ErrorCodes::InvalidReplicaSetConfig,
- str::stream()
- << "replica set IDs do not match, ours: " << _rsConfig.getReplicaSetId()
- << "; remote node's: " << replMetadata.getValue().getReplicaSetId());
+ responseStatus = Status(ErrorCodes::InvalidReplicaSetConfig,
+ str::stream() << "replica set IDs do not match, ours: "
+ << _rsConfig.getReplicaSetId()
+ << "; remote node's: "
+ << replMetadata.getValue().getReplicaSetId());
// Ignore metadata.
replMetadata = responseStatus;
}
@@ -435,14 +435,16 @@ void ReplicationCoordinatorImpl::_heartbeatReconfigStore(
if (!myIndex.getStatus().isOK() && myIndex.getStatus() != ErrorCodes::NodeNotFound) {
warning() << "Not persisting new configuration in heartbeat response to disk because "
- "it is invalid: " << myIndex.getStatus();
+ "it is invalid: "
+ << myIndex.getStatus();
} else {
Status status = _externalState->storeLocalConfigDocument(cbd.txn, newConfig.toBSON());
lk.lock();
if (!status.isOK()) {
error() << "Ignoring new configuration in heartbeat response because we failed to"
- " write it to stable storage; " << status;
+ " write it to stable storage; "
+ << status;
invariant(_rsConfigState == kConfigHBReconfiguring);
if (_rsConfig.isInitialized()) {
_setConfigState_inlock(kConfigSteady);
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 73c9e77c77c..91697d5ad01 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_heartbeat_test.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_heartbeat_test.cpp
@@ -90,7 +90,9 @@ TEST_F(ReplCoordHBTest, NodeJoinsExistingReplSetWhenReceivingAConfigContainingTh
logger::globalLogDomain()->setMinimumLoggedSeverity(logger::LogSeverity::Debug(3));
ReplicaSetConfig rsConfig = assertMakeRSConfigV0(BSON("_id"
<< "mySet"
- << "version" << 3 << "members"
+ << "version"
+ << 3
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1:1")
<< BSON("_id" << 2 << "host"
@@ -154,7 +156,9 @@ TEST_F(ReplCoordHBTest,
logger::globalLogDomain()->setMinimumLoggedSeverity(logger::LogSeverity::Debug(3));
ReplicaSetConfig rsConfig = assertMakeRSConfigV0(BSON("_id"
<< "mySet"
- << "version" << 3 << "members"
+ << "version"
+ << 3
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1:1")
<< BSON("_id" << 2 << "host"
@@ -230,7 +234,9 @@ TEST_F(ReplCoordHBTest,
logger::globalLogDomain()->setMinimumLoggedSeverity(logger::LogSeverity::Debug(3));
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -243,12 +249,12 @@ TEST_F(ReplCoordHBTest,
const NetworkInterfaceMock::NetworkOperationIterator noi = getNet()->getNextReadyRequest();
const RemoteCommandRequest& request = noi->getRequest();
log() << request.target.toString() << " processing " << request.cmdObj;
- getNet()->scheduleResponse(
- noi,
- getNet()->now(),
- makeResponseStatus(BSON("ok" << 0.0 << "errmsg"
- << "unauth'd"
- << "code" << ErrorCodes::Unauthorized)));
+ getNet()->scheduleResponse(noi,
+ getNet()->now(),
+ makeResponseStatus(BSON("ok" << 0.0 << "errmsg"
+ << "unauth'd"
+ << "code"
+ << ErrorCodes::Unauthorized)));
if (request.target != HostAndPort("node2", 12345) &&
request.cmdObj.firstElement().fieldNameStringData() != "replSetHeartbeat") {
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 2233e21cc21..2290786e343 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
@@ -86,16 +86,19 @@ ReplSetHeartbeatResponse ReplCoordHBV1Test::receiveHeartbeatFrom(const ReplicaSe
TEST_F(ReplCoordHBV1Test,
NodeJoinsExistingReplSetWhenReceivingAConfigContainingTheNodeViaHeartbeat) {
logger::globalLogDomain()->setMinimumLoggedSeverity(logger::LogSeverity::Debug(3));
- 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"))
- << "protocolVersion" << 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"))
+ << "protocolVersion"
+ << 1));
init("mySet");
addSelf(HostAndPort("h2", 1));
const Date_t startDate = getNet()->now();
@@ -150,17 +153,21 @@ TEST_F(ReplCoordHBV1Test,
TEST_F(ReplCoordHBV1Test,
ArbiterJoinsExistingReplSetWhenReceivingAConfigContainingTheArbiterViaHeartbeat) {
logger::globalLogDomain()->setMinimumLoggedSeverity(logger::LogSeverity::Debug(3));
- ReplicaSetConfig rsConfig =
- assertMakeRSConfig(BSON("_id"
- << "mySet"
- << "version" << 3 << "members"
- << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "h1:1")
- << BSON("_id" << 2 << "host"
- << "h2:1"
- << "arbiterOnly" << true)
- << BSON("_id" << 3 << "host"
- << "h3:1")) << "protocolVersion" << 1));
+ ReplicaSetConfig rsConfig = assertMakeRSConfig(BSON("_id"
+ << "mySet"
+ << "version"
+ << 3
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "h1:1")
+ << BSON("_id" << 2 << "host"
+ << "h2:1"
+ << "arbiterOnly"
+ << true)
+ << BSON("_id" << 3 << "host"
+ << "h3:1"))
+ << "protocolVersion"
+ << 1));
init("mySet");
addSelf(HostAndPort("h2", 1));
const Date_t startDate = getNet()->now();
@@ -217,16 +224,19 @@ TEST_F(ReplCoordHBV1Test,
// 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 =
- 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"))
- << "protocolVersion" << 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"))
+ << "protocolVersion"
+ << 1));
init("mySet");
addSelf(HostAndPort("h4", 1));
const Date_t startDate = getNet()->now();
@@ -296,7 +306,9 @@ TEST_F(ReplCoordHBV1Test,
logger::globalLogDomain()->setMinimumLoggedSeverity(logger::LogSeverity::Debug(3));
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -309,12 +321,12 @@ TEST_F(ReplCoordHBV1Test,
const NetworkInterfaceMock::NetworkOperationIterator noi = getNet()->getNextReadyRequest();
const RemoteCommandRequest& request = noi->getRequest();
log() << request.target.toString() << " processing " << request.cmdObj;
- getNet()->scheduleResponse(
- noi,
- getNet()->now(),
- makeResponseStatus(BSON("ok" << 0.0 << "errmsg"
- << "unauth'd"
- << "code" << ErrorCodes::Unauthorized)));
+ getNet()->scheduleResponse(noi,
+ getNet()->now(),
+ makeResponseStatus(BSON("ok" << 0.0 << "errmsg"
+ << "unauth'd"
+ << "code"
+ << ErrorCodes::Unauthorized)));
if (request.target != HostAndPort("node2", 12345) &&
request.cmdObj.firstElement().fieldNameStringData() != "replSetHeartbeat") {
@@ -331,10 +343,9 @@ TEST_F(ReplCoordHBV1Test,
TEST_F(ReplCoordHBV1Test, ArbiterRecordsCommittedOpTimeFromHeartbeatMetadata) {
// Tests that an arbiter will update its committed optime from the heartbeat metadata
- assertStartSuccess(fromjson(
- "{_id:'mySet', version:1, protocolVersion:1, members:["
- "{_id:1, host:'node1:12345', arbiterOnly:true}, "
- "{_id:2, host:'node2:12345'}]}"),
+ assertStartSuccess(fromjson("{_id:'mySet', version:1, protocolVersion:1, members:["
+ "{_id:1, host:'node1:12345', arbiterOnly:true}, "
+ "{_id:2, host:'node2:12345'}]}"),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_ARBITER));
@@ -342,14 +353,21 @@ TEST_F(ReplCoordHBV1Test, ArbiterRecordsCommittedOpTimeFromHeartbeatMetadata) {
// its current optime to 'expected'
auto test = [this](OpTime committedOpTime, OpTime expected) {
// process heartbeat metadata directly
- StatusWith<rpc::ReplSetMetadata> metadata = rpc::ReplSetMetadata::readFromMetadata(BSON(
- rpc::kReplSetMetadataFieldName
- << BSON("lastOpCommitted" << BSON("ts" << committedOpTime.getTimestamp() << "t"
- << committedOpTime.getTerm()) << "lastOpVisible"
- << BSON("ts" << committedOpTime.getTimestamp() << "t"
- << committedOpTime.getTerm()) << "configVersion"
- << 1 << "primaryIndex" << 1 << "term"
- << committedOpTime.getTerm() << "syncSourceIndex" << 1)));
+ StatusWith<rpc::ReplSetMetadata> metadata = rpc::ReplSetMetadata::readFromMetadata(
+ BSON(rpc::kReplSetMetadataFieldName
+ << BSON("lastOpCommitted" << BSON("ts" << committedOpTime.getTimestamp() << "t"
+ << committedOpTime.getTerm())
+ << "lastOpVisible"
+ << BSON("ts" << committedOpTime.getTimestamp() << "t"
+ << committedOpTime.getTerm())
+ << "configVersion"
+ << 1
+ << "primaryIndex"
+ << 1
+ << "term"
+ << committedOpTime.getTerm()
+ << "syncSourceIndex"
+ << 1)));
ASSERT_OK(metadata.getStatus());
getReplCoord()->processReplSetMetadata(metadata.getValue());
@@ -368,11 +386,15 @@ TEST_F(ReplCoordHBV1Test, IgnoreTheContentsOfMetadataWhenItsReplicaSetIdDoesNotM
HostAndPort host2("node2:12345");
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host" << host2.toString()))
- << "settings" << BSON("replicaSetId" << OID::gen()) << "protocolVersion"
+ << "settings"
+ << BSON("replicaSetId" << OID::gen())
+ << "protocolVersion"
<< 1),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
@@ -438,9 +460,10 @@ TEST_F(ReplCoordHBV1Test, IgnoreTheContentsOfMetadataWhenItsReplicaSetIdDoesNotM
ASSERT_EQ(MemberState(MemberState::RS_DOWN).toString(),
MemberState(member["state"].numberInt()).toString());
ASSERT_EQ(member["lastHeartbeatMessage"].String(),
- std::string(str::stream()
- << "replica set IDs do not match, ours: " << rsConfig.getReplicaSetId()
- << "; remote node's: " << unexpectedId));
+ std::string(str::stream() << "replica set IDs do not match, ours: "
+ << rsConfig.getReplicaSetId()
+ << "; remote node's: "
+ << unexpectedId));
}
} // namespace
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 5c97e3bc976..e91aa8cb1e0 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp
@@ -35,10 +35,10 @@
#include "mongo/db/repl/repl_set_heartbeat_args.h"
#include "mongo/db/repl/repl_set_heartbeat_response.h"
#include "mongo/db/repl/replica_set_config.h"
+#include "mongo/db/repl/replication_coordinator.h" // ReplSetReconfigArgs
#include "mongo/db/repl/replication_coordinator_external_state_mock.h"
#include "mongo/db/repl/replication_coordinator_impl.h"
#include "mongo/db/repl/replication_coordinator_test_fixture.h"
-#include "mongo/db/repl/replication_coordinator.h" // ReplSetReconfigArgs
#include "mongo/executor/network_interface_mock.h"
#include "mongo/unittest/unittest.h"
#include "mongo/util/log.h"
@@ -72,7 +72,9 @@ TEST_F(ReplCoordTest, NodeReturnsNotMasterWhenReconfigReceivedWhileSecondary) {
init();
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -96,7 +98,9 @@ TEST_F(ReplCoordTest, NodeReturnsInvalidReplicaSetConfigWhenReconfigReceivedWith
OperationContextNoop txn;
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -112,13 +116,19 @@ TEST_F(ReplCoordTest, NodeReturnsInvalidReplicaSetConfigWhenReconfigReceivedWith
args.force = false;
args.newConfigObj = BSON("_id"
<< "mySet"
- << "version" << 2 << "invalidlyNamedField" << 3 << "members"
+ << "version"
+ << 2
+ << "invalidlyNamedField"
+ << 3
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345"
- << "arbiterOnly" << true)
+ << "arbiterOnly"
+ << true)
<< BSON("_id" << 2 << "host"
<< "node2:12345"
- << "arbiterOnly" << true)));
+ << "arbiterOnly"
+ << true)));
// ErrorCodes::BadValue should be propagated from ReplicaSetConfig::initialize()
ASSERT_EQUALS(ErrorCodes::InvalidReplicaSetConfig,
getReplCoord()->processReplSetReconfig(&txn, args, &result));
@@ -130,7 +140,9 @@ TEST_F(ReplCoordTest, NodeReturnsInvalidReplicaSetConfigWhenReconfigReceivedWith
OperationContextNoop txn;
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -146,7 +158,9 @@ TEST_F(ReplCoordTest, NodeReturnsInvalidReplicaSetConfigWhenReconfigReceivedWith
args.force = false;
args.newConfigObj = BSON("_id"
<< "notMySet"
- << "version" << 3 << "members"
+ << "version"
+ << 3
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -162,11 +176,14 @@ TEST_F(ReplCoordTest, NodeReturnsInvalidReplicaSetConfigWhenReconfigReceivedWith
OperationContextNoop txn;
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
- << "node2:12345")) << "settings"
+ << "node2:12345"))
+ << "settings"
<< BSON("replicaSetId" << OID::gen())),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
@@ -179,11 +196,14 @@ TEST_F(ReplCoordTest, NodeReturnsInvalidReplicaSetConfigWhenReconfigReceivedWith
args.force = false;
args.newConfigObj = BSON("_id"
<< "mySet"
- << "version" << 3 << "members"
+ << "version"
+ << 3
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
- << "node2:12345")) << "settings"
+ << "node2:12345"))
+ << "settings"
<< BSON("replicaSetId" << OID::gen()));
ASSERT_EQUALS(ErrorCodes::NewReplicaSetConfigurationIncompatible,
@@ -197,7 +217,9 @@ TEST_F(ReplCoordTest,
OperationContextNoop txn;
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -213,7 +235,9 @@ TEST_F(ReplCoordTest,
args.force = false;
args.newConfigObj = BSON("_id"
<< "mySet"
- << "version" << -3 << "members"
+ << "version"
+ << -3
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -231,7 +255,9 @@ void doReplSetInitiate(ReplicationCoordinatorImpl* replCoord, Status* status) {
replCoord->processReplSetInitiate(&txn,
BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -247,12 +273,15 @@ void doReplSetReconfig(ReplicationCoordinatorImpl* replCoord, Status* status) {
// Replica set id will be copied from existing configuration.
args.newConfigObj = BSON("_id"
<< "mySet"
- << "version" << 3 << "members"
+ << "version"
+ << 3
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
<< "node2:12345"
- << "priority" << 3)));
+ << "priority"
+ << 3)));
*status = replCoord->processReplSetReconfig(&txn, args, &garbage);
}
@@ -263,7 +292,9 @@ TEST_F(ReplCoordTest,
OperationContextNoop txn;
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -302,7 +333,9 @@ TEST_F(ReplCoordTest, NodeReturnsOutOfDiskSpaceWhenSavingANewConfigFailsDuringRe
OperationContextNoop txn;
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -329,7 +362,9 @@ TEST_F(ReplCoordTest,
OperationContextNoop txn;
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -353,7 +388,9 @@ TEST_F(ReplCoordTest,
args.force = false;
args.newConfigObj = BSON("_id"
<< "mySet"
- << "version" << 3 << "members"
+ << "version"
+ << 3
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -389,7 +426,9 @@ TEST_F(ReplCoordTest, NodeReturnsConfigurationInProgressWhenReceivingAReconfigWh
args.force = false;
args.newConfigObj = BSON("_id"
<< "mySet"
- << "version" << 3 << "members"
+ << "version"
+ << 3
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -408,11 +447,14 @@ TEST_F(ReplCoordTest, PrimaryNodeAcceptsNewConfigWhenReceivingAReconfigWithAComp
OperationContextNoop txn;
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
- << "node2:12345")) << "settings"
+ << "node2:12345"))
+ << "settings"
<< BSON("replicaSetId" << OID::gen())),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
@@ -451,7 +493,9 @@ TEST_F(
OperationContextNoop txn;
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -473,7 +517,9 @@ TEST_F(
ReplicaSetConfig config;
config.initialize(BSON("_id"
<< "mySet"
- << "version" << 3 << "members"
+ << "version"
+ << 3
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -507,7 +553,9 @@ TEST_F(ReplCoordTest, NodeDoesNotAcceptHeartbeatReconfigWhileInTheMidstOfReconfi
OperationContextNoop txn;
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -536,7 +584,9 @@ TEST_F(ReplCoordTest, NodeDoesNotAcceptHeartbeatReconfigWhileInTheMidstOfReconfi
ReplicaSetConfig config;
config.initialize(BSON("_id"
<< "mySet"
- << "version" << 4 << "members"
+ << "version"
+ << 4
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -570,7 +620,9 @@ TEST_F(ReplCoordTest, NodeAcceptsConfigFromAReconfigWithForceTrueWhileNotPrimary
init();
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -586,7 +638,9 @@ TEST_F(ReplCoordTest, NodeAcceptsConfigFromAReconfigWithForceTrueWhileNotPrimary
args.force = false;
args.newConfigObj = BSON("_id"
<< "mySet"
- << "version" << 3 << "members"
+ << "version"
+ << 3
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
diff --git a/src/mongo/db/repl/replication_coordinator_impl_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_test.cpp
index 41bbb2a2d4b..0343865aa6c 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_test.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_test.cpp
@@ -37,8 +37,8 @@
#include "mongo/bson/util/bson_extract.h"
#include "mongo/db/operation_context_noop.h"
-#include "mongo/db/repl/handshake_args.h"
#include "mongo/db/repl/bson_extract_optime.h"
+#include "mongo/db/repl/handshake_args.h"
#include "mongo/db/repl/is_master_response.h"
#include "mongo/db/repl/old_update_position_args.h"
#include "mongo/db/repl/optime.h"
@@ -112,7 +112,9 @@ void runSingleNodeElection(ServiceContext::UniqueOperationContext txn,
TEST_F(ReplCoordTest, NodeEntersStartup2StateWhenStartingUpWithValidLocalConfig) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345"))),
HostAndPort("node1", 12345));
@@ -123,10 +125,13 @@ TEST_F(ReplCoordTest, NodeEntersStartup2StateWhenStartingUpWithValidLocalConfig)
TEST_F(ReplCoordTest, NodeEntersArbiterStateWhenStartingUpWithValidLocalConfigWhereItIsAnArbiter) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345"
- << "arbiterOnly" << true)
+ << "arbiterOnly"
+ << true)
<< BSON("_id" << 2 << "host"
<< "node2:12345"))),
HostAndPort("node1", 12345));
@@ -138,7 +143,9 @@ TEST_F(ReplCoordTest, NodeEntersRemovedStateWhenStartingUpWithALocalConfigWhichL
startCapturingLogMessages();
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -155,7 +162,9 @@ TEST_F(ReplCoordTest,
startCapturingLogMessages();
assertStartSuccess(BSON("_id"
<< "notMySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345"))),
HostAndPort("node1", 12345));
@@ -195,7 +204,9 @@ TEST_F(ReplCoordTest,
getReplCoord()->processReplSetInitiate(&txn,
BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "node1:12345"))),
&result1));
@@ -209,7 +220,9 @@ TEST_F(ReplCoordTest,
getReplCoord()->processReplSetInitiate(&txn,
BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "node1:12345"))),
&result2));
@@ -227,16 +240,20 @@ TEST_F(ReplCoordTest,
// Starting uninitialized, show that we can perform the initiate behavior.
BSONObjBuilder result1;
- auto status = getReplCoord()->processReplSetInitiate(
- &txn,
- BSON("_id"
- << "mySet"
- << "version" << 1 << "members" << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "node1:12345"
- << "arbiterOnly" << true)
- << BSON("_id" << 1 << "host"
- << "node2:12345"))),
- &result1);
+ auto status =
+ getReplCoord()->processReplSetInitiate(&txn,
+ BSON("_id"
+ << "mySet"
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "node1:12345"
+ << "arbiterOnly"
+ << true)
+ << BSON("_id" << 1 << "host"
+ << "node2:12345"))),
+ &result1);
ASSERT_EQUALS(ErrorCodes::InvalidReplicaSetConfig, status);
ASSERT_STRING_CONTAINS(status.reason(), "is not electable under the new configuration version");
ASSERT_FALSE(getExternalState()->threadsStarted());
@@ -258,7 +275,9 @@ TEST_F(ReplCoordTest,
getReplCoord()->processReplSetInitiate(&txn,
BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "node1:12345"))),
&result1));
@@ -276,7 +295,9 @@ TEST_F(ReplCoordTest,
getReplCoord()->processReplSetInitiate(&txn,
BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "node4"))),
&result));
@@ -289,7 +310,9 @@ void doReplSetInitiate(ReplicationCoordinatorImpl* replCoord, Status* status) {
replCoord->processReplSetInitiate(&txn,
BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "node1:12345")
<< BSON("_id" << 1 << "host"
@@ -376,7 +399,9 @@ TEST_F(ReplCoordTest,
getReplCoord()->processReplSetInitiate(&txn,
BSON("_id"
<< "wrongSet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "node1:12345"))),
&result1));
@@ -425,7 +450,9 @@ TEST_F(ReplCoordTest,
getReplCoord()->processReplSetInitiate(&txn,
BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "node1:12345"))),
&result1);
@@ -446,7 +473,9 @@ TEST_F(ReplCoordTest, InitiateFailsWithoutReplSetFlag) {
getReplCoord()->processReplSetInitiate(&txn,
BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "node1:12345"))),
&result1));
@@ -467,7 +496,9 @@ TEST_F(ReplCoordTest, NodeReturnsOutOfDiskSpaceWhenInitiateCannotWriteConfigToDi
getReplCoord()->processReplSetInitiate(&txn,
BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "node1:12345"))),
&result1));
@@ -519,9 +550,13 @@ TEST_F(
TEST_F(ReplCoordTest, NodeReturnsOkWhenCheckReplEnabledForCommandAfterReceivingAConfig) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members" << BSON_ARRAY(BSON("host"
- << "node1:12345"
- << "_id" << 0))),
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("host"
+ << "node1:12345"
+ << "_id"
+ << 0))),
HostAndPort("node1", 12345));
// check status OK and result is empty
@@ -580,15 +615,21 @@ TEST_F(ReplCoordTest, NodeReturnsImmediatelyWhenAwaitReplicationIsRanAgainstAMas
TEST_F(ReplCoordTest, NodeReturnsNotMasterWhenRunningAwaitReplicationAgainstASecondaryNode) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id" << 0)
+ << "_id"
+ << 0)
<< BSON("host"
<< "node2:12345"
- << "_id" << 1) << BSON("host"
- << "node3:12345"
- << "_id" << 2))),
+ << "_id"
+ << 1)
+ << BSON("host"
+ << "node3:12345"
+ << "_id"
+ << 2))),
HostAndPort("node1", 12345));
OperationContextNoop txn;
@@ -608,15 +649,21 @@ TEST_F(ReplCoordTest, NodeReturnsNotMasterWhenRunningAwaitReplicationAgainstASec
TEST_F(ReplCoordTest, NodeReturnsOkWhenRunningAwaitReplicationAgainstPrimaryWithWZero) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id" << 0)
+ << "_id"
+ << 0)
<< BSON("host"
<< "node2:12345"
- << "_id" << 1) << BSON("host"
- << "node3:12345"
- << "_id" << 2))),
+ << "_id"
+ << 1)
+ << BSON("host"
+ << "node3:12345"
+ << "_id"
+ << 2))),
HostAndPort("node1", 12345));
OperationContextNoop txn;
@@ -644,21 +691,28 @@ TEST_F(ReplCoordTest, NodeReturnsOkWhenRunningAwaitReplicationAgainstPrimaryWith
TEST_F(ReplCoordTest,
NodeReturnsWriteConcernFailedUntilASufficientNumberOfNodesHaveTheWriteDurable) {
OperationContextNoop txn;
- assertStartSuccess(
- BSON("_id"
- << "mySet"
- << "version" << 2 << "members"
- << BSON_ARRAY(BSON("host"
- << "node1:12345"
- << "_id" << 0)
- << BSON("host"
- << "node2:12345"
- << "_id" << 1) << BSON("host"
- << "node3:12345"
- << "_id" << 2) << BSON("host"
- << "node4:12345"
- << "_id" << 3))),
- HostAndPort("node1", 12345));
+ assertStartSuccess(BSON("_id"
+ << "mySet"
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("host"
+ << "node1:12345"
+ << "_id"
+ << 0)
+ << BSON("host"
+ << "node2:12345"
+ << "_id"
+ << 1)
+ << BSON("host"
+ << "node3:12345"
+ << "_id"
+ << 2)
+ << BSON("host"
+ << "node4:12345"
+ << "_id"
+ << 3))),
+ HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastAppliedOpTime(OpTimeWithTermZero(100, 0));
getReplCoord()->setMyLastDurableOpTime(OpTimeWithTermZero(100, 0));
@@ -717,21 +771,28 @@ TEST_F(ReplCoordTest,
TEST_F(ReplCoordTest, NodeReturnsWriteConcernFailedUntilASufficientNumberOfNodesHaveTheWrite) {
OperationContextNoop txn;
- assertStartSuccess(
- BSON("_id"
- << "mySet"
- << "version" << 2 << "members"
- << BSON_ARRAY(BSON("host"
- << "node1:12345"
- << "_id" << 0)
- << BSON("host"
- << "node2:12345"
- << "_id" << 1) << BSON("host"
- << "node3:12345"
- << "_id" << 2) << BSON("host"
- << "node4:12345"
- << "_id" << 3))),
- HostAndPort("node1", 12345));
+ assertStartSuccess(BSON("_id"
+ << "mySet"
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("host"
+ << "node1:12345"
+ << "_id"
+ << 0)
+ << BSON("host"
+ << "node2:12345"
+ << "_id"
+ << 1)
+ << BSON("host"
+ << "node3:12345"
+ << "_id"
+ << 2)
+ << BSON("host"
+ << "node4:12345"
+ << "_id"
+ << 3))),
+ HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastAppliedOpTime(OpTimeWithTermZero(100, 0));
getReplCoord()->setMyLastDurableOpTime(OpTimeWithTermZero(100, 0));
@@ -790,15 +851,19 @@ TEST_F(ReplCoordTest,
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "node0")
<< BSON("_id" << 1 << "host"
- << "node1") << BSON("_id" << 2 << "host"
- << "node2")
+ << "node1")
+ << BSON("_id" << 2 << "host"
+ << "node2")
<< BSON("_id" << 3 << "host"
- << "node3") << BSON("_id" << 4 << "host"
- << "node4"))),
+ << "node3")
+ << BSON("_id" << 4 << "host"
+ << "node4"))),
HostAndPort("node0"));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastAppliedOpTime(OpTime(Timestamp(100, 0), 0));
@@ -828,37 +893,45 @@ TEST_F(
assertStartSuccess(
BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "node0"
- << "tags" << BSON("dc"
- << "NA"
- << "rack"
- << "rackNA1"))
+ << "tags"
+ << BSON("dc"
+ << "NA"
+ << "rack"
+ << "rackNA1"))
<< BSON("_id" << 1 << "host"
<< "node1"
- << "tags" << BSON("dc"
- << "NA"
- << "rack"
- << "rackNA2"))
+ << "tags"
+ << BSON("dc"
+ << "NA"
+ << "rack"
+ << "rackNA2"))
<< BSON("_id" << 2 << "host"
<< "node2"
- << "tags" << BSON("dc"
- << "NA"
- << "rack"
- << "rackNA3"))
+ << "tags"
+ << BSON("dc"
+ << "NA"
+ << "rack"
+ << "rackNA3"))
<< BSON("_id" << 3 << "host"
<< "node3"
- << "tags" << BSON("dc"
- << "EU"
- << "rack"
- << "rackEU1"))
+ << "tags"
+ << BSON("dc"
+ << "EU"
+ << "rack"
+ << "rackEU1"))
<< BSON("_id" << 4 << "host"
<< "node4"
- << "tags" << BSON("dc"
- << "EU"
- << "rack"
- << "rackEU2"))) << "settings"
+ << "tags"
+ << BSON("dc"
+ << "EU"
+ << "rack"
+ << "rackEU2")))
+ << "settings"
<< BSON("getLastErrorModes" << BSON("multiDC" << BSON("dc" << 2) << "multiDCAndRack"
<< BSON("dc" << 2 << "rack" << 3)))),
HostAndPort("node0"));
@@ -1020,15 +1093,21 @@ TEST_F(ReplCoordTest, NodeReturnsOkWhenAWriteConcernWithNoTimeoutHasBeenSatisfie
OperationContextNoop txn;
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id" << 0)
+ << "_id"
+ << 0)
<< BSON("host"
<< "node2:12345"
- << "_id" << 1) << BSON("host"
- << "node3:12345"
- << "_id" << 2))),
+ << "_id"
+ << 1)
+ << BSON("host"
+ << "node3:12345"
+ << "_id"
+ << 2))),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastAppliedOpTime(OpTimeWithTermZero(100, 0));
@@ -1079,15 +1158,21 @@ TEST_F(ReplCoordTest, NodeReturnsWriteConcernFailedWhenAWriteConcernTimesOutBefo
OperationContextNoop txn;
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id" << 0)
+ << "_id"
+ << 0)
<< BSON("host"
<< "node2:12345"
- << "_id" << 1) << BSON("host"
- << "node3:12345"
- << "_id" << 2))),
+ << "_id"
+ << 1)
+ << BSON("host"
+ << "node3:12345"
+ << "_id"
+ << 2))),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastAppliedOpTime(OpTimeWithTermZero(100, 0));
@@ -1120,15 +1205,21 @@ TEST_F(ReplCoordTest,
OperationContextNoop txn;
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id" << 0)
+ << "_id"
+ << 0)
<< BSON("host"
<< "node2:12345"
- << "_id" << 1) << BSON("host"
- << "node3:12345"
- << "_id" << 2))),
+ << "_id"
+ << 1)
+ << BSON("host"
+ << "node3:12345"
+ << "_id"
+ << 2))),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastAppliedOpTime(OpTimeWithTermZero(100, 0));
@@ -1161,15 +1252,21 @@ TEST_F(ReplCoordTest, NodeReturnsNotMasterWhenSteppingDownBeforeSatisfyingAWrite
// if the node steps down while it is waiting.
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id" << 0)
+ << "_id"
+ << 0)
<< BSON("host"
<< "node2:12345"
- << "_id" << 1) << BSON("host"
- << "node3:12345"
- << "_id" << 2))),
+ << "_id"
+ << 1)
+ << BSON("host"
+ << "node3:12345"
+ << "_id"
+ << 2))),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastAppliedOpTime(OpTimeWithTermZero(100, 0));
@@ -1203,12 +1300,15 @@ TEST_F(ReplCoordTest,
// Tests that a thread blocked in awaitReplication can be killed by a killOp operation
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "node1")
<< BSON("_id" << 1 << "host"
- << "node2") << BSON("_id" << 2 << "host"
- << "node3"))),
+ << "node2")
+ << BSON("_id" << 2 << "host"
+ << "node3"))),
HostAndPort("node1"));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastAppliedOpTime(OpTimeWithTermZero(100, 0));
@@ -1254,7 +1354,9 @@ private:
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "test1:1234")
<< BSON("_id" << 1 << "host"
@@ -1277,17 +1379,20 @@ TEST_F(ReplCoordTest, NodeReturnsBadValueWhenUpdateTermIsRunAgainstANonReplNode)
TEST_F(ReplCoordTest, NodeChangesTermAndStepsDownWhenAndOnlyWhenUpdateTermSuppliesAHigherTerm) {
init("mySet/test1:1234,test2:1234,test3:1234");
- assertStartSuccess(
- BSON("_id"
- << "mySet"
- << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "test1:1234")
- << BSON("_id" << 1 << "host"
- << "test2:1234") << BSON("_id" << 2 << "host"
- << "test3:1234"))
- << "protocolVersion" << 1),
- HostAndPort("test1", 1234));
+ assertStartSuccess(BSON("_id"
+ << "mySet"
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "test1:1234")
+ << BSON("_id" << 1 << "host"
+ << "test2:1234")
+ << BSON("_id" << 2 << "host"
+ << "test3:1234"))
+ << "protocolVersion"
+ << 1),
+ HostAndPort("test1", 1234));
getReplCoord()->setMyLastAppliedOpTime(OpTime(Timestamp(100, 1), 0));
getReplCoord()->setMyLastDurableOpTime(OpTime(Timestamp(100, 1), 0));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
@@ -1324,17 +1429,20 @@ TEST_F(ReplCoordTest, NodeChangesTermAndStepsDownWhenAndOnlyWhenUpdateTermSuppli
TEST_F(ReplCoordTest, ConcurrentStepDownShouldNotSignalTheSameFinishEventMoreThanOnce) {
init("mySet/test1:1234,test2:1234,test3:1234");
- assertStartSuccess(
- BSON("_id"
- << "mySet"
- << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "test1:1234")
- << BSON("_id" << 1 << "host"
- << "test2:1234") << BSON("_id" << 2 << "host"
- << "test3:1234"))
- << "protocolVersion" << 1),
- HostAndPort("test1", 1234));
+ assertStartSuccess(BSON("_id"
+ << "mySet"
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "test1:1234")
+ << BSON("_id" << 1 << "host"
+ << "test2:1234")
+ << BSON("_id" << 2 << "host"
+ << "test3:1234"))
+ << "protocolVersion"
+ << 1),
+ HostAndPort("test1", 1234));
getReplCoord()->setMyLastAppliedOpTime(OpTime(Timestamp(100, 1), 0));
getReplCoord()->setMyLastDurableOpTime(OpTime(Timestamp(100, 1), 0));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
@@ -1484,7 +1592,9 @@ TEST_F(ReplCoordTest, NodeBecomesPrimaryAgainWhenStepDownTimeoutExpiresInASingle
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "test1:1234"))),
HostAndPort("test1", 1234));
@@ -1759,27 +1869,33 @@ TEST_F(ReplCoordTest,
ASSERT_EQUALS(MemberState::RS_STARTUP, getReplCoord()->getMemberState().s);
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members" << BSON_ARRAY(BSON("host"
- << "node1:12345"
- << "_id" << 0))),
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("host"
+ << "node1:12345"
+ << "_id"
+ << 0))),
HostAndPort("node1", 12345));
}
TEST_F(ReplCoordTest, NodeIncludesOtherMembersProgressInUpdatePositionCommand) {
OperationContextNoop txn;
init("mySet/test1:1234,test2:1234,test3:1234");
- assertStartSuccess(
- BSON("_id"
- << "mySet"
- << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "test1:1234")
- << BSON("_id" << 1 << "host"
- << "test2:1234") << BSON("_id" << 2 << "host"
- << "test3:1234")
- << BSON("_id" << 3 << "host"
- << "test4:1234"))),
- HostAndPort("test1", 1234));
+ assertStartSuccess(BSON("_id"
+ << "mySet"
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "test1:1234")
+ << BSON("_id" << 1 << "host"
+ << "test2:1234")
+ << BSON("_id" << 2 << "host"
+ << "test3:1234")
+ << BSON("_id" << 3 << "host"
+ << "test4:1234"))),
+ HostAndPort("test1", 1234));
OpTime optime1({2, 1}, 1);
OpTime optime2({100, 1}, 1);
OpTime optime3({100, 2}, 1);
@@ -1846,16 +1962,18 @@ TEST_F(ReplCoordTest, NodeIncludesOtherMembersProgressInUpdatePositionCommand) {
TEST_F(ReplCoordTest, NodeIncludesOtherMembersProgressInOldUpdatePositionCommand) {
OperationContextNoop txn;
init("mySet/test1:1234,test2:1234,test3:1234");
- assertStartSuccess(
- BSON("_id"
- << "mySet"
- << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "test1:1234")
- << BSON("_id" << 1 << "host"
- << "test2:1234") << BSON("_id" << 2 << "host"
- << "test3:1234"))),
- HostAndPort("test1", 1234));
+ assertStartSuccess(BSON("_id"
+ << "mySet"
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "test1:1234")
+ << BSON("_id" << 1 << "host"
+ << "test2:1234")
+ << BSON("_id" << 2 << "host"
+ << "test3:1234"))),
+ HostAndPort("test1", 1234));
OpTimeWithTermZero optime1(100, 1);
OpTimeWithTermZero optime2(100, 2);
OpTimeWithTermZero optime3(2, 1);
@@ -1899,16 +2017,20 @@ TEST_F(ReplCoordTest, NodeIncludesOtherMembersProgressInOldUpdatePositionCommand
TEST_F(ReplCoordTest,
NodeReturnsOperationFailedWhenSettingMaintenanceModeFalseWhenItHasNotBeenSetTrue) {
init("mySet/test1:1234,test2:1234,test3:1234");
- assertStartSuccess(
- BSON("_id"
- << "mySet"
- << "protocolVersion" << 1 << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "test1:1234")
- << BSON("_id" << 1 << "host"
- << "test2:1234") << BSON("_id" << 2 << "host"
- << "test3:1234"))),
- HostAndPort("test2", 1234));
+ assertStartSuccess(BSON("_id"
+ << "mySet"
+ << "protocolVersion"
+ << 1
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "test1:1234")
+ << BSON("_id" << 1 << "host"
+ << "test2:1234")
+ << BSON("_id" << 2 << "host"
+ << "test3:1234"))),
+ HostAndPort("test2", 1234));
OperationContextNoop txn;
getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY);
getReplCoord()->setMyLastAppliedOpTime(OpTimeWithTermZero(100, 0));
@@ -1923,16 +2045,20 @@ TEST_F(ReplCoordTest,
TEST_F(ReplCoordTest,
ReportRollbackWhileInBothRollbackAndMaintenanceModeAndRecoveryAfterFinishingRollback) {
init("mySet/test1:1234,test2:1234,test3:1234");
- assertStartSuccess(
- BSON("_id"
- << "mySet"
- << "protocolVersion" << 1 << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "test1:1234")
- << BSON("_id" << 1 << "host"
- << "test2:1234") << BSON("_id" << 2 << "host"
- << "test3:1234"))),
- HostAndPort("test2", 1234));
+ assertStartSuccess(BSON("_id"
+ << "mySet"
+ << "protocolVersion"
+ << 1
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "test1:1234")
+ << BSON("_id" << 1 << "host"
+ << "test2:1234")
+ << BSON("_id" << 2 << "host"
+ << "test3:1234"))),
+ HostAndPort("test2", 1234));
OperationContextNoop txn;
getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY);
getReplCoord()->setMyLastAppliedOpTime(OpTimeWithTermZero(100, 0));
@@ -1952,16 +2078,20 @@ TEST_F(ReplCoordTest,
TEST_F(ReplCoordTest, AllowAsManyUnsetMaintenanceModesAsThereHaveBeenSetMaintenanceModes) {
init("mySet/test1:1234,test2:1234,test3:1234");
- assertStartSuccess(
- BSON("_id"
- << "mySet"
- << "protocolVersion" << 1 << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "test1:1234")
- << BSON("_id" << 1 << "host"
- << "test2:1234") << BSON("_id" << 2 << "host"
- << "test3:1234"))),
- HostAndPort("test2", 1234));
+ assertStartSuccess(BSON("_id"
+ << "mySet"
+ << "protocolVersion"
+ << 1
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "test1:1234")
+ << BSON("_id" << 1 << "host"
+ << "test2:1234")
+ << BSON("_id" << 2 << "host"
+ << "test3:1234"))),
+ HostAndPort("test2", 1234));
OperationContextNoop txn;
getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY);
getReplCoord()->setMyLastAppliedOpTime(OpTimeWithTermZero(100, 0));
@@ -1983,16 +2113,20 @@ TEST_F(ReplCoordTest, AllowAsManyUnsetMaintenanceModesAsThereHaveBeenSetMaintena
TEST_F(ReplCoordTest, SettingAndUnsettingMaintenanceModeShouldNotAffectRollbackState) {
init("mySet/test1:1234,test2:1234,test3:1234");
- assertStartSuccess(
- BSON("_id"
- << "mySet"
- << "protocolVersion" << 1 << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "test1:1234")
- << BSON("_id" << 1 << "host"
- << "test2:1234") << BSON("_id" << 2 << "host"
- << "test3:1234"))),
- HostAndPort("test2", 1234));
+ assertStartSuccess(BSON("_id"
+ << "mySet"
+ << "protocolVersion"
+ << 1
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "test1:1234")
+ << BSON("_id" << 1 << "host"
+ << "test2:1234")
+ << BSON("_id" << 2 << "host"
+ << "test3:1234"))),
+ HostAndPort("test2", 1234));
OperationContextNoop txn;
getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY);
getReplCoord()->setMyLastAppliedOpTime(OpTimeWithTermZero(100, 0));
@@ -2022,16 +2156,20 @@ TEST_F(ReplCoordTest, SettingAndUnsettingMaintenanceModeShouldNotAffectRollbackS
TEST_F(ReplCoordTest, DoNotAllowMaintenanceModeWhilePrimary) {
init("mySet/test1:1234,test2:1234,test3:1234");
- assertStartSuccess(
- BSON("_id"
- << "mySet"
- << "protocolVersion" << 1 << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "test1:1234")
- << BSON("_id" << 1 << "host"
- << "test2:1234") << BSON("_id" << 2 << "host"
- << "test3:1234"))),
- HostAndPort("test2", 1234));
+ assertStartSuccess(BSON("_id"
+ << "mySet"
+ << "protocolVersion"
+ << 1
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "test1:1234")
+ << BSON("_id" << 1 << "host"
+ << "test2:1234")
+ << BSON("_id" << 2 << "host"
+ << "test3:1234"))),
+ HostAndPort("test2", 1234));
OperationContextNoop txn;
getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY);
getReplCoord()->setMyLastAppliedOpTime(OpTimeWithTermZero(100, 0));
@@ -2055,16 +2193,20 @@ TEST_F(ReplCoordTest, DoNotAllowMaintenanceModeWhilePrimary) {
TEST_F(ReplCoordTest, DoNotAllowSettingMaintenanceModeWhileConductingAnElection) {
init("mySet/test1:1234,test2:1234,test3:1234");
- assertStartSuccess(
- BSON("_id"
- << "mySet"
- << "protocolVersion" << 1 << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "test1:1234")
- << BSON("_id" << 1 << "host"
- << "test2:1234") << BSON("_id" << 2 << "host"
- << "test3:1234"))),
- HostAndPort("test2", 1234));
+ assertStartSuccess(BSON("_id"
+ << "mySet"
+ << "protocolVersion"
+ << 1
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "test1:1234")
+ << BSON("_id" << 1 << "host"
+ << "test2:1234")
+ << BSON("_id" << 2 << "host"
+ << "test3:1234"))),
+ HostAndPort("test2", 1234));
OperationContextNoop txn;
getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY);
getReplCoord()->setMyLastAppliedOpTime(OpTimeWithTermZero(100, 0));
@@ -2120,7 +2262,9 @@ TEST_F(ReplCoordTest,
HostAndPort client2Host("node3:12345");
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host" << myHost.toString())
<< BSON("_id" << 1 << "host" << client1Host.toString())
<< BSON("_id" << 2 << "host" << client2Host.toString()))),
@@ -2164,7 +2308,9 @@ TEST_F(ReplCoordTest,
HostAndPort client2Host("node3:12345");
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host" << myHost.toString())
<< BSON("_id" << 1 << "host" << client1Host.toString())
<< BSON("_id" << 2 << "host" << client2Host.toString()))),
@@ -2230,14 +2376,19 @@ TEST_F(ReplCoordTest, NodeReturnsNoNodesWhenGetOtherNodesInReplSetIsRunBeforeHav
TEST_F(ReplCoordTest, NodeReturnsListOfNodesOtherThanItselfInResponseToGetOtherNodesInReplSet) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "h1")
<< BSON("_id" << 1 << "host"
<< "h2")
<< BSON("_id" << 2 << "host"
<< "h3"
- << "priority" << 0 << "hidden" << true))),
+ << "priority"
+ << 0
+ << "hidden"
+ << true))),
HostAndPort("h1"));
std::vector<HostAndPort> otherNodes = getReplCoord()->getOtherNodesInReplSet();
@@ -2272,17 +2423,20 @@ TEST_F(ReplCoordTest, IsMaster) {
HostAndPort h3("h3");
HostAndPort h4("h4");
assertStartSuccess(
- BSON("_id"
- << "mySet"
- << "version" << 2 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host" << h1.toString())
- << BSON("_id" << 1 << "host" << h2.toString())
- << BSON("_id" << 2 << "host" << h3.toString() << "arbiterOnly" << true)
- << BSON("_id" << 3 << "host" << h4.toString() << "priority" << 0
- << "tags" << BSON("key1"
- << "value1"
- << "key2"
- << "value2")))),
+ BSON(
+ "_id"
+ << "mySet"
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host" << h1.toString())
+ << BSON("_id" << 1 << "host" << h2.toString())
+ << BSON("_id" << 2 << "host" << h3.toString() << "arbiterOnly" << true)
+ << BSON("_id" << 3 << "host" << h4.toString() << "priority" << 0 << "tags"
+ << BSON("key1"
+ << "value1"
+ << "key2"
+ << "value2")))),
h4);
getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY);
ASSERT_TRUE(getReplCoord()->getMemberState().secondary());
@@ -2337,7 +2491,9 @@ TEST_F(ReplCoordTest, IsMasterWithCommittedSnapshot) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "test1:1234"))),
HostAndPort("test1", 1234));
@@ -2374,15 +2530,21 @@ TEST_F(ReplCoordTest, DoNotProcessSelfWhenUpdatePositionContainsInfoAboutSelf) {
OperationContextNoop txn;
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id" << 0)
+ << "_id"
+ << 0)
<< BSON("host"
<< "node2:12345"
- << "_id" << 1) << BSON("host"
- << "node3:12345"
- << "_id" << 2))),
+ << "_id"
+ << 1)
+ << BSON("host"
+ << "node3:12345"
+ << "_id"
+ << 2))),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastAppliedOpTime(OpTimeWithTermZero(100, 0));
@@ -2405,9 +2567,12 @@ TEST_F(ReplCoordTest, DoNotProcessSelfWhenUpdatePositionContainsInfoAboutSelf) {
UpdatePositionArgs args;
ASSERT_OK(args.initialize(
BSON(UpdatePositionArgs::kCommandFieldName
- << 1 << UpdatePositionArgs::kUpdateArrayFieldName
+ << 1
+ << UpdatePositionArgs::kUpdateArrayFieldName
<< BSON_ARRAY(BSON(UpdatePositionArgs::kConfigVersionFieldName
- << 2 << UpdatePositionArgs::kMemberIdFieldName << 0
+ << 2
+ << UpdatePositionArgs::kMemberIdFieldName
+ << 0
<< UpdatePositionArgs::kDurableOpTimeFieldName
<< BSON("ts" << time2.getTimestamp() << "t" << 2)
<< UpdatePositionArgs::kAppliedOpTimeFieldName
@@ -2422,15 +2587,21 @@ TEST_F(ReplCoordTest, DoNotProcessSelfWhenOldUpdatePositionContainsInfoAboutSelf
OperationContextNoop txn;
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id" << 0)
+ << "_id"
+ << 0)
<< BSON("host"
<< "node2:12345"
- << "_id" << 1) << BSON("host"
- << "node3:12345"
- << "_id" << 2))),
+ << "_id"
+ << 1)
+ << BSON("host"
+ << "node3:12345"
+ << "_id"
+ << 2))),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastAppliedOpTime(OpTimeWithTermZero(100, 0));
@@ -2452,12 +2623,15 @@ TEST_F(ReplCoordTest, DoNotProcessSelfWhenOldUpdatePositionContainsInfoAboutSelf
// receive updatePosition containing ourself, should not process the update for self
OldUpdatePositionArgs args;
- ASSERT_OK(args.initialize(
- BSON(OldUpdatePositionArgs::kCommandFieldName
- << 1 << OldUpdatePositionArgs::kUpdateArrayFieldName
- << BSON_ARRAY(BSON(OldUpdatePositionArgs::kConfigVersionFieldName
- << 2 << OldUpdatePositionArgs::kMemberIdFieldName << 0
- << OldUpdatePositionArgs::kOpTimeFieldName << time2.timestamp)))));
+ ASSERT_OK(args.initialize(BSON(OldUpdatePositionArgs::kCommandFieldName
+ << 1
+ << OldUpdatePositionArgs::kUpdateArrayFieldName
+ << BSON_ARRAY(BSON(OldUpdatePositionArgs::kConfigVersionFieldName
+ << 2
+ << OldUpdatePositionArgs::kMemberIdFieldName
+ << 0
+ << OldUpdatePositionArgs::kOpTimeFieldName
+ << time2.timestamp)))));
ASSERT_OK(getReplCoord()->processReplSetUpdatePosition(args, 0));
ASSERT_EQUALS(ErrorCodes::WriteConcernFailed,
@@ -2468,15 +2642,21 @@ TEST_F(ReplCoordTest, DoNotProcessUpdatePositionWhenItsConfigVersionIsIncorrect)
OperationContextNoop txn;
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id" << 0)
+ << "_id"
+ << 0)
<< BSON("host"
<< "node2:12345"
- << "_id" << 1) << BSON("host"
- << "node3:12345"
- << "_id" << 2))),
+ << "_id"
+ << 1)
+ << BSON("host"
+ << "node3:12345"
+ << "_id"
+ << 2))),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastAppliedOpTime(OpTimeWithTermZero(100, 0));
@@ -2496,9 +2676,12 @@ TEST_F(ReplCoordTest, DoNotProcessUpdatePositionWhenItsConfigVersionIsIncorrect)
UpdatePositionArgs args;
ASSERT_OK(args.initialize(
BSON(UpdatePositionArgs::kCommandFieldName
- << 1 << UpdatePositionArgs::kUpdateArrayFieldName
+ << 1
+ << UpdatePositionArgs::kUpdateArrayFieldName
<< BSON_ARRAY(BSON(UpdatePositionArgs::kConfigVersionFieldName
- << 3 << UpdatePositionArgs::kMemberIdFieldName << 1
+ << 3
+ << UpdatePositionArgs::kMemberIdFieldName
+ << 1
<< UpdatePositionArgs::kDurableOpTimeFieldName
<< BSON("ts" << time2.getTimestamp() << "t" << 3)
<< UpdatePositionArgs::kAppliedOpTimeFieldName
@@ -2515,15 +2698,21 @@ TEST_F(ReplCoordTest, DoNotProcessOldUpdatePositionWhenItsConfigVersionIsIncorre
OperationContextNoop txn;
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id" << 0)
+ << "_id"
+ << 0)
<< BSON("host"
<< "node2:12345"
- << "_id" << 1) << BSON("host"
- << "node3:12345"
- << "_id" << 2))),
+ << "_id"
+ << 1)
+ << BSON("host"
+ << "node3:12345"
+ << "_id"
+ << 2))),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastAppliedOpTime(OpTimeWithTermZero(100, 0));
@@ -2542,12 +2731,15 @@ TEST_F(ReplCoordTest, DoNotProcessOldUpdatePositionWhenItsConfigVersionIsIncorre
// receive updatePosition with incorrect config version
OldUpdatePositionArgs args;
- ASSERT_OK(args.initialize(
- BSON(OldUpdatePositionArgs::kCommandFieldName
- << 1 << OldUpdatePositionArgs::kUpdateArrayFieldName
- << BSON_ARRAY(BSON(OldUpdatePositionArgs::kConfigVersionFieldName
- << 3 << OldUpdatePositionArgs::kMemberIdFieldName << 1
- << OldUpdatePositionArgs::kOpTimeFieldName << time2.timestamp)))));
+ ASSERT_OK(args.initialize(BSON(OldUpdatePositionArgs::kCommandFieldName
+ << 1
+ << OldUpdatePositionArgs::kUpdateArrayFieldName
+ << BSON_ARRAY(BSON(OldUpdatePositionArgs::kConfigVersionFieldName
+ << 3
+ << OldUpdatePositionArgs::kMemberIdFieldName
+ << 1
+ << OldUpdatePositionArgs::kOpTimeFieldName
+ << time2.timestamp)))));
long long cfgver;
ASSERT_EQUALS(ErrorCodes::InvalidReplicaSetConfig,
@@ -2560,15 +2752,21 @@ TEST_F(ReplCoordTest, DoNotProcessUpdatePositionOfMembersWhoseIdsAreNotInTheConf
OperationContextNoop txn;
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id" << 0)
+ << "_id"
+ << 0)
<< BSON("host"
<< "node2:12345"
- << "_id" << 1) << BSON("host"
- << "node3:12345"
- << "_id" << 2))),
+ << "_id"
+ << 1)
+ << BSON("host"
+ << "node3:12345"
+ << "_id"
+ << 2))),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastAppliedOpTime(OpTimeWithTermZero(100, 0));
@@ -2588,9 +2786,12 @@ TEST_F(ReplCoordTest, DoNotProcessUpdatePositionOfMembersWhoseIdsAreNotInTheConf
UpdatePositionArgs args;
ASSERT_OK(args.initialize(
BSON(UpdatePositionArgs::kCommandFieldName
- << 1 << UpdatePositionArgs::kUpdateArrayFieldName
+ << 1
+ << UpdatePositionArgs::kUpdateArrayFieldName
<< BSON_ARRAY(BSON(UpdatePositionArgs::kConfigVersionFieldName
- << 2 << UpdatePositionArgs::kMemberIdFieldName << 9
+ << 2
+ << UpdatePositionArgs::kMemberIdFieldName
+ << 9
<< UpdatePositionArgs::kDurableOpTimeFieldName
<< BSON("ts" << time2.getTimestamp() << "t" << 2)
<< UpdatePositionArgs::kAppliedOpTimeFieldName
@@ -2605,15 +2806,21 @@ TEST_F(ReplCoordTest, DoNotProcessOldUpdatePositionOfMembersWhoseIdsAreNotInTheC
OperationContextNoop txn;
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id" << 0)
+ << "_id"
+ << 0)
<< BSON("host"
<< "node2:12345"
- << "_id" << 1) << BSON("host"
- << "node3:12345"
- << "_id" << 2))),
+ << "_id"
+ << 1)
+ << BSON("host"
+ << "node3:12345"
+ << "_id"
+ << 2))),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastAppliedOpTime(OpTimeWithTermZero(100, 0));
@@ -2632,12 +2839,15 @@ TEST_F(ReplCoordTest, DoNotProcessOldUpdatePositionOfMembersWhoseIdsAreNotInTheC
// receive updatePosition with nonexistent member id
OldUpdatePositionArgs args;
- ASSERT_OK(args.initialize(
- BSON(OldUpdatePositionArgs::kCommandFieldName
- << 1 << OldUpdatePositionArgs::kUpdateArrayFieldName
- << BSON_ARRAY(BSON(OldUpdatePositionArgs::kConfigVersionFieldName
- << 2 << OldUpdatePositionArgs::kMemberIdFieldName << 9
- << OldUpdatePositionArgs::kOpTimeFieldName << time2.timestamp)))));
+ ASSERT_OK(args.initialize(BSON(OldUpdatePositionArgs::kCommandFieldName
+ << 1
+ << OldUpdatePositionArgs::kUpdateArrayFieldName
+ << BSON_ARRAY(BSON(OldUpdatePositionArgs::kConfigVersionFieldName
+ << 2
+ << OldUpdatePositionArgs::kMemberIdFieldName
+ << 9
+ << OldUpdatePositionArgs::kOpTimeFieldName
+ << time2.timestamp)))));
ASSERT_EQUALS(ErrorCodes::NodeNotFound, getReplCoord()->processReplSetUpdatePosition(args, 0));
ASSERT_EQUALS(ErrorCodes::WriteConcernFailed,
@@ -2649,15 +2859,21 @@ TEST_F(ReplCoordTest,
OperationContextNoop txn;
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id" << 0)
+ << "_id"
+ << 0)
<< BSON("host"
<< "node2:12345"
- << "_id" << 1) << BSON("host"
- << "node3:12345"
- << "_id" << 2))),
+ << "_id"
+ << 1)
+ << BSON("host"
+ << "node3:12345"
+ << "_id"
+ << 2))),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastAppliedOpTime(OpTimeWithTermZero(100, 0));
@@ -2678,15 +2894,22 @@ TEST_F(ReplCoordTest,
getReplCoord()->setMyLastAppliedOpTime(time2);
getReplCoord()->setMyLastDurableOpTime(time2);
OldUpdatePositionArgs args;
- ASSERT_OK(args.initialize(BSON(
- OldUpdatePositionArgs::kCommandFieldName
- << 1 << OldUpdatePositionArgs::kUpdateArrayFieldName
- << BSON_ARRAY(BSON(OldUpdatePositionArgs::kConfigVersionFieldName
- << 2 << OldUpdatePositionArgs::kMemberIdFieldName << 1
- << OldUpdatePositionArgs::kOpTimeFieldName << time2.timestamp)
- << BSON(OldUpdatePositionArgs::kConfigVersionFieldName
- << 2 << OldUpdatePositionArgs::kMemberIdFieldName << 2
- << OldUpdatePositionArgs::kOpTimeFieldName << time2.timestamp)))));
+ ASSERT_OK(
+ args.initialize(BSON(OldUpdatePositionArgs::kCommandFieldName
+ << 1
+ << OldUpdatePositionArgs::kUpdateArrayFieldName
+ << BSON_ARRAY(BSON(OldUpdatePositionArgs::kConfigVersionFieldName
+ << 2
+ << OldUpdatePositionArgs::kMemberIdFieldName
+ << 1
+ << OldUpdatePositionArgs::kOpTimeFieldName
+ << time2.timestamp)
+ << BSON(OldUpdatePositionArgs::kConfigVersionFieldName
+ << 2
+ << OldUpdatePositionArgs::kMemberIdFieldName
+ << 2
+ << OldUpdatePositionArgs::kOpTimeFieldName
+ << time2.timestamp)))));
ASSERT_OK(getReplCoord()->processReplSetUpdatePosition(args, 0));
ASSERT_OK(getReplCoord()->awaitReplication(&txn, time2, writeConcern).status);
@@ -2702,10 +2925,13 @@ void doReplSetReconfig(ReplicationCoordinatorImpl* replCoord, Status* status) {
args.force = false;
args.newConfigObj = BSON("_id"
<< "mySet"
- << "version" << 3 << "members"
+ << "version"
+ << 3
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "node1:12345"
- << "priority" << 3)
+ << "priority"
+ << 3)
<< BSON("_id" << 1 << "host"
<< "node2:12345")
<< BSON("_id" << 2 << "host"
@@ -2717,15 +2943,21 @@ TEST_F(ReplCoordTest, AwaitReplicationShouldResolveAsNormalDuringAReconfig) {
OperationContextNoop txn;
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id" << 0)
+ << "_id"
+ << 0)
<< BSON("host"
<< "node2:12345"
- << "_id" << 1) << BSON("host"
- << "node3:12345"
- << "_id" << 2))),
+ << "_id"
+ << 1)
+ << BSON("host"
+ << "node3:12345"
+ << "_id"
+ << 2))),
HostAndPort("node1", 12345));
// Turn off readconcern majority support, and snapshots.
@@ -2790,7 +3022,9 @@ void doReplSetReconfigToFewer(ReplicationCoordinatorImpl* replCoord, Status* sta
args.force = false;
args.newConfigObj = BSON("_id"
<< "mySet"
- << "version" << 3 << "members"
+ << "version"
+ << 3
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -2804,15 +3038,21 @@ TEST_F(
OperationContextNoop txn;
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id" << 0)
+ << "_id"
+ << 0)
<< BSON("host"
<< "node2:12345"
- << "_id" << 1) << BSON("host"
- << "node3:12345"
- << "_id" << 2))),
+ << "_id"
+ << 1)
+ << BSON("host"
+ << "node3:12345"
+ << "_id"
+ << 2))),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->setMyLastAppliedOpTime(OpTimeWithTermZero(100, 2));
@@ -2860,20 +3100,29 @@ TEST_F(ReplCoordTest,
OperationContextNoop txn;
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id" << 0)
+ << "_id"
+ << 0)
<< BSON("host"
<< "node2:12345"
- << "_id" << 1) << BSON("host"
- << "node3:12345"
- << "_id" << 2)
+ << "_id"
+ << 1)
+ << BSON("host"
+ << "node3:12345"
+ << "_id"
+ << 2)
<< BSON("host"
<< "node4:12345"
- << "_id" << 3) << BSON("host"
- << "node5:12345"
- << "_id" << 4))),
+ << "_id"
+ << 3)
+ << BSON("host"
+ << "node5:12345"
+ << "_id"
+ << 4))),
HostAndPort("node1", 12345));
// Turn off readconcern majority support, and snapshots.
@@ -2934,21 +3183,35 @@ TEST_F(ReplCoordTest,
OperationContextNoop txn;
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id" << 0)
+ << "_id"
+ << 0)
<< BSON("host"
<< "node2:12345"
- << "_id" << 1) << BSON("host"
- << "node3:12345"
- << "_id" << 2)
+ << "_id"
+ << 1)
+ << BSON("host"
+ << "node3:12345"
+ << "_id"
+ << 2)
<< BSON("host"
<< "node4:12345"
- << "_id" << 3 << "votes" << 0 << "priority" << 0)
+ << "_id"
+ << 3
+ << "votes"
+ << 0
+ << "priority"
+ << 0)
<< BSON("host"
<< "node5:12345"
- << "_id" << 4 << "arbiterOnly" << true))),
+ << "_id"
+ << 4
+ << "arbiterOnly"
+ << true))),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
OpTime time(Timestamp(100, 0), 1);
@@ -2990,21 +3253,35 @@ TEST_F(ReplCoordTest,
OperationContextNoop txn;
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id" << 0)
+ << "_id"
+ << 0)
<< BSON("host"
<< "node2:12345"
- << "_id" << 1) << BSON("host"
- << "node3:12345"
- << "_id" << 2)
+ << "_id"
+ << 1)
+ << BSON("host"
+ << "node3:12345"
+ << "_id"
+ << 2)
<< BSON("host"
<< "node4:12345"
- << "_id" << 3 << "votes" << 0 << "priority" << 0)
+ << "_id"
+ << 3
+ << "votes"
+ << 0
+ << "priority"
+ << 0)
<< BSON("host"
<< "node5:12345"
- << "_id" << 4 << "arbiterOnly" << true))),
+ << "_id"
+ << 4
+ << "arbiterOnly"
+ << true))),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
OpTime zero(Timestamp(0, 0), 0);
@@ -3048,9 +3325,13 @@ TEST_F(ReplCoordTest, NodeReturnsShutdownInProgressWhenWaitingUntilAnOpTimeDurin
OperationContextNoop txn;
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members" << BSON_ARRAY(BSON("host"
- << "node1:12345"
- << "_id" << 0))),
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("host"
+ << "node1:12345"
+ << "_id"
+ << 0))),
HostAndPort("node1", 12345));
getReplCoord()->setMyLastAppliedOpTime(OpTimeWithTermZero(10, 0));
@@ -3068,9 +3349,13 @@ TEST_F(ReplCoordTest, NodeReturnsShutdownInProgressWhenWaitingUntilAnOpTimeDurin
TEST_F(ReplCoordTest, NodeReturnsInterruptedWhenWaitingUntilAnOpTimeIsInterrupted) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members" << BSON_ARRAY(BSON("host"
- << "node1:12345"
- << "_id" << 0))),
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("host"
+ << "node1:12345"
+ << "_id"
+ << 0))),
HostAndPort("node1", 12345));
getReplCoord()->setMyLastAppliedOpTime(OpTimeWithTermZero(10, 0));
@@ -3092,9 +3377,13 @@ TEST_F(ReplCoordTest, NodeReturnsOkImmediatelyWhenWaitingUntilOpTimePassesNoOpTi
OperationContextNoop txn;
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members" << BSON_ARRAY(BSON("host"
- << "node1:12345"
- << "_id" << 0))),
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("host"
+ << "node1:12345"
+ << "_id"
+ << 0))),
HostAndPort("node1", 12345));
auto result = getReplCoord()->waitUntilOpTime(&txn, ReadConcernArgs());
@@ -3107,9 +3396,13 @@ TEST_F(ReplCoordTest, NodeReturnsOkImmediatelyWhenWaitingUntilOpTimePassesAnOpTi
OperationContextNoop txn;
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members" << BSON_ARRAY(BSON("host"
- << "node1:12345"
- << "_id" << 0))),
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("host"
+ << "node1:12345"
+ << "_id"
+ << 0))),
HostAndPort("node1", 12345));
getReplCoord()->setMyLastAppliedOpTime(OpTimeWithTermZero(100, 0));
@@ -3125,9 +3418,13 @@ TEST_F(ReplCoordTest, NodeReturnsOkImmediatelyWhenWaitingUntilOpTimePassesAnOpTi
OperationContextNoop txn;
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members" << BSON_ARRAY(BSON("host"
- << "node1:12345"
- << "_id" << 0))),
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("host"
+ << "node1:12345"
+ << "_id"
+ << 0))),
HostAndPort("node1", 12345));
@@ -3170,9 +3467,13 @@ TEST_F(ReplCoordTest, ReadAfterCommittedWhileShutdown) {
OperationContextNoop txn;
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members" << BSON_ARRAY(BSON("host"
- << "node1:12345"
- << "_id" << 0))),
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("host"
+ << "node1:12345"
+ << "_id"
+ << 0))),
HostAndPort("node1", 12345));
runSingleNodeElection(makeOperationContext(), getReplCoord());
@@ -3191,9 +3492,13 @@ TEST_F(ReplCoordTest, ReadAfterCommittedWhileShutdown) {
TEST_F(ReplCoordTest, ReadAfterCommittedInterrupted) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members" << BSON_ARRAY(BSON("host"
- << "node1:12345"
- << "_id" << 0))),
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("host"
+ << "node1:12345"
+ << "_id"
+ << 0))),
HostAndPort("node1", 12345));
runSingleNodeElection(makeOperationContext(), getReplCoord());
const auto txnPtr = makeOperationContext();
@@ -3215,9 +3520,13 @@ TEST_F(ReplCoordTest, ReadAfterCommittedGreaterOpTime) {
OperationContextNoop txn;
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members" << BSON_ARRAY(BSON("host"
- << "node1:12345"
- << "_id" << 0))),
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("host"
+ << "node1:12345"
+ << "_id"
+ << 0))),
HostAndPort("node1", 12345));
runSingleNodeElection(makeOperationContext(), getReplCoord());
@@ -3235,9 +3544,13 @@ TEST_F(ReplCoordTest, ReadAfterCommittedEqualOpTime) {
OperationContextNoop txn;
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members" << BSON_ARRAY(BSON("host"
- << "node1:12345"
- << "_id" << 0))),
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("host"
+ << "node1:12345"
+ << "_id"
+ << 0))),
HostAndPort("node1", 12345));
runSingleNodeElection(makeOperationContext(), getReplCoord());
OpTime time(Timestamp(100, 0), 1);
@@ -3255,22 +3568,24 @@ TEST_F(ReplCoordTest, ReadAfterCommittedDeferredGreaterOpTime) {
OperationContextNoop txn;
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members" << BSON_ARRAY(BSON("host"
- << "node1:12345"
- << "_id" << 0))),
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("host"
+ << "node1:12345"
+ << "_id"
+ << 0))),
HostAndPort("node1", 12345));
runSingleNodeElection(makeOperationContext(), getReplCoord());
getReplCoord()->setMyLastAppliedOpTime(OpTime(Timestamp(0, 0), 1));
getReplCoord()->setMyLastDurableOpTime(OpTime(Timestamp(0, 0), 1));
OpTime committedOpTime(Timestamp(200, 0), 1);
- auto pseudoLogOp =
- stdx::async(stdx::launch::async,
- [this, &committedOpTime]() {
- // Not guaranteed to be scheduled after waitUntil blocks...
- getReplCoord()->setMyLastAppliedOpTime(committedOpTime);
- getReplCoord()->setMyLastDurableOpTime(committedOpTime);
- getReplCoord()->onSnapshotCreate(committedOpTime, SnapshotName(1));
- });
+ auto pseudoLogOp = stdx::async(stdx::launch::async, [this, &committedOpTime]() {
+ // Not guaranteed to be scheduled after waitUntil blocks...
+ getReplCoord()->setMyLastAppliedOpTime(committedOpTime);
+ getReplCoord()->setMyLastDurableOpTime(committedOpTime);
+ getReplCoord()->onSnapshotCreate(committedOpTime, SnapshotName(1));
+ });
auto result = getReplCoord()->waitUntilOpTime(
&txn,
@@ -3285,9 +3600,13 @@ TEST_F(ReplCoordTest, ReadAfterCommittedDeferredEqualOpTime) {
OperationContextNoop txn;
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members" << BSON_ARRAY(BSON("host"
- << "node1:12345"
- << "_id" << 0))),
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("host"
+ << "node1:12345"
+ << "_id"
+ << 0))),
HostAndPort("node1", 12345));
runSingleNodeElection(makeOperationContext(), getReplCoord());
getReplCoord()->setMyLastAppliedOpTime(OpTime(Timestamp(0, 0), 1));
@@ -3295,14 +3614,12 @@ TEST_F(ReplCoordTest, ReadAfterCommittedDeferredEqualOpTime) {
OpTime opTimeToWait(Timestamp(100, 0), 1);
- auto pseudoLogOp =
- stdx::async(stdx::launch::async,
- [this, &opTimeToWait]() {
- // Not guaranteed to be scheduled after waitUntil blocks...
- getReplCoord()->setMyLastAppliedOpTime(opTimeToWait);
- getReplCoord()->setMyLastDurableOpTime(opTimeToWait);
- getReplCoord()->onSnapshotCreate(opTimeToWait, SnapshotName(1));
- });
+ auto pseudoLogOp = stdx::async(stdx::launch::async, [this, &opTimeToWait]() {
+ // Not guaranteed to be scheduled after waitUntil blocks...
+ getReplCoord()->setMyLastAppliedOpTime(opTimeToWait);
+ getReplCoord()->setMyLastDurableOpTime(opTimeToWait);
+ getReplCoord()->onSnapshotCreate(opTimeToWait, SnapshotName(1));
+ });
auto result = getReplCoord()->waitUntilOpTime(
&txn, ReadConcernArgs(opTimeToWait, ReadConcernLevel::kMajorityReadConcern));
@@ -3316,34 +3633,53 @@ TEST_F(ReplCoordTest, IgnoreTheContentsOfMetadataWhenItsConfigVersionDoesNotMatc
// Ensure that we do not process ReplSetMetadata when ConfigVersions do not match.
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id" << 0)
+ << "_id"
+ << 0)
<< BSON("host"
<< "node2:12345"
- << "_id" << 1) << BSON("host"
- << "node3:12345"
- << "_id" << 2))),
+ << "_id"
+ << 1)
+ << BSON("host"
+ << "node3:12345"
+ << "_id"
+ << 2))),
HostAndPort("node1", 12345));
ASSERT_EQUALS(OpTime(Timestamp(0, 0), 0), getReplCoord()->getLastCommittedOpTime());
// lower configVersion
StatusWith<rpc::ReplSetMetadata> metadata = rpc::ReplSetMetadata::readFromMetadata(BSON(
- rpc::kReplSetMetadataFieldName << BSON(
- "lastOpCommitted" << BSON("ts" << Timestamp(10, 0) << "t" << 2) << "lastOpVisible"
- << BSON("ts" << Timestamp(10, 0) << "t" << 2) << "configVersion" << 1
- << "primaryIndex" << 2 << "term" << 2 << "syncSourceIndex" << 1)));
+ rpc::kReplSetMetadataFieldName
+ << BSON("lastOpCommitted" << BSON("ts" << Timestamp(10, 0) << "t" << 2) << "lastOpVisible"
+ << BSON("ts" << Timestamp(10, 0) << "t" << 2)
+ << "configVersion"
+ << 1
+ << "primaryIndex"
+ << 2
+ << "term"
+ << 2
+ << "syncSourceIndex"
+ << 1)));
getReplCoord()->processReplSetMetadata(metadata.getValue());
ASSERT_EQUALS(OpTime(Timestamp(0, 0), 0), getReplCoord()->getLastCommittedOpTime());
// higher configVersion
- StatusWith<rpc::ReplSetMetadata> metadata2 = rpc::ReplSetMetadata::readFromMetadata(
- BSON(rpc::kReplSetMetadataFieldName
- << BSON("lastOpCommitted"
- << BSON("ts" << Timestamp(10, 0) << "t" << 2) << "lastOpVisible"
- << BSON("ts" << Timestamp(10, 0) << "t" << 2) << "configVersion" << 100
- << "primaryIndex" << 2 << "term" << 2 << "syncSourceIndex" << 1)));
+ StatusWith<rpc::ReplSetMetadata> metadata2 = rpc::ReplSetMetadata::readFromMetadata(BSON(
+ rpc::kReplSetMetadataFieldName
+ << BSON("lastOpCommitted" << BSON("ts" << Timestamp(10, 0) << "t" << 2) << "lastOpVisible"
+ << BSON("ts" << Timestamp(10, 0) << "t" << 2)
+ << "configVersion"
+ << 100
+ << "primaryIndex"
+ << 2
+ << "term"
+ << 2
+ << "syncSourceIndex"
+ << 1)));
getReplCoord()->processReplSetMetadata(metadata2.getValue());
ASSERT_EQUALS(OpTime(Timestamp(0, 0), 0), getReplCoord()->getLastCommittedOpTime());
}
@@ -3353,16 +3689,23 @@ TEST_F(ReplCoordTest, UpdateLastCommittedOpTimeWhenTheLastCommittedOpTimeFromMet
// but not if the OpTime is older than the current LastCommittedOpTime.
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id" << 0)
+ << "_id"
+ << 0)
<< BSON("host"
<< "node2:12345"
- << "_id" << 1) << BSON("host"
- << "node3:12345"
- << "_id" << 2))
- << "protocolVersion" << 1),
+ << "_id"
+ << 1)
+ << BSON("host"
+ << "node3:12345"
+ << "_id"
+ << 2))
+ << "protocolVersion"
+ << 1),
HostAndPort("node1", 12345));
getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY);
ASSERT_EQUALS(OpTime(Timestamp(0, 0), 0), getReplCoord()->getLastCommittedOpTime());
@@ -3375,20 +3718,34 @@ TEST_F(ReplCoordTest, UpdateLastCommittedOpTimeWhenTheLastCommittedOpTimeFromMet
// higher OpTime, should change
StatusWith<rpc::ReplSetMetadata> metadata = rpc::ReplSetMetadata::readFromMetadata(BSON(
- rpc::kReplSetMetadataFieldName << BSON(
- "lastOpCommitted" << BSON("ts" << Timestamp(10, 0) << "t" << 1) << "lastOpVisible"
- << BSON("ts" << Timestamp(10, 0) << "t" << 1) << "configVersion" << 2
- << "primaryIndex" << 2 << "term" << 1 << "syncSourceIndex" << 1)));
+ rpc::kReplSetMetadataFieldName
+ << BSON("lastOpCommitted" << BSON("ts" << Timestamp(10, 0) << "t" << 1) << "lastOpVisible"
+ << BSON("ts" << Timestamp(10, 0) << "t" << 1)
+ << "configVersion"
+ << 2
+ << "primaryIndex"
+ << 2
+ << "term"
+ << 1
+ << "syncSourceIndex"
+ << 1)));
getReplCoord()->processReplSetMetadata(metadata.getValue());
ASSERT_EQUALS(OpTime(Timestamp(10, 0), 1), getReplCoord()->getLastCommittedOpTime());
ASSERT_EQUALS(OpTime(Timestamp(10, 0), 1), getReplCoord()->getCurrentCommittedSnapshotOpTime());
// lower OpTime, should not change
StatusWith<rpc::ReplSetMetadata> metadata2 = rpc::ReplSetMetadata::readFromMetadata(BSON(
- rpc::kReplSetMetadataFieldName << BSON(
- "lastOpCommitted" << BSON("ts" << Timestamp(9, 0) << "t" << 1) << "lastOpVisible"
- << BSON("ts" << Timestamp(9, 0) << "t" << 1) << "configVersion" << 2
- << "primaryIndex" << 2 << "term" << 1 << "syncSourceIndex" << 1)));
+ rpc::kReplSetMetadataFieldName
+ << BSON("lastOpCommitted" << BSON("ts" << Timestamp(9, 0) << "t" << 1) << "lastOpVisible"
+ << BSON("ts" << Timestamp(9, 0) << "t" << 1)
+ << "configVersion"
+ << 2
+ << "primaryIndex"
+ << 2
+ << "term"
+ << 1
+ << "syncSourceIndex"
+ << 1)));
getReplCoord()->processReplSetMetadata(metadata2.getValue());
ASSERT_EQUALS(OpTime(Timestamp(10, 0), 1), getReplCoord()->getLastCommittedOpTime());
}
@@ -3398,16 +3755,23 @@ TEST_F(ReplCoordTest, UpdateTermWhenTheTermFromMetadataIsNewerButNeverUpdateCurr
// Ensure that currentPrimaryIndex is never altered by ReplSetMetadata.
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id" << 0)
+ << "_id"
+ << 0)
<< BSON("host"
<< "node2:12345"
- << "_id" << 1) << BSON("host"
- << "node3:12345"
- << "_id" << 2))
- << "protocolVersion" << 1),
+ << "_id"
+ << 1)
+ << BSON("host"
+ << "node3:12345"
+ << "_id"
+ << 2))
+ << "protocolVersion"
+ << 1),
HostAndPort("node1", 12345));
ASSERT_EQUALS(OpTime(Timestamp(0, 0), 0), getReplCoord()->getLastCommittedOpTime());
OperationContextNoop txn;
@@ -3416,10 +3780,17 @@ TEST_F(ReplCoordTest, UpdateTermWhenTheTermFromMetadataIsNewerButNeverUpdateCurr
// higher term, should change
StatusWith<rpc::ReplSetMetadata> metadata = rpc::ReplSetMetadata::readFromMetadata(BSON(
- rpc::kReplSetMetadataFieldName << BSON(
- "lastOpCommitted" << BSON("ts" << Timestamp(10, 0) << "t" << 3) << "lastOpVisible"
- << BSON("ts" << Timestamp(10, 0) << "t" << 3) << "configVersion" << 2
- << "primaryIndex" << 2 << "term" << 3 << "syncSourceIndex" << 1)));
+ rpc::kReplSetMetadataFieldName
+ << BSON("lastOpCommitted" << BSON("ts" << Timestamp(10, 0) << "t" << 3) << "lastOpVisible"
+ << BSON("ts" << Timestamp(10, 0) << "t" << 3)
+ << "configVersion"
+ << 2
+ << "primaryIndex"
+ << 2
+ << "term"
+ << 3
+ << "syncSourceIndex"
+ << 1)));
getReplCoord()->processReplSetMetadata(metadata.getValue());
ASSERT_EQUALS(OpTime(Timestamp(10, 0), 3), getReplCoord()->getLastCommittedOpTime());
ASSERT_EQUALS(3, getReplCoord()->getTerm());
@@ -3427,10 +3798,17 @@ TEST_F(ReplCoordTest, UpdateTermWhenTheTermFromMetadataIsNewerButNeverUpdateCurr
// lower term, should not change
StatusWith<rpc::ReplSetMetadata> metadata2 = rpc::ReplSetMetadata::readFromMetadata(BSON(
- rpc::kReplSetMetadataFieldName << BSON(
- "lastOpCommitted" << BSON("ts" << Timestamp(11, 0) << "t" << 3) << "lastOpVisible"
- << BSON("ts" << Timestamp(11, 0) << "t" << 3) << "configVersion" << 2
- << "primaryIndex" << 1 << "term" << 2 << "syncSourceIndex" << 1)));
+ rpc::kReplSetMetadataFieldName
+ << BSON("lastOpCommitted" << BSON("ts" << Timestamp(11, 0) << "t" << 3) << "lastOpVisible"
+ << BSON("ts" << Timestamp(11, 0) << "t" << 3)
+ << "configVersion"
+ << 2
+ << "primaryIndex"
+ << 1
+ << "term"
+ << 2
+ << "syncSourceIndex"
+ << 1)));
getReplCoord()->processReplSetMetadata(metadata2.getValue());
ASSERT_EQUALS(OpTime(Timestamp(11, 0), 3), getReplCoord()->getLastCommittedOpTime());
ASSERT_EQUALS(3, getReplCoord()->getTerm());
@@ -3438,10 +3816,17 @@ TEST_F(ReplCoordTest, UpdateTermWhenTheTermFromMetadataIsNewerButNeverUpdateCurr
// same term, should not change
StatusWith<rpc::ReplSetMetadata> metadata3 = rpc::ReplSetMetadata::readFromMetadata(BSON(
- rpc::kReplSetMetadataFieldName << BSON(
- "lastOpCommitted" << BSON("ts" << Timestamp(11, 0) << "t" << 3) << "lastOpVisible"
- << BSON("ts" << Timestamp(11, 0) << "t" << 3) << "configVersion" << 2
- << "primaryIndex" << 1 << "term" << 3 << "syncSourceIndex" << 1)));
+ rpc::kReplSetMetadataFieldName
+ << BSON("lastOpCommitted" << BSON("ts" << Timestamp(11, 0) << "t" << 3) << "lastOpVisible"
+ << BSON("ts" << Timestamp(11, 0) << "t" << 3)
+ << "configVersion"
+ << 2
+ << "primaryIndex"
+ << 1
+ << "term"
+ << 3
+ << "syncSourceIndex"
+ << 1)));
getReplCoord()->processReplSetMetadata(metadata3.getValue());
ASSERT_EQUALS(OpTime(Timestamp(11, 0), 3), getReplCoord()->getLastCommittedOpTime());
ASSERT_EQUALS(3, getReplCoord()->getTerm());
@@ -3453,13 +3838,19 @@ TEST_F(ReplCoordTest,
// Ensure that the metadata is processed if it is contained in a heartbeat response.
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members" << BSON_ARRAY(BSON("host"
- << "node1:12345"
- << "_id" << 0)
- << BSON("host"
- << "node2:12345"
- << "_id" << 1))
- << "protocolVersion" << 1),
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("host"
+ << "node1:12345"
+ << "_id"
+ << 0)
+ << BSON("host"
+ << "node2:12345"
+ << "_id"
+ << 1))
+ << "protocolVersion"
+ << 1),
HostAndPort("node1", 12345));
ASSERT_EQUALS(OpTime(Timestamp(0, 0), 0), getReplCoord()->getLastCommittedOpTime());
OperationContextNoop txn;
@@ -3473,9 +3864,15 @@ TEST_F(ReplCoordTest,
StatusWith<rpc::ReplSetMetadata> metadata = rpc::ReplSetMetadata::readFromMetadata(BSON(
rpc::kReplSetMetadataFieldName
<< BSON("lastOpCommitted" << BSON("ts" << Timestamp(10, 0) << "t" << 3) << "lastOpVisible"
- << BSON("ts" << Timestamp(10, 0) << "t" << 3) << "configVersion"
- << config.getConfigVersion() << "primaryIndex" << 1 << "term" << 3
- << "syncSourceIndex" << 1)));
+ << BSON("ts" << Timestamp(10, 0) << "t" << 3)
+ << "configVersion"
+ << config.getConfigVersion()
+ << "primaryIndex"
+ << 1
+ << "term"
+ << 3
+ << "syncSourceIndex"
+ << 1)));
BSONObjBuilder metadataBuilder;
ASSERT_OK(metadata.getValue().writeToMetadata(&metadataBuilder));
auto metadataObj = metadataBuilder.obj();
@@ -3506,13 +3903,19 @@ TEST_F(ReplCoordTest,
ScheduleElectionToBeRunInElectionTimeoutFromNowWhenCancelAndRescheduleElectionTimeoutIsRun) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "protocolVersion" << 1 << "version" << 2 << "members"
+ << "protocolVersion"
+ << 1
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id" << 0)
+ << "_id"
+ << 0)
<< BSON("host"
<< "node2:12345"
- << "_id" << 1))),
+ << "_id"
+ << 1))),
HostAndPort("node1", 12345));
ReplicationCoordinatorImpl* replCoord = getReplCoord();
@@ -3551,13 +3954,19 @@ TEST_F(ReplCoordTest,
TEST_F(ReplCoordTest, DoNotScheduleElectionWhenCancelAndRescheduleElectionTimeoutIsRunInPV0) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "protocolVersion" << 0 << "version" << 2 << "members"
+ << "protocolVersion"
+ << 0
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id" << 0)
+ << "_id"
+ << 0)
<< BSON("host"
<< "node2:12345"
- << "_id" << 1))),
+ << "_id"
+ << 1))),
HostAndPort("node1", 12345));
ReplicationCoordinatorImpl* replCoord = getReplCoord();
ASSERT_TRUE(replCoord->setFollowerMode(MemberState::RS_SECONDARY));
@@ -3571,13 +3980,19 @@ TEST_F(ReplCoordTest, DoNotScheduleElectionWhenCancelAndRescheduleElectionTimeou
TEST_F(ReplCoordTest, DoNotScheduleElectionWhenCancelAndRescheduleElectionTimeoutIsRunInRollback) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "protocolVersion" << 1 << "version" << 2 << "members"
+ << "protocolVersion"
+ << 1
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id" << 0)
+ << "_id"
+ << 0)
<< BSON("host"
<< "node2:12345"
- << "_id" << 1))),
+ << "_id"
+ << 1))),
HostAndPort("node1", 12345));
ReplicationCoordinatorImpl* replCoord = getReplCoord();
ASSERT_TRUE(replCoord->setFollowerMode(MemberState::RS_ROLLBACK));
@@ -3592,13 +4007,23 @@ TEST_F(ReplCoordTest,
DoNotScheduleElectionWhenCancelAndRescheduleElectionTimeoutIsRunWhileUnelectable) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "protocolVersion" << 1 << "version" << 2 << "members"
+ << "protocolVersion"
+ << 1
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id" << 0 << "priority" << 0 << "hidden" << true)
+ << "_id"
+ << 0
+ << "priority"
+ << 0
+ << "hidden"
+ << true)
<< BSON("host"
<< "node2:12345"
- << "_id" << 1))),
+ << "_id"
+ << 1))),
HostAndPort("node1", 12345));
ReplicationCoordinatorImpl* replCoord = getReplCoord();
ASSERT_TRUE(replCoord->setFollowerMode(MemberState::RS_SECONDARY));
@@ -3613,13 +4038,19 @@ TEST_F(ReplCoordTest,
DoNotScheduleElectionWhenCancelAndRescheduleElectionTimeoutIsRunWhileRemoved) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "protocolVersion" << 1 << "version" << 2 << "members"
+ << "protocolVersion"
+ << 1
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id" << 0)
+ << "_id"
+ << 0)
<< BSON("host"
<< "node2:12345"
- << "_id" << 1))),
+ << "_id"
+ << 1))),
HostAndPort("node1", 12345));
ReplicationCoordinatorImpl* replCoord = getReplCoord();
@@ -3644,10 +4075,15 @@ TEST_F(ReplCoordTest,
ReplicaSetConfig config;
config.initialize(BSON("_id"
<< "mySet"
- << "protocolVersion" << 1 << "version" << 3 << "members"
+ << "protocolVersion"
+ << 1
+ << "version"
+ << 3
+ << "members"
<< BSON_ARRAY(BSON("host"
<< "node2:12345"
- << "_id" << 1))));
+ << "_id"
+ << 1))));
hbResp.setConfig(config);
hbResp.setConfigVersion(3);
hbResp.setSetName("mySet");
@@ -3668,13 +4104,19 @@ TEST_F(ReplCoordTest,
CancelAndRescheduleElectionTimeoutWhenProcessingHeartbeatResponseFromPrimary) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "protocolVersion" << 1 << "version" << 2 << "members"
+ << "protocolVersion"
+ << 1
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id" << 0)
+ << "_id"
+ << 0)
<< BSON("host"
<< "node2:12345"
- << "_id" << 1))),
+ << "_id"
+ << 1))),
HostAndPort("node1", 12345));
ReplicationCoordinatorImpl* replCoord = getReplCoord();
@@ -3714,13 +4156,19 @@ TEST_F(ReplCoordTest,
CancelAndRescheduleElectionTimeoutWhenProcessingHeartbeatResponseWithoutState) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "protocolVersion" << 1 << "version" << 2 << "members"
+ << "protocolVersion"
+ << 1
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id" << 0)
+ << "_id"
+ << 0)
<< BSON("host"
<< "node2:12345"
- << "_id" << 1))),
+ << "_id"
+ << 1))),
HostAndPort("node1", 12345));
ReplicationCoordinatorImpl* replCoord = getReplCoord();
@@ -3760,7 +4208,9 @@ TEST_F(ReplCoordTest, AdvanceCommittedSnapshotToMostRecentSnapshotPriorToOpTimeW
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "test1:1234"))),
HostAndPort("test1", 1234));
@@ -3791,7 +4241,9 @@ TEST_F(ReplCoordTest, DoNotAdvanceCommittedSnapshotWhenAnOpTimeIsNewerThanOurLat
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "test1:1234"))),
HostAndPort("test1", 1234));
@@ -3820,7 +4272,9 @@ TEST_F(ReplCoordTest,
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "test1:1234"))),
HostAndPort("test1", 1234));
@@ -3851,7 +4305,9 @@ TEST_F(ReplCoordTest, ZeroCommittedSnapshotWhenAllSnapshotsAreDropped) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "test1:1234"))),
HostAndPort("test1", 1234));
@@ -3878,7 +4334,9 @@ TEST_F(ReplCoordTest, DoNotAdvanceCommittedSnapshotWhenAppliedOpTimeChanges) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "test1:1234"))),
HostAndPort("test1", 1234));
@@ -3902,9 +4360,13 @@ TEST_F(ReplCoordTest,
NodeChangesMyLastOpTimeWhenAndOnlyWhensetMyLastDurableOpTimeReceivesANewerOpTime4DurableSE) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 2 << "members" << BSON_ARRAY(BSON("host"
- << "node1:12345"
- << "_id" << 0))),
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("host"
+ << "node1:12345"
+ << "_id"
+ << 0))),
HostAndPort("node1", 12345));
@@ -3925,13 +4387,18 @@ TEST_F(ReplCoordTest, OnlyForwardSyncProgressForOtherNodesWhenTheNodesAreBelieve
assertStartSuccess(
BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "test1:1234")
<< BSON("_id" << 1 << "host"
- << "test2:1234") << BSON("_id" << 2 << "host"
- << "test3:1234"))
- << "protocolVersion" << 1 << "settings"
+ << "test2:1234")
+ << BSON("_id" << 2 << "host"
+ << "test3:1234"))
+ << "protocolVersion"
+ << 1
+ << "settings"
<< BSON("electionTimeoutMillis" << 2000 << "heartbeatIntervalMillis" << 40000)),
HostAndPort("test1", 1234));
OpTime optime(Timestamp(100, 2), 0);
@@ -4020,20 +4487,32 @@ TEST_F(ReplCoordTest, StepDownWhenHandleLivenessTimeoutMarksAMajorityOfVotingNod
assertStartSuccess(
BSON("_id"
<< "mySet"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id" << 0)
+ << "_id"
+ << 0)
<< BSON("host"
<< "node2:12345"
- << "_id" << 1) << BSON("host"
- << "node3:12345"
- << "_id" << 2) << BSON("host"
- << "node4:12345"
- << "_id" << 3)
+ << "_id"
+ << 1)
+ << BSON("host"
+ << "node3:12345"
+ << "_id"
+ << 2)
+ << BSON("host"
+ << "node4:12345"
+ << "_id"
+ << 3)
<< BSON("host"
<< "node5:12345"
- << "_id" << 4)) << "protocolVersion" << 1 << "settings"
+ << "_id"
+ << 4))
+ << "protocolVersion"
+ << 1
+ << "settings"
<< BSON("electionTimeoutMillis" << 2000 << "heartbeatIntervalMillis" << 40000)),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
@@ -4043,23 +4522,34 @@ TEST_F(ReplCoordTest, StepDownWhenHandleLivenessTimeoutMarksAMajorityOfVotingNod
// Receive notification that every node is up.
OldUpdatePositionArgs args;
- ASSERT_OK(args.initialize(BSON(
- OldUpdatePositionArgs::kCommandFieldName
- << 1 << OldUpdatePositionArgs::kUpdateArrayFieldName
- << BSON_ARRAY(
- BSON(OldUpdatePositionArgs::kConfigVersionFieldName
- << 2 << OldUpdatePositionArgs::kMemberIdFieldName << 1
- << OldUpdatePositionArgs::kOpTimeFieldName << startingOpTime.getTimestamp())
- << BSON(OldUpdatePositionArgs::kConfigVersionFieldName
- << 2 << OldUpdatePositionArgs::kMemberIdFieldName << 2
- << OldUpdatePositionArgs::kOpTimeFieldName << startingOpTime.getTimestamp())
- << BSON(OldUpdatePositionArgs::kConfigVersionFieldName
- << 2 << OldUpdatePositionArgs::kMemberIdFieldName << 3
- << OldUpdatePositionArgs::kOpTimeFieldName << startingOpTime.getTimestamp())
- << BSON(OldUpdatePositionArgs::kConfigVersionFieldName
- << 2 << OldUpdatePositionArgs::kMemberIdFieldName << 4
- << OldUpdatePositionArgs::kOpTimeFieldName
- << startingOpTime.getTimestamp())))));
+ ASSERT_OK(
+ args.initialize(BSON(OldUpdatePositionArgs::kCommandFieldName
+ << 1
+ << OldUpdatePositionArgs::kUpdateArrayFieldName
+ << BSON_ARRAY(BSON(OldUpdatePositionArgs::kConfigVersionFieldName
+ << 2
+ << OldUpdatePositionArgs::kMemberIdFieldName
+ << 1
+ << OldUpdatePositionArgs::kOpTimeFieldName
+ << startingOpTime.getTimestamp())
+ << BSON(OldUpdatePositionArgs::kConfigVersionFieldName
+ << 2
+ << OldUpdatePositionArgs::kMemberIdFieldName
+ << 2
+ << OldUpdatePositionArgs::kOpTimeFieldName
+ << startingOpTime.getTimestamp())
+ << BSON(OldUpdatePositionArgs::kConfigVersionFieldName
+ << 2
+ << OldUpdatePositionArgs::kMemberIdFieldName
+ << 3
+ << OldUpdatePositionArgs::kOpTimeFieldName
+ << startingOpTime.getTimestamp())
+ << BSON(OldUpdatePositionArgs::kConfigVersionFieldName
+ << 2
+ << OldUpdatePositionArgs::kMemberIdFieldName
+ << 4
+ << OldUpdatePositionArgs::kOpTimeFieldName
+ << startingOpTime.getTimestamp())))));
ASSERT_OK(getReplCoord()->processReplSetUpdatePosition(args, 0));
// Become PRIMARY.
@@ -4067,17 +4557,22 @@ TEST_F(ReplCoordTest, StepDownWhenHandleLivenessTimeoutMarksAMajorityOfVotingNod
// Keep two nodes alive.
OldUpdatePositionArgs args1;
- ASSERT_OK(args1.initialize(
- BSON(OldUpdatePositionArgs::kCommandFieldName
- << 1 << OldUpdatePositionArgs::kUpdateArrayFieldName
- << BSON_ARRAY(BSON(OldUpdatePositionArgs::kConfigVersionFieldName
- << 2 << OldUpdatePositionArgs::kMemberIdFieldName << 1
- << OldUpdatePositionArgs::kOpTimeFieldName
- << startingOpTime.getTimestamp())
- << BSON(OldUpdatePositionArgs::kConfigVersionFieldName
- << 2 << OldUpdatePositionArgs::kMemberIdFieldName << 2
- << OldUpdatePositionArgs::kOpTimeFieldName
- << startingOpTime.getTimestamp())))));
+ ASSERT_OK(
+ args1.initialize(BSON(OldUpdatePositionArgs::kCommandFieldName
+ << 1
+ << OldUpdatePositionArgs::kUpdateArrayFieldName
+ << BSON_ARRAY(BSON(OldUpdatePositionArgs::kConfigVersionFieldName
+ << 2
+ << OldUpdatePositionArgs::kMemberIdFieldName
+ << 1
+ << OldUpdatePositionArgs::kOpTimeFieldName
+ << startingOpTime.getTimestamp())
+ << BSON(OldUpdatePositionArgs::kConfigVersionFieldName
+ << 2
+ << OldUpdatePositionArgs::kMemberIdFieldName
+ << 2
+ << OldUpdatePositionArgs::kOpTimeFieldName
+ << startingOpTime.getTimestamp())))));
ASSERT_OK(getReplCoord()->processReplSetUpdatePosition(args1, 0));
// Confirm that the node remains PRIMARY after the other two nodes are marked DOWN.
@@ -4091,10 +4586,13 @@ TEST_F(ReplCoordTest, StepDownWhenHandleLivenessTimeoutMarksAMajorityOfVotingNod
OldUpdatePositionArgs args2;
ASSERT_OK(
args2.initialize(BSON(OldUpdatePositionArgs::kCommandFieldName
- << 1 << OldUpdatePositionArgs::kUpdateArrayFieldName
+ << 1
+ << OldUpdatePositionArgs::kUpdateArrayFieldName
<< BSON_ARRAY(BSON(OldUpdatePositionArgs::kConfigVersionFieldName
- << 2 << OldUpdatePositionArgs::kMemberIdFieldName
- << 1 << OldUpdatePositionArgs::kOpTimeFieldName
+ << 2
+ << OldUpdatePositionArgs::kMemberIdFieldName
+ << 1
+ << OldUpdatePositionArgs::kOpTimeFieldName
<< startingOpTime.getTimestamp())))));
ASSERT_OK(getReplCoord()->processReplSetUpdatePosition(args2, 0));
@@ -4131,7 +4629,9 @@ TEST_F(ReplCoordTest, WaitForMemberState) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "test1:1234"))),
HostAndPort("test1", 1234));
@@ -4166,7 +4666,9 @@ TEST_F(ReplCoordTest, WaitForDrainFinish) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "test1:1234"))),
HostAndPort("test1", 1234));
@@ -4205,39 +4707,62 @@ TEST_F(ReplCoordTest, UpdatePositionArgsReturnsNoSuchKeyWhenParsingOldUpdatePosi
OpTime opTime = OpTime(Timestamp(100, 1), 0);
ASSERT_EQUALS(
ErrorCodes::NoSuchKey,
- args2.initialize(BSON(
- OldUpdatePositionArgs::kCommandFieldName
- << 1 << OldUpdatePositionArgs::kUpdateArrayFieldName
- << BSON_ARRAY(
- BSON(OldUpdatePositionArgs::kConfigVersionFieldName
- << 2 << OldUpdatePositionArgs::kMemberIdFieldName << 1
- << OldUpdatePositionArgs::kOpTimeFieldName << opTime.getTimestamp())
- << BSON(OldUpdatePositionArgs::kConfigVersionFieldName
- << 2 << OldUpdatePositionArgs::kMemberIdFieldName << 2
- << OldUpdatePositionArgs::kOpTimeFieldName << opTime.getTimestamp())
- << BSON(OldUpdatePositionArgs::kConfigVersionFieldName
- << 2 << OldUpdatePositionArgs::kMemberIdFieldName << 3
- << OldUpdatePositionArgs::kOpTimeFieldName << opTime.getTimestamp())
- << BSON(OldUpdatePositionArgs::kConfigVersionFieldName
- << 2 << OldUpdatePositionArgs::kMemberIdFieldName << 4
- << OldUpdatePositionArgs::kOpTimeFieldName << opTime.getTimestamp())))));
-
- ASSERT_OK(args.initialize(BSON(
- OldUpdatePositionArgs::kCommandFieldName
- << 1 << OldUpdatePositionArgs::kUpdateArrayFieldName
- << BSON_ARRAY(BSON(OldUpdatePositionArgs::kConfigVersionFieldName
- << 2 << OldUpdatePositionArgs::kMemberIdFieldName << 1
- << OldUpdatePositionArgs::kOpTimeFieldName << opTime.getTimestamp())
- << BSON(OldUpdatePositionArgs::kConfigVersionFieldName
- << 2 << OldUpdatePositionArgs::kMemberIdFieldName << 2
- << OldUpdatePositionArgs::kOpTimeFieldName << opTime.getTimestamp())
- << BSON(OldUpdatePositionArgs::kConfigVersionFieldName
- << 2 << OldUpdatePositionArgs::kMemberIdFieldName << 3
- << OldUpdatePositionArgs::kOpTimeFieldName << opTime.getTimestamp())
- << BSON(OldUpdatePositionArgs::kConfigVersionFieldName
- << 2 << OldUpdatePositionArgs::kMemberIdFieldName << 4
- << OldUpdatePositionArgs::kOpTimeFieldName
- << opTime.getTimestamp())))));
+ args2.initialize(BSON(OldUpdatePositionArgs::kCommandFieldName
+ << 1
+ << OldUpdatePositionArgs::kUpdateArrayFieldName
+ << BSON_ARRAY(BSON(OldUpdatePositionArgs::kConfigVersionFieldName
+ << 2
+ << OldUpdatePositionArgs::kMemberIdFieldName
+ << 1
+ << OldUpdatePositionArgs::kOpTimeFieldName
+ << opTime.getTimestamp())
+ << BSON(OldUpdatePositionArgs::kConfigVersionFieldName
+ << 2
+ << OldUpdatePositionArgs::kMemberIdFieldName
+ << 2
+ << OldUpdatePositionArgs::kOpTimeFieldName
+ << opTime.getTimestamp())
+ << BSON(OldUpdatePositionArgs::kConfigVersionFieldName
+ << 2
+ << OldUpdatePositionArgs::kMemberIdFieldName
+ << 3
+ << OldUpdatePositionArgs::kOpTimeFieldName
+ << opTime.getTimestamp())
+ << BSON(OldUpdatePositionArgs::kConfigVersionFieldName
+ << 2
+ << OldUpdatePositionArgs::kMemberIdFieldName
+ << 4
+ << OldUpdatePositionArgs::kOpTimeFieldName
+ << opTime.getTimestamp())))));
+
+ ASSERT_OK(
+ args.initialize(BSON(OldUpdatePositionArgs::kCommandFieldName
+ << 1
+ << OldUpdatePositionArgs::kUpdateArrayFieldName
+ << BSON_ARRAY(BSON(OldUpdatePositionArgs::kConfigVersionFieldName
+ << 2
+ << OldUpdatePositionArgs::kMemberIdFieldName
+ << 1
+ << OldUpdatePositionArgs::kOpTimeFieldName
+ << opTime.getTimestamp())
+ << BSON(OldUpdatePositionArgs::kConfigVersionFieldName
+ << 2
+ << OldUpdatePositionArgs::kMemberIdFieldName
+ << 2
+ << OldUpdatePositionArgs::kOpTimeFieldName
+ << opTime.getTimestamp())
+ << BSON(OldUpdatePositionArgs::kConfigVersionFieldName
+ << 2
+ << OldUpdatePositionArgs::kMemberIdFieldName
+ << 3
+ << OldUpdatePositionArgs::kOpTimeFieldName
+ << opTime.getTimestamp())
+ << BSON(OldUpdatePositionArgs::kConfigVersionFieldName
+ << 2
+ << OldUpdatePositionArgs::kMemberIdFieldName
+ << 4
+ << OldUpdatePositionArgs::kOpTimeFieldName
+ << opTime.getTimestamp())))));
}
@@ -4248,54 +4773,72 @@ TEST_F(ReplCoordTest, OldUpdatePositionArgsReturnsBadValueWhenParsingUpdatePosit
ASSERT_EQUALS(ErrorCodes::BadValue,
args.initialize(BSON(
UpdatePositionArgs::kCommandFieldName
- << 1 << UpdatePositionArgs::kUpdateArrayFieldName
+ << 1
+ << UpdatePositionArgs::kUpdateArrayFieldName
<< BSON_ARRAY(BSON(UpdatePositionArgs::kConfigVersionFieldName
- << 2 << UpdatePositionArgs::kMemberIdFieldName << 1
+ << 2
+ << UpdatePositionArgs::kMemberIdFieldName
+ << 1
<< UpdatePositionArgs::kDurableOpTimeFieldName
<< BSON("ts" << opTime.getTimestamp() << "t" << 3)
<< UpdatePositionArgs::kAppliedOpTimeFieldName
<< BSON("ts" << opTime.getTimestamp() << "t" << 3))
<< BSON(UpdatePositionArgs::kConfigVersionFieldName
- << 2 << UpdatePositionArgs::kMemberIdFieldName << 2
+ << 2
+ << UpdatePositionArgs::kMemberIdFieldName
+ << 2
<< UpdatePositionArgs::kDurableOpTimeFieldName
<< BSON("ts" << opTime.getTimestamp() << "t" << 3)
<< UpdatePositionArgs::kAppliedOpTimeFieldName
<< BSON("ts" << opTime.getTimestamp() << "t" << 3))
<< BSON(UpdatePositionArgs::kConfigVersionFieldName
- << 2 << UpdatePositionArgs::kMemberIdFieldName << 3
+ << 2
+ << UpdatePositionArgs::kMemberIdFieldName
+ << 3
<< UpdatePositionArgs::kDurableOpTimeFieldName
<< BSON("ts" << opTime.getTimestamp() << "t" << 3)
<< UpdatePositionArgs::kAppliedOpTimeFieldName
<< BSON("ts" << opTime.getTimestamp() << "t" << 3))
<< BSON(UpdatePositionArgs::kConfigVersionFieldName
- << 2 << UpdatePositionArgs::kMemberIdFieldName << 4
+ << 2
+ << UpdatePositionArgs::kMemberIdFieldName
+ << 4
<< UpdatePositionArgs::kDurableOpTimeFieldName
<< BSON("ts" << opTime.getTimestamp() << "t" << 3)
<< UpdatePositionArgs::kAppliedOpTimeFieldName
<< BSON("ts" << opTime.getTimestamp() << "t" << 3))))));
ASSERT_OK(args2.initialize(
BSON(UpdatePositionArgs::kCommandFieldName
- << 1 << UpdatePositionArgs::kUpdateArrayFieldName
+ << 1
+ << UpdatePositionArgs::kUpdateArrayFieldName
<< BSON_ARRAY(BSON(UpdatePositionArgs::kConfigVersionFieldName
- << 2 << UpdatePositionArgs::kMemberIdFieldName << 1
+ << 2
+ << UpdatePositionArgs::kMemberIdFieldName
+ << 1
<< UpdatePositionArgs::kDurableOpTimeFieldName
<< BSON("ts" << opTime.getTimestamp() << "t" << 3)
<< UpdatePositionArgs::kAppliedOpTimeFieldName
<< BSON("ts" << opTime.getTimestamp() << "t" << 3))
<< BSON(UpdatePositionArgs::kConfigVersionFieldName
- << 2 << UpdatePositionArgs::kMemberIdFieldName << 2
+ << 2
+ << UpdatePositionArgs::kMemberIdFieldName
+ << 2
<< UpdatePositionArgs::kDurableOpTimeFieldName
<< BSON("ts" << opTime.getTimestamp() << "t" << 3)
<< UpdatePositionArgs::kAppliedOpTimeFieldName
<< BSON("ts" << opTime.getTimestamp() << "t" << 3))
<< BSON(UpdatePositionArgs::kConfigVersionFieldName
- << 2 << UpdatePositionArgs::kMemberIdFieldName << 3
+ << 2
+ << UpdatePositionArgs::kMemberIdFieldName
+ << 3
<< UpdatePositionArgs::kDurableOpTimeFieldName
<< BSON("ts" << opTime.getTimestamp() << "t" << 3)
<< UpdatePositionArgs::kAppliedOpTimeFieldName
<< BSON("ts" << opTime.getTimestamp() << "t" << 3))
<< BSON(UpdatePositionArgs::kConfigVersionFieldName
- << 2 << UpdatePositionArgs::kMemberIdFieldName << 4
+ << 2
+ << UpdatePositionArgs::kMemberIdFieldName
+ << 4
<< UpdatePositionArgs::kDurableOpTimeFieldName
<< BSON("ts" << opTime.getTimestamp() << "t" << 3)
<< UpdatePositionArgs::kAppliedOpTimeFieldName
@@ -4309,10 +4852,13 @@ TEST_F(
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "test1:1234"))
- << "writeConcernMajorityJournalDefault" << false),
+ << "writeConcernMajorityJournalDefault"
+ << false),
HostAndPort("test1", 1234));
WriteConcernOptions wc;
@@ -4329,10 +4875,13 @@ TEST_F(
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "test1:1234"))
- << "writeConcernMajorityJournalDefault" << true),
+ << "writeConcernMajorityJournalDefault"
+ << true),
HostAndPort("test1", 1234));
WriteConcernOptions wc;
@@ -4347,10 +4896,13 @@ TEST_F(ReplCoordTest, PopulateUnsetWriteConcernOptionsSyncModeReturnsInputIfSync
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "test1:1234"))
- << "writeConcernMajorityJournalDefault" << false),
+ << "writeConcernMajorityJournalDefault"
+ << false),
HostAndPort("test1", 1234));
WriteConcernOptions wc;
@@ -4372,10 +4924,13 @@ TEST_F(ReplCoordTest, PopulateUnsetWriteConcernOptionsSyncModeReturnsInputIfWMod
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "test1:1234"))
- << "writeConcernMajorityJournalDefault" << false),
+ << "writeConcernMajorityJournalDefault"
+ << false),
HostAndPort("test1", 1234));
WriteConcernOptions wc;
diff --git a/src/mongo/db/repl/replication_coordinator_mock.cpp b/src/mongo/db/repl/replication_coordinator_mock.cpp
index fc0f9866f55..e8617423953 100644
--- a/src/mongo/db/repl/replication_coordinator_mock.cpp
+++ b/src/mongo/db/repl/replication_coordinator_mock.cpp
@@ -32,12 +32,12 @@
#include "mongo/base/status.h"
#include "mongo/db/namespace_string.h"
-#include "mongo/db/write_concern_options.h"
#include "mongo/db/repl/read_concern_args.h"
#include "mongo/db/repl/read_concern_response.h"
#include "mongo/db/repl/replica_set_config.h"
#include "mongo/db/repl/sync_source_resolver.h"
#include "mongo/db/storage/snapshot_name.h"
+#include "mongo/db/write_concern_options.h"
#include "mongo/util/assert_util.h"
namespace mongo {
diff --git a/src/mongo/db/repl/replication_coordinator_test_fixture.cpp b/src/mongo/db/repl/replication_coordinator_test_fixture.cpp
index 7d6d29614d2..319f67c3893 100644
--- a/src/mongo/db/repl/replication_coordinator_test_fixture.cpp
+++ b/src/mongo/db/repl/replication_coordinator_test_fixture.cpp
@@ -34,9 +34,9 @@
#include "mongo/db/operation_context_noop.h"
#include "mongo/db/repl/is_master_response.h"
-#include "mongo/db/repl/repl_settings.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/replication_coordinator_external_state_mock.h"
#include "mongo/db/repl/replication_coordinator_impl.h"
#include "mongo/db/repl/storage_interface_mock.h"
@@ -238,13 +238,14 @@ void ReplCoordTest::simulateSuccessfulDryRun(
if (request.cmdObj.firstElement().fieldNameStringData() == "replSetRequestVotes") {
ASSERT_TRUE(request.cmdObj.getBoolField("dryRun"));
onDryRunRequest(request);
- net->scheduleResponse(
- noi,
- net->now(),
- makeResponseStatus(BSON("ok" << 1 << "reason"
- << ""
- << "term" << request.cmdObj["term"].Long()
- << "voteGranted" << true)));
+ net->scheduleResponse(noi,
+ net->now(),
+ makeResponseStatus(BSON("ok" << 1 << "reason"
+ << ""
+ << "term"
+ << request.cmdObj["term"].Long()
+ << "voteGranted"
+ << true)));
voteRequests++;
} else {
error() << "Black holing unexpected request to " << request.target << ": "
@@ -298,13 +299,14 @@ void ReplCoordTest::simulateSuccessfulV1Election() {
hbResp.setConfigVersion(rsConfig.getConfigVersion());
net->scheduleResponse(noi, net->now(), makeResponseStatus(hbResp.toBSON(true)));
} else if (request.cmdObj.firstElement().fieldNameStringData() == "replSetRequestVotes") {
- net->scheduleResponse(
- noi,
- net->now(),
- makeResponseStatus(BSON("ok" << 1 << "reason"
- << ""
- << "term" << request.cmdObj["term"].Long()
- << "voteGranted" << true)));
+ net->scheduleResponse(noi,
+ net->now(),
+ makeResponseStatus(BSON("ok" << 1 << "reason"
+ << ""
+ << "term"
+ << request.cmdObj["term"].Long()
+ << "voteGranted"
+ << true)));
} else {
error() << "Black holing unexpected request to " << request.target << ": "
<< request.cmdObj;
@@ -359,8 +361,8 @@ void ReplCoordTest::simulateSuccessfulElection() {
net->scheduleResponse(
noi,
net->now(),
- makeResponseStatus(BSON("ok" << 1 << "fresher" << false << "opTime" << Date_t()
- << "veto" << false)));
+ makeResponseStatus(BSON(
+ "ok" << 1 << "fresher" << false << "opTime" << Date_t() << "veto" << false)));
} else if (request.cmdObj.firstElement().fieldNameStringData() == "replSetElect") {
net->scheduleResponse(noi,
net->now(),
diff --git a/src/mongo/db/repl/replication_executor.cpp b/src/mongo/db/repl/replication_executor.cpp
index 0caabfe808d..0154c5b53e7 100644
--- a/src/mongo/db/repl/replication_executor.cpp
+++ b/src/mongo/db/repl/replication_executor.cpp
@@ -310,8 +310,8 @@ void ReplicationExecutor::_finishRemoteCommand(const RemoteCommandRequest& reque
return;
}
- LOG(4) << "Received remote response: " << (response.isOK() ? response.getValue().toString()
- : response.getStatus().toString());
+ LOG(4) << "Received remote response: "
+ << (response.isOK() ? response.getValue().toString() : response.getStatus().toString());
callback->_callbackFn =
stdx::bind(remoteCommandFinished, stdx::placeholders::_1, cb, request, response);
diff --git a/src/mongo/db/repl/replication_executor_test.cpp b/src/mongo/db/repl/replication_executor_test.cpp
index ceb4ec89beb..7b2de1e1fe1 100644
--- a/src/mongo/db/repl/replication_executor_test.cpp
+++ b/src/mongo/db/repl/replication_executor_test.cpp
@@ -31,14 +31,14 @@
#include <map>
#include "mongo/base/init.h"
-#include "mongo/executor/task_executor_test_common.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/operation_context.h"
#include "mongo/db/repl/replication_executor.h"
#include "mongo/db/repl/replication_executor_test_fixture.h"
#include "mongo/executor/network_interface_mock.h"
-#include "mongo/stdx/memory.h"
+#include "mongo/executor/task_executor_test_common.h"
#include "mongo/stdx/functional.h"
+#include "mongo/stdx/memory.h"
#include "mongo/stdx/thread.h"
#include "mongo/unittest/barrier.h"
#include "mongo/unittest/unittest.h"
@@ -56,11 +56,10 @@ using unittest::assertGet;
const int64_t prngSeed = 1;
MONGO_INITIALIZER(ReplExecutorCommonTests)(InitializerContext*) {
- mongo::executor::addTestsForExecutor("ReplicationExecutorCommon",
- [](std::unique_ptr<executor::NetworkInterfaceMock>* net) {
- return stdx::make_unique<ReplicationExecutor>(
- net->release(), prngSeed);
- });
+ mongo::executor::addTestsForExecutor(
+ "ReplicationExecutorCommon", [](std::unique_ptr<executor::NetworkInterfaceMock>* net) {
+ return stdx::make_unique<ReplicationExecutor>(net->release(), prngSeed);
+ });
return Status::OK();
}
@@ -71,16 +70,19 @@ TEST_F(ReplicationExecutorTest, ScheduleDBWorkAndExclusiveWorkConcurrently) {
Status status1 = getDetectableErrorStatus();
OperationContext* txn = nullptr;
using CallbackData = ReplicationExecutor::CallbackArgs;
- ASSERT_OK(executor.scheduleDBWork([&](const CallbackData& cbData) {
- status1 = cbData.status;
- txn = cbData.txn;
- barrier.countDownAndWait();
- if (cbData.status != ErrorCodes::CallbackCanceled)
- cbData.executor->shutdown();
- }).getStatus());
- ASSERT_OK(executor.scheduleWorkWithGlobalExclusiveLock([&](const CallbackData& cbData) {
- barrier.countDownAndWait();
- }).getStatus());
+ ASSERT_OK(executor
+ .scheduleDBWork([&](const CallbackData& cbData) {
+ status1 = cbData.status;
+ txn = cbData.txn;
+ barrier.countDownAndWait();
+ if (cbData.status != ErrorCodes::CallbackCanceled)
+ cbData.executor->shutdown();
+ })
+ .getStatus());
+ ASSERT_OK(executor
+ .scheduleWorkWithGlobalExclusiveLock(
+ [&](const CallbackData& cbData) { barrier.countDownAndWait(); })
+ .getStatus());
executor.run();
ASSERT_OK(status1);
ASSERT(txn);
@@ -93,14 +95,20 @@ TEST_F(ReplicationExecutorTest, ScheduleDBWorkWithCollectionLock) {
OperationContext* txn = nullptr;
bool collectionIsLocked = false;
using CallbackData = ReplicationExecutor::CallbackArgs;
- ASSERT_OK(executor.scheduleDBWork([&](const CallbackData& cbData) {
- status1 = cbData.status;
- txn = cbData.txn;
- collectionIsLocked =
- txn ? txn->lockState()->isCollectionLockedForMode(nss.ns(), MODE_X) : false;
- if (cbData.status != ErrorCodes::CallbackCanceled)
- cbData.executor->shutdown();
- }, nss, MODE_X).getStatus());
+ ASSERT_OK(executor
+ .scheduleDBWork(
+ [&](const CallbackData& cbData) {
+ status1 = cbData.status;
+ txn = cbData.txn;
+ collectionIsLocked = txn
+ ? txn->lockState()->isCollectionLockedForMode(nss.ns(), MODE_X)
+ : false;
+ if (cbData.status != ErrorCodes::CallbackCanceled)
+ cbData.executor->shutdown();
+ },
+ nss,
+ MODE_X)
+ .getStatus());
executor.run();
ASSERT_OK(status1);
ASSERT(txn);
@@ -113,13 +121,15 @@ TEST_F(ReplicationExecutorTest, ScheduleExclusiveLockOperation) {
OperationContext* txn = nullptr;
bool lockIsW = false;
using CallbackData = ReplicationExecutor::CallbackArgs;
- ASSERT_OK(executor.scheduleWorkWithGlobalExclusiveLock([&](const CallbackData& cbData) {
- status1 = cbData.status;
- txn = cbData.txn;
- lockIsW = txn ? txn->lockState()->isW() : false;
- if (cbData.status != ErrorCodes::CallbackCanceled)
- cbData.executor->shutdown();
- }).getStatus());
+ ASSERT_OK(executor
+ .scheduleWorkWithGlobalExclusiveLock([&](const CallbackData& cbData) {
+ status1 = cbData.status;
+ txn = cbData.txn;
+ lockIsW = txn ? txn->lockState()->isW() : false;
+ if (cbData.status != ErrorCodes::CallbackCanceled)
+ cbData.executor->shutdown();
+ })
+ .getStatus());
executor.run();
ASSERT_OK(status1);
ASSERT(txn);
@@ -130,20 +140,24 @@ TEST_F(ReplicationExecutorTest, ShutdownBeforeRunningSecondExclusiveLockOperatio
ReplicationExecutor& executor = getReplExecutor();
using CallbackData = ReplicationExecutor::CallbackArgs;
Status status1 = getDetectableErrorStatus();
- ASSERT_OK(executor.scheduleWorkWithGlobalExclusiveLock([&](const CallbackData& cbData) {
- status1 = cbData.status;
- if (cbData.status != ErrorCodes::CallbackCanceled)
- cbData.executor->shutdown();
- }).getStatus());
+ ASSERT_OK(executor
+ .scheduleWorkWithGlobalExclusiveLock([&](const CallbackData& cbData) {
+ status1 = cbData.status;
+ if (cbData.status != ErrorCodes::CallbackCanceled)
+ cbData.executor->shutdown();
+ })
+ .getStatus());
// Second db work item is invoked by the main executor thread because the work item is
// moved from the exclusive lock queue to the ready work item queue when the first callback
// cancels the executor.
Status status2 = getDetectableErrorStatus();
- ASSERT_OK(executor.scheduleWorkWithGlobalExclusiveLock([&](const CallbackData& cbData) {
- status2 = cbData.status;
- if (cbData.status != ErrorCodes::CallbackCanceled)
- cbData.executor->shutdown();
- }).getStatus());
+ ASSERT_OK(executor
+ .scheduleWorkWithGlobalExclusiveLock([&](const CallbackData& cbData) {
+ status2 = cbData.status;
+ if (cbData.status != ErrorCodes::CallbackCanceled)
+ cbData.executor->shutdown();
+ })
+ .getStatus());
executor.run();
ASSERT_OK(status1);
ASSERT_EQUALS(ErrorCodes::CallbackCanceled, status2.code());
@@ -153,13 +167,12 @@ TEST_F(ReplicationExecutorTest, CancelBeforeRunningFutureWork) {
ReplicationExecutor& executor = getReplExecutor();
using CallbackData = ReplicationExecutor::CallbackArgs;
Status status1 = getDetectableErrorStatus();
- auto cbhWithStatus =
- executor.scheduleWorkAt(executor.now() + Milliseconds(1000),
- [&](const CallbackData& cbData) {
- status1 = cbData.status;
- if (cbData.status != ErrorCodes::CallbackCanceled)
- cbData.executor->shutdown();
- });
+ auto cbhWithStatus = executor.scheduleWorkAt(
+ executor.now() + Milliseconds(1000), [&](const CallbackData& cbData) {
+ status1 = cbData.status;
+ if (cbData.status != ErrorCodes::CallbackCanceled)
+ cbData.executor->shutdown();
+ });
ASSERT_OK(cbhWithStatus.getStatus());
ASSERT_EQUALS(1, executor.getDiagnosticBSON().getFieldDotted("queues.sleepers").Int());
diff --git a/src/mongo/db/repl/replication_executor_test_fixture.h b/src/mongo/db/repl/replication_executor_test_fixture.h
index 73e5ae2c504..7b7845302d7 100644
--- a/src/mongo/db/repl/replication_executor_test_fixture.h
+++ b/src/mongo/db/repl/replication_executor_test_fixture.h
@@ -28,9 +28,9 @@
#pragma once
-#include "mongo/stdx/memory.h"
#include "mongo/db/repl/replication_executor.h"
#include "mongo/executor/task_executor_test_fixture.h"
+#include "mongo/stdx/memory.h"
#include "mongo/unittest/unittest.h"
namespace mongo {
diff --git a/src/mongo/db/repl/replset_commands.cpp b/src/mongo/db/repl/replset_commands.cpp
index 70aaa8b7b6d..c91e28b71a6 100644
--- a/src/mongo/db/repl/replset_commands.cpp
+++ b/src/mongo/db/repl/replset_commands.cpp
@@ -47,8 +47,8 @@
#include "mongo/db/repl/initial_sync.h"
#include "mongo/db/repl/old_update_position_args.h"
#include "mongo/db/repl/oplog.h"
-#include "mongo/db/repl/repl_set_heartbeat_args_v1.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_set_heartbeat_response.h"
#include "mongo/db/repl/replication_coordinator_external_state_impl.h"
#include "mongo/db/repl/replication_coordinator_global.h"
@@ -451,7 +451,8 @@ public:
txn,
BSON("msg"
<< "Reconfig set"
- << "version" << parsedArgs.newConfigObj["version"]));
+ << "version"
+ << parsedArgs.newConfigObj["version"]));
}
wuow.commit();
@@ -837,7 +838,8 @@ public:
BSONElement cfgverElement = cmdObj["cfgver"];
uassert(28525,
str::stream() << "Expected cfgver argument to replSetFresh command to have "
- "numeric type, but found " << typeName(cfgverElement.type()),
+ "numeric type, but found "
+ << typeName(cfgverElement.type()),
cfgverElement.isNumber());
parsedArgs.cfgver = cfgverElement.safeNumberLong();
parsedArgs.opTime = Timestamp(cmdObj["opTime"].Date());
@@ -871,7 +873,8 @@ private:
BSONElement cfgverElement = cmdObj["cfgver"];
uassert(28526,
str::stream() << "Expected cfgver argument to replSetElect command to have "
- "numeric type, but found " << typeName(cfgverElement.type()),
+ "numeric type, but found "
+ << typeName(cfgverElement.type()),
cfgverElement.isNumber());
parsedArgs.cfgver = cfgverElement.safeNumberLong();
parsedArgs.round = cmdObj["round"].OID();
diff --git a/src/mongo/db/repl/replset_web_handler.cpp b/src/mongo/db/repl/replset_web_handler.cpp
index 6ec53363396..3f67cd9a45c 100644
--- a/src/mongo/db/repl/replset_web_handler.cpp
+++ b/src/mongo/db/repl/replset_web_handler.cpp
@@ -32,8 +32,8 @@
#include "mongo/db/dbwebserver.h"
#include "mongo/db/jsobj.h"
-#include "mongo/db/repl/replication_coordinator_global.h"
#include "mongo/db/repl/repl_set_html_summary.h"
+#include "mongo/db/repl/replication_coordinator_global.h"
#include "mongo/db/repl/rslog.h"
#include "mongo/util/mongoutils/html.h"
#include "mongo/util/mongoutils/str.h"
diff --git a/src/mongo/db/repl/reporter_test.cpp b/src/mongo/db/repl/reporter_test.cpp
index 3d6b8b81b43..926df8f3a62 100644
--- a/src/mongo/db/repl/reporter_test.cpp
+++ b/src/mongo/db/repl/reporter_test.cpp
@@ -32,8 +32,8 @@
#include "mongo/db/repl/optime.h"
#include "mongo/db/repl/reporter.h"
#include "mongo/db/repl/update_position_args.h"
-#include "mongo/executor/thread_pool_task_executor_test_fixture.h"
#include "mongo/executor/network_interface_mock.h"
+#include "mongo/executor/thread_pool_task_executor_test_fixture.h"
#include "mongo/stdx/memory.h"
#include "mongo/unittest/task_executor_proxy.h"
#include "mongo/unittest/unittest.h"
@@ -370,7 +370,8 @@ TEST_F(ReporterTestNoTriggerAtSetUp,
processNetworkResponse(BSON("ok" << 0 << "code" << int(ErrorCodes::InvalidReplicaSetConfig)
<< "errmsg"
<< "newer config"
- << "configVersion" << 100));
+ << "configVersion"
+ << 100));
ASSERT_EQUALS(Status(ErrorCodes::InvalidReplicaSetConfig, "invalid config"), reporter->join());
assertReporterDone();
@@ -389,7 +390,8 @@ TEST_F(ReporterTest, InvalidReplicaSetResponseWithSameConfigVersionOnSyncTargetS
processNetworkResponse(BSON("ok" << 0 << "code" << int(ErrorCodes::InvalidReplicaSetConfig)
<< "errmsg"
<< "invalid config"
- << "configVersion" << posUpdater->getConfigVersion()));
+ << "configVersion"
+ << posUpdater->getConfigVersion()));
ASSERT_EQUALS(Status(ErrorCodes::InvalidReplicaSetConfig, "invalid config"), reporter->join());
assertReporterDone();
@@ -406,7 +408,8 @@ TEST_F(
processNetworkResponse(BSON("ok" << 0 << "code" << int(ErrorCodes::InvalidReplicaSetConfig)
<< "errmsg"
<< "newer config"
- << "configVersion" << posUpdater->getConfigVersion() + 1));
+ << "configVersion"
+ << posUpdater->getConfigVersion() + 1));
ASSERT_TRUE(reporter->isActive());
}
@@ -430,7 +433,8 @@ TEST_F(
commandRequest = processNetworkResponse(
BSON("ok" << 0 << "code" << int(ErrorCodes::InvalidReplicaSetConfig) << "errmsg"
<< "newer config"
- << "configVersion" << posUpdater->getConfigVersion() + 1));
+ << "configVersion"
+ << posUpdater->getConfigVersion() + 1));
ASSERT_EQUALS(expectedOldStyleCommandRequest, commandRequest);
ASSERT_TRUE(reporter->isActive());
@@ -526,7 +530,7 @@ TEST_F(ReporterTestNoTriggerAtSetUp, CommandPreparationFailureStopsTheReporter)
Status expectedStatus(ErrorCodes::UnknownError, "unknown error");
prepareReplSetUpdatePositionCommandFn =
[expectedStatus](ReplicationCoordinator::ReplSetUpdatePositionCommandStyle commandStyle)
- -> StatusWith<BSONObj> { return expectedStatus; };
+ -> StatusWith<BSONObj> { return expectedStatus; };
ASSERT_OK(reporter->trigger());
ASSERT_EQUALS(expectedStatus, reporter->join());
@@ -544,7 +548,7 @@ TEST_F(ReporterTest, CommandPreparationFailureDuringRescheduleStopsTheReporter)
Status expectedStatus(ErrorCodes::UnknownError, "unknown error");
prepareReplSetUpdatePositionCommandFn =
[expectedStatus](ReplicationCoordinator::ReplSetUpdatePositionCommandStyle commandStyle)
- -> StatusWith<BSONObj> { return expectedStatus; };
+ -> StatusWith<BSONObj> { return expectedStatus; };
processNetworkResponse(BSON("ok" << 1));
@@ -704,7 +708,7 @@ TEST_F(ReporterTest, KeepAliveTimeoutFailingToScheduleRemoteCommandShouldMakeRep
Status expectedStatus(ErrorCodes::UnknownError, "failed to prepare update command");
prepareReplSetUpdatePositionCommandFn =
[expectedStatus](ReplicationCoordinator::ReplSetUpdatePositionCommandStyle commandStyle)
- -> StatusWith<BSONObj> { return expectedStatus; };
+ -> StatusWith<BSONObj> { return expectedStatus; };
runUntil(until);
diff --git a/src/mongo/db/repl/resync.cpp b/src/mongo/db/repl/resync.cpp
index 674b43f969a..86797724eed 100644
--- a/src/mongo/db/repl/resync.cpp
+++ b/src/mongo/db/repl/resync.cpp
@@ -28,10 +28,10 @@
#include "mongo/db/commands.h"
#include "mongo/db/concurrency/d_concurrency.h"
+#include "mongo/db/operation_context.h"
#include "mongo/db/repl/bgsync.h"
#include "mongo/db/repl/master_slave.h" // replSettings
#include "mongo/db/repl/replication_coordinator_global.h"
-#include "mongo/db/operation_context.h"
namespace mongo {
diff --git a/src/mongo/db/repl/roll_back_local_operations_test.cpp b/src/mongo/db/repl/roll_back_local_operations_test.cpp
index 06af9890571..87e888a62d0 100644
--- a/src/mongo/db/repl/roll_back_local_operations_test.cpp
+++ b/src/mongo/db/repl/roll_back_local_operations_test.cpp
@@ -121,8 +121,9 @@ TEST(RollBackLocalOperationsTest, RollbackOperationFailed) {
makeOpAndRecordId(2, 1), commonOperation,
});
OplogInterfaceMock localOplog(localOperations);
- auto rollbackOperation =
- [&](const BSONObj& operation) { return Status(ErrorCodes::OperationFailed, ""); };
+ auto rollbackOperation = [&](const BSONObj& operation) {
+ return Status(ErrorCodes::OperationFailed, "");
+ };
RollBackLocalOperations finder(localOplog, rollbackOperation);
auto result = finder.onRemoteOperation(commonOperation.first);
ASSERT_EQUALS(ErrorCodes::OperationFailed, result.getStatus().code());
@@ -211,8 +212,9 @@ TEST(RollBackLocalOperationsTest, SameTimestampDifferentHashesRollbackOperationF
makeOpAndRecordId(1, 3), commonOperation,
});
OplogInterfaceMock localOplog(localOperations);
- auto rollbackOperation =
- [&](const BSONObj& operation) { return Status(ErrorCodes::OperationFailed, ""); };
+ auto rollbackOperation = [&](const BSONObj& operation) {
+ return Status(ErrorCodes::OperationFailed, "");
+ };
RollBackLocalOperations finder(localOplog, rollbackOperation);
auto result = finder.onRemoteOperation(makeOp(1, 2));
ASSERT_EQUALS(ErrorCodes::OperationFailed, result.getStatus().code());
diff --git a/src/mongo/db/repl/rollback_checker.cpp b/src/mongo/db/repl/rollback_checker.cpp
index 7d1a710982a..cb86eb2a811 100644
--- a/src/mongo/db/repl/rollback_checker.cpp
+++ b/src/mongo/db/repl/rollback_checker.cpp
@@ -49,32 +49,34 @@ RollbackChecker::RollbackChecker(executor::TaskExecutor* executor, HostAndPort s
RollbackChecker::~RollbackChecker() {}
RollbackChecker::CallbackHandle RollbackChecker::checkForRollback(const CallbackFn& nextAction) {
- return _scheduleGetRollbackId([this, nextAction](const RemoteCommandCallbackArgs& args) {
- if (args.response.getStatus() == ErrorCodes::CallbackCanceled) {
- return;
- }
- if (!args.response.isOK()) {
- nextAction(args.response.getStatus());
- return;
- }
- if (auto rbidElement = args.response.getValue().data["rbid"]) {
- int remoteRBID = rbidElement.numberInt();
-
- UniqueLock lk(_mutex);
- bool hadRollback = _checkForRollback_inlock(remoteRBID);
- lk.unlock();
-
- if (hadRollback) {
- nextAction(Status(ErrorCodes::UnrecoverableRollbackError,
- "RollbackChecker detected rollback occurred"));
+ return _scheduleGetRollbackId(
+ [this, nextAction](const RemoteCommandCallbackArgs& args) {
+ if (args.response.getStatus() == ErrorCodes::CallbackCanceled) {
+ return;
+ }
+ if (!args.response.isOK()) {
+ nextAction(args.response.getStatus());
+ return;
+ }
+ if (auto rbidElement = args.response.getValue().data["rbid"]) {
+ int remoteRBID = rbidElement.numberInt();
+
+ UniqueLock lk(_mutex);
+ bool hadRollback = _checkForRollback_inlock(remoteRBID);
+ lk.unlock();
+
+ if (hadRollback) {
+ nextAction(Status(ErrorCodes::UnrecoverableRollbackError,
+ "RollbackChecker detected rollback occurred"));
+ } else {
+ nextAction(Status::OK());
+ }
} else {
- nextAction(Status::OK());
+ nextAction(Status(ErrorCodes::CommandFailed,
+ "replSetGetRBID command failed when checking for rollback"));
}
- } else {
- nextAction(Status(ErrorCodes::CommandFailed,
- "replSetGetRBID command failed when checking for rollback"));
- }
- }, nextAction);
+ },
+ nextAction);
}
bool RollbackChecker::hasHadRollback() {
@@ -87,27 +89,29 @@ bool RollbackChecker::hasHadRollback() {
}
RollbackChecker::CallbackHandle RollbackChecker::reset(const CallbackFn& nextAction) {
- return _scheduleGetRollbackId([this, nextAction](const RemoteCommandCallbackArgs& args) {
- if (args.response.getStatus() == ErrorCodes::CallbackCanceled) {
- return;
- }
- if (!args.response.isOK()) {
- nextAction(args.response.getStatus());
- return;
- }
- if (auto rbidElement = args.response.getValue().data["rbid"]) {
- int newRBID = rbidElement.numberInt();
-
- UniqueLock lk(_mutex);
- _setRBID_inlock(newRBID);
- lk.unlock();
-
- nextAction(Status::OK());
- } else {
- nextAction(Status(ErrorCodes::CommandFailed,
- "replSetGetRBID command failed when checking for rollback"));
- }
- }, nextAction);
+ return _scheduleGetRollbackId(
+ [this, nextAction](const RemoteCommandCallbackArgs& args) {
+ if (args.response.getStatus() == ErrorCodes::CallbackCanceled) {
+ return;
+ }
+ if (!args.response.isOK()) {
+ nextAction(args.response.getStatus());
+ return;
+ }
+ if (auto rbidElement = args.response.getValue().data["rbid"]) {
+ int newRBID = rbidElement.numberInt();
+
+ UniqueLock lk(_mutex);
+ _setRBID_inlock(newRBID);
+ lk.unlock();
+
+ nextAction(Status::OK());
+ } else {
+ nextAction(Status(ErrorCodes::CommandFailed,
+ "replSetGetRBID command failed when checking for rollback"));
+ }
+ },
+ nextAction);
}
Status RollbackChecker::reset_sync() {
diff --git a/src/mongo/db/repl/rollback_source_impl.cpp b/src/mongo/db/repl/rollback_source_impl.cpp
index 443e242deb2..f416af8c716 100644
--- a/src/mongo/db/repl/rollback_source_impl.cpp
+++ b/src/mongo/db/repl/rollback_source_impl.cpp
@@ -35,8 +35,8 @@
#include "mongo/db/jsobj.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/repl/oplogreader.h"
-#include "mongo/util/mongoutils/str.h"
#include "mongo/util/assert_util.h"
+#include "mongo/util/mongoutils/str.h"
namespace mongo {
namespace repl {
diff --git a/src/mongo/db/repl/rs_initialsync.cpp b/src/mongo/db/repl/rs_initialsync.cpp
index 2f31e9a63d7..fe25036f399 100644
--- a/src/mongo/db/repl/rs_initialsync.cpp
+++ b/src/mongo/db/repl/rs_initialsync.cpp
@@ -40,10 +40,9 @@
#include "mongo/db/catalog/document_validation.h"
#include "mongo/db/client.h"
#include "mongo/db/cloner.h"
-#include "mongo/db/db_raii.h"
#include "mongo/db/concurrency/write_conflict_exception.h"
+#include "mongo/db/db_raii.h"
#include "mongo/db/dbhelpers.h"
-#include "mongo/db/service_context.h"
#include "mongo/db/op_observer.h"
#include "mongo/db/repl/bgsync.h"
#include "mongo/db/repl/initial_sync.h"
@@ -52,6 +51,7 @@
#include "mongo/db/repl/repl_client_info.h"
#include "mongo/db/repl/replication_coordinator_global.h"
#include "mongo/db/repl/storage_interface.h"
+#include "mongo/db/service_context.h"
#include "mongo/util/exit.h"
#include "mongo/util/fail_point_service.h"
#include "mongo/util/log.h"
@@ -143,7 +143,8 @@ void checkAdminDatabasePostClone(OperationContext* txn, Database* adminDb) {
<< " but could not find an auth schema version document in "
<< AuthorizationManager::versionCollectionNamespace;
severe() << "This indicates that the primary of this replica set was not successfully "
- "upgraded to schema version " << AuthorizationManager::schemaVersion26Final
+ "upgraded to schema version "
+ << AuthorizationManager::schemaVersion26Final
<< ", which is the minimum supported schema version in this version of MongoDB";
fassertFailedNoTrace(28620);
}
diff --git a/src/mongo/db/repl/rs_rollback.cpp b/src/mongo/db/repl/rs_rollback.cpp
index bb5531dbf34..0663c13e4dd 100644
--- a/src/mongo/db/repl/rs_rollback.cpp
+++ b/src/mongo/db/repl/rs_rollback.cpp
@@ -37,17 +37,17 @@
#include <memory>
#include "mongo/bson/util/bson_extract.h"
-#include "mongo/db/auth/authorization_manager_global.h"
#include "mongo/db/auth/authorization_manager.h"
+#include "mongo/db/auth/authorization_manager_global.h"
#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/collection_catalog_entry.h"
#include "mongo/db/catalog/document_validation.h"
#include "mongo/db/client.h"
#include "mongo/db/commands.h"
#include "mongo/db/concurrency/write_conflict_exception.h"
+#include "mongo/db/db_raii.h"
#include "mongo/db/dbhelpers.h"
#include "mongo/db/exec/working_set_common.h"
-#include "mongo/db/db_raii.h"
#include "mongo/db/ops/delete.h"
#include "mongo/db/ops/update.h"
#include "mongo/db/ops/update_lifecycle_impl.h"
@@ -454,7 +454,8 @@ void syncFixUp(OperationContext* txn,
auto status = options.parse(optionsField.Obj());
if (!status.isOK()) {
throw RSFatalException(str::stream() << "Failed to parse options " << info
- << ": " << status.toString());
+ << ": "
+ << status.toString());
}
} else {
// Use default options.
@@ -467,19 +468,19 @@ void syncFixUp(OperationContext* txn,
auto status = collection->setValidator(txn, options.validator);
if (!status.isOK()) {
- throw RSFatalException(str::stream()
- << "Failed to set validator: " << status.toString());
+ throw RSFatalException(str::stream() << "Failed to set validator: "
+ << status.toString());
}
status = collection->setValidationAction(txn, options.validationAction);
if (!status.isOK()) {
- throw RSFatalException(str::stream()
- << "Failed to set validationAction: " << status.toString());
+ throw RSFatalException(str::stream() << "Failed to set validationAction: "
+ << status.toString());
}
status = collection->setValidationLevel(txn, options.validationLevel);
if (!status.isOK()) {
- throw RSFatalException(str::stream()
- << "Failed to set validationLevel: " << status.toString());
+ throw RSFatalException(str::stream() << "Failed to set validationLevel: "
+ << status.toString());
}
wuow.commit();
@@ -822,7 +823,8 @@ Status _syncRollback(OperationContext* txn,
if (!replCoord->setFollowerMode(MemberState::RS_ROLLBACK)) {
return Status(ErrorCodes::OperationFailed,
str::stream() << "Cannot transition from "
- << replCoord->getMemberState().toString() << " to "
+ << replCoord->getMemberState().toString()
+ << " to "
<< MemberState(MemberState::RS_ROLLBACK).toString());
}
}
@@ -833,8 +835,9 @@ Status _syncRollback(OperationContext* txn,
{
log() << "rollback 2 FindCommonPoint";
try {
- auto processOperationForFixUp =
- [&how](const BSONObj& operation) { return refetch(how, operation); };
+ auto processOperationForFixUp = [&how](const BSONObj& operation) {
+ return refetch(how, operation);
+ };
auto res = syncRollBackLocalOperations(
localOplog, rollbackSource.getOplog(), processOperationForFixUp);
if (!res.isOK()) {
@@ -856,7 +859,8 @@ Status _syncRollback(OperationContext* txn,
return Status(ErrorCodes::UnrecoverableRollbackError,
str::stream()
<< "need to rollback, but unable to determine common point between"
- " local and remote oplog: " << e.what(),
+ " local and remote oplog: "
+ << e.what(),
18752);
} catch (const DBException& e) {
warning() << "rollback 2 exception " << e.toString() << "; sleeping 1 min";
@@ -912,11 +916,9 @@ Status syncRollback(OperationContext* txn,
const OplogInterface& localOplog,
const RollbackSource& rollbackSource,
ReplicationCoordinator* replCoord) {
- return syncRollback(txn,
- localOplog,
- rollbackSource,
- replCoord,
- [](Seconds seconds) { sleepsecs(durationCount<Seconds>(seconds)); });
+ return syncRollback(txn, localOplog, rollbackSource, replCoord, [](Seconds seconds) {
+ sleepsecs(durationCount<Seconds>(seconds));
+ });
}
} // namespace repl
diff --git a/src/mongo/db/repl/rs_rollback_test.cpp b/src/mongo/db/repl/rs_rollback_test.cpp
index 5387be5eb7c..096e3902bed 100644
--- a/src/mongo/db/repl/rs_rollback_test.cpp
+++ b/src/mongo/db/repl/rs_rollback_test.cpp
@@ -199,7 +199,8 @@ TEST_F(RSRollbackTest, SetFollowerModeFailed) {
RollbackSourceMock(std::unique_ptr<OplogInterface>(
new OplogInterfaceMock(kEmptyMockOperations))),
_coordinator,
- noSleep).code());
+ noSleep)
+ .code());
}
TEST_F(RSRollbackTest, OplogStartMissing) {
@@ -214,7 +215,8 @@ TEST_F(RSRollbackTest, OplogStartMissing) {
operation,
}))),
_coordinator,
- noSleep).code());
+ noSleep)
+ .code());
}
TEST_F(RSRollbackTest, NoRemoteOpLog) {
@@ -307,7 +309,8 @@ int _testRollbackDelete(OperationContext* txn,
<< "d"
<< "ns"
<< "test.t"
- << "o" << BSON("_id" << 0)),
+ << "o"
+ << BSON("_id" << 0)),
RecordId(2));
class RollbackSourceLocal : public RollbackSourceMock {
public:
@@ -383,7 +386,8 @@ TEST_F(RSRollbackTest, RollbackInsertDocumentWithNoId) {
<< "i"
<< "ns"
<< "test.t"
- << "o" << BSON("a" << 1)),
+ << "o"
+ << BSON("a" << 1)),
RecordId(2));
class RollbackSourceLocal : public RollbackSourceMock {
public:
@@ -419,7 +423,9 @@ TEST_F(RSRollbackTest, RollbackCreateIndexCommand) {
auto collection = _createCollection(_txn.get(), "test.t", CollectionOptions());
auto indexSpec = BSON("ns"
<< "test.t"
- << "key" << BSON("a" << 1) << "name"
+ << "key"
+ << BSON("a" << 1)
+ << "name"
<< "a_1");
{
Lock::DBLock dbLock(_txn->lockState(), "test", MODE_X);
@@ -439,7 +445,8 @@ TEST_F(RSRollbackTest, RollbackCreateIndexCommand) {
<< "i"
<< "ns"
<< "test.system.indexes"
- << "o" << indexSpec),
+ << "o"
+ << indexSpec),
RecordId(2));
class RollbackSourceLocal : public RollbackSourceMock {
public:
@@ -483,7 +490,9 @@ TEST_F(RSRollbackTest, RollbackCreateIndexCommandIndexNotInCatalog) {
auto collection = _createCollection(_txn.get(), "test.t", CollectionOptions());
auto indexSpec = BSON("ns"
<< "test.t"
- << "key" << BSON("a" << 1) << "name"
+ << "key"
+ << BSON("a" << 1)
+ << "name"
<< "a_1");
// Skip index creation to trigger warning during rollback.
{
@@ -499,7 +508,8 @@ TEST_F(RSRollbackTest, RollbackCreateIndexCommandIndexNotInCatalog) {
<< "i"
<< "ns"
<< "test.system.indexes"
- << "o" << indexSpec),
+ << "o"
+ << indexSpec),
RecordId(2));
class RollbackSourceLocal : public RollbackSourceMock {
public:
@@ -545,8 +555,9 @@ TEST_F(RSRollbackTest, RollbackCreateIndexCommandMissingNamespace) {
<< "i"
<< "ns"
<< "test.system.indexes"
- << "o" << BSON("key" << BSON("a" << 1) << "name"
- << "a_1")),
+ << "o"
+ << BSON("key" << BSON("a" << 1) << "name"
+ << "a_1")),
RecordId(2));
class RollbackSourceLocal : public RollbackSourceMock {
public:
@@ -587,10 +598,13 @@ TEST_F(RSRollbackTest, RollbackCreateIndexCommandInvalidNamespace) {
<< "i"
<< "ns"
<< "test.system.indexes"
- << "o" << BSON("ns"
- << "test."
- << "key" << BSON("a" << 1) << "name"
- << "a_1")),
+ << "o"
+ << BSON("ns"
+ << "test."
+ << "key"
+ << BSON("a" << 1)
+ << "name"
+ << "a_1")),
RecordId(2));
class RollbackSourceLocal : public RollbackSourceMock {
public:
@@ -631,9 +645,11 @@ TEST_F(RSRollbackTest, RollbackCreateIndexCommandMissingIndexName) {
<< "i"
<< "ns"
<< "test.system.indexes"
- << "o" << BSON("ns"
- << "test.t"
- << "key" << BSON("a" << 1))),
+ << "o"
+ << BSON("ns"
+ << "test.t"
+ << "key"
+ << BSON("a" << 1))),
RecordId(2));
class RollbackSourceLocal : public RollbackSourceMock {
public:
@@ -673,8 +689,9 @@ TEST_F(RSRollbackTest, RollbackUnknownCommand) {
<< "c"
<< "ns"
<< "test.t"
- << "o" << BSON("unknown_command"
- << "t")),
+ << "o"
+ << BSON("unknown_command"
+ << "t")),
RecordId(2));
{
Lock::DBLock dbLock(_txn->lockState(), "test", MODE_X);
@@ -705,8 +722,9 @@ TEST_F(RSRollbackTest, RollbackDropCollectionCommand) {
<< "c"
<< "ns"
<< "test.t"
- << "o" << BSON("drop"
- << "t")),
+ << "o"
+ << BSON("drop"
+ << "t")),
RecordId(2));
class RollbackSourceLocal : public RollbackSourceMock {
public:
@@ -787,24 +805,30 @@ TEST_F(RSRollbackTest, RollbackApplyOpsCommand) {
<< "u"
<< "ns"
<< "test.t"
- << "o2" << BSON("_id" << 1) << "o"
+ << "o2"
+ << BSON("_id" << 1)
+ << "o"
<< BSON("_id" << 1 << "v" << 2)),
BSON("op"
<< "u"
<< "ns"
<< "test.t"
- << "o2" << BSON("_id" << 2) << "o"
+ << "o2"
+ << BSON("_id" << 2)
+ << "o"
<< BSON("_id" << 2 << "v" << 4)),
BSON("op"
<< "d"
<< "ns"
<< "test.t"
- << "o" << BSON("_id" << 3)),
+ << "o"
+ << BSON("_id" << 3)),
BSON("op"
<< "i"
<< "ns"
<< "test.t"
- << "o" << BSON("_id" << 4))}),
+ << "o"
+ << BSON("_id" << 4))}),
RecordId(2));
class RollbackSourceLocal : public RollbackSourceMock {
@@ -870,8 +894,9 @@ TEST_F(RSRollbackTest, RollbackCreateCollectionCommand) {
<< "c"
<< "ns"
<< "test.t"
- << "o" << BSON("create"
- << "t")),
+ << "o"
+ << BSON("create"
+ << "t")),
RecordId(2));
RollbackSourceMock rollbackSource(std::unique_ptr<OplogInterface>(new OplogInterfaceMock({
commonOperation,
@@ -899,9 +924,11 @@ TEST_F(RSRollbackTest, RollbackCollectionModificationCommand) {
<< "c"
<< "ns"
<< "test.t"
- << "o" << BSON("collMod"
- << "t"
- << "noPadding" << false)),
+ << "o"
+ << BSON("collMod"
+ << "t"
+ << "noPadding"
+ << false)),
RecordId(2));
class RollbackSourceLocal : public RollbackSourceMock {
public:
@@ -940,9 +967,11 @@ TEST_F(RSRollbackTest, RollbackCollectionModificationCommandInvalidCollectionOpt
<< "c"
<< "ns"
<< "test.t"
- << "o" << BSON("collMod"
- << "t"
- << "noPadding" << false)),
+ << "o"
+ << BSON("collMod"
+ << "t"
+ << "noPadding"
+ << false)),
RecordId(2));
class RollbackSourceLocal : public RollbackSourceMock {
public:
diff --git a/src/mongo/db/repl/rs_sync.cpp b/src/mongo/db/repl/rs_sync.cpp
index cc8eaa320e5..455235e519c 100644
--- a/src/mongo/db/repl/rs_sync.cpp
+++ b/src/mongo/db/repl/rs_sync.cpp
@@ -41,8 +41,8 @@
#include "mongo/db/client.h"
#include "mongo/db/commands/fsync.h"
#include "mongo/db/commands/server_status.h"
-#include "mongo/db/curop.h"
#include "mongo/db/concurrency/d_concurrency.h"
+#include "mongo/db/curop.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/repl/bgsync.h"
#include "mongo/db/repl/optime.h"
diff --git a/src/mongo/db/repl/rs_sync.h b/src/mongo/db/repl/rs_sync.h
index ec174268b5c..513c6265657 100644
--- a/src/mongo/db/repl/rs_sync.h
+++ b/src/mongo/db/repl/rs_sync.h
@@ -32,10 +32,10 @@
#include <vector>
#include "mongo/db/client.h"
-#include "mongo/db/storage/mmap_v1/dur.h"
#include "mongo/db/jsobj.h"
#include "mongo/db/repl/initial_sync.h"
#include "mongo/db/repl/sync_tail.h"
+#include "mongo/db/storage/mmap_v1/dur.h"
#include "mongo/util/concurrency/old_thread_pool.h"
namespace mongo {
diff --git a/src/mongo/db/repl/storage_interface_impl.cpp b/src/mongo/db/repl/storage_interface_impl.cpp
index ef9935ae86f..3f3267158d8 100644
--- a/src/mongo/db/repl/storage_interface_impl.cpp
+++ b/src/mongo/db/repl/storage_interface_impl.cpp
@@ -154,7 +154,8 @@ void StorageInterfaceImpl::setMinValid(OperationContext* txn,
txn,
_minValidNss.ns().c_str(),
BSON("$set" << BSON("ts" << endOpTime.getTimestamp() << "t" << endOpTime.getTerm())
- << "$unset" << BSON(kBeginFieldName << 1)));
+ << "$unset"
+ << BSON(kBeginFieldName << 1)));
}
MONGO_WRITE_CONFLICT_RETRY_LOOP_END(
txn, "StorageInterfaceImpl::setMinValid", _minValidNss.ns());
@@ -174,7 +175,8 @@ void StorageInterfaceImpl::setMinValid(OperationContext* txn, const BatchBoundar
Helpers::putSingleton(txn,
_minValidNss.ns().c_str(),
BSON("$set" << BSON("ts" << end.getTimestamp() << "t" << end.getTerm()
- << kBeginFieldName << start.toBSON())));
+ << kBeginFieldName
+ << start.toBSON())));
}
MONGO_WRITE_CONFLICT_RETRY_LOOP_END(
txn, "StorageInterfaceImpl::setMinValid", _minValidNss.ns());
diff --git a/src/mongo/db/repl/sync_source_feedback.cpp b/src/mongo/db/repl/sync_source_feedback.cpp
index 411b3fb0133..ed05b1fc48b 100644
--- a/src/mongo/db/repl/sync_source_feedback.cpp
+++ b/src/mongo/db/repl/sync_source_feedback.cpp
@@ -33,11 +33,11 @@
#include "mongo/db/repl/sync_source_feedback.h"
#include "mongo/db/client.h"
+#include "mongo/db/operation_context.h"
#include "mongo/db/repl/bgsync.h"
#include "mongo/db/repl/replica_set_config.h"
#include "mongo/db/repl/replication_coordinator.h"
#include "mongo/db/repl/reporter.h"
-#include "mongo/db/operation_context.h"
#include "mongo/executor/network_interface_factory.h"
#include "mongo/executor/network_interface_thread_pool.h"
#include "mongo/executor/thread_pool_task_executor.h"
@@ -75,25 +75,24 @@ Milliseconds calculateKeepAliveInterval(OperationContext* txn, stdx::mutex& mtx)
*/
Reporter::PrepareReplSetUpdatePositionCommandFn makePrepareReplSetUpdatePositionCommandFn(
OperationContext* txn, stdx::mutex& mtx, const HostAndPort& syncTarget) {
- return [&mtx, syncTarget, txn](
- ReplicationCoordinator::ReplSetUpdatePositionCommandStyle commandStyle)
- -> StatusWith<BSONObj> {
- auto currentSyncTarget = BackgroundSync::get()->getSyncTarget();
- if (currentSyncTarget != syncTarget) {
- // Change in sync target
- return Status(ErrorCodes::InvalidSyncSource, "Sync target is no longer valid");
- }
+ return [&mtx, syncTarget, txn](ReplicationCoordinator::ReplSetUpdatePositionCommandStyle
+ commandStyle) -> StatusWith<BSONObj> {
+ auto currentSyncTarget = BackgroundSync::get()->getSyncTarget();
+ if (currentSyncTarget != syncTarget) {
+ // Change in sync target
+ return Status(ErrorCodes::InvalidSyncSource, "Sync target is no longer valid");
+ }
- stdx::lock_guard<stdx::mutex> lock(mtx);
- auto replCoord = repl::ReplicationCoordinator::get(txn);
- if (replCoord->getMemberState().primary()) {
- // Primary has no one to send updates to.
- return Status(ErrorCodes::InvalidSyncSource,
- "Currently primary - no one to send updates to");
- }
+ stdx::lock_guard<stdx::mutex> lock(mtx);
+ auto replCoord = repl::ReplicationCoordinator::get(txn);
+ if (replCoord->getMemberState().primary()) {
+ // Primary has no one to send updates to.
+ return Status(ErrorCodes::InvalidSyncSource,
+ "Currently primary - no one to send updates to");
+ }
- return replCoord->prepareReplSetUpdatePositionCommand(commandStyle);
- };
+ return replCoord->prepareReplSetUpdatePositionCommand(commandStyle);
+ };
}
} // namespace
@@ -254,7 +253,8 @@ void SyncSourceFeedback::run() {
auto status = _updateUpstream(txn.get());
if (!status.isOK()) {
LOG(1) << "The replication progress command (replSetUpdatePosition) failed and will be "
- "retried: " << status;
+ "retried: "
+ << status;
}
}
}
diff --git a/src/mongo/db/repl/sync_tail.cpp b/src/mongo/db/repl/sync_tail.cpp
index ebaff27d29c..d8bcb020c50 100644
--- a/src/mongo/db/repl/sync_tail.cpp
+++ b/src/mongo/db/repl/sync_tail.cpp
@@ -33,9 +33,9 @@
#include "mongo/db/repl/sync_tail.h"
+#include "third_party/murmurhash3/MurmurHash3.h"
#include <boost/functional/hash.hpp>
#include <memory>
-#include "third_party/murmurhash3/MurmurHash3.h"
#include "mongo/base/counter.h"
#include "mongo/db/auth/authorization_session.h"
@@ -749,7 +749,8 @@ void SyncTail::oplogApplication() {
str::stream() << "Attempted to apply an oplog entry ("
<< lastOpTime.toString()
<< ") which is not greater than our lastWrittenOptime ("
- << lastWriteOpTime.toString() << ")."));
+ << lastWriteOpTime.toString()
+ << ")."));
}
handleSlaveDelay(lastOpTime.getTimestamp());
@@ -1029,9 +1030,7 @@ void multiSyncApply(const std::vector<OplogEntry>& ops, SyncTail*) {
int batchSize = 0;
int batchCount = 0;
auto endOfGroupableOpsIterator = std::find_if(
- oplogEntriesIterator + 1,
- oplogEntryPointers.end(),
- [&](OplogEntry* nextEntry) {
+ oplogEntriesIterator + 1, oplogEntryPointers.end(), [&](OplogEntry* nextEntry) {
return nextEntry->opType[0] != 'i' || // Must be an insert.
nextEntry->ns != entry->ns || // Must be the same namespace.
// Must not create too large an object.
diff --git a/src/mongo/db/repl/sync_tail_test.cpp b/src/mongo/db/repl/sync_tail_test.cpp
index f81852dad0f..087889ed5ac 100644
--- a/src/mongo/db/repl/sync_tail_test.cpp
+++ b/src/mongo/db/repl/sync_tail_test.cpp
@@ -160,11 +160,11 @@ TEST_F(SyncTailTest, SyncApplyNoOp) {
ASSERT_FALSE(convertUpdateToUpsert);
return Status::OK();
};
- SyncTail::ApplyCommandInLockFn applyCmd =
- [&](OperationContext* txn, const BSONObj& theOperation) {
- FAIL("applyCommand unexpectedly invoked.");
- return Status::OK();
- };
+ SyncTail::ApplyCommandInLockFn applyCmd = [&](OperationContext* txn,
+ const BSONObj& theOperation) {
+ FAIL("applyCommand unexpectedly invoked.");
+ return Status::OK();
+ };
ASSERT_TRUE(_txn->writesAreReplicated());
ASSERT_FALSE(documentValidationDisabled(_txn.get()));
ASSERT_OK(SyncTail::syncApply(_txn.get(), op, false, applyOp, applyCmd, _incOps));
@@ -188,11 +188,11 @@ TEST_F(SyncTailTest, SyncApplyNoOpApplyOpThrowsException) {
}
return Status::OK();
};
- SyncTail::ApplyCommandInLockFn applyCmd =
- [&](OperationContext* txn, const BSONObj& theOperation) {
- FAIL("applyCommand unexpectedly invoked.");
- return Status::OK();
- };
+ SyncTail::ApplyCommandInLockFn applyCmd = [&](OperationContext* txn,
+ const BSONObj& theOperation) {
+ FAIL("applyCommand unexpectedly invoked.");
+ return Status::OK();
+ };
ASSERT_OK(SyncTail::syncApply(_txn.get(), op, false, applyOp, applyCmd, _incOps));
ASSERT_EQUALS(5, applyOpCalled);
}
@@ -219,11 +219,11 @@ void SyncTailTest::_testSyncApplyInsertDocument(LockMode expectedMode) {
ASSERT_TRUE(convertUpdateToUpsert);
return Status::OK();
};
- SyncTail::ApplyCommandInLockFn applyCmd =
- [&](OperationContext* txn, const BSONObj& theOperation) {
- FAIL("applyCommand unexpectedly invoked.");
- return Status::OK();
- };
+ SyncTail::ApplyCommandInLockFn applyCmd = [&](OperationContext* txn,
+ const BSONObj& theOperation) {
+ FAIL("applyCommand unexpectedly invoked.");
+ return Status::OK();
+ };
ASSERT_TRUE(_txn->writesAreReplicated());
ASSERT_FALSE(documentValidationDisabled(_txn.get()));
ASSERT_OK(SyncTail::syncApply(_txn.get(), op, true, applyOp, applyCmd, _incOps));
@@ -279,11 +279,11 @@ TEST_F(SyncTailTest, SyncApplyIndexBuild) {
ASSERT_FALSE(convertUpdateToUpsert);
return Status::OK();
};
- SyncTail::ApplyCommandInLockFn applyCmd =
- [&](OperationContext* txn, const BSONObj& theOperation) {
- FAIL("applyCommand unexpectedly invoked.");
- return Status::OK();
- };
+ SyncTail::ApplyCommandInLockFn applyCmd = [&](OperationContext* txn,
+ const BSONObj& theOperation) {
+ FAIL("applyCommand unexpectedly invoked.");
+ return Status::OK();
+ };
ASSERT_TRUE(_txn->writesAreReplicated());
ASSERT_FALSE(documentValidationDisabled(_txn.get()));
ASSERT_OK(SyncTail::syncApply(_txn.get(), op, false, applyOp, applyCmd, _incOps));
@@ -304,16 +304,16 @@ TEST_F(SyncTailTest, SyncApplyCommand) {
FAIL("applyOperation unexpectedly invoked.");
return Status::OK();
};
- SyncTail::ApplyCommandInLockFn applyCmd =
- [&](OperationContext* txn, const BSONObj& theOperation) {
- applyCmdCalled = true;
- ASSERT_TRUE(txn);
- ASSERT_TRUE(txn->lockState()->isW());
- ASSERT_TRUE(txn->writesAreReplicated());
- ASSERT_FALSE(documentValidationDisabled(txn));
- ASSERT_EQUALS(op, theOperation);
- return Status::OK();
- };
+ SyncTail::ApplyCommandInLockFn applyCmd = [&](OperationContext* txn,
+ const BSONObj& theOperation) {
+ applyCmdCalled = true;
+ ASSERT_TRUE(txn);
+ ASSERT_TRUE(txn->lockState()->isW());
+ ASSERT_TRUE(txn->writesAreReplicated());
+ ASSERT_FALSE(documentValidationDisabled(txn));
+ ASSERT_EQUALS(op, theOperation);
+ return Status::OK();
+ };
ASSERT_TRUE(_txn->writesAreReplicated());
ASSERT_FALSE(documentValidationDisabled(_txn.get()));
ASSERT_OK(SyncTail::syncApply(_txn.get(), op, false, applyOp, applyCmd, _incOps));
@@ -335,14 +335,14 @@ TEST_F(SyncTailTest, SyncApplyCommandThrowsException) {
FAIL("applyOperation unexpectedly invoked.");
return Status::OK();
};
- SyncTail::ApplyCommandInLockFn applyCmd =
- [&](OperationContext* txn, const BSONObj& theOperation) {
- applyCmdCalled++;
- if (applyCmdCalled < 5) {
- throw WriteConflictException();
- }
- return Status::OK();
- };
+ SyncTail::ApplyCommandInLockFn applyCmd = [&](OperationContext* txn,
+ const BSONObj& theOperation) {
+ applyCmdCalled++;
+ if (applyCmdCalled < 5) {
+ throw WriteConflictException();
+ }
+ return Status::OK();
+ };
ASSERT_OK(SyncTail::syncApply(_txn.get(), op, false, applyOp, applyCmd, _incOps));
ASSERT_EQUALS(5, applyCmdCalled);
ASSERT_EQUALS(1U, _opsApplied);
diff --git a/src/mongo/db/repl/task_runner.cpp b/src/mongo/db/repl/task_runner.cpp
index 1558e88929a..5cb02e05c0e 100644
--- a/src/mongo/db/repl/task_runner.cpp
+++ b/src/mongo/db/repl/task_runner.cpp
@@ -43,8 +43,8 @@
#include "mongo/util/concurrency/old_thread_pool.h"
#include "mongo/util/concurrency/thread_name.h"
#include "mongo/util/destructor_guard.h"
-#include "mongo/util/mongoutils/str.h"
#include "mongo/util/log.h"
+#include "mongo/util/mongoutils/str.h"
namespace mongo {
namespace repl {
diff --git a/src/mongo/db/repl/topology_coordinator.h b/src/mongo/db/repl/topology_coordinator.h
index 27242c393d8..1548cb774a9 100644
--- a/src/mongo/db/repl/topology_coordinator.h
+++ b/src/mongo/db/repl/topology_coordinator.h
@@ -28,8 +28,8 @@
#pragma once
-#include <string>
#include <iosfwd>
+#include <string>
#include "mongo/base/disallow_copying.h"
#include "mongo/db/repl/repl_set_heartbeat_response.h"
diff --git a/src/mongo/db/repl/topology_coordinator_impl.cpp b/src/mongo/db/repl/topology_coordinator_impl.cpp
index 1cfaee288d4..b72fe47f524 100644
--- a/src/mongo/db/repl/topology_coordinator_impl.cpp
+++ b/src/mongo/db/repl/topology_coordinator_impl.cpp
@@ -47,8 +47,8 @@
#include "mongo/db/repl/repl_set_request_votes_args.h"
#include "mongo/db/repl/replication_executor.h"
#include "mongo/db/repl/rslog.h"
-#include "mongo/s/catalog/catalog_manager.h"
#include "mongo/rpc/metadata/repl_set_metadata.h"
+#include "mongo/s/catalog/catalog_manager.h"
#include "mongo/util/hex.h"
#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
@@ -466,14 +466,16 @@ void TopologyCoordinatorImpl::prepareFreshResponse(
*result =
Status(ErrorCodes::ReplicaSetNotFound,
str::stream() << "Wrong repl set name. Expected: " << _rsConfig.getReplSetName()
- << ", received: " << args.setName);
+ << ", received: "
+ << args.setName);
return;
}
if (args.id == static_cast<unsigned>(_selfConfig().getId())) {
*result = Status(ErrorCodes::BadValue,
str::stream() << "Received replSetFresh command from member with the "
- "same member ID as ourself: " << args.id);
+ "same member ID as ourself: "
+ << args.id);
return;
}
@@ -606,7 +608,8 @@ void TopologyCoordinatorImpl::prepareElectResponse(
} else if (myver > args.cfgver) {
// they are stale!
log() << "replSetElect command received stale config version # during election. "
- "Our version: " << myver << ", their version: " << args.cfgver;
+ "Our version: "
+ << myver << ", their version: " << args.cfgver;
vote = -10000;
} else if (!hopeful) {
log() << "replSetElect couldn't find member with id " << args.whoid;
@@ -666,7 +669,8 @@ Status TopologyCoordinatorImpl::prepareHeartbeatResponse(Date_t now,
response->noteMismatched();
return Status(ErrorCodes::InconsistentReplicaSetNames,
str::stream() << "Our set name of " << ourSetName << " does not match name "
- << rshb << " reported by remote node");
+ << rshb
+ << " reported by remote node");
}
const MemberState myState = getMemberState();
@@ -680,7 +684,8 @@ Status TopologyCoordinatorImpl::prepareHeartbeatResponse(Date_t now,
if (args.getSenderId() == _selfConfig().getId()) {
return Status(ErrorCodes::BadValue,
str::stream() << "Received heartbeat from member with the same "
- "member ID as ourself: " << args.getSenderId());
+ "member ID as ourself: "
+ << args.getSenderId());
}
}
@@ -752,7 +757,8 @@ Status TopologyCoordinatorImpl::prepareHeartbeatResponseV1(Date_t now,
<< "; remote node's: " << rshb;
return Status(ErrorCodes::InconsistentReplicaSetNames,
str::stream() << "Our set name of " << ourSetName << " does not match name "
- << rshb << " reported by remote node");
+ << rshb
+ << " reported by remote node");
}
const MemberState myState = getMemberState();
@@ -765,7 +771,8 @@ Status TopologyCoordinatorImpl::prepareHeartbeatResponseV1(Date_t now,
if (args.getSenderId() == _selfConfig().getId()) {
return Status(ErrorCodes::BadValue,
str::stream() << "Received heartbeat from member with the same "
- "member ID as ourself: " << args.getSenderId());
+ "member ID as ourself: "
+ << args.getSenderId());
}
}
@@ -988,7 +995,8 @@ HeartbeatResponseAction TopologyCoordinatorImpl::processHeartbeatResponse(
const int memberIndex = _rsConfig.findMemberIndexByHostAndPort(target);
if (memberIndex == -1) {
LOG(1) << "Could not find " << target << " in current config so ignoring --"
- " current config: " << _rsConfig.toBSON();
+ " current config: "
+ << _rsConfig.toBSON();
HeartbeatResponseAction nextAction = HeartbeatResponseAction::makeNoAction();
nextAction.setNextHeartbeatStartDate(nextHeartbeatStartDate);
return nextAction;
@@ -1001,7 +1009,8 @@ HeartbeatResponseAction TopologyCoordinatorImpl::processHeartbeatResponse(
if (!hbResponse.isOK()) {
if (isUnauthorized) {
LOG(1) << "setAuthIssue: heartbeat response failed due to authentication"
- " issue for member _id:" << member.getId();
+ " issue for member _id:"
+ << member.getId();
hbData.setAuthIssue(now);
} else if (hbStats.getNumFailuresSinceLastStart() > kMaxHeartbeatRetries ||
alreadyElapsed >= _rsConfig.getHeartbeatTimeoutPeriod()) {
@@ -1319,7 +1328,8 @@ Status TopologyCoordinatorImpl::checkShouldStandForElection(Date_t now,
return {ErrorCodes::NodeNotElectable,
str::stream() << "Not standing for election because "
<< _getUnelectableReasonString(unelectableReason)
- << "; my last optime is " << lastOpApplied.toString()
+ << "; my last optime is "
+ << lastOpApplied.toString()
<< " and the newest is "
<< _latestKnownOpTime(lastOpApplied).toString()};
}
diff --git a/src/mongo/db/repl/topology_coordinator_impl_test.cpp b/src/mongo/db/repl/topology_coordinator_impl_test.cpp
index 6d1e9f08a97..030142c628b 100644
--- a/src/mongo/db/repl/topology_coordinator_impl_test.cpp
+++ b/src/mongo/db/repl/topology_coordinator_impl_test.cpp
@@ -244,12 +244,15 @@ TEST_F(TopoCoordTest, NodeReturnsSecondaryWithMostRecentDataAsSyncSource) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -309,26 +312,41 @@ TEST_F(TopoCoordTest, NodeReturnsSecondaryWithMostRecentDataAsSyncSource) {
TEST_F(TopoCoordTest, NodeReturnsClosestValidSyncSourceAsSyncSource) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "hself")
<< BSON("_id" << 10 << "host"
<< "h1")
<< BSON("_id" << 20 << "host"
<< "h2"
- << "buildIndexes" << false << "priority" << 0)
+ << "buildIndexes"
+ << false
+ << "priority"
+ << 0)
<< BSON("_id" << 30 << "host"
<< "h3"
- << "hidden" << true << "priority" << 0 << "votes"
- << 0) << BSON("_id" << 40 << "host"
- << "h4"
- << "arbiterOnly" << true)
+ << "hidden"
+ << true
+ << "priority"
+ << 0
+ << "votes"
+ << 0)
+ << BSON("_id" << 40 << "host"
+ << "h4"
+ << "arbiterOnly"
+ << true)
<< BSON("_id" << 50 << "host"
<< "h5"
- << "slaveDelay" << 1 << "priority" << 0)
+ << "slaveDelay"
+ << 1
+ << "priority"
+ << 0)
<< BSON("_id" << 60 << "host"
- << "h6") << BSON("_id" << 70 << "host"
- << "hprimary"))),
+ << "h6")
+ << BSON("_id" << 70 << "host"
+ << "hprimary"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -460,13 +478,17 @@ TEST_F(TopoCoordTest, NodeReturnsClosestValidSyncSourceAsSyncSource) {
TEST_F(TopoCoordTest, ChooseOnlyPrimaryAsSyncSourceWhenChainingIsDisallowed) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "settings" << BSON("chainingAllowed" << false)
+ << "version"
+ << 1
+ << "settings"
+ << BSON("chainingAllowed" << false)
<< "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -512,12 +534,11 @@ TEST_F(TopoCoordTest, ChooseOnlyPrimaryAsSyncSourceWhenChainingIsDisallowed) {
}
TEST_F(TopoCoordTest, ChooseOnlyVotersAsSyncSourceWhenNodeIsAVoter) {
- updateConfig(fromjson(
- "{_id:'rs0', version:1, members:["
- "{_id:10, host:'hself'}, "
- "{_id:20, host:'h2', votes:0, priority:0}, "
- "{_id:30, host:'h3'} "
- "]}"),
+ updateConfig(fromjson("{_id:'rs0', version:1, members:["
+ "{_id:10, host:'hself'}, "
+ "{_id:20, host:'h2', votes:0, priority:0}, "
+ "{_id:30, host:'h3'} "
+ "]}"),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -550,12 +571,15 @@ TEST_F(TopoCoordTest, ChooseOnlyVotersAsSyncSourceWhenNodeIsAVoter) {
TEST_F(TopoCoordTest, ChooseNoSyncSourceWhenPrimary) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -597,12 +621,15 @@ TEST_F(TopoCoordTest, ChooseNoSyncSourceWhenPrimary) {
TEST_F(TopoCoordTest, ChooseRequestedSyncSourceOnlyTheFirstTimeAfterTheSyncSourceIsForciblySet) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -650,12 +677,15 @@ TEST_F(TopoCoordTest, ChooseRequestedSyncSourceOnlyTheFirstTimeAfterTheSyncSourc
TEST_F(TopoCoordTest, NodeDoesNotChooseBlacklistedSyncSourceUntilBlacklistingExpires) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -699,13 +729,17 @@ TEST_F(TopoCoordTest, NodeDoesNotChooseBlacklistedSyncSourceUntilBlacklistingExp
TEST_F(TopoCoordTest, ChooseNoSyncSourceWhenPrimaryIsBlacklistedAndChainingIsDisallowed) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "settings" << BSON("chainingAllowed" << false)
+ << "version"
+ << 1
+ << "settings"
+ << BSON("chainingAllowed" << false)
<< "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -750,12 +784,15 @@ TEST_F(TopoCoordTest, ChooseNoSyncSourceWhenPrimaryIsBlacklistedAndChainingIsDis
TEST_F(TopoCoordTest, NodeChangesToRecoveringWhenOnlyUnauthorizedNodesAreUp) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -814,18 +851,22 @@ TEST_F(TopoCoordTest, NodeChangesToRecoveringWhenOnlyUnauthorizedNodesAreUp) {
TEST_F(TopoCoordTest, NodeDoesNotActOnHeartbeatsWhenAbsentFromConfig) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "h1")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
-1);
ASSERT_NO_ACTION(heartbeatFromMember(HostAndPort("h2"),
"rs0",
MemberState::RS_SECONDARY,
OpTime(Timestamp(1, 0), 0),
- Milliseconds(300)).getAction());
+ Milliseconds(300))
+ .getAction());
}
TEST_F(TopoCoordTest, NodeReturnsNotSecondaryWhenSyncFromIsRunPriorToHavingAConfig) {
@@ -852,10 +893,13 @@ TEST_F(TopoCoordTest, NodeReturnsNotSecondaryWhenSyncFromIsRunAgainstArbiter) {
// Test trying to sync from another node when we are an arbiter
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "hself"
- << "arbiterOnly" << true)
+ << "arbiterOnly"
+ << true)
<< BSON("_id" << 1 << "host"
<< "h1"))),
0);
@@ -874,21 +918,29 @@ TEST_F(TopoCoordTest, NodeReturnsNotSecondaryWhenSyncFromIsRunAgainstPrimary) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "hself")
<< BSON("_id" << 1 << "host"
<< "h1"
- << "arbiterOnly" << true)
+ << "arbiterOnly"
+ << true)
<< BSON("_id" << 2 << "host"
<< "h2"
- << "priority" << 0 << "buildIndexes" << false)
+ << "priority"
+ << 0
+ << "buildIndexes"
+ << false)
<< BSON("_id" << 3 << "host"
- << "h3") << BSON("_id" << 4 << "host"
- << "h4")
+ << "h3")
+ << BSON("_id" << 4 << "host"
+ << "h4")
<< BSON("_id" << 5 << "host"
- << "h5") << BSON("_id" << 6 << "host"
- << "h6"))),
+ << "h5")
+ << BSON("_id" << 6 << "host"
+ << "h6"))),
0);
// Try to sync while PRIMARY
@@ -911,21 +963,29 @@ TEST_F(TopoCoordTest, NodeReturnsNodeNotFoundWhenSyncFromRequestsANodeNotInConfi
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "hself")
<< BSON("_id" << 1 << "host"
<< "h1"
- << "arbiterOnly" << true)
+ << "arbiterOnly"
+ << true)
<< BSON("_id" << 2 << "host"
<< "h2"
- << "priority" << 0 << "buildIndexes" << false)
+ << "priority"
+ << 0
+ << "buildIndexes"
+ << false)
<< BSON("_id" << 3 << "host"
- << "h3") << BSON("_id" << 4 << "host"
- << "h4")
+ << "h3")
+ << BSON("_id" << 4 << "host"
+ << "h4")
<< BSON("_id" << 5 << "host"
- << "h5") << BSON("_id" << 6 << "host"
- << "h6"))),
+ << "h5")
+ << BSON("_id" << 6 << "host"
+ << "h6"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -944,21 +1004,29 @@ TEST_F(TopoCoordTest, NodeReturnsInvalidOptionsWhenSyncFromRequestsSelf) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "hself")
<< BSON("_id" << 1 << "host"
<< "h1"
- << "arbiterOnly" << true)
+ << "arbiterOnly"
+ << true)
<< BSON("_id" << 2 << "host"
<< "h2"
- << "priority" << 0 << "buildIndexes" << false)
+ << "priority"
+ << 0
+ << "buildIndexes"
+ << false)
<< BSON("_id" << 3 << "host"
- << "h3") << BSON("_id" << 4 << "host"
- << "h4")
+ << "h3")
+ << BSON("_id" << 4 << "host"
+ << "h4")
<< BSON("_id" << 5 << "host"
- << "h5") << BSON("_id" << 6 << "host"
- << "h6"))),
+ << "h5")
+ << BSON("_id" << 6 << "host"
+ << "h6"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -977,21 +1045,29 @@ TEST_F(TopoCoordTest, NodeReturnsInvalidOptionsWhenSyncFromRequestsArbiter) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "hself")
<< BSON("_id" << 1 << "host"
<< "h1"
- << "arbiterOnly" << true)
+ << "arbiterOnly"
+ << true)
<< BSON("_id" << 2 << "host"
<< "h2"
- << "priority" << 0 << "buildIndexes" << false)
+ << "priority"
+ << 0
+ << "buildIndexes"
+ << false)
<< BSON("_id" << 3 << "host"
- << "h3") << BSON("_id" << 4 << "host"
- << "h4")
+ << "h3")
+ << BSON("_id" << 4 << "host"
+ << "h4")
<< BSON("_id" << 5 << "host"
- << "h5") << BSON("_id" << 6 << "host"
- << "h6"))),
+ << "h5")
+ << BSON("_id" << 6 << "host"
+ << "h6"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -1011,21 +1087,29 @@ TEST_F(TopoCoordTest, NodeReturnsInvalidOptionsWhenSyncFromRequestsAnIndexNonbui
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "hself")
<< BSON("_id" << 1 << "host"
<< "h1"
- << "arbiterOnly" << true)
+ << "arbiterOnly"
+ << true)
<< BSON("_id" << 2 << "host"
<< "h2"
- << "priority" << 0 << "buildIndexes" << false)
+ << "priority"
+ << 0
+ << "buildIndexes"
+ << false)
<< BSON("_id" << 3 << "host"
- << "h3") << BSON("_id" << 4 << "host"
- << "h4")
+ << "h3")
+ << BSON("_id" << 4 << "host"
+ << "h4")
<< BSON("_id" << 5 << "host"
- << "h5") << BSON("_id" << 6 << "host"
- << "h6"))),
+ << "h5")
+ << BSON("_id" << 6 << "host"
+ << "h6"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -1045,21 +1129,29 @@ TEST_F(TopoCoordTest, NodeReturnsHostUnreachableWhenSyncFromRequestsADownNode) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "hself")
<< BSON("_id" << 1 << "host"
<< "h1"
- << "arbiterOnly" << true)
+ << "arbiterOnly"
+ << true)
<< BSON("_id" << 2 << "host"
<< "h2"
- << "priority" << 0 << "buildIndexes" << false)
+ << "priority"
+ << 0
+ << "buildIndexes"
+ << false)
<< BSON("_id" << 3 << "host"
- << "h3") << BSON("_id" << 4 << "host"
- << "h4")
+ << "h3")
+ << BSON("_id" << 4 << "host"
+ << "h4")
<< BSON("_id" << 5 << "host"
- << "h5") << BSON("_id" << 6 << "host"
- << "h6"))),
+ << "h5")
+ << BSON("_id" << 6 << "host"
+ << "h6"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -1080,21 +1172,29 @@ TEST_F(TopoCoordTest, ChooseRequestedNodeWhenSyncFromRequestsAStaleNode) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "hself")
<< BSON("_id" << 1 << "host"
<< "h1"
- << "arbiterOnly" << true)
+ << "arbiterOnly"
+ << true)
<< BSON("_id" << 2 << "host"
<< "h2"
- << "priority" << 0 << "buildIndexes" << false)
+ << "priority"
+ << 0
+ << "buildIndexes"
+ << false)
<< BSON("_id" << 3 << "host"
- << "h3") << BSON("_id" << 4 << "host"
- << "h4")
+ << "h3")
+ << BSON("_id" << 4 << "host"
+ << "h4")
<< BSON("_id" << 5 << "host"
- << "h5") << BSON("_id" << 6 << "host"
- << "h6"))),
+ << "h5")
+ << BSON("_id" << 6 << "host"
+ << "h6"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -1119,21 +1219,29 @@ TEST_F(TopoCoordTest, ChooseRequestedNodeWhenSyncFromRequestsAValidNode) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "hself")
<< BSON("_id" << 1 << "host"
<< "h1"
- << "arbiterOnly" << true)
+ << "arbiterOnly"
+ << true)
<< BSON("_id" << 2 << "host"
<< "h2"
- << "priority" << 0 << "buildIndexes" << false)
+ << "priority"
+ << 0
+ << "buildIndexes"
+ << false)
<< BSON("_id" << 3 << "host"
- << "h3") << BSON("_id" << 4 << "host"
- << "h4")
+ << "h3")
+ << BSON("_id" << 4 << "host"
+ << "h4")
<< BSON("_id" << 5 << "host"
- << "h5") << BSON("_id" << 6 << "host"
- << "h6"))),
+ << "h5")
+ << BSON("_id" << 6 << "host"
+ << "h6"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -1159,21 +1267,29 @@ TEST_F(TopoCoordTest,
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "hself")
<< BSON("_id" << 1 << "host"
<< "h1"
- << "arbiterOnly" << true)
+ << "arbiterOnly"
+ << true)
<< BSON("_id" << 2 << "host"
<< "h2"
- << "priority" << 0 << "buildIndexes" << false)
+ << "priority"
+ << 0
+ << "buildIndexes"
+ << false)
<< BSON("_id" << 3 << "host"
- << "h3") << BSON("_id" << 4 << "host"
- << "h4")
+ << "h3")
+ << BSON("_id" << 4 << "host"
+ << "h4")
<< BSON("_id" << 5 << "host"
- << "h5") << BSON("_id" << 6 << "host"
- << "h6"))),
+ << "h5")
+ << BSON("_id" << 6 << "host"
+ << "h6"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -1198,21 +1314,29 @@ TEST_F(TopoCoordTest, NodeReturnsUnauthorizedWhenSyncFromRequestsANodeWeAreNotAu
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "hself")
<< BSON("_id" << 1 << "host"
<< "h1"
- << "arbiterOnly" << true)
+ << "arbiterOnly"
+ << true)
<< BSON("_id" << 2 << "host"
<< "h2"
- << "priority" << 0 << "buildIndexes" << false)
+ << "priority"
+ << 0
+ << "buildIndexes"
+ << false)
<< BSON("_id" << 3 << "host"
- << "h3") << BSON("_id" << 4 << "host"
- << "h4")
+ << "h3")
+ << BSON("_id" << 4 << "host"
+ << "h4")
<< BSON("_id" << 5 << "host"
- << "h5") << BSON("_id" << 6 << "host"
- << "h6"))),
+ << "h5")
+ << BSON("_id" << 6 << "host"
+ << "h6"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -1233,12 +1357,11 @@ TEST_F(TopoCoordTest, NodeReturnsInvalidOptionsWhenAskedToSyncFromANonVoterAsAVo
BSONObjBuilder response;
// Test trying to sync from another node
- updateConfig(fromjson(
- "{_id:'rs0', version:1, members:["
- "{_id:0, host:'self'},"
- "{_id:1, host:'h1'},"
- "{_id:2, host:'h2', votes:0, priority:0}"
- "]}"),
+ updateConfig(fromjson("{_id:'rs0', version:1, members:["
+ "{_id:0, host:'self'},"
+ "{_id:1, host:'h1'},"
+ "{_id:2, host:'h2', votes:0, priority:0}"
+ "]}"),
0);
getTopoCoord().prepareSyncFromResponse(HostAndPort("h2"), ourOpTime, &response, &result);
@@ -1257,21 +1380,29 @@ TEST_F(TopoCoordTest,
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "hself")
<< BSON("_id" << 1 << "host"
<< "h1"
- << "arbiterOnly" << true)
+ << "arbiterOnly"
+ << true)
<< BSON("_id" << 2 << "host"
<< "h2"
- << "priority" << 0 << "buildIndexes" << false)
+ << "priority"
+ << 0
+ << "buildIndexes"
+ << false)
<< BSON("_id" << 3 << "host"
- << "h3") << BSON("_id" << 4 << "host"
- << "h4")
+ << "h3")
+ << BSON("_id" << 4 << "host"
+ << "h4")
<< BSON("_id" << 5 << "host"
- << "h5") << BSON("_id" << 6 << "host"
- << "h6"))),
+ << "h5")
+ << BSON("_id" << 6 << "host"
+ << "h6"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -1328,17 +1459,17 @@ TEST_F(TopoCoordTest, ReplSetGetStatus) {
hb.setDurableOpTime(oplogDurable);
StatusWith<ReplSetHeartbeatResponse> hbResponseGood = StatusWith<ReplSetHeartbeatResponse>(hb);
- updateConfig(
- BSON("_id" << setName << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "test0:1234")
- << BSON("_id" << 1 << "host"
- << "test1:1234") << BSON("_id" << 2 << "host"
- << "test2:1234")
- << BSON("_id" << 3 << "host"
- << "test3:1234"))),
- 3,
- startupTime + Milliseconds(1));
+ updateConfig(BSON("_id" << setName << "version" << 1 << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "test0:1234")
+ << BSON("_id" << 1 << "host"
+ << "test1:1234")
+ << BSON("_id" << 2 << "host"
+ << "test2:1234")
+ << BSON("_id" << 3 << "host"
+ << "test3:1234"))),
+ 3,
+ startupTime + Milliseconds(1));
// Now that the replica set is setup, put the members into the states we want them in.
HostAndPort member = HostAndPort("test0:1234");
@@ -1467,15 +1598,15 @@ TEST_F(TopoCoordTest, NodeReturnsInvalidReplicaSetConfigInResponseToGetStatusWhe
OpTime oplogProgress(Timestamp(3, 4), 0);
std::string setName = "mySet";
- updateConfig(
- BSON("_id" << setName << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "test0:1234")
- << BSON("_id" << 1 << "host"
- << "test1:1234") << BSON("_id" << 2 << "host"
- << "test2:1234"))),
- -1, // This one is not part of the replica set.
- startupTime + Milliseconds(1));
+ updateConfig(BSON("_id" << setName << "version" << 1 << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "test0:1234")
+ << BSON("_id" << 1 << "host"
+ << "test1:1234")
+ << BSON("_id" << 2 << "host"
+ << "test2:1234"))),
+ -1, // This one is not part of the replica set.
+ startupTime + Milliseconds(1));
BSONObjBuilder statusBuilder;
Status resultStatus(ErrorCodes::InternalError, "prepareStatusResponse didn't set result");
@@ -1519,16 +1650,21 @@ TEST_F(TopoCoordTest,
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 10 << "members"
+ << "version"
+ << 10
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself"
- << "priority" << 10)
+ << "priority"
+ << 10)
<< BSON("_id" << 20 << "host"
- << "h1") << BSON("_id" << 30 << "host"
- << "h2")
+ << "h1")
+ << BSON("_id" << 30 << "host"
+ << "h2")
<< BSON("_id" << 40 << "host"
<< "h3"
- << "priority" << 10))),
+ << "priority"
+ << 10))),
0);
heartbeatFromMember(HostAndPort("h1"), "rs0", MemberState::RS_SECONDARY, ourOpTime);
@@ -1551,16 +1687,21 @@ TEST_F(TopoCoordTest, NodeReturnsFresherWhenFreshnessIsCheckedWithStaleConfigVer
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 10 << "members"
+ << "version"
+ << 10
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself"
- << "priority" << 10)
+ << "priority"
+ << 10)
<< BSON("_id" << 20 << "host"
- << "h1") << BSON("_id" << 30 << "host"
- << "h2")
+ << "h1")
+ << BSON("_id" << 30 << "host"
+ << "h2")
<< BSON("_id" << 40 << "host"
<< "h3"
- << "priority" << 10))),
+ << "priority"
+ << 10))),
0);
heartbeatFromMember(HostAndPort("h1"), "rs0", MemberState::RS_SECONDARY, ourOpTime);
@@ -1592,16 +1733,21 @@ TEST_F(TopoCoordTest, VetoWhenFreshnessIsCheckedWithAMemberWhoIsNotInTheConfig)
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 10 << "members"
+ << "version"
+ << 10
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself"
- << "priority" << 10)
+ << "priority"
+ << 10)
<< BSON("_id" << 20 << "host"
- << "h1") << BSON("_id" << 30 << "host"
- << "h2")
+ << "h1")
+ << BSON("_id" << 30 << "host"
+ << "h2")
<< BSON("_id" << 40 << "host"
<< "h3"
- << "priority" << 10))),
+ << "priority"
+ << 10))),
0);
heartbeatFromMember(HostAndPort("h1"), "rs0", MemberState::RS_SECONDARY, ourOpTime);
@@ -1632,16 +1778,21 @@ TEST_F(TopoCoordTest, VetoWhenFreshnessIsCheckedWhilePrimary) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 10 << "members"
+ << "version"
+ << 10
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself"
- << "priority" << 10)
+ << "priority"
+ << 10)
<< BSON("_id" << 20 << "host"
- << "h1") << BSON("_id" << 30 << "host"
- << "h2")
+ << "h1")
+ << BSON("_id" << 30 << "host"
+ << "h2")
<< BSON("_id" << 40 << "host"
<< "h3"
- << "priority" << 10))),
+ << "priority"
+ << 10))),
0);
heartbeatFromMember(HostAndPort("h1"), "rs0", MemberState::RS_SECONDARY, ourOpTime);
@@ -1677,16 +1828,21 @@ TEST_F(TopoCoordTest, VetoWhenFreshnessIsCheckedWhilePrimaryExists) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 10 << "members"
+ << "version"
+ << 10
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself"
- << "priority" << 10)
+ << "priority"
+ << 10)
<< BSON("_id" << 20 << "host"
- << "h1") << BSON("_id" << 30 << "host"
- << "h2")
+ << "h1")
+ << BSON("_id" << 30 << "host"
+ << "h2")
<< BSON("_id" << 40 << "host"
<< "h3"
- << "priority" << 10))),
+ << "priority"
+ << 10))),
0);
heartbeatFromMember(HostAndPort("h1"), "rs0", MemberState::RS_SECONDARY, ourOpTime);
@@ -1725,16 +1881,21 @@ TEST_F(TopoCoordTest, NodeReturnsNotFreshestWhenFreshnessIsCheckedByALowPriority
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 10 << "members"
+ << "version"
+ << 10
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself"
- << "priority" << 10)
+ << "priority"
+ << 10)
<< BSON("_id" << 20 << "host"
- << "h1") << BSON("_id" << 30 << "host"
- << "h2")
+ << "h1")
+ << BSON("_id" << 30 << "host"
+ << "h2")
<< BSON("_id" << 40 << "host"
<< "h3"
- << "priority" << 10))),
+ << "priority"
+ << 10))),
0);
heartbeatFromMember(HostAndPort("h1"), "rs0", MemberState::RS_SECONDARY, ourOpTime);
@@ -1772,16 +1933,21 @@ TEST_F(TopoCoordTest, VetoWhenFreshnessIsCheckedByANodeWeBelieveToBeDown) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 10 << "members"
+ << "version"
+ << 10
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself"
- << "priority" << 10)
+ << "priority"
+ << 10)
<< BSON("_id" << 20 << "host"
- << "h1") << BSON("_id" << 30 << "host"
- << "h2")
+ << "h1")
+ << BSON("_id" << 30 << "host"
+ << "h2")
<< BSON("_id" << 40 << "host"
<< "h3"
- << "priority" << 10))),
+ << "priority"
+ << 10))),
0);
heartbeatFromMember(HostAndPort("h1"), "rs0", MemberState::RS_SECONDARY, ourOpTime);
@@ -1822,16 +1988,21 @@ TEST_F(TopoCoordTest, VetoWhenFreshnessIsCheckedByANodeThatIsPrimary) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 10 << "members"
+ << "version"
+ << 10
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself"
- << "priority" << 10)
+ << "priority"
+ << 10)
<< BSON("_id" << 20 << "host"
- << "h1") << BSON("_id" << 30 << "host"
- << "h2")
+ << "h1")
+ << BSON("_id" << 30 << "host"
+ << "h2")
<< BSON("_id" << 40 << "host"
<< "h3"
- << "priority" << 10))),
+ << "priority"
+ << 10))),
0);
heartbeatFromMember(HostAndPort("h1"), "rs0", MemberState::RS_SECONDARY, ourOpTime);
@@ -1871,16 +2042,21 @@ TEST_F(TopoCoordTest, VetoWhenFreshnessIsCheckedByANodeThatIsInStartup) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 10 << "members"
+ << "version"
+ << 10
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself"
- << "priority" << 10)
+ << "priority"
+ << 10)
<< BSON("_id" << 20 << "host"
- << "h1") << BSON("_id" << 30 << "host"
- << "h2")
+ << "h1")
+ << BSON("_id" << 30 << "host"
+ << "h2")
<< BSON("_id" << 40 << "host"
<< "h3"
- << "priority" << 10))),
+ << "priority"
+ << 10))),
0);
heartbeatFromMember(HostAndPort("h1"), "rs0", MemberState::RS_SECONDARY, ourOpTime);
@@ -1918,16 +2094,21 @@ TEST_F(TopoCoordTest, VetoWhenFreshnessIsCheckedByANodeThatIsRecovering) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 10 << "members"
+ << "version"
+ << 10
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself"
- << "priority" << 10)
+ << "priority"
+ << 10)
<< BSON("_id" << 20 << "host"
- << "h1") << BSON("_id" << 30 << "host"
- << "h2")
+ << "h1")
+ << BSON("_id" << 30 << "host"
+ << "h2")
<< BSON("_id" << 40 << "host"
<< "h3"
- << "priority" << 10))),
+ << "priority"
+ << 10))),
0);
heartbeatFromMember(HostAndPort("h1"), "rs0", MemberState::RS_SECONDARY, ourOpTime);
@@ -1966,16 +2147,21 @@ TEST_F(TopoCoordTest,
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 10 << "members"
+ << "version"
+ << 10
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself"
- << "priority" << 10)
+ << "priority"
+ << 10)
<< BSON("_id" << 20 << "host"
- << "h1") << BSON("_id" << 30 << "host"
- << "h2")
+ << "h1")
+ << BSON("_id" << 30 << "host"
+ << "h2")
<< BSON("_id" << 40 << "host"
<< "h3"
- << "priority" << 10))),
+ << "priority"
+ << 10))),
0);
// Test trying to elect a node that is fresher but lower priority than the existing primary
args.setName = "rs0";
@@ -2010,16 +2196,21 @@ TEST_F(TopoCoordTest, RespondPositivelyWhenFreshnessIsCheckedByAnElectableNode)
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 10 << "members"
+ << "version"
+ << 10
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself"
- << "priority" << 10)
+ << "priority"
+ << 10)
<< BSON("_id" << 20 << "host"
- << "h1") << BSON("_id" << 30 << "host"
- << "h2")
+ << "h1")
+ << BSON("_id" << 30 << "host"
+ << "h2")
<< BSON("_id" << 40 << "host"
<< "h3"
- << "priority" << 10))),
+ << "priority"
+ << 10))),
0);
heartbeatFromMember(HostAndPort("h1"), "rs0", MemberState::RS_SECONDARY, ourOpTime);
@@ -2055,16 +2246,21 @@ TEST_F(TopoCoordTest, NodeReturnsBadValueWhenFreshnessIsCheckedByANodeWithOurID)
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 10 << "members"
+ << "version"
+ << 10
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself"
- << "priority" << 10)
+ << "priority"
+ << 10)
<< BSON("_id" << 20 << "host"
- << "h1") << BSON("_id" << 30 << "host"
- << "h2")
+ << "h1")
+ << BSON("_id" << 30 << "host"
+ << "h2")
<< BSON("_id" << 40 << "host"
<< "h3"
- << "priority" << 10))),
+ << "priority"
+ << 10))),
0);
heartbeatFromMember(HostAndPort("h1"), "rs0", MemberState::RS_SECONDARY, ourOpTime);
@@ -2088,11 +2284,10 @@ TEST_F(TopoCoordTest, NodeReturnsBadValueWhenFreshnessIsCheckedByANodeWithOurID)
TEST_F(TopoCoordTest, HeartbeatFrequencyShouldBeHalfElectionTimeoutWhenArbiter) {
// This tests that arbiters issue heartbeats at electionTimeout/2 frequencies
TopoCoordTest::setUp();
- updateConfig(fromjson(
- "{_id:'mySet', version:1, protocolVersion:1, members:["
- "{_id:1, host:'node1:12345', arbiterOnly:true}, "
- "{_id:2, host:'node2:12345'}], "
- "settings:{heartbeatIntervalMillis:10, electionTimeoutMillis:5000}}"),
+ updateConfig(fromjson("{_id:'mySet', version:1, protocolVersion:1, members:["
+ "{_id:1, host:'node1:12345', arbiterOnly:true}, "
+ "{_id:2, host:'node2:12345'}], "
+ "settings:{heartbeatIntervalMillis:10, electionTimeoutMillis:5000}}"),
0);
HostAndPort target("host2", 27017);
Date_t requestDate = now();
@@ -2112,17 +2307,20 @@ class HeartbeatResponseTest : public TopoCoordTest {
public:
virtual void setUp() {
TopoCoordTest::setUp();
- updateConfig(
- BSON("_id"
- << "rs0"
- << "version" << 5 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "host1:27017")
- << BSON("_id" << 1 << "host"
- << "host2:27017") << BSON("_id" << 2 << "host"
- << "host3:27017"))
- << "settings" << BSON("heartbeatTimeoutSecs" << 5)),
- 0);
+ updateConfig(BSON("_id"
+ << "rs0"
+ << "version"
+ << 5
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "host1:27017")
+ << BSON("_id" << 1 << "host"
+ << "host2:27017")
+ << BSON("_id" << 2 << "host"
+ << "host3:27017"))
+ << "settings"
+ << BSON("heartbeatTimeoutSecs" << 5)),
+ 0);
}
};
@@ -2338,13 +2536,16 @@ TEST_F(HeartbeatResponseHighVerbosityTest, UpdateHeartbeatDataSameConfig) {
ReplicaSetConfig originalConfig;
originalConfig.initialize(BSON("_id"
<< "rs0"
- << "version" << 5 << "members"
+ << "version"
+ << 5
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host1:27017")
<< BSON("_id" << 1 << "host"
<< "host2:27017")
<< BSON("_id" << 2 << "host"
- << "host3:27017")) << "settings"
+ << "host3:27017"))
+ << "settings"
<< BSON("heartbeatTimeoutSecs" << 5)));
ReplSetHeartbeatResponse sameConfigResponse;
@@ -2399,7 +2600,9 @@ TEST_F(HeartbeatResponseTestOneRetry, ReconfigWhenHeartbeatResponseContainsAConf
ReplicaSetConfig newConfig;
ASSERT_OK(newConfig.initialize(BSON("_id"
<< "rs0"
- << "version" << 7 << "members"
+ << "version"
+ << 7
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host1:27017")
<< BSON("_id" << 1 << "host"
@@ -2407,7 +2610,8 @@ TEST_F(HeartbeatResponseTestOneRetry, ReconfigWhenHeartbeatResponseContainsAConf
<< BSON("_id" << 2 << "host"
<< "host3:27017")
<< BSON("_id" << 3 << "host"
- << "host4:27017")) << "settings"
+ << "host4:27017"))
+ << "settings"
<< BSON("heartbeatTimeoutSecs" << 5))));
ASSERT_OK(newConfig.validate());
@@ -2580,7 +2784,9 @@ TEST_F(HeartbeatResponseTestTwoRetries, ReconfigWhenHeartbeatResponseContainsACo
ReplicaSetConfig newConfig;
ASSERT_OK(newConfig.initialize(BSON("_id"
<< "rs0"
- << "version" << 7 << "members"
+ << "version"
+ << 7
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host1:27017")
<< BSON("_id" << 1 << "host"
@@ -2588,7 +2794,8 @@ TEST_F(HeartbeatResponseTestTwoRetries, ReconfigWhenHeartbeatResponseContainsACo
<< BSON("_id" << 2 << "host"
<< "host3:27017")
<< BSON("_id" << 3 << "host"
- << "host4:27017")) << "settings"
+ << "host4:27017"))
+ << "settings"
<< BSON("heartbeatTimeoutSecs" << 5))));
ASSERT_OK(newConfig.validate());
@@ -2913,18 +3120,22 @@ TEST_F(HeartbeatResponseTest, UpdateHeartbeatDataStepDownPrimaryForHighPriorityF
// In this test, the Topology coordinator sees a PRIMARY ("host2") and then sees a higher
// priority and similarly fresh node ("host3"). However, since the coordinator's node
// (host1) is not the higher priority node, it takes no action.
- updateConfig(
- BSON("_id"
- << "rs0"
- << "version" << 6 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "host1:27017")
- << BSON("_id" << 1 << "host"
- << "host2:27017") << BSON("_id" << 2 << "host"
- << "host3:27017"
- << "priority" << 3))
- << "settings" << BSON("heartbeatTimeoutSecs" << 5)),
- 0);
+ updateConfig(BSON("_id"
+ << "rs0"
+ << "version"
+ << 6
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "host1:27017")
+ << BSON("_id" << 1 << "host"
+ << "host2:27017")
+ << BSON("_id" << 2 << "host"
+ << "host3:27017"
+ << "priority"
+ << 3))
+ << "settings"
+ << BSON("heartbeatTimeoutSecs" << 5)),
+ 0);
setSelfMemberState(MemberState::RS_SECONDARY);
OpTime election = OpTime();
@@ -2957,18 +3168,22 @@ TEST_F(
//
// Despite having stepped down, we should remain electable, in order to dissuade lower
// priority nodes from standing for election.
- updateConfig(
- BSON("_id"
- << "rs0"
- << "version" << 6 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "host1:27017")
- << BSON("_id" << 1 << "host"
- << "host2:27017") << BSON("_id" << 2 << "host"
- << "host3:27017"
- << "priority" << 3))
- << "settings" << BSON("heartbeatTimeoutSecs" << 5)),
- 0);
+ updateConfig(BSON("_id"
+ << "rs0"
+ << "version"
+ << 6
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "host1:27017")
+ << BSON("_id" << 1 << "host"
+ << "host2:27017")
+ << BSON("_id" << 2 << "host"
+ << "host3:27017"
+ << "priority"
+ << 3))
+ << "settings"
+ << BSON("heartbeatTimeoutSecs" << 5)),
+ 0);
OpTime election = OpTime(Timestamp(1000, 0), 0);
getTopoCoord().setFollowerMode(MemberState::RS_SECONDARY);
@@ -3000,18 +3215,22 @@ TEST_F(HeartbeatResponseTest,
NodeDoesNotStepDownSelfWhenHeartbeatResponseContainsALessFreshHigherPriorityNode) {
// In this test, the Topology coordinator becomes PRIMARY and then sees a higher priority
// and stale node ("host3"). As a result it responds with NoAction.
- updateConfig(
- BSON("_id"
- << "rs0"
- << "version" << 6 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "host1:27017")
- << BSON("_id" << 1 << "host"
- << "host2:27017") << BSON("_id" << 2 << "host"
- << "host3:27017"
- << "priority" << 3))
- << "settings" << BSON("heartbeatTimeoutSecs" << 5)),
- 0);
+ updateConfig(BSON("_id"
+ << "rs0"
+ << "version"
+ << 6
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "host1:27017")
+ << BSON("_id" << 1 << "host"
+ << "host2:27017")
+ << BSON("_id" << 2 << "host"
+ << "host3:27017"
+ << "priority"
+ << 3))
+ << "settings"
+ << BSON("heartbeatTimeoutSecs" << 5)),
+ 0);
OpTime election = OpTime(Timestamp(1000, 0), 0);
OpTime staleTime = OpTime();
@@ -3028,18 +3247,22 @@ TEST_F(HeartbeatResponseTest,
NodeDoesNotStepDownRemoteWhenHeartbeatResponseContainsALessFreshHigherPriorityNode) {
// In this test, the Topology coordinator sees a PRIMARY ("host2") and then sees a higher
// priority and stale node ("host3"). As a result it responds with NoAction.
- updateConfig(
- BSON("_id"
- << "rs0"
- << "version" << 6 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "host1:27017")
- << BSON("_id" << 1 << "host"
- << "host2:27017") << BSON("_id" << 2 << "host"
- << "host3:27017"
- << "priority" << 3))
- << "settings" << BSON("heartbeatTimeoutSecs" << 5)),
- 0);
+ updateConfig(BSON("_id"
+ << "rs0"
+ << "version"
+ << 6
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "host1:27017")
+ << BSON("_id" << 1 << "host"
+ << "host2:27017")
+ << BSON("_id" << 2 << "host"
+ << "host3:27017"
+ << "priority"
+ << 3))
+ << "settings"
+ << BSON("heartbeatTimeoutSecs" << 5)),
+ 0);
setSelfMemberState(MemberState::RS_SECONDARY);
OpTime election = OpTime(Timestamp(1000, 0), 0);
@@ -3107,17 +3330,20 @@ TEST_F(HeartbeatResponseTest,
NodeDoesNotStandForElectionWhenPrimaryIsMarkedDownViaHeartbeatButWeHaveZeroPriority) {
setSelfMemberState(MemberState::RS_SECONDARY);
- updateConfig(
- BSON("_id"
- << "rs0"
- << "version" << 5 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "host1:27017"
- << "priority" << 0)
- << BSON("_id" << 1 << "host"
- << "host2:27017") << BSON("_id" << 2 << "host"
- << "host3:27017"))),
- 0);
+ updateConfig(BSON("_id"
+ << "rs0"
+ << "version"
+ << 5
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "host1:27017"
+ << "priority"
+ << 0)
+ << BSON("_id" << 1 << "host"
+ << "host2:27017")
+ << BSON("_id" << 2 << "host"
+ << "host3:27017"))),
+ 0);
OpTime election = OpTime(Timestamp(400, 0), 0);
OpTime lastOpTimeApplied = OpTime(Timestamp(300, 0), 0);
@@ -3238,17 +3464,20 @@ TEST_F(HeartbeatResponseTest,
TEST_F(HeartbeatResponseTest,
NodeDoesNotStandForElectionWhenPrimaryIsMarkedDownViaHeartbeatButWeAreAnArbiter) {
- updateConfig(
- BSON("_id"
- << "rs0"
- << "version" << 5 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "host1:27017"
- << "arbiterOnly" << true)
- << BSON("_id" << 1 << "host"
- << "host2:27017") << BSON("_id" << 2 << "host"
- << "host3:27017"))),
- 0);
+ updateConfig(BSON("_id"
+ << "rs0"
+ << "version"
+ << 5
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "host1:27017"
+ << "arbiterOnly"
+ << true)
+ << BSON("_id" << 1 << "host"
+ << "host2:27017")
+ << BSON("_id" << 2 << "host"
+ << "host3:27017"))),
+ 0);
OpTime election = OpTime(Timestamp(400, 0), 0);
OpTime lastOpTimeApplied = OpTime(Timestamp(300, 0), 0);
@@ -3693,25 +3922,40 @@ TEST_F(HeartbeatResponseTest,
StartElectionIfAMajorityOfVotersIsVisibleEvenThoughATrueMajorityIsNot) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 5 << "members"
+ << "version"
+ << 5
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host1:27017")
<< BSON("_id" << 1 << "host"
<< "host2:27017")
<< BSON("_id" << 2 << "host"
<< "host3:27017"
- << "votes" << 0 << "priority" << 0)
+ << "votes"
+ << 0
+ << "priority"
+ << 0)
<< BSON("_id" << 3 << "host"
<< "host4:27017"
- << "votes" << 0 << "priority" << 0)
+ << "votes"
+ << 0
+ << "priority"
+ << 0)
<< BSON("_id" << 4 << "host"
<< "host5:27017"
- << "votes" << 0 << "priority" << 0)
+ << "votes"
+ << 0
+ << "priority"
+ << 0)
<< BSON("_id" << 5 << "host"
<< "host6:27017"
- << "votes" << 0 << "priority" << 0)
+ << "votes"
+ << 0
+ << "priority"
+ << 0)
<< BSON("_id" << 6 << "host"
- << "host7:27017")) << "settings"
+ << "host7:27017"))
+ << "settings"
<< BSON("heartbeatTimeoutSecs" << 5)),
0);
@@ -3793,16 +4037,21 @@ public:
TopoCoordTest::setUp();
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 10 << "members"
+ << "version"
+ << 10
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "hself")
<< BSON("_id" << 1 << "host"
- << "h1") << BSON("_id" << 2 << "host"
- << "h2"
- << "priority" << 10)
+ << "h1")
+ << BSON("_id" << 2 << "host"
+ << "h2"
+ << "priority"
+ << 10)
<< BSON("_id" << 3 << "host"
<< "h3"
- << "priority" << 10))),
+ << "priority"
+ << 10))),
0);
}
@@ -4079,9 +4328,8 @@ TEST_F(PrepareElectResponseTest,
ASSERT_EQUALS(0, response2["vote"].Int());
ASSERT_EQUALS(round, response2["round"].OID());
ASSERT_EQUALS(1,
- countLogLinesContaining(
- "voting no for h3:27017; "
- "voted for h2:27017 0 secs ago"));
+ countLogLinesContaining("voting no for h3:27017; "
+ "voted for h2:27017 0 secs ago"));
// Test that after enough time passes the same vote can proceed
now += Seconds(30) + Milliseconds(1); // just over 30 seconds later
@@ -4100,7 +4348,9 @@ TEST_F(PrepareElectResponseTest,
TEST_F(TopoCoordTest, NodeReturnsReplicaSetNotFoundWhenReceivingElectCommandWhileRemoved) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 5 << "members"
+ << "version"
+ << 5
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host1:27017")
<< BSON("_id" << 1 << "host"
@@ -4109,7 +4359,9 @@ TEST_F(TopoCoordTest, NodeReturnsReplicaSetNotFoundWhenReceivingElectCommandWhil
// Reconfig to remove self.
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "host2:27017")
<< BSON("_id" << 2 << "host"
@@ -4140,7 +4392,9 @@ public:
TopoCoordTest::setUp();
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 5 << "members"
+ << "version"
+ << 5
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host1:27017")
<< BSON("_id" << 1 << "host"
@@ -4211,8 +4465,11 @@ TEST_F(TopoCoordTest,
UnfreezeImmediatelyWhenToldToFreezeForZeroSecondsAfterBeingToldToFreezeForLonger) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 5 << "members" << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "host1:27017"))),
+ << "version"
+ << 5
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "host1:27017"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -4231,12 +4488,15 @@ public:
TopoCoordTest::setUp();
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
}
@@ -4296,9 +4556,8 @@ TEST_F(PrepareHeartbeatResponseTest,
ASSERT(result.reason().find("repl set names do not match")) << "Actual string was \""
<< result.reason() << '"';
ASSERT_EQUALS(1,
- countLogLinesContaining(
- "replSet set names do not match, ours: rs0; remote "
- "node's: rs1"));
+ countLogLinesContaining("replSet set names do not match, ours: rs0; remote "
+ "node's: rs1"));
ASSERT_TRUE(response.isMismatched());
ASSERT_EQUALS("", response.getHbMsg());
}
@@ -4541,8 +4800,11 @@ TEST_F(TopoCoordTest, BecomeCandidateWhenBecomingSecondaryInSingleNodeSet) {
ASSERT_EQUALS(MemberState::RS_STARTUP, getTopoCoord().getMemberState().s);
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members" << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "hself"))),
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "hself"))),
0);
ASSERT_EQUALS(MemberState::RS_STARTUP2, getTopoCoord().getMemberState().s);
@@ -4559,10 +4821,13 @@ TEST_F(TopoCoordTest, BecomeCandidateWhenReconfigToBeElectableInSingleNodeSet) {
ReplicaSetConfig cfg;
cfg.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "hself"
- << "priority" << 0))));
+ << "priority"
+ << 0))));
getTopoCoord().updateConfig(cfg, 0, now()++, OpTime());
ASSERT_EQUALS(MemberState::RS_STARTUP2, getTopoCoord().getMemberState().s);
@@ -4575,8 +4840,11 @@ TEST_F(TopoCoordTest, BecomeCandidateWhenReconfigToBeElectableInSingleNodeSet) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members" << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "hself"))),
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "hself"))),
0);
ASSERT_TRUE(TopologyCoordinator::Role::candidate == getTopoCoord().getRole());
}
@@ -4587,10 +4855,13 @@ TEST_F(TopoCoordTest, NodeDoesNotBecomeCandidateWhenBecomingSecondaryInSingleNod
ReplicaSetConfig cfg;
cfg.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "hself"
- << "priority" << 0))));
+ << "priority"
+ << 0))));
getTopoCoord().updateConfig(cfg, 0, now()++, OpTime());
ASSERT_EQUALS(MemberState::RS_STARTUP2, getTopoCoord().getMemberState().s);
@@ -4608,7 +4879,9 @@ TEST_F(TopoCoordTest, NodeTransitionsFromRemovedToStartup2WhenAddedToConfig) {
// config to be absent from the set
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "host2:27017")
<< BSON("_id" << 2 << "host"
@@ -4619,16 +4892,18 @@ TEST_F(TopoCoordTest, NodeTransitionsFromRemovedToStartup2WhenAddedToConfig) {
ASSERT_EQUALS(MemberState::RS_REMOVED, getTopoCoord().getMemberState().s);
// reconfig to add to set
- updateConfig(
- BSON("_id"
- << "rs0"
- << "version" << 2 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "host1:27017")
- << BSON("_id" << 1 << "host"
- << "host2:27017") << BSON("_id" << 2 << "host"
- << "host3:27017"))),
- 0);
+ updateConfig(BSON("_id"
+ << "rs0"
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "host1:27017")
+ << BSON("_id" << 1 << "host"
+ << "host2:27017")
+ << BSON("_id" << 2 << "host"
+ << "host3:27017"))),
+ 0);
// having been added to the config, we should no longer be REMOVED and should enter STARTUP2
ASSERT_TRUE(TopologyCoordinator::Role::follower == getTopoCoord().getRole());
ASSERT_EQUALS(MemberState::RS_STARTUP2, getTopoCoord().getMemberState().s);
@@ -4637,23 +4912,27 @@ TEST_F(TopoCoordTest, NodeTransitionsFromRemovedToStartup2WhenAddedToConfig) {
TEST_F(TopoCoordTest, NodeTransitionsToRemovedWhenRemovedFromConfig) {
ASSERT_TRUE(TopologyCoordinator::Role::follower == getTopoCoord().getRole());
ASSERT_EQUALS(MemberState::RS_STARTUP, getTopoCoord().getMemberState().s);
- updateConfig(
- BSON("_id"
- << "rs0"
- << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "host1:27017")
- << BSON("_id" << 1 << "host"
- << "host2:27017") << BSON("_id" << 2 << "host"
- << "host3:27017"))),
- 0);
+ updateConfig(BSON("_id"
+ << "rs0"
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "host1:27017")
+ << BSON("_id" << 1 << "host"
+ << "host2:27017")
+ << BSON("_id" << 2 << "host"
+ << "host3:27017"))),
+ 0);
ASSERT_TRUE(TopologyCoordinator::Role::follower == getTopoCoord().getRole());
ASSERT_EQUALS(MemberState::RS_STARTUP2, getTopoCoord().getMemberState().s);
// reconfig to remove self
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "host2:27017")
<< BSON("_id" << 2 << "host"
@@ -4669,8 +4948,11 @@ TEST_F(TopoCoordTest, NodeTransitionsToRemovedWhenRemovedFromConfigEvenWhenPrima
ASSERT_EQUALS(MemberState::RS_STARTUP, getTopoCoord().getMemberState().s);
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members" << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "host1:27017"))),
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "host1:27017"))),
0);
ASSERT_FALSE(TopologyCoordinator::Role::candidate == getTopoCoord().getRole());
ASSERT_EQUALS(MemberState::RS_STARTUP2, getTopoCoord().getMemberState().s);
@@ -4685,7 +4967,9 @@ TEST_F(TopoCoordTest, NodeTransitionsToRemovedWhenRemovedFromConfigEvenWhenPrima
// reconfig to remove self
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "host2:27017")
<< BSON("_id" << 2 << "host"
@@ -4701,8 +4985,11 @@ TEST_F(TopoCoordTest, NodeTransitionsToSecondaryWhenReconfiggingToBeUnelectable)
ASSERT_EQUALS(MemberState::RS_STARTUP, getTopoCoord().getMemberState().s);
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members" << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "host1:27017"))),
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "host1:27017"))),
0);
ASSERT_FALSE(TopologyCoordinator::Role::candidate == getTopoCoord().getRole());
ASSERT_EQUALS(MemberState::RS_STARTUP2, getTopoCoord().getMemberState().s);
@@ -4715,17 +5002,20 @@ TEST_F(TopoCoordTest, NodeTransitionsToSecondaryWhenReconfiggingToBeUnelectable)
ASSERT_EQUALS(MemberState::RS_PRIMARY, getTopoCoord().getMemberState().s);
// now lose primary due to loss of electability
- updateConfig(
- BSON("_id"
- << "rs0"
- << "version" << 2 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "host1:27017"
- << "priority" << 0)
- << BSON("_id" << 1 << "host"
- << "host2:27017") << BSON("_id" << 2 << "host"
- << "host3:27017"))),
- 0);
+ updateConfig(BSON("_id"
+ << "rs0"
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "host1:27017"
+ << "priority"
+ << 0)
+ << BSON("_id" << 1 << "host"
+ << "host2:27017")
+ << BSON("_id" << 2 << "host"
+ << "host3:27017"))),
+ 0);
ASSERT_TRUE(TopologyCoordinator::Role::follower == getTopoCoord().getRole());
ASSERT_EQUALS(MemberState::RS_SECONDARY, getTopoCoord().getMemberState().s);
}
@@ -4735,8 +5025,11 @@ TEST_F(TopoCoordTest, NodeMaintainsPrimaryStateAcrossReconfigIfNodeRemainsElecta
ASSERT_EQUALS(MemberState::RS_STARTUP, getTopoCoord().getMemberState().s);
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members" << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "host1:27017"))),
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "host1:27017"))),
0);
ASSERT_FALSE(TopologyCoordinator::Role::candidate == getTopoCoord().getRole());
@@ -4751,38 +5044,45 @@ TEST_F(TopoCoordTest, NodeMaintainsPrimaryStateAcrossReconfigIfNodeRemainsElecta
// Now reconfig in ways that leave us electable and ensure we are still the primary.
// Add hosts
- updateConfig(
- BSON("_id"
- << "rs0"
- << "version" << 2 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "host1:27017")
- << BSON("_id" << 1 << "host"
- << "host2:27017") << BSON("_id" << 2 << "host"
- << "host3:27017"))),
- 0,
- Date_t::fromMillisSinceEpoch(-1),
- OpTime(Timestamp(10, 0), 0));
+ updateConfig(BSON("_id"
+ << "rs0"
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "host1:27017")
+ << BSON("_id" << 1 << "host"
+ << "host2:27017")
+ << BSON("_id" << 2 << "host"
+ << "host3:27017"))),
+ 0,
+ Date_t::fromMillisSinceEpoch(-1),
+ OpTime(Timestamp(10, 0), 0));
ASSERT_TRUE(TopologyCoordinator::Role::leader == getTopoCoord().getRole());
ASSERT_EQUALS(MemberState::RS_PRIMARY, getTopoCoord().getMemberState().s);
// Change priorities and tags
- updateConfig(
- BSON("_id"
- << "rs0"
- << "version" << 2 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "host1:27017"
- << "priority" << 10)
- << BSON("_id" << 1 << "host"
- << "host2:27017"
- << "priority" << 5 << "tags" << BSON("dc"
- << "NA"
- << "rack"
- << "rack1")))),
- 0,
- Date_t::fromMillisSinceEpoch(-1),
- OpTime(Timestamp(10, 0), 0));
+ updateConfig(BSON("_id"
+ << "rs0"
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "host1:27017"
+ << "priority"
+ << 10)
+ << BSON("_id" << 1 << "host"
+ << "host2:27017"
+ << "priority"
+ << 5
+ << "tags"
+ << BSON("dc"
+ << "NA"
+ << "rack"
+ << "rack1")))),
+ 0,
+ Date_t::fromMillisSinceEpoch(-1),
+ OpTime(Timestamp(10, 0), 0));
ASSERT_TRUE(TopologyCoordinator::Role::leader == getTopoCoord().getRole());
ASSERT_EQUALS(MemberState::RS_PRIMARY, getTopoCoord().getMemberState().s);
}
@@ -4790,7 +5090,9 @@ TEST_F(TopoCoordTest, NodeMaintainsPrimaryStateAcrossReconfigIfNodeRemainsElecta
TEST_F(TopoCoordTest, NodeMaintainsSecondaryStateAcrossReconfig) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "host1:27017")
<< BSON("_id" << 2 << "host"
@@ -4802,16 +5104,18 @@ TEST_F(TopoCoordTest, NodeMaintainsSecondaryStateAcrossReconfig) {
ASSERT_EQUALS(MemberState::RS_SECONDARY, getTopoCoord().getMemberState().s);
// reconfig and stay secondary
- updateConfig(
- BSON("_id"
- << "rs0"
- << "version" << 2 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "host1:27017")
- << BSON("_id" << 1 << "host"
- << "host2:27017") << BSON("_id" << 2 << "host"
- << "host3:27017"))),
- 0);
+ updateConfig(BSON("_id"
+ << "rs0"
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "host1:27017")
+ << BSON("_id" << 1 << "host"
+ << "host2:27017")
+ << BSON("_id" << 2 << "host"
+ << "host3:27017"))),
+ 0);
ASSERT_TRUE(TopologyCoordinator::Role::follower == getTopoCoord().getRole());
ASSERT_EQUALS(MemberState::RS_SECONDARY, getTopoCoord().getMemberState().s);
}
@@ -4845,7 +5149,9 @@ TEST_F(HeartbeatResponseTest, ReconfigBetweenHeartbeatRequestAndRepsonse) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host1:27017")
<< BSON("_id" << 2 << "host"
@@ -4894,7 +5200,9 @@ TEST_F(HeartbeatResponseTest, ReconfigNodeRemovedBetweenHeartbeatRequestAndRepso
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host1:27017")
<< BSON("_id" << 1 << "host"
@@ -5148,14 +5456,19 @@ TEST_F(HeartbeatResponseTest, ShouldNotChangeSyncSourceWhenFresherMemberDoesNotB
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 6 << "members"
+ << "version"
+ << 6
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "hself")
<< BSON("_id" << 1 << "host"
<< "host2")
<< BSON("_id" << 2 << "host"
<< "host3"
- << "buildIndexes" << false << "priority" << 0))),
+ << "buildIndexes"
+ << false
+ << "priority"
+ << 0))),
0);
HeartbeatResponseAction nextAction = receiveUpHeartbeat(HostAndPort("host2"),
"rs0",
@@ -5189,15 +5502,23 @@ TEST_F(HeartbeatResponseTest,
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 7 << "members"
+ << "version"
+ << 7
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "hself"
- << "buildIndexes" << false << "priority" << 0)
+ << "buildIndexes"
+ << false
+ << "priority"
+ << 0)
<< BSON("_id" << 1 << "host"
<< "host2")
<< BSON("_id" << 2 << "host"
<< "host3"
- << "buildIndexes" << false << "priority" << 0))),
+ << "buildIndexes"
+ << false
+ << "priority"
+ << 0))),
0);
HeartbeatResponseAction nextAction = receiveUpHeartbeat(HostAndPort("host2"),
"rs0",
@@ -5225,12 +5546,15 @@ TEST_F(HeartbeatResponseTest,
TEST_F(TopoCoordTest, ShouldNotStandForElectionWhileAwareOfPrimary) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -5244,12 +5568,15 @@ TEST_F(TopoCoordTest, ShouldNotStandForElectionWhileAwareOfPrimary) {
TEST_F(TopoCoordTest, ShouldNotStandForElectionWhileTooStale) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -5264,12 +5591,15 @@ TEST_F(TopoCoordTest, ShouldNotStandForElectionWhileTooStale) {
TEST_F(TopoCoordTest, VoteForMyselfFailsWhileNotCandidate) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
ASSERT_FALSE(getTopoCoord().voteForMyself(now()++));
@@ -5278,13 +5608,17 @@ TEST_F(TopoCoordTest, VoteForMyselfFailsWhileNotCandidate) {
TEST_F(TopoCoordTest, NodeReturnsArbiterWhenGetMemberStateRunsAgainstArbiter) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself"
- << "arbiterOnly" << true)
+ << "arbiterOnly"
+ << true)
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
ASSERT_EQUALS(MemberState::RS_ARBITER, getTopoCoord().getMemberState().s);
}
@@ -5299,12 +5633,15 @@ TEST_F(TopoCoordTest, ShouldNotStandForElectionWhileRemovedFromTheConfig) {
TEST_F(TopoCoordTest, ShouldNotStandForElectionWhenAPositiveResponseWasGivenInTheVoteLeasePeriod) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
heartbeatFromMember(
@@ -5339,20 +5676,28 @@ TEST_F(TopoCoordTest, ShouldNotStandForElectionWhenAPositiveResponseWasGivenInTh
TEST_F(TopoCoordTest, NodeDoesNotGrantVotesToTwoDifferentNodesInTheSameTerm) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
ReplSetRequestVotesArgs args;
args.initialize(BSON("replSetRequestVotes" << 1 << "setName"
<< "rs0"
- << "term" << 1LL << "candidateIndex" << 0LL
- << "configVersion" << 1LL << "lastCommittedOp"
+ << "term"
+ << 1LL
+ << "candidateIndex"
+ << 0LL
+ << "configVersion"
+ << 1LL
+ << "lastCommittedOp"
<< BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse response;
OpTime lastAppliedOpTime;
@@ -5362,11 +5707,17 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantVotesToTwoDifferentNodesInTheSameTerm) {
ASSERT_TRUE(response.getVoteGranted());
ReplSetRequestVotesArgs args2;
- args2.initialize(BSON("replSetRequestVotes"
- << 1 << "setName"
- << "rs0"
- << "term" << 1LL << "candidateIndex" << 1LL << "configVersion" << 1LL
- << "lastCommittedOp" << BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
+ args2.initialize(
+ BSON("replSetRequestVotes" << 1 << "setName"
+ << "rs0"
+ << "term"
+ << 1LL
+ << "candidateIndex"
+ << 1LL
+ << "configVersion"
+ << 1LL
+ << "lastCommittedOp"
+ << BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse response2;
// different candidate same term, should be a problem
@@ -5378,12 +5729,15 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantVotesToTwoDifferentNodesInTheSameTerm) {
TEST_F(TopoCoordTest, DryRunVoteRequestShouldNotPreventSubsequentDryRunsForThatTerm) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -5391,8 +5745,14 @@ TEST_F(TopoCoordTest, DryRunVoteRequestShouldNotPreventSubsequentDryRunsForThatT
ReplSetRequestVotesArgs args;
args.initialize(BSON("replSetRequestVotes" << 1 << "setName"
<< "rs0"
- << "dryRun" << true << "term" << 1LL
- << "candidateIndex" << 0LL << "configVersion" << 1LL
+ << "dryRun"
+ << true
+ << "term"
+ << 1LL
+ << "candidateIndex"
+ << 0LL
+ << "configVersion"
+ << 1LL
<< "lastCommittedOp"
<< BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse response;
@@ -5404,12 +5764,19 @@ TEST_F(TopoCoordTest, DryRunVoteRequestShouldNotPreventSubsequentDryRunsForThatT
// second dry run fine
ReplSetRequestVotesArgs args2;
- args2.initialize(BSON("replSetRequestVotes"
- << 1 << "setName"
- << "rs0"
- << "dryRun" << true << "term" << 1LL << "candidateIndex" << 0LL
- << "configVersion" << 1LL << "lastCommittedOp"
- << BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
+ args2.initialize(
+ BSON("replSetRequestVotes" << 1 << "setName"
+ << "rs0"
+ << "dryRun"
+ << true
+ << "term"
+ << 1LL
+ << "candidateIndex"
+ << 0LL
+ << "configVersion"
+ << 1LL
+ << "lastCommittedOp"
+ << BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse response2;
getTopoCoord().processReplSetRequestVotes(args2, &response2, lastAppliedOpTime);
@@ -5420,12 +5787,15 @@ TEST_F(TopoCoordTest, DryRunVoteRequestShouldNotPreventSubsequentDryRunsForThatT
TEST_F(TopoCoordTest, VoteRequestShouldNotPreventDryRunsForThatTerm) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -5433,8 +5803,14 @@ TEST_F(TopoCoordTest, VoteRequestShouldNotPreventDryRunsForThatTerm) {
ReplSetRequestVotesArgs args;
args.initialize(BSON("replSetRequestVotes" << 1 << "setName"
<< "rs0"
- << "dryRun" << false << "term" << 1LL
- << "candidateIndex" << 0LL << "configVersion" << 1LL
+ << "dryRun"
+ << false
+ << "term"
+ << 1LL
+ << "candidateIndex"
+ << 0LL
+ << "configVersion"
+ << 1LL
<< "lastCommittedOp"
<< BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse response;
@@ -5446,12 +5822,19 @@ TEST_F(TopoCoordTest, VoteRequestShouldNotPreventDryRunsForThatTerm) {
// dry post real, fails
ReplSetRequestVotesArgs args2;
- args2.initialize(BSON("replSetRequestVotes"
- << 1 << "setName"
- << "rs0"
- << "dryRun" << false << "term" << 1LL << "candidateIndex" << 0LL
- << "configVersion" << 1LL << "lastCommittedOp"
- << BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
+ args2.initialize(
+ BSON("replSetRequestVotes" << 1 << "setName"
+ << "rs0"
+ << "dryRun"
+ << false
+ << "term"
+ << 1LL
+ << "candidateIndex"
+ << 0LL
+ << "configVersion"
+ << 1LL
+ << "lastCommittedOp"
+ << BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse response2;
getTopoCoord().processReplSetRequestVotes(args2, &response2, lastAppliedOpTime);
@@ -5462,12 +5845,15 @@ TEST_F(TopoCoordTest, VoteRequestShouldNotPreventDryRunsForThatTerm) {
TEST_F(TopoCoordTest, NodeDoesNotGrantVoteWhenReplSetNameDoesNotMatch) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -5475,8 +5861,13 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantVoteWhenReplSetNameDoesNotMatch) {
ReplSetRequestVotesArgs args;
args.initialize(BSON("replSetRequestVotes" << 1 << "setName"
<< "wrongName"
- << "term" << 1LL << "candidateIndex" << 0LL
- << "configVersion" << 1LL << "lastCommittedOp"
+ << "term"
+ << 1LL
+ << "candidateIndex"
+ << 0LL
+ << "configVersion"
+ << 1LL
+ << "lastCommittedOp"
<< BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse response;
OpTime lastAppliedOpTime;
@@ -5489,12 +5880,15 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantVoteWhenReplSetNameDoesNotMatch) {
TEST_F(TopoCoordTest, NodeDoesNotGrantVoteWhenConfigVersionDoesNotMatch) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -5502,8 +5896,13 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantVoteWhenConfigVersionDoesNotMatch) {
ReplSetRequestVotesArgs args;
args.initialize(BSON("replSetRequestVotes" << 1 << "setName"
<< "rs0"
- << "term" << 1LL << "candidateIndex" << 1LL
- << "configVersion" << 0LL << "lastCommittedOp"
+ << "term"
+ << 1LL
+ << "candidateIndex"
+ << 1LL
+ << "configVersion"
+ << 0LL
+ << "lastCommittedOp"
<< BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse response;
OpTime lastAppliedOpTime;
@@ -5516,12 +5915,15 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantVoteWhenConfigVersionDoesNotMatch) {
TEST_F(TopoCoordTest, NodeDoesNotGrantVoteWhenTermIsStale) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -5533,8 +5935,13 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantVoteWhenTermIsStale) {
ReplSetRequestVotesArgs args;
args.initialize(BSON("replSetRequestVotes" << 1 << "setName"
<< "rs0"
- << "term" << 1LL << "candidateIndex" << 1LL
- << "configVersion" << 1LL << "lastCommittedOp"
+ << "term"
+ << 1LL
+ << "candidateIndex"
+ << 1LL
+ << "configVersion"
+ << 1LL
+ << "lastCommittedOp"
<< BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse response;
OpTime lastAppliedOpTime;
@@ -5548,12 +5955,15 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantVoteWhenTermIsStale) {
TEST_F(TopoCoordTest, NodeDoesNotGrantVoteWhenOpTimeIsStale) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -5562,8 +5972,13 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantVoteWhenOpTimeIsStale) {
ReplSetRequestVotesArgs args;
args.initialize(BSON("replSetRequestVotes" << 1 << "setName"
<< "rs0"
- << "term" << 3LL << "candidateIndex" << 1LL
- << "configVersion" << 1LL << "lastCommittedOp"
+ << "term"
+ << 3LL
+ << "candidateIndex"
+ << 1LL
+ << "configVersion"
+ << 1LL
+ << "lastCommittedOp"
<< BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse response;
OpTime lastAppliedOpTime2 = {Timestamp(20, 0), 0};
@@ -5576,12 +5991,15 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantVoteWhenOpTimeIsStale) {
TEST_F(TopoCoordTest, NodeDoesNotGrantDryRunVoteWhenReplSetNameDoesNotMatch) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
// set term to 1
@@ -5589,12 +6007,17 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantDryRunVoteWhenReplSetNameDoesNotMatch) {
getTopoCoord().updateTerm(1, now()));
// and make sure we voted in term 1
ReplSetRequestVotesArgs argsForRealVote;
- argsForRealVote.initialize(BSON("replSetRequestVotes"
- << 1 << "setName"
- << "rs0"
- << "term" << 1LL << "candidateIndex" << 0LL << "configVersion"
- << 1LL << "lastCommittedOp"
- << BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
+ argsForRealVote.initialize(
+ BSON("replSetRequestVotes" << 1 << "setName"
+ << "rs0"
+ << "term"
+ << 1LL
+ << "candidateIndex"
+ << 0LL
+ << "configVersion"
+ << 1LL
+ << "lastCommittedOp"
+ << BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse responseForRealVote;
OpTime lastAppliedOpTime;
@@ -5608,8 +6031,14 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantDryRunVoteWhenReplSetNameDoesNotMatch) {
ReplSetRequestVotesArgs args;
args.initialize(BSON("replSetRequestVotes" << 1 << "setName"
<< "wrongName"
- << "dryRun" << true << "term" << 2LL
- << "candidateIndex" << 0LL << "configVersion" << 1LL
+ << "dryRun"
+ << true
+ << "term"
+ << 2LL
+ << "candidateIndex"
+ << 0LL
+ << "configVersion"
+ << 1LL
<< "lastCommittedOp"
<< BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse response;
@@ -5623,12 +6052,15 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantDryRunVoteWhenReplSetNameDoesNotMatch) {
TEST_F(TopoCoordTest, NodeDoesNotGrantDryRunVoteWhenConfigVersionDoesNotMatch) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
// set term to 1
@@ -5636,12 +6068,17 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantDryRunVoteWhenConfigVersionDoesNotMatch) {
getTopoCoord().updateTerm(1, now()));
// and make sure we voted in term 1
ReplSetRequestVotesArgs argsForRealVote;
- argsForRealVote.initialize(BSON("replSetRequestVotes"
- << 1 << "setName"
- << "rs0"
- << "term" << 1LL << "candidateIndex" << 0LL << "configVersion"
- << 1LL << "lastCommittedOp"
- << BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
+ argsForRealVote.initialize(
+ BSON("replSetRequestVotes" << 1 << "setName"
+ << "rs0"
+ << "term"
+ << 1LL
+ << "candidateIndex"
+ << 0LL
+ << "configVersion"
+ << 1LL
+ << "lastCommittedOp"
+ << BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse responseForRealVote;
OpTime lastAppliedOpTime;
@@ -5655,8 +6092,14 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantDryRunVoteWhenConfigVersionDoesNotMatch) {
ReplSetRequestVotesArgs args;
args.initialize(BSON("replSetRequestVotes" << 1 << "setName"
<< "rs0"
- << "dryRun" << true << "term" << 2LL
- << "candidateIndex" << 1LL << "configVersion" << 0LL
+ << "dryRun"
+ << true
+ << "term"
+ << 2LL
+ << "candidateIndex"
+ << 1LL
+ << "configVersion"
+ << 0LL
<< "lastCommittedOp"
<< BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse response;
@@ -5670,12 +6113,15 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantDryRunVoteWhenConfigVersionDoesNotMatch) {
TEST_F(TopoCoordTest, NodeDoesNotGrantDryRunVoteWhenTermIsStale) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
// set term to 1
@@ -5683,12 +6129,17 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantDryRunVoteWhenTermIsStale) {
getTopoCoord().updateTerm(1, now()));
// and make sure we voted in term 1
ReplSetRequestVotesArgs argsForRealVote;
- argsForRealVote.initialize(BSON("replSetRequestVotes"
- << 1 << "setName"
- << "rs0"
- << "term" << 1LL << "candidateIndex" << 0LL << "configVersion"
- << 1LL << "lastCommittedOp"
- << BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
+ argsForRealVote.initialize(
+ BSON("replSetRequestVotes" << 1 << "setName"
+ << "rs0"
+ << "term"
+ << 1LL
+ << "candidateIndex"
+ << 0LL
+ << "configVersion"
+ << 1LL
+ << "lastCommittedOp"
+ << BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse responseForRealVote;
OpTime lastAppliedOpTime;
@@ -5701,8 +6152,14 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantDryRunVoteWhenTermIsStale) {
ReplSetRequestVotesArgs args;
args.initialize(BSON("replSetRequestVotes" << 1 << "setName"
<< "rs0"
- << "dryRun" << true << "term" << 0LL
- << "candidateIndex" << 1LL << "configVersion" << 1LL
+ << "dryRun"
+ << true
+ << "term"
+ << 0LL
+ << "candidateIndex"
+ << 1LL
+ << "configVersion"
+ << 1LL
<< "lastCommittedOp"
<< BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse response;
@@ -5716,12 +6173,15 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantDryRunVoteWhenTermIsStale) {
TEST_F(TopoCoordTest, GrantDryRunVoteEvenWhenTermHasBeenSeen) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
// set term to 1
@@ -5729,12 +6189,17 @@ TEST_F(TopoCoordTest, GrantDryRunVoteEvenWhenTermHasBeenSeen) {
getTopoCoord().updateTerm(1, now()));
// and make sure we voted in term 1
ReplSetRequestVotesArgs argsForRealVote;
- argsForRealVote.initialize(BSON("replSetRequestVotes"
- << 1 << "setName"
- << "rs0"
- << "term" << 1LL << "candidateIndex" << 0LL << "configVersion"
- << 1LL << "lastCommittedOp"
- << BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
+ argsForRealVote.initialize(
+ BSON("replSetRequestVotes" << 1 << "setName"
+ << "rs0"
+ << "term"
+ << 1LL
+ << "candidateIndex"
+ << 0LL
+ << "configVersion"
+ << 1LL
+ << "lastCommittedOp"
+ << BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse responseForRealVote;
OpTime lastAppliedOpTime;
@@ -5748,8 +6213,14 @@ TEST_F(TopoCoordTest, GrantDryRunVoteEvenWhenTermHasBeenSeen) {
ReplSetRequestVotesArgs args;
args.initialize(BSON("replSetRequestVotes" << 1 << "setName"
<< "rs0"
- << "dryRun" << true << "term" << 1LL
- << "candidateIndex" << 1LL << "configVersion" << 1LL
+ << "dryRun"
+ << true
+ << "term"
+ << 1LL
+ << "candidateIndex"
+ << 1LL
+ << "configVersion"
+ << 1LL
<< "lastCommittedOp"
<< BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse response;
@@ -5763,12 +6234,15 @@ TEST_F(TopoCoordTest, GrantDryRunVoteEvenWhenTermHasBeenSeen) {
TEST_F(TopoCoordTest, DoNotGrantDryRunVoteWhenOpTimeIsStale) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
// set term to 1
@@ -5776,12 +6250,17 @@ TEST_F(TopoCoordTest, DoNotGrantDryRunVoteWhenOpTimeIsStale) {
getTopoCoord().updateTerm(1, now()));
// and make sure we voted in term 1
ReplSetRequestVotesArgs argsForRealVote;
- argsForRealVote.initialize(BSON("replSetRequestVotes"
- << 1 << "setName"
- << "rs0"
- << "term" << 1LL << "candidateIndex" << 0LL << "configVersion"
- << 1LL << "lastCommittedOp"
- << BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
+ argsForRealVote.initialize(
+ BSON("replSetRequestVotes" << 1 << "setName"
+ << "rs0"
+ << "term"
+ << 1LL
+ << "candidateIndex"
+ << 0LL
+ << "configVersion"
+ << 1LL
+ << "lastCommittedOp"
+ << BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse responseForRealVote;
OpTime lastAppliedOpTime;
@@ -5795,8 +6274,14 @@ TEST_F(TopoCoordTest, DoNotGrantDryRunVoteWhenOpTimeIsStale) {
ReplSetRequestVotesArgs args;
args.initialize(BSON("replSetRequestVotes" << 1 << "setName"
<< "rs0"
- << "dryRun" << true << "term" << 3LL
- << "candidateIndex" << 1LL << "configVersion" << 1LL
+ << "dryRun"
+ << true
+ << "term"
+ << 3LL
+ << "candidateIndex"
+ << 1LL
+ << "configVersion"
+ << 1LL
<< "lastCommittedOp"
<< BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse response;
@@ -5818,12 +6303,17 @@ TEST_F(TopoCoordTest, CSRSConfigServerRejectsPV0Config) {
auto configObj = BSON("_id"
<< "rs0"
- << "version" << 1 << "configsvr" << true << "members"
+ << "version"
+ << 1
+ << "configsvr"
+ << true
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3")));
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3")));
ReplicaSetConfig config;
ASSERT_OK(config.initialize(configObj, false));
ASSERT_EQ(ErrorCodes::BadValue, config.validate());
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 826905a860a..9e04bf8942d 100644
--- a/src/mongo/db/repl/topology_coordinator_impl_v1_test.cpp
+++ b/src/mongo/db/repl/topology_coordinator_impl_v1_test.cpp
@@ -255,12 +255,15 @@ TEST_F(TopoCoordTest, NodeReturnsSecondaryWithMostRecentDataAsSyncSource) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -320,26 +323,41 @@ TEST_F(TopoCoordTest, NodeReturnsSecondaryWithMostRecentDataAsSyncSource) {
TEST_F(TopoCoordTest, NodeReturnsClosestValidSyncSourceAsSyncSource) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "hself")
<< BSON("_id" << 10 << "host"
<< "h1")
<< BSON("_id" << 20 << "host"
<< "h2"
- << "buildIndexes" << false << "priority" << 0)
+ << "buildIndexes"
+ << false
+ << "priority"
+ << 0)
<< BSON("_id" << 30 << "host"
<< "h3"
- << "hidden" << true << "priority" << 0 << "votes"
- << 0) << BSON("_id" << 40 << "host"
- << "h4"
- << "arbiterOnly" << true)
+ << "hidden"
+ << true
+ << "priority"
+ << 0
+ << "votes"
+ << 0)
+ << BSON("_id" << 40 << "host"
+ << "h4"
+ << "arbiterOnly"
+ << true)
<< BSON("_id" << 50 << "host"
<< "h5"
- << "slaveDelay" << 1 << "priority" << 0)
+ << "slaveDelay"
+ << 1
+ << "priority"
+ << 0)
<< BSON("_id" << 60 << "host"
- << "h6") << BSON("_id" << 70 << "host"
- << "hprimary"))),
+ << "h6")
+ << BSON("_id" << 70 << "host"
+ << "hprimary"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -471,13 +489,17 @@ TEST_F(TopoCoordTest, NodeReturnsClosestValidSyncSourceAsSyncSource) {
TEST_F(TopoCoordTest, ChooseOnlyPrimaryAsSyncSourceWhenChainingIsDisallowed) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "settings" << BSON("chainingAllowed" << false)
+ << "version"
+ << 1
+ << "settings"
+ << BSON("chainingAllowed" << false)
<< "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -523,12 +545,11 @@ TEST_F(TopoCoordTest, ChooseOnlyPrimaryAsSyncSourceWhenChainingIsDisallowed) {
}
TEST_F(TopoCoordTest, ChooseOnlyVotersAsSyncSourceWhenNodeIsAVoter) {
- updateConfig(fromjson(
- "{_id:'rs0', version:1, members:["
- "{_id:10, host:'hself'}, "
- "{_id:20, host:'h2', votes:0, priority:0}, "
- "{_id:30, host:'h3'} "
- "]}"),
+ updateConfig(fromjson("{_id:'rs0', version:1, members:["
+ "{_id:10, host:'hself'}, "
+ "{_id:20, host:'h2', votes:0, priority:0}, "
+ "{_id:30, host:'h3'} "
+ "]}"),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -561,12 +582,15 @@ TEST_F(TopoCoordTest, ChooseOnlyVotersAsSyncSourceWhenNodeIsAVoter) {
TEST_F(TopoCoordTest, ChooseNoSyncSourceWhenPrimary) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -608,12 +632,15 @@ TEST_F(TopoCoordTest, ChooseNoSyncSourceWhenPrimary) {
TEST_F(TopoCoordTest, ChooseRequestedSyncSourceOnlyTheFirstTimeAfterTheSyncSourceIsForciblySet) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -651,12 +678,15 @@ TEST_F(TopoCoordTest, ChooseRequestedSyncSourceOnlyTheFirstTimeAfterTheSyncSourc
TEST_F(TopoCoordTest, NodeDoesNotChooseBlacklistedSyncSourceUntilBlacklistingExpires) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -700,13 +730,17 @@ TEST_F(TopoCoordTest, NodeDoesNotChooseBlacklistedSyncSourceUntilBlacklistingExp
TEST_F(TopoCoordTest, ChooseNoSyncSourceWhenPrimaryIsBlacklistedAndChainingIsDisallowed) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "settings" << BSON("chainingAllowed" << false)
+ << "version"
+ << 1
+ << "settings"
+ << BSON("chainingAllowed" << false)
<< "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -751,12 +785,15 @@ TEST_F(TopoCoordTest, ChooseNoSyncSourceWhenPrimaryIsBlacklistedAndChainingIsDis
TEST_F(TopoCoordTest, NodeChangesToRecoveringWhenOnlyUnauthorizedNodesAreUp) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -815,18 +852,22 @@ TEST_F(TopoCoordTest, NodeChangesToRecoveringWhenOnlyUnauthorizedNodesAreUp) {
TEST_F(TopoCoordTest, NodeDoesNotActOnHeartbeatsWhenAbsentFromConfig) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "h1")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
-1);
ASSERT_NO_ACTION(heartbeatFromMember(HostAndPort("h2"),
"rs0",
MemberState::RS_SECONDARY,
OpTime(Timestamp(1, 0), 0),
- Milliseconds(300)).getAction());
+ Milliseconds(300))
+ .getAction());
}
TEST_F(TopoCoordTest, NodeReturnsNotSecondaryWhenSyncFromIsRunPriorToHavingAConfig) {
@@ -853,10 +894,13 @@ TEST_F(TopoCoordTest, NodeReturnsNotSecondaryWhenSyncFromIsRunAgainstArbiter) {
// Test trying to sync from another node when we are an arbiter
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "hself"
- << "arbiterOnly" << true)
+ << "arbiterOnly"
+ << true)
<< BSON("_id" << 1 << "host"
<< "h1"))),
0);
@@ -875,21 +919,29 @@ TEST_F(TopoCoordTest, NodeReturnsNotSecondaryWhenSyncFromIsRunAgainstPrimary) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "hself")
<< BSON("_id" << 1 << "host"
<< "h1"
- << "arbiterOnly" << true)
+ << "arbiterOnly"
+ << true)
<< BSON("_id" << 2 << "host"
<< "h2"
- << "priority" << 0 << "buildIndexes" << false)
+ << "priority"
+ << 0
+ << "buildIndexes"
+ << false)
<< BSON("_id" << 3 << "host"
- << "h3") << BSON("_id" << 4 << "host"
- << "h4")
+ << "h3")
+ << BSON("_id" << 4 << "host"
+ << "h4")
<< BSON("_id" << 5 << "host"
- << "h5") << BSON("_id" << 6 << "host"
- << "h6"))),
+ << "h5")
+ << BSON("_id" << 6 << "host"
+ << "h6"))),
0);
// Try to sync while PRIMARY
@@ -912,21 +964,29 @@ TEST_F(TopoCoordTest, NodeReturnsNodeNotFoundWhenSyncFromRequestsANodeNotInConfi
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "hself")
<< BSON("_id" << 1 << "host"
<< "h1"
- << "arbiterOnly" << true)
+ << "arbiterOnly"
+ << true)
<< BSON("_id" << 2 << "host"
<< "h2"
- << "priority" << 0 << "buildIndexes" << false)
+ << "priority"
+ << 0
+ << "buildIndexes"
+ << false)
<< BSON("_id" << 3 << "host"
- << "h3") << BSON("_id" << 4 << "host"
- << "h4")
+ << "h3")
+ << BSON("_id" << 4 << "host"
+ << "h4")
<< BSON("_id" << 5 << "host"
- << "h5") << BSON("_id" << 6 << "host"
- << "h6"))),
+ << "h5")
+ << BSON("_id" << 6 << "host"
+ << "h6"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -945,21 +1005,29 @@ TEST_F(TopoCoordTest, NodeReturnsInvalidOptionsWhenSyncFromRequestsSelf) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "hself")
<< BSON("_id" << 1 << "host"
<< "h1"
- << "arbiterOnly" << true)
+ << "arbiterOnly"
+ << true)
<< BSON("_id" << 2 << "host"
<< "h2"
- << "priority" << 0 << "buildIndexes" << false)
+ << "priority"
+ << 0
+ << "buildIndexes"
+ << false)
<< BSON("_id" << 3 << "host"
- << "h3") << BSON("_id" << 4 << "host"
- << "h4")
+ << "h3")
+ << BSON("_id" << 4 << "host"
+ << "h4")
<< BSON("_id" << 5 << "host"
- << "h5") << BSON("_id" << 6 << "host"
- << "h6"))),
+ << "h5")
+ << BSON("_id" << 6 << "host"
+ << "h6"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -978,21 +1046,29 @@ TEST_F(TopoCoordTest, NodeReturnsInvalidOptionsWhenSyncFromRequestsArbiter) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "hself")
<< BSON("_id" << 1 << "host"
<< "h1"
- << "arbiterOnly" << true)
+ << "arbiterOnly"
+ << true)
<< BSON("_id" << 2 << "host"
<< "h2"
- << "priority" << 0 << "buildIndexes" << false)
+ << "priority"
+ << 0
+ << "buildIndexes"
+ << false)
<< BSON("_id" << 3 << "host"
- << "h3") << BSON("_id" << 4 << "host"
- << "h4")
+ << "h3")
+ << BSON("_id" << 4 << "host"
+ << "h4")
<< BSON("_id" << 5 << "host"
- << "h5") << BSON("_id" << 6 << "host"
- << "h6"))),
+ << "h5")
+ << BSON("_id" << 6 << "host"
+ << "h6"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -1012,21 +1088,29 @@ TEST_F(TopoCoordTest, NodeReturnsInvalidOptionsWhenSyncFromRequestsAnIndexNonbui
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "hself")
<< BSON("_id" << 1 << "host"
<< "h1"
- << "arbiterOnly" << true)
+ << "arbiterOnly"
+ << true)
<< BSON("_id" << 2 << "host"
<< "h2"
- << "priority" << 0 << "buildIndexes" << false)
+ << "priority"
+ << 0
+ << "buildIndexes"
+ << false)
<< BSON("_id" << 3 << "host"
- << "h3") << BSON("_id" << 4 << "host"
- << "h4")
+ << "h3")
+ << BSON("_id" << 4 << "host"
+ << "h4")
<< BSON("_id" << 5 << "host"
- << "h5") << BSON("_id" << 6 << "host"
- << "h6"))),
+ << "h5")
+ << BSON("_id" << 6 << "host"
+ << "h6"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -1046,21 +1130,29 @@ TEST_F(TopoCoordTest, NodeReturnsHostUnreachableWhenSyncFromRequestsADownNode) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "hself")
<< BSON("_id" << 1 << "host"
<< "h1"
- << "arbiterOnly" << true)
+ << "arbiterOnly"
+ << true)
<< BSON("_id" << 2 << "host"
<< "h2"
- << "priority" << 0 << "buildIndexes" << false)
+ << "priority"
+ << 0
+ << "buildIndexes"
+ << false)
<< BSON("_id" << 3 << "host"
- << "h3") << BSON("_id" << 4 << "host"
- << "h4")
+ << "h3")
+ << BSON("_id" << 4 << "host"
+ << "h4")
<< BSON("_id" << 5 << "host"
- << "h5") << BSON("_id" << 6 << "host"
- << "h6"))),
+ << "h5")
+ << BSON("_id" << 6 << "host"
+ << "h6"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -1081,21 +1173,29 @@ TEST_F(TopoCoordTest, ChooseRequestedNodeWhenSyncFromRequestsAStaleNode) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "hself")
<< BSON("_id" << 1 << "host"
<< "h1"
- << "arbiterOnly" << true)
+ << "arbiterOnly"
+ << true)
<< BSON("_id" << 2 << "host"
<< "h2"
- << "priority" << 0 << "buildIndexes" << false)
+ << "priority"
+ << 0
+ << "buildIndexes"
+ << false)
<< BSON("_id" << 3 << "host"
- << "h3") << BSON("_id" << 4 << "host"
- << "h4")
+ << "h3")
+ << BSON("_id" << 4 << "host"
+ << "h4")
<< BSON("_id" << 5 << "host"
- << "h5") << BSON("_id" << 6 << "host"
- << "h6"))),
+ << "h5")
+ << BSON("_id" << 6 << "host"
+ << "h6"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -1120,21 +1220,29 @@ TEST_F(TopoCoordTest, ChooseRequestedNodeWhenSyncFromRequestsAValidNode) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "hself")
<< BSON("_id" << 1 << "host"
<< "h1"
- << "arbiterOnly" << true)
+ << "arbiterOnly"
+ << true)
<< BSON("_id" << 2 << "host"
<< "h2"
- << "priority" << 0 << "buildIndexes" << false)
+ << "priority"
+ << 0
+ << "buildIndexes"
+ << false)
<< BSON("_id" << 3 << "host"
- << "h3") << BSON("_id" << 4 << "host"
- << "h4")
+ << "h3")
+ << BSON("_id" << 4 << "host"
+ << "h4")
<< BSON("_id" << 5 << "host"
- << "h5") << BSON("_id" << 6 << "host"
- << "h6"))),
+ << "h5")
+ << BSON("_id" << 6 << "host"
+ << "h6"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -1160,21 +1268,29 @@ TEST_F(TopoCoordTest,
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "hself")
<< BSON("_id" << 1 << "host"
<< "h1"
- << "arbiterOnly" << true)
+ << "arbiterOnly"
+ << true)
<< BSON("_id" << 2 << "host"
<< "h2"
- << "priority" << 0 << "buildIndexes" << false)
+ << "priority"
+ << 0
+ << "buildIndexes"
+ << false)
<< BSON("_id" << 3 << "host"
- << "h3") << BSON("_id" << 4 << "host"
- << "h4")
+ << "h3")
+ << BSON("_id" << 4 << "host"
+ << "h4")
<< BSON("_id" << 5 << "host"
- << "h5") << BSON("_id" << 6 << "host"
- << "h6"))),
+ << "h5")
+ << BSON("_id" << 6 << "host"
+ << "h6"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -1199,21 +1315,29 @@ TEST_F(TopoCoordTest, NodeReturnsUnauthorizedWhenSyncFromRequestsANodeWeAreNotAu
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "hself")
<< BSON("_id" << 1 << "host"
<< "h1"
- << "arbiterOnly" << true)
+ << "arbiterOnly"
+ << true)
<< BSON("_id" << 2 << "host"
<< "h2"
- << "priority" << 0 << "buildIndexes" << false)
+ << "priority"
+ << 0
+ << "buildIndexes"
+ << false)
<< BSON("_id" << 3 << "host"
- << "h3") << BSON("_id" << 4 << "host"
- << "h4")
+ << "h3")
+ << BSON("_id" << 4 << "host"
+ << "h4")
<< BSON("_id" << 5 << "host"
- << "h5") << BSON("_id" << 6 << "host"
- << "h6"))),
+ << "h5")
+ << BSON("_id" << 6 << "host"
+ << "h6"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -1234,12 +1358,11 @@ TEST_F(TopoCoordTest, NodeReturnsInvalidOptionsWhenAskedToSyncFromANonVoterAsAVo
BSONObjBuilder response;
// Test trying to sync from another node
- updateConfig(fromjson(
- "{_id:'rs0', version:1, members:["
- "{_id:0, host:'self'},"
- "{_id:1, host:'h1'},"
- "{_id:2, host:'h2', votes:0, priority:0}"
- "]}"),
+ updateConfig(fromjson("{_id:'rs0', version:1, members:["
+ "{_id:0, host:'self'},"
+ "{_id:1, host:'h1'},"
+ "{_id:2, host:'h2', votes:0, priority:0}"
+ "]}"),
0);
getTopoCoord().prepareSyncFromResponse(HostAndPort("h2"), ourOpTime, &response, &result);
@@ -1258,21 +1381,29 @@ TEST_F(TopoCoordTest,
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "hself")
<< BSON("_id" << 1 << "host"
<< "h1"
- << "arbiterOnly" << true)
+ << "arbiterOnly"
+ << true)
<< BSON("_id" << 2 << "host"
<< "h2"
- << "priority" << 0 << "buildIndexes" << false)
+ << "priority"
+ << 0
+ << "buildIndexes"
+ << false)
<< BSON("_id" << 3 << "host"
- << "h3") << BSON("_id" << 4 << "host"
- << "h4")
+ << "h3")
+ << BSON("_id" << 4 << "host"
+ << "h4")
<< BSON("_id" << 5 << "host"
- << "h5") << BSON("_id" << 6 << "host"
- << "h6"))),
+ << "h5")
+ << BSON("_id" << 6 << "host"
+ << "h6"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -1329,17 +1460,17 @@ TEST_F(TopoCoordTest, ReplSetGetStatus) {
hb.setAppliedOpTime(oplogProgress);
StatusWith<ReplSetHeartbeatResponse> hbResponseGood = StatusWith<ReplSetHeartbeatResponse>(hb);
- updateConfig(
- BSON("_id" << setName << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "test0:1234")
- << BSON("_id" << 1 << "host"
- << "test1:1234") << BSON("_id" << 2 << "host"
- << "test2:1234")
- << BSON("_id" << 3 << "host"
- << "test3:1234"))),
- 3,
- startupTime + Milliseconds(1));
+ updateConfig(BSON("_id" << setName << "version" << 1 << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "test0:1234")
+ << BSON("_id" << 1 << "host"
+ << "test1:1234")
+ << BSON("_id" << 2 << "host"
+ << "test2:1234")
+ << BSON("_id" << 3 << "host"
+ << "test3:1234"))),
+ 3,
+ startupTime + Milliseconds(1));
// Now that the replica set is setup, put the members into the states we want them in.
HostAndPort member = HostAndPort("test0:1234");
@@ -1468,15 +1599,15 @@ TEST_F(TopoCoordTest, NodeReturnsInvalidReplicaSetConfigInResponseToGetStatusWhe
OpTime oplogProgress(Timestamp(3, 4), 0);
std::string setName = "mySet";
- updateConfig(
- BSON("_id" << setName << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "test0:1234")
- << BSON("_id" << 1 << "host"
- << "test1:1234") << BSON("_id" << 2 << "host"
- << "test2:1234"))),
- -1, // This one is not part of the replica set.
- startupTime + Milliseconds(1));
+ updateConfig(BSON("_id" << setName << "version" << 1 << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "test0:1234")
+ << BSON("_id" << 1 << "host"
+ << "test1:1234")
+ << BSON("_id" << 2 << "host"
+ << "test2:1234"))),
+ -1, // This one is not part of the replica set.
+ startupTime + Milliseconds(1));
BSONObjBuilder statusBuilder;
Status resultStatus(ErrorCodes::InternalError, "prepareStatusResponse didn't set result");
@@ -1497,11 +1628,10 @@ TEST_F(TopoCoordTest, NodeReturnsInvalidReplicaSetConfigInResponseToGetStatusWhe
TEST_F(TopoCoordTest, HeartbeatFrequencyShouldBeHalfElectionTimeoutWhenArbiter) {
// This tests that arbiters issue heartbeats at electionTimeout/2 frequencies
TopoCoordTest::setUp();
- updateConfig(fromjson(
- "{_id:'mySet', version:1, protocolVersion:1, members:["
- "{_id:1, host:'node1:12345', arbiterOnly:true}, "
- "{_id:2, host:'node2:12345'}], "
- "settings:{heartbeatIntervalMillis:10, electionTimeoutMillis:5000}}"),
+ updateConfig(fromjson("{_id:'mySet', version:1, protocolVersion:1, members:["
+ "{_id:1, host:'node1:12345', arbiterOnly:true}, "
+ "{_id:2, host:'node2:12345'}], "
+ "settings:{heartbeatIntervalMillis:10, electionTimeoutMillis:5000}}"),
0);
HostAndPort target("host2", 27017);
Date_t requestDate = now();
@@ -1523,12 +1653,16 @@ public:
TopoCoordTest::setUp();
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3")) << "settings"
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))
+ << "settings"
<< BSON("protocolVersion" << 1)),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -1558,9 +1692,8 @@ TEST_F(PrepareHeartbeatResponseV1Test,
ASSERT(result.reason().find("repl set names do not match")) << "Actual string was \""
<< result.reason() << '"';
ASSERT_EQUALS(1,
- countLogLinesContaining(
- "replSet set names do not match, ours: rs0; remote "
- "node's: rs1"));
+ countLogLinesContaining("replSet set names do not match, ours: rs0; remote "
+ "node's: rs1"));
// only protocolVersion should be set in this failure case
ASSERT_EQUALS("", response.getReplicaSetName());
}
@@ -1570,11 +1703,15 @@ TEST_F(PrepareHeartbeatResponseV1Test,
// reconfig self out of set
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 3 << "members" << BSON_ARRAY(BSON("_id" << 20 << "host"
- << "h2")
- << BSON("_id" << 30 << "host"
- << "h3"))
- << "settings" << BSON("protocolVersion" << 1)),
+ << "version"
+ << 3
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 20 << "host"
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))
+ << "settings"
+ << BSON("protocolVersion" << 1)),
-1);
ReplSetHeartbeatArgsV1 args;
args.setSetName("rs0");
@@ -1764,8 +1901,11 @@ TEST_F(TopoCoordTest, BecomeCandidateWhenBecomingSecondaryInSingleNodeSet) {
ASSERT_EQUALS(MemberState::RS_STARTUP, getTopoCoord().getMemberState().s);
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members" << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "hself"))),
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "hself"))),
0);
ASSERT_EQUALS(MemberState::RS_STARTUP2, getTopoCoord().getMemberState().s);
@@ -1782,10 +1922,13 @@ TEST_F(TopoCoordTest, BecomeCandidateWhenReconfigToBeElectableInSingleNodeSet) {
ReplicaSetConfig cfg;
cfg.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "hself"
- << "priority" << 0))));
+ << "priority"
+ << 0))));
getTopoCoord().updateConfig(cfg, 0, now()++, OpTime());
ASSERT_EQUALS(MemberState::RS_STARTUP2, getTopoCoord().getMemberState().s);
@@ -1798,8 +1941,11 @@ TEST_F(TopoCoordTest, BecomeCandidateWhenReconfigToBeElectableInSingleNodeSet) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members" << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "hself"))),
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "hself"))),
0);
ASSERT_TRUE(TopologyCoordinator::Role::candidate == getTopoCoord().getRole());
}
@@ -1810,10 +1956,13 @@ TEST_F(TopoCoordTest, NodeDoesNotBecomeCandidateWhenBecomingSecondaryInSingleNod
ReplicaSetConfig cfg;
cfg.initialize(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "hself"
- << "priority" << 0))));
+ << "priority"
+ << 0))));
getTopoCoord().updateConfig(cfg, 0, now()++, OpTime());
ASSERT_EQUALS(MemberState::RS_STARTUP2, getTopoCoord().getMemberState().s);
@@ -1831,7 +1980,9 @@ TEST_F(TopoCoordTest, NodeTransitionsFromRemovedToStartup2WhenAddedToConfig) {
// config to be absent from the set
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "host2:27017")
<< BSON("_id" << 2 << "host"
@@ -1842,16 +1993,18 @@ TEST_F(TopoCoordTest, NodeTransitionsFromRemovedToStartup2WhenAddedToConfig) {
ASSERT_EQUALS(MemberState::RS_REMOVED, getTopoCoord().getMemberState().s);
// reconfig to add to set
- updateConfig(
- BSON("_id"
- << "rs0"
- << "version" << 2 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "host1:27017")
- << BSON("_id" << 1 << "host"
- << "host2:27017") << BSON("_id" << 2 << "host"
- << "host3:27017"))),
- 0);
+ updateConfig(BSON("_id"
+ << "rs0"
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "host1:27017")
+ << BSON("_id" << 1 << "host"
+ << "host2:27017")
+ << BSON("_id" << 2 << "host"
+ << "host3:27017"))),
+ 0);
// having been added to the config, we should no longer be REMOVED and should enter STARTUP2
ASSERT_TRUE(TopologyCoordinator::Role::follower == getTopoCoord().getRole());
ASSERT_EQUALS(MemberState::RS_STARTUP2, getTopoCoord().getMemberState().s);
@@ -1860,23 +2013,27 @@ TEST_F(TopoCoordTest, NodeTransitionsFromRemovedToStartup2WhenAddedToConfig) {
TEST_F(TopoCoordTest, NodeTransitionsToRemovedWhenRemovedFromConfig) {
ASSERT_TRUE(TopologyCoordinator::Role::follower == getTopoCoord().getRole());
ASSERT_EQUALS(MemberState::RS_STARTUP, getTopoCoord().getMemberState().s);
- updateConfig(
- BSON("_id"
- << "rs0"
- << "version" << 1 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "host1:27017")
- << BSON("_id" << 1 << "host"
- << "host2:27017") << BSON("_id" << 2 << "host"
- << "host3:27017"))),
- 0);
+ updateConfig(BSON("_id"
+ << "rs0"
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "host1:27017")
+ << BSON("_id" << 1 << "host"
+ << "host2:27017")
+ << BSON("_id" << 2 << "host"
+ << "host3:27017"))),
+ 0);
ASSERT_TRUE(TopologyCoordinator::Role::follower == getTopoCoord().getRole());
ASSERT_EQUALS(MemberState::RS_STARTUP2, getTopoCoord().getMemberState().s);
// reconfig to remove self
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "host2:27017")
<< BSON("_id" << 2 << "host"
@@ -1892,8 +2049,11 @@ TEST_F(TopoCoordTest, NodeTransitionsToRemovedWhenRemovedFromConfigEvenWhenPrima
ASSERT_EQUALS(MemberState::RS_STARTUP, getTopoCoord().getMemberState().s);
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members" << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "host1:27017"))),
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "host1:27017"))),
0);
ASSERT_FALSE(TopologyCoordinator::Role::candidate == getTopoCoord().getRole());
ASSERT_EQUALS(MemberState::RS_STARTUP2, getTopoCoord().getMemberState().s);
@@ -1908,7 +2068,9 @@ TEST_F(TopoCoordTest, NodeTransitionsToRemovedWhenRemovedFromConfigEvenWhenPrima
// reconfig to remove self
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 2 << "members"
+ << "version"
+ << 2
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "host2:27017")
<< BSON("_id" << 2 << "host"
@@ -1924,8 +2086,11 @@ TEST_F(TopoCoordTest, NodeTransitionsToSecondaryWhenReconfiggingToBeUnelectable)
ASSERT_EQUALS(MemberState::RS_STARTUP, getTopoCoord().getMemberState().s);
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members" << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "host1:27017"))),
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "host1:27017"))),
0);
ASSERT_FALSE(TopologyCoordinator::Role::candidate == getTopoCoord().getRole());
ASSERT_EQUALS(MemberState::RS_STARTUP2, getTopoCoord().getMemberState().s);
@@ -1938,17 +2103,20 @@ TEST_F(TopoCoordTest, NodeTransitionsToSecondaryWhenReconfiggingToBeUnelectable)
ASSERT_EQUALS(MemberState::RS_PRIMARY, getTopoCoord().getMemberState().s);
// now lose primary due to loss of electability
- updateConfig(
- BSON("_id"
- << "rs0"
- << "version" << 2 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "host1:27017"
- << "priority" << 0)
- << BSON("_id" << 1 << "host"
- << "host2:27017") << BSON("_id" << 2 << "host"
- << "host3:27017"))),
- 0);
+ updateConfig(BSON("_id"
+ << "rs0"
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "host1:27017"
+ << "priority"
+ << 0)
+ << BSON("_id" << 1 << "host"
+ << "host2:27017")
+ << BSON("_id" << 2 << "host"
+ << "host3:27017"))),
+ 0);
ASSERT_TRUE(TopologyCoordinator::Role::follower == getTopoCoord().getRole());
ASSERT_EQUALS(MemberState::RS_SECONDARY, getTopoCoord().getMemberState().s);
}
@@ -1958,8 +2126,11 @@ TEST_F(TopoCoordTest, NodeMaintainsPrimaryStateAcrossReconfigIfNodeRemainsElecta
ASSERT_EQUALS(MemberState::RS_STARTUP, getTopoCoord().getMemberState().s);
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members" << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "host1:27017"))),
+ << "version"
+ << 1
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "host1:27017"))),
0);
ASSERT_FALSE(TopologyCoordinator::Role::candidate == getTopoCoord().getRole());
@@ -1974,38 +2145,45 @@ TEST_F(TopoCoordTest, NodeMaintainsPrimaryStateAcrossReconfigIfNodeRemainsElecta
// Now reconfig in ways that leave us electable and ensure we are still the primary.
// Add hosts
- updateConfig(
- BSON("_id"
- << "rs0"
- << "version" << 2 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "host1:27017")
- << BSON("_id" << 1 << "host"
- << "host2:27017") << BSON("_id" << 2 << "host"
- << "host3:27017"))),
- 0,
- Date_t::fromMillisSinceEpoch(-1),
- OpTime(Timestamp(10, 0), 0));
+ updateConfig(BSON("_id"
+ << "rs0"
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "host1:27017")
+ << BSON("_id" << 1 << "host"
+ << "host2:27017")
+ << BSON("_id" << 2 << "host"
+ << "host3:27017"))),
+ 0,
+ Date_t::fromMillisSinceEpoch(-1),
+ OpTime(Timestamp(10, 0), 0));
ASSERT_TRUE(TopologyCoordinator::Role::leader == getTopoCoord().getRole());
ASSERT_EQUALS(MemberState::RS_PRIMARY, getTopoCoord().getMemberState().s);
// Change priorities and tags
- updateConfig(
- BSON("_id"
- << "rs0"
- << "version" << 2 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "host1:27017"
- << "priority" << 10)
- << BSON("_id" << 1 << "host"
- << "host2:27017"
- << "priority" << 5 << "tags" << BSON("dc"
- << "NA"
- << "rack"
- << "rack1")))),
- 0,
- Date_t::fromMillisSinceEpoch(-1),
- OpTime(Timestamp(10, 0), 0));
+ updateConfig(BSON("_id"
+ << "rs0"
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "host1:27017"
+ << "priority"
+ << 10)
+ << BSON("_id" << 1 << "host"
+ << "host2:27017"
+ << "priority"
+ << 5
+ << "tags"
+ << BSON("dc"
+ << "NA"
+ << "rack"
+ << "rack1")))),
+ 0,
+ Date_t::fromMillisSinceEpoch(-1),
+ OpTime(Timestamp(10, 0), 0));
ASSERT_TRUE(TopologyCoordinator::Role::leader == getTopoCoord().getRole());
ASSERT_EQUALS(MemberState::RS_PRIMARY, getTopoCoord().getMemberState().s);
}
@@ -2013,7 +2191,9 @@ TEST_F(TopoCoordTest, NodeMaintainsPrimaryStateAcrossReconfigIfNodeRemainsElecta
TEST_F(TopoCoordTest, NodeMaintainsSecondaryStateAcrossReconfig) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "host1:27017")
<< BSON("_id" << 2 << "host"
@@ -2025,16 +2205,18 @@ TEST_F(TopoCoordTest, NodeMaintainsSecondaryStateAcrossReconfig) {
ASSERT_EQUALS(MemberState::RS_SECONDARY, getTopoCoord().getMemberState().s);
// reconfig and stay secondary
- updateConfig(
- BSON("_id"
- << "rs0"
- << "version" << 2 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "host1:27017")
- << BSON("_id" << 1 << "host"
- << "host2:27017") << BSON("_id" << 2 << "host"
- << "host3:27017"))),
- 0);
+ updateConfig(BSON("_id"
+ << "rs0"
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "host1:27017")
+ << BSON("_id" << 1 << "host"
+ << "host2:27017")
+ << BSON("_id" << 2 << "host"
+ << "host3:27017"))),
+ 0);
ASSERT_TRUE(TopologyCoordinator::Role::follower == getTopoCoord().getRole());
ASSERT_EQUALS(MemberState::RS_SECONDARY, getTopoCoord().getMemberState().s);
}
@@ -2042,12 +2224,15 @@ TEST_F(TopoCoordTest, NodeMaintainsSecondaryStateAcrossReconfig) {
TEST_F(TopoCoordTest, ShouldNotStandForElectionWhileAwareOfPrimary) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -2059,12 +2244,15 @@ TEST_F(TopoCoordTest, ShouldNotStandForElectionWhileAwareOfPrimary) {
TEST_F(TopoCoordTest, ShouldStandForElectionDespiteNotCloseEnoughToLastOptime) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -2076,12 +2264,15 @@ TEST_F(TopoCoordTest, ShouldStandForElectionDespiteNotCloseEnoughToLastOptime) {
TEST_F(TopoCoordTest, VoteForMyselfFailsWhileNotCandidate) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
ASSERT_FALSE(getTopoCoord().voteForMyself(now()++));
@@ -2090,13 +2281,17 @@ TEST_F(TopoCoordTest, VoteForMyselfFailsWhileNotCandidate) {
TEST_F(TopoCoordTest, NodeReturnsArbiterWhenGetMemberStateRunsAgainstArbiter) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself"
- << "arbiterOnly" << true)
+ << "arbiterOnly"
+ << true)
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
ASSERT_EQUALS(MemberState::RS_ARBITER, getTopoCoord().getMemberState().s);
}
@@ -2111,20 +2306,28 @@ TEST_F(TopoCoordTest, ShouldNotStandForElectionWhileRemovedFromTheConfig) {
TEST_F(TopoCoordTest, NodeDoesNotGrantVotesToTwoDifferentNodesInTheSameTerm) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
ReplSetRequestVotesArgs args;
args.initialize(BSON("replSetRequestVotes" << 1 << "setName"
<< "rs0"
- << "term" << 1LL << "candidateIndex" << 0LL
- << "configVersion" << 1LL << "lastCommittedOp"
+ << "term"
+ << 1LL
+ << "candidateIndex"
+ << 0LL
+ << "configVersion"
+ << 1LL
+ << "lastCommittedOp"
<< BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse response;
OpTime lastAppliedOpTime;
@@ -2134,11 +2337,17 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantVotesToTwoDifferentNodesInTheSameTerm) {
ASSERT_TRUE(response.getVoteGranted());
ReplSetRequestVotesArgs args2;
- args2.initialize(BSON("replSetRequestVotes"
- << 1 << "setName"
- << "rs0"
- << "term" << 1LL << "candidateIndex" << 1LL << "configVersion" << 1LL
- << "lastCommittedOp" << BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
+ args2.initialize(
+ BSON("replSetRequestVotes" << 1 << "setName"
+ << "rs0"
+ << "term"
+ << 1LL
+ << "candidateIndex"
+ << 1LL
+ << "configVersion"
+ << 1LL
+ << "lastCommittedOp"
+ << BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse response2;
// different candidate same term, should be a problem
@@ -2150,12 +2359,15 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantVotesToTwoDifferentNodesInTheSameTerm) {
TEST_F(TopoCoordTest, DryRunVoteRequestShouldNotPreventSubsequentDryRunsForThatTerm) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -2163,8 +2375,14 @@ TEST_F(TopoCoordTest, DryRunVoteRequestShouldNotPreventSubsequentDryRunsForThatT
ReplSetRequestVotesArgs args;
args.initialize(BSON("replSetRequestVotes" << 1 << "setName"
<< "rs0"
- << "dryRun" << true << "term" << 1LL
- << "candidateIndex" << 0LL << "configVersion" << 1LL
+ << "dryRun"
+ << true
+ << "term"
+ << 1LL
+ << "candidateIndex"
+ << 0LL
+ << "configVersion"
+ << 1LL
<< "lastCommittedOp"
<< BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse response;
@@ -2176,12 +2394,19 @@ TEST_F(TopoCoordTest, DryRunVoteRequestShouldNotPreventSubsequentDryRunsForThatT
// second dry run fine
ReplSetRequestVotesArgs args2;
- args2.initialize(BSON("replSetRequestVotes"
- << 1 << "setName"
- << "rs0"
- << "dryRun" << true << "term" << 1LL << "candidateIndex" << 0LL
- << "configVersion" << 1LL << "lastCommittedOp"
- << BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
+ args2.initialize(
+ BSON("replSetRequestVotes" << 1 << "setName"
+ << "rs0"
+ << "dryRun"
+ << true
+ << "term"
+ << 1LL
+ << "candidateIndex"
+ << 0LL
+ << "configVersion"
+ << 1LL
+ << "lastCommittedOp"
+ << BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse response2;
getTopoCoord().processReplSetRequestVotes(args2, &response2, lastAppliedOpTime);
@@ -2190,12 +2415,19 @@ TEST_F(TopoCoordTest, DryRunVoteRequestShouldNotPreventSubsequentDryRunsForThatT
// real request fine
ReplSetRequestVotesArgs args3;
- args3.initialize(BSON("replSetRequestVotes"
- << 1 << "setName"
- << "rs0"
- << "dryRun" << false << "term" << 1LL << "candidateIndex" << 0LL
- << "configVersion" << 1LL << "lastCommittedOp"
- << BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
+ args3.initialize(
+ BSON("replSetRequestVotes" << 1 << "setName"
+ << "rs0"
+ << "dryRun"
+ << false
+ << "term"
+ << 1LL
+ << "candidateIndex"
+ << 0LL
+ << "configVersion"
+ << 1LL
+ << "lastCommittedOp"
+ << BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse response3;
getTopoCoord().processReplSetRequestVotes(args3, &response3, lastAppliedOpTime);
@@ -2204,12 +2436,19 @@ TEST_F(TopoCoordTest, DryRunVoteRequestShouldNotPreventSubsequentDryRunsForThatT
// dry post real, fails
ReplSetRequestVotesArgs args4;
- args4.initialize(BSON("replSetRequestVotes"
- << 1 << "setName"
- << "rs0"
- << "dryRun" << false << "term" << 1LL << "candidateIndex" << 0LL
- << "configVersion" << 1LL << "lastCommittedOp"
- << BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
+ args4.initialize(
+ BSON("replSetRequestVotes" << 1 << "setName"
+ << "rs0"
+ << "dryRun"
+ << false
+ << "term"
+ << 1LL
+ << "candidateIndex"
+ << 0LL
+ << "configVersion"
+ << 1LL
+ << "lastCommittedOp"
+ << BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse response4;
getTopoCoord().processReplSetRequestVotes(args4, &response4, lastAppliedOpTime);
@@ -2220,12 +2459,15 @@ TEST_F(TopoCoordTest, DryRunVoteRequestShouldNotPreventSubsequentDryRunsForThatT
TEST_F(TopoCoordTest, VoteRequestShouldNotPreventDryRunsForThatTerm) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -2233,8 +2475,14 @@ TEST_F(TopoCoordTest, VoteRequestShouldNotPreventDryRunsForThatTerm) {
ReplSetRequestVotesArgs args;
args.initialize(BSON("replSetRequestVotes" << 1 << "setName"
<< "rs0"
- << "dryRun" << false << "term" << 1LL
- << "candidateIndex" << 0LL << "configVersion" << 1LL
+ << "dryRun"
+ << false
+ << "term"
+ << 1LL
+ << "candidateIndex"
+ << 0LL
+ << "configVersion"
+ << 1LL
<< "lastCommittedOp"
<< BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse response;
@@ -2246,12 +2494,19 @@ TEST_F(TopoCoordTest, VoteRequestShouldNotPreventDryRunsForThatTerm) {
// dry post real, fails
ReplSetRequestVotesArgs args2;
- args2.initialize(BSON("replSetRequestVotes"
- << 1 << "setName"
- << "rs0"
- << "dryRun" << false << "term" << 1LL << "candidateIndex" << 0LL
- << "configVersion" << 1LL << "lastCommittedOp"
- << BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
+ args2.initialize(
+ BSON("replSetRequestVotes" << 1 << "setName"
+ << "rs0"
+ << "dryRun"
+ << false
+ << "term"
+ << 1LL
+ << "candidateIndex"
+ << 0LL
+ << "configVersion"
+ << 1LL
+ << "lastCommittedOp"
+ << BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse response2;
getTopoCoord().processReplSetRequestVotes(args2, &response2, lastAppliedOpTime);
@@ -2262,12 +2517,15 @@ TEST_F(TopoCoordTest, VoteRequestShouldNotPreventDryRunsForThatTerm) {
TEST_F(TopoCoordTest, NodeDoesNotGrantVoteWhenReplSetNameDoesNotMatch) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -2275,8 +2533,13 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantVoteWhenReplSetNameDoesNotMatch) {
ReplSetRequestVotesArgs args;
args.initialize(BSON("replSetRequestVotes" << 1 << "setName"
<< "wrongName"
- << "term" << 1LL << "candidateIndex" << 0LL
- << "configVersion" << 1LL << "lastCommittedOp"
+ << "term"
+ << 1LL
+ << "candidateIndex"
+ << 0LL
+ << "configVersion"
+ << 1LL
+ << "lastCommittedOp"
<< BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse response;
OpTime lastAppliedOpTime;
@@ -2289,12 +2552,15 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantVoteWhenReplSetNameDoesNotMatch) {
TEST_F(TopoCoordTest, NodeDoesNotGrantVoteWhenConfigVersionDoesNotMatch) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -2302,8 +2568,13 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantVoteWhenConfigVersionDoesNotMatch) {
ReplSetRequestVotesArgs args;
args.initialize(BSON("replSetRequestVotes" << 1 << "setName"
<< "rs0"
- << "term" << 1LL << "candidateIndex" << 1LL
- << "configVersion" << 0LL << "lastCommittedOp"
+ << "term"
+ << 1LL
+ << "candidateIndex"
+ << 1LL
+ << "configVersion"
+ << 0LL
+ << "lastCommittedOp"
<< BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse response;
OpTime lastAppliedOpTime;
@@ -2316,12 +2587,15 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantVoteWhenConfigVersionDoesNotMatch) {
TEST_F(TopoCoordTest, NodeDoesNotGrantVoteWhenTermIsStale) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -2333,8 +2607,13 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantVoteWhenTermIsStale) {
ReplSetRequestVotesArgs args;
args.initialize(BSON("replSetRequestVotes" << 1 << "setName"
<< "rs0"
- << "term" << 1LL << "candidateIndex" << 1LL
- << "configVersion" << 1LL << "lastCommittedOp"
+ << "term"
+ << 1LL
+ << "candidateIndex"
+ << 1LL
+ << "configVersion"
+ << 1LL
+ << "lastCommittedOp"
<< BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse response;
OpTime lastAppliedOpTime;
@@ -2348,12 +2627,15 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantVoteWhenTermIsStale) {
TEST_F(TopoCoordTest, NodeDoesNotGrantVoteWhenOpTimeIsStale) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -2362,8 +2644,13 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantVoteWhenOpTimeIsStale) {
ReplSetRequestVotesArgs args;
args.initialize(BSON("replSetRequestVotes" << 1 << "setName"
<< "rs0"
- << "term" << 3LL << "candidateIndex" << 1LL
- << "configVersion" << 1LL << "lastCommittedOp"
+ << "term"
+ << 3LL
+ << "candidateIndex"
+ << 1LL
+ << "configVersion"
+ << 1LL
+ << "lastCommittedOp"
<< BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse response;
OpTime lastAppliedOpTime2 = {Timestamp(20, 0), 0};
@@ -2376,12 +2663,15 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantVoteWhenOpTimeIsStale) {
TEST_F(TopoCoordTest, NodeDoesNotGrantDryRunVoteWhenReplSetNameDoesNotMatch) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
// set term to 1
@@ -2389,12 +2679,17 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantDryRunVoteWhenReplSetNameDoesNotMatch) {
getTopoCoord().updateTerm(1, now()));
// and make sure we voted in term 1
ReplSetRequestVotesArgs argsForRealVote;
- argsForRealVote.initialize(BSON("replSetRequestVotes"
- << 1 << "setName"
- << "rs0"
- << "term" << 1LL << "candidateIndex" << 0LL << "configVersion"
- << 1LL << "lastCommittedOp"
- << BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
+ argsForRealVote.initialize(
+ BSON("replSetRequestVotes" << 1 << "setName"
+ << "rs0"
+ << "term"
+ << 1LL
+ << "candidateIndex"
+ << 0LL
+ << "configVersion"
+ << 1LL
+ << "lastCommittedOp"
+ << BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse responseForRealVote;
OpTime lastAppliedOpTime;
@@ -2408,8 +2703,14 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantDryRunVoteWhenReplSetNameDoesNotMatch) {
ReplSetRequestVotesArgs args;
args.initialize(BSON("replSetRequestVotes" << 1 << "setName"
<< "wrongName"
- << "dryRun" << true << "term" << 2LL
- << "candidateIndex" << 0LL << "configVersion" << 1LL
+ << "dryRun"
+ << true
+ << "term"
+ << 2LL
+ << "candidateIndex"
+ << 0LL
+ << "configVersion"
+ << 1LL
<< "lastCommittedOp"
<< BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse response;
@@ -2423,12 +2724,15 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantDryRunVoteWhenReplSetNameDoesNotMatch) {
TEST_F(TopoCoordTest, NodeDoesNotGrantDryRunVoteWhenConfigVersionDoesNotMatch) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
// set term to 1
@@ -2436,12 +2740,17 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantDryRunVoteWhenConfigVersionDoesNotMatch) {
getTopoCoord().updateTerm(1, now()));
// and make sure we voted in term 1
ReplSetRequestVotesArgs argsForRealVote;
- argsForRealVote.initialize(BSON("replSetRequestVotes"
- << 1 << "setName"
- << "rs0"
- << "term" << 1LL << "candidateIndex" << 0LL << "configVersion"
- << 1LL << "lastCommittedOp"
- << BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
+ argsForRealVote.initialize(
+ BSON("replSetRequestVotes" << 1 << "setName"
+ << "rs0"
+ << "term"
+ << 1LL
+ << "candidateIndex"
+ << 0LL
+ << "configVersion"
+ << 1LL
+ << "lastCommittedOp"
+ << BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse responseForRealVote;
OpTime lastAppliedOpTime;
@@ -2455,8 +2764,14 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantDryRunVoteWhenConfigVersionDoesNotMatch) {
ReplSetRequestVotesArgs args;
args.initialize(BSON("replSetRequestVotes" << 1 << "setName"
<< "rs0"
- << "dryRun" << true << "term" << 2LL
- << "candidateIndex" << 1LL << "configVersion" << 0LL
+ << "dryRun"
+ << true
+ << "term"
+ << 2LL
+ << "candidateIndex"
+ << 1LL
+ << "configVersion"
+ << 0LL
<< "lastCommittedOp"
<< BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse response;
@@ -2470,12 +2785,15 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantDryRunVoteWhenConfigVersionDoesNotMatch) {
TEST_F(TopoCoordTest, NodeDoesNotGrantDryRunVoteWhenTermIsStale) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
// set term to 1
@@ -2483,12 +2801,17 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantDryRunVoteWhenTermIsStale) {
getTopoCoord().updateTerm(1, now()));
// and make sure we voted in term 1
ReplSetRequestVotesArgs argsForRealVote;
- argsForRealVote.initialize(BSON("replSetRequestVotes"
- << 1 << "setName"
- << "rs0"
- << "term" << 1LL << "candidateIndex" << 0LL << "configVersion"
- << 1LL << "lastCommittedOp"
- << BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
+ argsForRealVote.initialize(
+ BSON("replSetRequestVotes" << 1 << "setName"
+ << "rs0"
+ << "term"
+ << 1LL
+ << "candidateIndex"
+ << 0LL
+ << "configVersion"
+ << 1LL
+ << "lastCommittedOp"
+ << BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse responseForRealVote;
OpTime lastAppliedOpTime;
@@ -2501,8 +2824,14 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantDryRunVoteWhenTermIsStale) {
ReplSetRequestVotesArgs args;
args.initialize(BSON("replSetRequestVotes" << 1 << "setName"
<< "rs0"
- << "dryRun" << true << "term" << 0LL
- << "candidateIndex" << 1LL << "configVersion" << 1LL
+ << "dryRun"
+ << true
+ << "term"
+ << 0LL
+ << "candidateIndex"
+ << 1LL
+ << "configVersion"
+ << 1LL
<< "lastCommittedOp"
<< BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse response;
@@ -2516,12 +2845,15 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantDryRunVoteWhenTermIsStale) {
TEST_F(TopoCoordTest, GrantDryRunVoteEvenWhenTermHasBeenSeen) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
// set term to 1
@@ -2529,12 +2861,17 @@ TEST_F(TopoCoordTest, GrantDryRunVoteEvenWhenTermHasBeenSeen) {
getTopoCoord().updateTerm(1, now()));
// and make sure we voted in term 1
ReplSetRequestVotesArgs argsForRealVote;
- argsForRealVote.initialize(BSON("replSetRequestVotes"
- << 1 << "setName"
- << "rs0"
- << "term" << 1LL << "candidateIndex" << 0LL << "configVersion"
- << 1LL << "lastCommittedOp"
- << BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
+ argsForRealVote.initialize(
+ BSON("replSetRequestVotes" << 1 << "setName"
+ << "rs0"
+ << "term"
+ << 1LL
+ << "candidateIndex"
+ << 0LL
+ << "configVersion"
+ << 1LL
+ << "lastCommittedOp"
+ << BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse responseForRealVote;
OpTime lastAppliedOpTime;
@@ -2548,8 +2885,14 @@ TEST_F(TopoCoordTest, GrantDryRunVoteEvenWhenTermHasBeenSeen) {
ReplSetRequestVotesArgs args;
args.initialize(BSON("replSetRequestVotes" << 1 << "setName"
<< "rs0"
- << "dryRun" << true << "term" << 1LL
- << "candidateIndex" << 1LL << "configVersion" << 1LL
+ << "dryRun"
+ << true
+ << "term"
+ << 1LL
+ << "candidateIndex"
+ << 1LL
+ << "configVersion"
+ << 1LL
<< "lastCommittedOp"
<< BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse response;
@@ -2563,12 +2906,15 @@ TEST_F(TopoCoordTest, GrantDryRunVoteEvenWhenTermHasBeenSeen) {
TEST_F(TopoCoordTest, DoNotGrantDryRunVoteWhenOpTimeIsStale) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 1 << "members"
+ << "version"
+ << 1
+ << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
// set term to 1
@@ -2576,12 +2922,17 @@ TEST_F(TopoCoordTest, DoNotGrantDryRunVoteWhenOpTimeIsStale) {
getTopoCoord().updateTerm(1, now()));
// and make sure we voted in term 1
ReplSetRequestVotesArgs argsForRealVote;
- argsForRealVote.initialize(BSON("replSetRequestVotes"
- << 1 << "setName"
- << "rs0"
- << "term" << 1LL << "candidateIndex" << 0LL << "configVersion"
- << 1LL << "lastCommittedOp"
- << BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
+ argsForRealVote.initialize(
+ BSON("replSetRequestVotes" << 1 << "setName"
+ << "rs0"
+ << "term"
+ << 1LL
+ << "candidateIndex"
+ << 0LL
+ << "configVersion"
+ << 1LL
+ << "lastCommittedOp"
+ << BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse responseForRealVote;
OpTime lastAppliedOpTime;
@@ -2595,8 +2946,14 @@ TEST_F(TopoCoordTest, DoNotGrantDryRunVoteWhenOpTimeIsStale) {
ReplSetRequestVotesArgs args;
args.initialize(BSON("replSetRequestVotes" << 1 << "setName"
<< "rs0"
- << "dryRun" << true << "term" << 3LL
- << "candidateIndex" << 1LL << "configVersion" << 1LL
+ << "dryRun"
+ << true
+ << "term"
+ << 3LL
+ << "candidateIndex"
+ << 1LL
+ << "configVersion"
+ << 1LL
<< "lastCommittedOp"
<< BSON("ts" << Timestamp(10, 0) << "term" << 0LL)));
ReplSetRequestVotesResponse response;
@@ -2618,13 +2975,19 @@ TEST_F(TopoCoordTest, NodeTransitionsToRemovedIfCSRSButHaveNoReadCommittedSuppor
updateConfig(BSON("_id"
<< "rs0"
- << "protocolVersion" << 1 << "version" << 1 << "configsvr" << true
+ << "protocolVersion"
+ << 1
+ << "version"
+ << 1
+ << "configsvr"
+ << true
<< "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
ASSERT_EQUALS(MemberState::RS_REMOVED, getTopoCoord().getMemberState().s);
}
@@ -2639,13 +3002,19 @@ TEST_F(TopoCoordTest, NodeBecomesSecondaryAsNormalWhenReadCommittedSupportedAndC
updateConfig(BSON("_id"
<< "rs0"
- << "protocolVersion" << 1 << "version" << 1 << "configsvr" << true
+ << "protocolVersion"
+ << 1
+ << "version"
+ << 1
+ << "configsvr"
+ << true
<< "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
- << "h2") << BSON("_id" << 30 << "host"
- << "h3"))),
+ << "h2")
+ << BSON("_id" << 30 << "host"
+ << "h3"))),
0);
ASSERT_EQUALS(MemberState::RS_STARTUP2, getTopoCoord().getMemberState().s);
@@ -2657,17 +3026,22 @@ class HeartbeatResponseTestV1 : public TopoCoordTest {
public:
virtual void setUp() {
TopoCoordTest::setUp();
- updateConfig(
- BSON("_id"
- << "rs0"
- << "version" << 5 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "host1:27017")
- << BSON("_id" << 1 << "host"
- << "host2:27017") << BSON("_id" << 2 << "host"
- << "host3:27017"))
- << "protocolVersion" << 1 << "settings" << BSON("heartbeatTimeoutSecs" << 5)),
- 0);
+ updateConfig(BSON("_id"
+ << "rs0"
+ << "version"
+ << 5
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "host1:27017")
+ << BSON("_id" << 1 << "host"
+ << "host2:27017")
+ << BSON("_id" << 2 << "host"
+ << "host3:27017"))
+ << "protocolVersion"
+ << 1
+ << "settings"
+ << BSON("heartbeatTimeoutSecs" << 5)),
+ 0);
}
};
@@ -2683,15 +3057,23 @@ TEST_F(HeartbeatResponseTestV1,
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 7 << "members"
+ << "version"
+ << 7
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "hself"
- << "buildIndexes" << false << "priority" << 0)
+ << "buildIndexes"
+ << false
+ << "priority"
+ << 0)
<< BSON("_id" << 1 << "host"
<< "host2")
<< BSON("_id" << 2 << "host"
<< "host3"
- << "buildIndexes" << false << "priority" << 0))),
+ << "buildIndexes"
+ << false
+ << "priority"
+ << 0))),
0);
HeartbeatResponseAction nextAction = receiveUpHeartbeat(HostAndPort("host2"),
"rs0",
@@ -3017,11 +3399,15 @@ TEST_F(HeartbeatResponseTestV1, ReconfigNodeRemovedBetweenHeartbeatRequestAndRep
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 2 << "members" << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "host1:27017")
- << BSON("_id" << 1 << "host"
- << "host2:27017"))
- << "protocolVersion" << 1),
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "host1:27017")
+ << BSON("_id" << 1 << "host"
+ << "host2:27017"))
+ << "protocolVersion"
+ << 1),
0);
ReplSetHeartbeatResponse hb;
@@ -3066,11 +3452,15 @@ TEST_F(HeartbeatResponseTestV1, ReconfigBetweenHeartbeatRequestAndRepsonse) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 2 << "members" << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "host1:27017")
- << BSON("_id" << 2 << "host"
- << "host3:27017"))
- << "protocolVersion" << 1),
+ << "version"
+ << 2
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "host1:27017")
+ << BSON("_id" << 2 << "host"
+ << "host3:27017"))
+ << "protocolVersion"
+ << 1),
0);
ReplSetHeartbeatResponse hb;
@@ -3131,14 +3521,20 @@ TEST_F(HeartbeatResponseTestV1,
ScheduleAPriorityTakeoverWhenElectableAndReceiveHeartbeatFromLowerPriorityPrimary) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 5 << "members"
+ << "version"
+ << 5
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host1:27017"
- << "priority" << 2)
+ << "priority"
+ << 2)
<< BSON("_id" << 1 << "host"
- << "host2:27017") << BSON("_id" << 6 << "host"
- << "host7:27017"))
- << "protocolVersion" << 1 << "settings"
+ << "host2:27017")
+ << BSON("_id" << 6 << "host"
+ << "host7:27017"))
+ << "protocolVersion"
+ << 1
+ << "settings"
<< BSON("heartbeatTimeoutSecs" << 5)),
0);
@@ -3162,15 +3558,21 @@ TEST_F(HeartbeatResponseTestV1,
TEST_F(HeartbeatResponseTestV1, UpdateHeartbeatDataTermPreventsPriorityTakeover) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 5 << "members" << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "host0:27017"
- << "priority" << 2)
- << BSON("_id" << 1 << "host"
- << "host1:27017"
- << "priority" << 3)
- << BSON("_id" << 2 << "host"
- << "host2:27017"))
- << "settings" << BSON("heartbeatTimeoutSecs" << 5)),
+ << "version"
+ << 5
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "host0:27017"
+ << "priority"
+ << 2)
+ << BSON("_id" << 1 << "host"
+ << "host1:27017"
+ << "priority"
+ << 3)
+ << BSON("_id" << 2 << "host"
+ << "host2:27017"))
+ << "settings"
+ << BSON("heartbeatTimeoutSecs" << 5)),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -3223,26 +3625,43 @@ TEST_F(HeartbeatResponseTestV1,
ScheduleElectionIfAMajorityOfVotersIsVisibleEvenThoughATrueMajorityIsNot) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 5 << "members"
+ << "version"
+ << 5
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host1:27017")
<< BSON("_id" << 1 << "host"
<< "host2:27017")
<< BSON("_id" << 2 << "host"
<< "host3:27017"
- << "votes" << 0 << "priority" << 0)
+ << "votes"
+ << 0
+ << "priority"
+ << 0)
<< BSON("_id" << 3 << "host"
<< "host4:27017"
- << "votes" << 0 << "priority" << 0)
+ << "votes"
+ << 0
+ << "priority"
+ << 0)
<< BSON("_id" << 4 << "host"
<< "host5:27017"
- << "votes" << 0 << "priority" << 0)
+ << "votes"
+ << 0
+ << "priority"
+ << 0)
<< BSON("_id" << 5 << "host"
<< "host6:27017"
- << "votes" << 0 << "priority" << 0)
+ << "votes"
+ << 0
+ << "priority"
+ << 0)
<< BSON("_id" << 6 << "host"
- << "host7:27017")) << "protocolVersion" << 1
- << "settings" << BSON("heartbeatTimeoutSecs" << 5)),
+ << "host7:27017"))
+ << "protocolVersion"
+ << 1
+ << "settings"
+ << BSON("heartbeatTimeoutSecs" << 5)),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -3323,14 +3742,19 @@ TEST_F(HeartbeatResponseTestV1,
NodeDoesNotStandForElectionWhenPrimaryIsMarkedDownViaHeartbeatButWeAreAnArbiter) {
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 5 << "members"
+ << "version"
+ << 5
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host1:27017"
- << "arbiterOnly" << true)
+ << "arbiterOnly"
+ << true)
<< BSON("_id" << 1 << "host"
- << "host2:27017") << BSON("_id" << 2 << "host"
- << "host3:27017"))
- << "protocolVersion" << 1),
+ << "host2:27017")
+ << BSON("_id" << 2 << "host"
+ << "host3:27017"))
+ << "protocolVersion"
+ << 1),
0);
OpTime election = OpTime(Timestamp(400, 0), 0);
@@ -3455,14 +3879,19 @@ TEST_F(HeartbeatResponseTestV1,
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 5 << "members"
+ << "version"
+ << 5
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host1:27017"
- << "priority" << 0)
+ << "priority"
+ << 0)
<< BSON("_id" << 1 << "host"
- << "host2:27017") << BSON("_id" << 2 << "host"
- << "host3:27017"))
- << "protocolVersion" << 1),
+ << "host2:27017")
+ << BSON("_id" << 2 << "host"
+ << "host3:27017"))
+ << "protocolVersion"
+ << 1),
0);
OpTime election = OpTime(Timestamp(400, 0), 0);
@@ -3553,18 +3982,24 @@ TEST_F(HeartbeatResponseTestV1,
// In this test, the Topology coordinator sees a PRIMARY ("host2") and then sees a higher
// priority and stale node ("host3"). It responds with NoAction, as it should in all
// multiprimary states in PV1.
- updateConfig(
- BSON("_id"
- << "rs0"
- << "version" << 6 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "host1:27017")
- << BSON("_id" << 1 << "host"
- << "host2:27017") << BSON("_id" << 2 << "host"
- << "host3:27017"
- << "priority" << 3))
- << "protocolVersion" << 1 << "settings" << BSON("heartbeatTimeoutSecs" << 5)),
- 0);
+ updateConfig(BSON("_id"
+ << "rs0"
+ << "version"
+ << 6
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "host1:27017")
+ << BSON("_id" << 1 << "host"
+ << "host2:27017")
+ << BSON("_id" << 2 << "host"
+ << "host3:27017"
+ << "priority"
+ << 3))
+ << "protocolVersion"
+ << 1
+ << "settings"
+ << BSON("heartbeatTimeoutSecs" << 5)),
+ 0);
setSelfMemberState(MemberState::RS_SECONDARY);
OpTime election = OpTime(Timestamp(1000, 0), 0);
@@ -3585,18 +4020,24 @@ TEST_F(HeartbeatResponseTestV1,
// In this test, the Topology coordinator becomes PRIMARY and then sees a higher priority
// and stale node ("host3"). It responds with NoAction, as it should in all
// multiprimary states in PV1.
- updateConfig(
- BSON("_id"
- << "rs0"
- << "version" << 6 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "host1:27017")
- << BSON("_id" << 1 << "host"
- << "host2:27017") << BSON("_id" << 2 << "host"
- << "host3:27017"
- << "priority" << 3))
- << "protocolVersion" << 1 << "settings" << BSON("heartbeatTimeoutSecs" << 5)),
- 0);
+ updateConfig(BSON("_id"
+ << "rs0"
+ << "version"
+ << 6
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "host1:27017")
+ << BSON("_id" << 1 << "host"
+ << "host2:27017")
+ << BSON("_id" << 2 << "host"
+ << "host3:27017"
+ << "priority"
+ << 3))
+ << "protocolVersion"
+ << 1
+ << "settings"
+ << BSON("heartbeatTimeoutSecs" << 5)),
+ 0);
OpTime election = OpTime(Timestamp(1000, 0), 0);
OpTime staleTime = OpTime();
@@ -3614,18 +4055,24 @@ TEST_F(HeartbeatResponseTestV1,
// In this test, the Topology coordinator becomes PRIMARY and then sees a higher priority
// and equally fresh node ("host3"). It responds with NoAction, as it should in all
// multiprimary states in PV1.
- updateConfig(
- BSON("_id"
- << "rs0"
- << "version" << 6 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "host1:27017")
- << BSON("_id" << 1 << "host"
- << "host2:27017") << BSON("_id" << 2 << "host"
- << "host3:27017"
- << "priority" << 3))
- << "protocolVersion" << 1 << "settings" << BSON("heartbeatTimeoutSecs" << 5)),
- 0);
+ updateConfig(BSON("_id"
+ << "rs0"
+ << "version"
+ << 6
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "host1:27017")
+ << BSON("_id" << 1 << "host"
+ << "host2:27017")
+ << BSON("_id" << 2 << "host"
+ << "host3:27017"
+ << "priority"
+ << 3))
+ << "protocolVersion"
+ << 1
+ << "settings"
+ << BSON("heartbeatTimeoutSecs" << 5)),
+ 0);
OpTime election = OpTime(Timestamp(1000, 0), 0);
getTopoCoord().setFollowerMode(MemberState::RS_SECONDARY);
@@ -3644,18 +4091,24 @@ TEST_F(HeartbeatResponseTestV1,
// In this test, the Topology coordinator sees a PRIMARY ("host2") and then sees a higher
// priority and similarly fresh node ("host3"). It responds with NoAction, as it should
// in all multiprimary states in PV1.
- updateConfig(
- BSON("_id"
- << "rs0"
- << "version" << 6 << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "host1:27017")
- << BSON("_id" << 1 << "host"
- << "host2:27017") << BSON("_id" << 2 << "host"
- << "host3:27017"
- << "priority" << 3))
- << "protocolVersion" << 1 << "settings" << BSON("heartbeatTimeoutSecs" << 5)),
- 0);
+ updateConfig(BSON("_id"
+ << "rs0"
+ << "version"
+ << 6
+ << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "host1:27017")
+ << BSON("_id" << 1 << "host"
+ << "host2:27017")
+ << BSON("_id" << 2 << "host"
+ << "host3:27017"
+ << "priority"
+ << 3))
+ << "protocolVersion"
+ << 1
+ << "settings"
+ << BSON("heartbeatTimeoutSecs" << 5)),
+ 0);
setSelfMemberState(MemberState::RS_SECONDARY);
OpTime election = OpTime();
@@ -3811,15 +4264,21 @@ TEST_F(HeartbeatResponseTestV1, ShouldNotChangeSyncSourceWhenFresherMemberDoesNo
updateConfig(BSON("_id"
<< "rs0"
- << "version" << 6 << "members"
+ << "version"
+ << 6
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "hself")
<< BSON("_id" << 1 << "host"
<< "host2")
<< BSON("_id" << 2 << "host"
<< "host3"
- << "buildIndexes" << false << "priority" << 0))
- << "protocolVersion" << 1),
+ << "buildIndexes"
+ << false
+ << "priority"
+ << 0))
+ << "protocolVersion"
+ << 1),
0);
HeartbeatResponseAction nextAction = receiveUpHeartbeat(HostAndPort("host2"),
"rs0",
@@ -4184,14 +4643,18 @@ TEST_F(HeartbeatResponseHighVerbosityTestV1, UpdateHeartbeatDataSameConfig) {
ReplicaSetConfig originalConfig;
originalConfig.initialize(BSON("_id"
<< "rs0"
- << "version" << 5 << "members"
+ << "version"
+ << 5
+ << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host1:27017")
<< BSON("_id" << 1 << "host"
<< "host2:27017")
<< BSON("_id" << 2 << "host"
<< "host3:27017"))
- << "protocolVersion" << 1 << "settings"
+ << "protocolVersion"
+ << 1
+ << "settings"
<< BSON("heartbeatTimeoutSecs" << 5)));
ReplSetHeartbeatResponse sameConfigResponse;
@@ -4212,9 +4675,8 @@ TEST_F(HeartbeatResponseHighVerbosityTestV1, UpdateHeartbeatDataSameConfig) {
stopCapturingLogMessages();
ASSERT_NO_ACTION(action.getAction());
ASSERT_EQUALS(1,
- countLogLinesContaining(
- "Config from heartbeat response was "
- "same as ours."));
+ countLogLinesContaining("Config from heartbeat response was "
+ "same as ours."));
}
TEST_F(HeartbeatResponseHighVerbosityTestV1,
diff --git a/src/mongo/db/repl/update_position_args.cpp b/src/mongo/db/repl/update_position_args.cpp
index 6fa63988a45..80f3505b2cc 100644
--- a/src/mongo/db/repl/update_position_args.cpp
+++ b/src/mongo/db/repl/update_position_args.cpp
@@ -33,8 +33,8 @@
#include "mongo/base/status.h"
#include "mongo/bson/util/bson_check.h"
#include "mongo/bson/util/bson_extract.h"
-#include "mongo/db/repl/bson_extract_optime.h"
#include "mongo/db/jsobj.h"
+#include "mongo/db/repl/bson_extract_optime.h"
namespace mongo {
namespace repl {
diff --git a/src/mongo/db/repl/vote_requester_test.cpp b/src/mongo/db/repl/vote_requester_test.cpp
index c6e1ebe7b61..ba4691019d8 100644
--- a/src/mongo/db/repl/vote_requester_test.cpp
+++ b/src/mongo/db/repl/vote_requester_test.cpp
@@ -32,9 +32,9 @@
#include "mongo/base/status.h"
#include "mongo/db/jsobj.h"
-#include "mongo/db/repl/vote_requester.h"
#include "mongo/db/repl/repl_set_request_votes_args.h"
#include "mongo/db/repl/replication_executor.h"
+#include "mongo/db/repl/vote_requester.h"
#include "mongo/executor/network_interface_mock.h"
#include "mongo/stdx/functional.h"
#include "mongo/unittest/unittest.h"
@@ -58,22 +58,29 @@ 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 << "priority" << 0)
- << BSON("_id" << 4 << "host"
- << "host4"
- << "votes" << 0 << "priority" << 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;
@@ -184,22 +191,29 @@ 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 << "priority" << 0)
- << BSON("_id" << 4 << "host"
- << "host4"
- << "votes" << 0 << "priority" << 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;