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/abstract_async_component.cpp13
-rw-r--r--src/mongo/db/repl/abstract_async_component.h3
-rw-r--r--src/mongo/db/repl/abstract_oplog_fetcher_test_fixture.cpp2
-rw-r--r--src/mongo/db/repl/abstract_oplog_fetcher_test_fixture.h2
-rw-r--r--src/mongo/db/repl/applier_helpers.cpp3
-rw-r--r--src/mongo/db/repl/apply_ops.cpp11
-rw-r--r--src/mongo/db/repl/apply_ops.h2
-rw-r--r--src/mongo/db/repl/apply_ops_test.cpp83
-rw-r--r--src/mongo/db/repl/base_cloner_test_fixture.cpp3
-rw-r--r--src/mongo/db/repl/bgsync.h22
-rw-r--r--src/mongo/db/repl/check_quorum_for_config_change.cpp5
-rw-r--r--src/mongo/db/repl/check_quorum_for_config_change_test.cpp241
-rw-r--r--src/mongo/db/repl/collection_bulk_loader_impl.cpp65
-rw-r--r--src/mongo/db/repl/collection_cloner.cpp11
-rw-r--r--src/mongo/db/repl/collection_cloner_test.cpp68
-rw-r--r--src/mongo/db/repl/database_cloner.cpp43
-rw-r--r--src/mongo/db/repl/database_cloner_test.cpp111
-rw-r--r--src/mongo/db/repl/databases_cloner_test.cpp68
-rw-r--r--src/mongo/db/repl/dbcheck.cpp32
-rw-r--r--src/mongo/db/repl/dbcheck.h4
-rw-r--r--src/mongo/db/repl/dbcheck_idl.h2
-rw-r--r--src/mongo/db/repl/drop_pending_collection_reaper_test.cpp2
-rw-r--r--src/mongo/db/repl/election_reason_counter.h2
-rw-r--r--src/mongo/db/repl/idempotency_test_fixture.cpp7
-rw-r--r--src/mongo/db/repl/initial_syncer.cpp28
-rw-r--r--src/mongo/db/repl/initial_syncer_test.cpp92
-rw-r--r--src/mongo/db/repl/is_master_response.cpp27
-rw-r--r--src/mongo/db/repl/isself.cpp3
-rw-r--r--src/mongo/db/repl/member_config.cpp12
-rw-r--r--src/mongo/db/repl/member_config_test.cpp180
-rw-r--r--src/mongo/db/repl/member_data.cpp5
-rw-r--r--src/mongo/db/repl/mock_repl_coord_server_fixture.h2
-rw-r--r--src/mongo/db/repl/oplog.cpp13
-rw-r--r--src/mongo/db/repl/oplog_buffer_collection.cpp9
-rw-r--r--src/mongo/db/repl/oplog_buffer_collection_test.cpp41
-rw-r--r--src/mongo/db/repl/oplog_entry.cpp5
-rw-r--r--src/mongo/db/repl/oplog_entry.h42
-rw-r--r--src/mongo/db/repl/oplog_fetcher.cpp28
-rw-r--r--src/mongo/db/repl/oplog_interface_mock.cpp3
-rw-r--r--src/mongo/db/repl/oplog_test.cpp6
-rw-r--r--src/mongo/db/repl/optime_extract_test.cpp3
-rw-r--r--src/mongo/db/repl/read_concern_args.cpp38
-rw-r--r--src/mongo/db/repl/read_concern_args_test.cpp323
-rw-r--r--src/mongo/db/repl/repl_set_commands.cpp12
-rw-r--r--src/mongo/db/repl/repl_set_config.cpp112
-rw-r--r--src/mongo/db/repl/repl_set_config_checks.cpp47
-rw-r--r--src/mongo/db/repl/repl_set_config_checks_test.cpp432
-rw-r--r--src/mongo/db/repl/repl_set_config_test.cpp1272
-rw-r--r--src/mongo/db/repl/repl_set_heartbeat_args_v1.cpp7
-rw-r--r--src/mongo/db/repl/repl_set_heartbeat_response.cpp15
-rw-r--r--src/mongo/db/repl/repl_set_heartbeat_response_test.cpp128
-rw-r--r--src/mongo/db/repl/replication_consistency_markers_impl.cpp21
-rw-r--r--src/mongo/db/repl/replication_coordinator.h12
-rw-r--r--src/mongo/db/repl/replication_coordinator_external_state_impl.cpp22
-rw-r--r--src/mongo/db/repl/replication_coordinator_external_state_impl.h10
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl.cpp12
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl.h2
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_elect_v1_test.cpp371
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp10
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_heartbeat_v1_test.cpp111
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp131
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_test.cpp1489
-rw-r--r--src/mongo/db/repl/replication_coordinator_test_fixture.cpp30
-rw-r--r--src/mongo/db/repl/replication_info.cpp5
-rw-r--r--src/mongo/db/repl/replication_recovery.cpp3
-rw-r--r--src/mongo/db/repl/replication_recovery_test.cpp8
-rw-r--r--src/mongo/db/repl/reporter_test.cpp9
-rw-r--r--src/mongo/db/repl/roll_back_local_operations.cpp20
-rw-r--r--src/mongo/db/repl/roll_back_local_operations_test.cpp31
-rw-r--r--src/mongo/db/repl/rollback_impl.cpp39
-rw-r--r--src/mongo/db/repl/rollback_impl.h2
-rw-r--r--src/mongo/db/repl/rollback_impl_test.cpp92
-rw-r--r--src/mongo/db/repl/rollback_source_impl.cpp4
-rw-r--r--src/mongo/db/repl/rollback_test_fixture.cpp7
-rw-r--r--src/mongo/db/repl/rs_rollback.cpp51
-rw-r--r--src/mongo/db/repl/rs_rollback_test.cpp633
-rw-r--r--src/mongo/db/repl/split_horizon_test.cpp3
-rw-r--r--src/mongo/db/repl/storage_interface_impl.cpp42
-rw-r--r--src/mongo/db/repl/storage_interface_impl_test.cpp42
-rw-r--r--src/mongo/db/repl/storage_interface_mock.h9
-rw-r--r--src/mongo/db/repl/sync_source_resolver.cpp22
-rw-r--r--src/mongo/db/repl/sync_source_selector.h2
-rw-r--r--src/mongo/db/repl/sync_tail.cpp34
-rw-r--r--src/mongo/db/repl/sync_tail_test.cpp170
-rw-r--r--src/mongo/db/repl/task_runner.cpp1
-rw-r--r--src/mongo/db/repl/topology_coordinator.cpp43
-rw-r--r--src/mongo/db/repl/topology_coordinator.h2
-rw-r--r--src/mongo/db/repl/topology_coordinator_v1_test.cpp1206
-rw-r--r--src/mongo/db/repl/vote_requester_test.cpp90
89 files changed, 2746 insertions, 5735 deletions
diff --git a/src/mongo/db/repl/abstract_async_component.cpp b/src/mongo/db/repl/abstract_async_component.cpp
index 181f2f5ef69..1b99507fc5c 100644
--- a/src/mongo/db/repl/abstract_async_component.cpp
+++ b/src/mongo/db/repl/abstract_async_component.cpp
@@ -189,16 +189,15 @@ Status AbstractAsyncComponent::_scheduleWorkAtAndSaveHandle_inlock(
const std::string& name) {
invariant(handle);
if (_isShuttingDown_inlock()) {
- return Status(
- ErrorCodes::CallbackCanceled,
- str::stream() << "failed to schedule work " << name << " at " << when.toString() << ": "
- << _componentName
- << " is shutting down");
+ return Status(ErrorCodes::CallbackCanceled,
+ str::stream()
+ << "failed to schedule work " << name << " at " << when.toString() << ": "
+ << _componentName << " is shutting down");
}
auto result = _executor->scheduleWorkAt(when, std::move(work));
if (!result.isOK()) {
- return result.getStatus().withContext(
- str::stream() << "failed to schedule work " << name << " at " << when.toString());
+ return result.getStatus().withContext(str::stream() << "failed to schedule work " << name
+ << " at " << when.toString());
}
*handle = result.getValue();
return Status::OK();
diff --git a/src/mongo/db/repl/abstract_async_component.h b/src/mongo/db/repl/abstract_async_component.h
index 8d5e784b591..64d88ad41e8 100644
--- a/src/mongo/db/repl/abstract_async_component.h
+++ b/src/mongo/db/repl/abstract_async_component.h
@@ -247,8 +247,7 @@ Status AbstractAsyncComponent::_startupComponent_inlock(std::unique_ptr<T>& comp
component.reset();
return Status(ErrorCodes::CallbackCanceled,
str::stream() << "failed to start up " << componentToStartUp << ": "
- << _componentName
- << " is shutting down");
+ << _componentName << " is shutting down");
}
auto status = component->startup();
diff --git a/src/mongo/db/repl/abstract_oplog_fetcher_test_fixture.cpp b/src/mongo/db/repl/abstract_oplog_fetcher_test_fixture.cpp
index f3d44242ffb..882cf5f4fa8 100644
--- a/src/mongo/db/repl/abstract_oplog_fetcher_test_fixture.cpp
+++ b/src/mongo/db/repl/abstract_oplog_fetcher_test_fixture.cpp
@@ -135,4 +135,4 @@ executor::RemoteCommandRequest AbstractOplogFetcherTest::processNetworkResponse(
}
} // namespace repl
-} // namespace mango
+} // namespace mongo
diff --git a/src/mongo/db/repl/abstract_oplog_fetcher_test_fixture.h b/src/mongo/db/repl/abstract_oplog_fetcher_test_fixture.h
index 2164f93cac6..7349689bb32 100644
--- a/src/mongo/db/repl/abstract_oplog_fetcher_test_fixture.h
+++ b/src/mongo/db/repl/abstract_oplog_fetcher_test_fixture.h
@@ -97,4 +97,4 @@ protected:
Date_t lastFetchedWall;
};
} // namespace repl
-} // namespace mango
+} // namespace mongo
diff --git a/src/mongo/db/repl/applier_helpers.cpp b/src/mongo/db/repl/applier_helpers.cpp
index 0113057b57a..82a4cade0ed 100644
--- a/src/mongo/db/repl/applier_helpers.cpp
+++ b/src/mongo/db/repl/applier_helpers.cpp
@@ -196,8 +196,7 @@ StatusWith<InsertGroup::ConstIterator> InsertGroup::groupAndApplyInserts(ConstIt
// application of an individual op.
auto status = exceptionToStatus().withContext(
str::stream() << "Error applying inserts in bulk: " << redact(groupedInsertObj)
- << ". Trying first insert as a lone insert: "
- << redact(entry.getRaw()));
+ << ". Trying first insert as a lone insert: " << redact(entry.getRaw()));
// It's not an error during initial sync to encounter DuplicateKey errors.
if (Mode::kInitialSync == _mode && ErrorCodes::DuplicateKey == status) {
diff --git a/src/mongo/db/repl/apply_ops.cpp b/src/mongo/db/repl/apply_ops.cpp
index df72f0faea8..03e0c8ac566 100644
--- a/src/mongo/db/repl/apply_ops.cpp
+++ b/src/mongo/db/repl/apply_ops.cpp
@@ -157,9 +157,7 @@ Status _applyOps(OperationContext* opCtx,
ErrorCodes::AtomicityFailure,
str::stream()
<< "cannot apply insert or update operation on a non-existent namespace "
- << nss.ns()
- << " in atomic applyOps mode: "
- << redact(opObj));
+ << nss.ns() << " in atomic applyOps mode: " << redact(opObj));
}
// Reject malformed operations in an atomic applyOps.
@@ -169,8 +167,7 @@ Status _applyOps(OperationContext* opCtx,
uasserted(ErrorCodes::AtomicityFailure,
str::stream()
<< "cannot apply a malformed operation in atomic applyOps mode: "
- << redact(opObj)
- << "; will retry without atomicity: "
+ << redact(opObj) << "; will retry without atomicity: "
<< exceptionToStatus().toString());
}
@@ -229,9 +226,7 @@ Status _applyOps(OperationContext* opCtx,
str::stream()
<< "cannot apply insert or update operation on a "
"non-existent namespace "
- << nss.ns()
- << ": "
- << mongo::redact(opObj));
+ << nss.ns() << ": " << mongo::redact(opObj));
}
OldClientContext ctx(opCtx, nss.ns());
diff --git a/src/mongo/db/repl/apply_ops.h b/src/mongo/db/repl/apply_ops.h
index c5cca31569f..8aac61a39b9 100644
--- a/src/mongo/db/repl/apply_ops.h
+++ b/src/mongo/db/repl/apply_ops.h
@@ -116,7 +116,7 @@ Status applyOps(OperationContext* opCtx,
/**
* Applies a non-transactional 'applyOps' oplog entry. That is, an 'applyOps' entry that was not
* generated by a transaction.
-*/
+ */
Status applyApplyOpsOplogEntry(OperationContext* opCtx,
const OplogEntry& entry,
repl::OplogApplication::Mode oplogApplicationMode);
diff --git a/src/mongo/db/repl/apply_ops_test.cpp b/src/mongo/db/repl/apply_ops_test.cpp
index 6416f751a2f..eaa21394384 100644
--- a/src/mongo/db/repl/apply_ops_test.cpp
+++ b/src/mongo/db/repl/apply_ops_test.cpp
@@ -142,17 +142,13 @@ TEST_F(ApplyOpsTest, CommandInNestedApplyOpsReturnsSuccess) {
auto mode = OplogApplication::Mode::kApplyOpsCmd;
BSONObjBuilder resultBuilder;
NamespaceString nss("test", "foo");
- auto innerCmdObj = BSON("op"
- << "c"
- << "ns"
- << nss.getCommandNS().ns()
- << "o"
- << BSON("create" << nss.coll()));
+ auto innerCmdObj =
+ BSON("op"
+ << "c"
+ << "ns" << nss.getCommandNS().ns() << "o" << BSON("create" << nss.coll()));
auto innerApplyOpsObj = BSON("op"
<< "c"
- << "ns"
- << nss.getCommandNS().ns()
- << "o"
+ << "ns" << nss.getCommandNS().ns() << "o"
<< BSON("applyOps" << BSON_ARRAY(innerCmdObj)));
auto cmdObj = BSON("applyOps" << BSON_ARRAY(innerApplyOpsObj));
@@ -170,18 +166,13 @@ TEST_F(ApplyOpsTest, InsertInNestedApplyOpsReturnsSuccess) {
NamespaceString nss("test", "foo");
auto innerCmdObj = BSON("op"
<< "i"
- << "ns"
- << nss.ns()
- << "o"
+ << "ns" << nss.ns() << "o"
<< BSON("_id"
<< "a")
- << "ui"
- << options.uuid.get());
+ << "ui" << options.uuid.get());
auto innerApplyOpsObj = BSON("op"
<< "c"
- << "ns"
- << nss.getCommandNS().ns()
- << "o"
+ << "ns" << nss.getCommandNS().ns() << "o"
<< BSON("applyOps" << BSON_ARRAY(innerCmdObj)));
auto cmdObj = BSON("applyOps" << BSON_ARRAY(innerApplyOpsObj));
@@ -207,18 +198,10 @@ BSONObj makeApplyOpsWithInsertOperation(const NamespaceString& nss,
const BSONObj& documentToInsert) {
auto insertOp = uuid ? BSON("op"
<< "i"
- << "ns"
- << nss.ns()
- << "o"
- << documentToInsert
- << "ui"
- << *uuid)
+ << "ns" << nss.ns() << "o" << documentToInsert << "ui" << *uuid)
: BSON("op"
<< "i"
- << "ns"
- << nss.ns()
- << "o"
- << documentToInsert);
+ << "ns" << nss.ns() << "o" << documentToInsert);
return BSON("applyOps" << BSON_ARRAY(insertOp));
}
@@ -396,53 +379,35 @@ TEST_F(ApplyOpsTest, ExtractOperationsReturnsOperationsWithSameOpTimeAsApplyOps)
auto ui1 = UUID::gen();
auto op1 = BSON("op"
<< "i"
- << "ns"
- << ns1.ns()
- << "ui"
- << ui1
- << "o"
- << BSON("_id" << 1));
+ << "ns" << ns1.ns() << "ui" << ui1 << "o" << BSON("_id" << 1));
NamespaceString ns2("test.b");
auto ui2 = UUID::gen();
auto op2 = BSON("op"
<< "i"
- << "ns"
- << ns2.ns()
- << "ui"
- << ui2
- << "o"
- << BSON("_id" << 2));
+ << "ns" << ns2.ns() << "ui" << ui2 << "o" << BSON("_id" << 2));
NamespaceString ns3("test.c");
auto ui3 = UUID::gen();
auto op3 = BSON("op"
<< "u"
- << "ns"
- << ns3.ns()
- << "ui"
- << ui3
- << "b"
- << true
- << "o"
- << BSON("x" << 1)
- << "o2"
- << BSON("_id" << 3));
+ << "ns" << ns3.ns() << "ui" << ui3 << "b" << true << "o" << BSON("x" << 1)
+ << "o2" << BSON("_id" << 3));
auto oplogEntry =
makeOplogEntry(OpTypeEnum::kCommand, BSON("applyOps" << BSON_ARRAY(op1 << op2 << op3)));
auto operations = ApplyOps::extractOperations(oplogEntry);
- ASSERT_EQUALS(3U, operations.size()) << "Unexpected number of operations extracted: "
- << oplogEntry.toBSON();
+ ASSERT_EQUALS(3U, operations.size())
+ << "Unexpected number of operations extracted: " << oplogEntry.toBSON();
// Check extracted CRUD operations.
auto it = operations.cbegin();
{
ASSERT(operations.cend() != it);
const auto& operation1 = *(it++);
- ASSERT(OpTypeEnum::kInsert == operation1.getOpType()) << "Unexpected op type: "
- << operation1.toBSON();
+ ASSERT(OpTypeEnum::kInsert == operation1.getOpType())
+ << "Unexpected op type: " << operation1.toBSON();
ASSERT_EQUALS(ui1, *operation1.getUuid());
ASSERT_EQUALS(ns1, operation1.getNss());
ASSERT_BSONOBJ_EQ(BSON("_id" << 1), operation1.getOperationToApply());
@@ -454,8 +419,8 @@ TEST_F(ApplyOpsTest, ExtractOperationsReturnsOperationsWithSameOpTimeAsApplyOps)
{
ASSERT(operations.cend() != it);
const auto& operation2 = *(it++);
- ASSERT(OpTypeEnum::kInsert == operation2.getOpType()) << "Unexpected op type: "
- << operation2.toBSON();
+ ASSERT(OpTypeEnum::kInsert == operation2.getOpType())
+ << "Unexpected op type: " << operation2.toBSON();
ASSERT_EQUALS(ui2, *operation2.getUuid());
ASSERT_EQUALS(ns2, operation2.getNss());
ASSERT_BSONOBJ_EQ(BSON("_id" << 2), operation2.getOperationToApply());
@@ -467,8 +432,8 @@ TEST_F(ApplyOpsTest, ExtractOperationsReturnsOperationsWithSameOpTimeAsApplyOps)
{
ASSERT(operations.cend() != it);
const auto& operation3 = *(it++);
- ASSERT(OpTypeEnum::kUpdate == operation3.getOpType()) << "Unexpected op type: "
- << operation3.toBSON();
+ ASSERT(OpTypeEnum::kUpdate == operation3.getOpType())
+ << "Unexpected op type: " << operation3.toBSON();
ASSERT_EQUALS(ui3, *operation3.getUuid());
ASSERT_EQUALS(ns3, operation3.getNss());
ASSERT_BSONOBJ_EQ(BSON("x" << 1), operation3.getOperationToApply());
@@ -496,9 +461,7 @@ TEST_F(ApplyOpsTest, ApplyOpsFailsToDropAdmin) {
auto dropDatabaseOp = BSON("op"
<< "c"
- << "ns"
- << nss.getCommandNS().ns()
- << "o"
+ << "ns" << nss.getCommandNS().ns() << "o"
<< BSON("dropDatabase" << 1));
auto dropDatabaseCmdObj = BSON("applyOps" << BSON_ARRAY(dropDatabaseOp));
diff --git a/src/mongo/db/repl/base_cloner_test_fixture.cpp b/src/mongo/db/repl/base_cloner_test_fixture.cpp
index 7d0dad39e6f..8d9fc63f6cd 100644
--- a/src/mongo/db/repl/base_cloner_test_fixture.cpp
+++ b/src/mongo/db/repl/base_cloner_test_fixture.cpp
@@ -47,8 +47,7 @@ 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::createCountResponse(int documentCount) {
diff --git a/src/mongo/db/repl/bgsync.h b/src/mongo/db/repl/bgsync.h
index f6f3dc53d0f..e44427a656d 100644
--- a/src/mongo/db/repl/bgsync.h
+++ b/src/mongo/db/repl/bgsync.h
@@ -221,17 +221,17 @@ private:
ReplicationProcess* _replicationProcess;
/**
- * All member variables are labeled with one of the following codes indicating the
- * synchronization rules for accessing them:
- *
- * (PR) Completely private to BackgroundSync. Can be read or written to from within the main
- * BackgroundSync thread without synchronization. Shouldn't be accessed outside of this
- * thread.
- *
- * (S) Self-synchronizing; access in any way from any context.
- *
- * (M) Reads and writes guarded by _mutex
- *
+ * All member variables are labeled with one of the following codes indicating the
+ * synchronization rules for accessing them:
+ *
+ * (PR) Completely private to BackgroundSync. Can be read or written to from within the main
+ * BackgroundSync thread without synchronization. Shouldn't be accessed outside of this
+ * thread.
+ *
+ * (S) Self-synchronizing; access in any way from any context.
+ *
+ * (M) Reads and writes guarded by _mutex
+ *
*/
// Protects member data of BackgroundSync.
diff --git a/src/mongo/db/repl/check_quorum_for_config_change.cpp b/src/mongo/db/repl/check_quorum_for_config_change.cpp
index 7f6f6af9672..8f2dfc40664 100644
--- a/src/mongo/db/repl/check_quorum_for_config_change.cpp
+++ b/src/mongo/db/repl/check_quorum_for_config_change.cpp
@@ -40,7 +40,6 @@
#include "mongo/db/repl/scatter_gather_algorithm.h"
#include "mongo/db/repl/scatter_gather_runner.h"
#include "mongo/db/server_options.h"
-#include "mongo/db/server_options.h"
#include "mongo/rpc/metadata/repl_set_metadata.h"
#include "mongo/util/log.h"
#include "mongo/util/str.h"
@@ -199,8 +198,8 @@ void QuorumChecker::_tabulateHeartbeatResponse(const RemoteCommandRequest& reque
Status hbStatus = hbResp.initialize(resBSON, 0, /*requireWallTime*/ false);
if (hbStatus.code() == ErrorCodes::InconsistentReplicaSetNames) {
- std::string message = str::stream() << "Our set name did not match that of "
- << request.target.toString();
+ std::string message = str::stream()
+ << "Our set name did not match that of " << request.target.toString();
_vetoStatus = Status(ErrorCodes::NewReplicaSetConfigurationIncompatible, message);
warning() << message;
return;
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 4658863cb0c..5bb4fefbc08 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
@@ -48,18 +48,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 {
@@ -141,30 +141,24 @@ ReplSetConfig assertMakeRSConfig(const BSONObj& configBson) {
}
TEST_F(CheckQuorumForInitiate, ValidSingleNodeSet) {
- ReplSetConfig config = assertMakeRSConfig(BSON("_id"
- << "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
- << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "h1"))));
+ ReplSetConfig config =
+ assertMakeRSConfig(BSON("_id"
+ << "rs0"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "h1"))));
startQuorumCheck(config, 0);
ASSERT_OK(waitForQuorumCheck());
}
TEST_F(CheckQuorumForInitiate, QuorumCheckCanceledByShutdown) {
getExecutor().shutdown();
- ReplSetConfig config = assertMakeRSConfig(BSON("_id"
- << "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
- << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "h1"))));
+ ReplSetConfig config =
+ assertMakeRSConfig(BSON("_id"
+ << "rs0"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "h1"))));
startQuorumCheck(config, 0);
ASSERT_EQUALS(ErrorCodes::ShutdownInProgress, waitForQuorumCheck());
}
@@ -173,23 +167,20 @@ 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.
- ReplSetConfig config = assertMakeRSConfig(BSON("_id"
- << "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 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"))));
+ ReplSetConfig config =
+ assertMakeRSConfig(BSON("_id"
+ << "rs0"
+ << "version" << 1 << "protocolVersion" << 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);
getNet()->enterNetwork();
const Date_t startDate = getNet()->now();
@@ -255,11 +246,7 @@ TEST_F(CheckQuorumForInitiate, QuorumCheckSuccessForFiveNodes) {
const ReplSetConfig rsConfig =
assertMakeRSConfig(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1:1")
<< BSON("_id" << 2 << "host"
@@ -283,8 +270,8 @@ TEST_F(CheckQuorumForInitiate, QuorumCheckSuccessForFiveNodes) {
const RemoteCommandRequest& request = noi->getRequest();
ASSERT_EQUALS("admin", request.dbname);
ASSERT_BSONOBJ_EQ(hbRequest, request.cmdObj);
- ASSERT(seenHosts.insert(request.target).second) << "Already saw "
- << request.target.toString();
+ ASSERT(seenHosts.insert(request.target).second)
+ << "Already saw " << request.target.toString();
getNet()->scheduleResponse(
noi, startDate + Milliseconds(10), makeHeartbeatResponse(rsConfig, Milliseconds(8)));
}
@@ -302,19 +289,12 @@ TEST_F(CheckQuorumForInitiate, QuorumCheckFailedDueToOneDownNode) {
const ReplSetConfig rsConfig =
assertMakeRSConfig(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 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"
@@ -336,8 +316,8 @@ TEST_F(CheckQuorumForInitiate, QuorumCheckFailedDueToOneDownNode) {
const RemoteCommandRequest& request = noi->getRequest();
ASSERT_EQUALS("admin", request.dbname);
ASSERT_BSONOBJ_EQ(hbRequest, request.cmdObj);
- ASSERT(seenHosts.insert(request.target).second) << "Already saw "
- << request.target.toString();
+ ASSERT(seenHosts.insert(request.target).second)
+ << "Already saw " << request.target.toString();
if (request.target == HostAndPort("h2", 1)) {
getNet()->scheduleResponse(
noi, startDate + Milliseconds(10), {ErrorCodes::NoSuchKey, "No response"});
@@ -369,11 +349,7 @@ TEST_F(CheckQuorumForInitiate, QuorumCheckFailedDueToSetNameMismatch) {
const ReplSetConfig rsConfig =
assertMakeRSConfig(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1:1")
<< BSON("_id" << 2 << "host"
@@ -397,8 +373,8 @@ TEST_F(CheckQuorumForInitiate, QuorumCheckFailedDueToSetNameMismatch) {
const RemoteCommandRequest& request = noi->getRequest();
ASSERT_EQUALS("admin", request.dbname);
ASSERT_BSONOBJ_EQ(hbRequest, request.cmdObj);
- ASSERT(seenHosts.insert(request.target).second) << "Already saw "
- << request.target.toString();
+ ASSERT(seenHosts.insert(request.target).second)
+ << "Already saw " << request.target.toString();
if (request.target == HostAndPort("h4", 1)) {
getNet()->scheduleResponse(
noi,
@@ -434,11 +410,7 @@ TEST_F(CheckQuorumForInitiate, QuorumCheckFailedDueToSetIdMismatch) {
const ReplSetConfig rsConfig =
assertMakeRSConfig(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1:1")
<< BSON("_id" << 2 << "host"
@@ -449,8 +421,7 @@ TEST_F(CheckQuorumForInitiate, QuorumCheckFailedDueToSetIdMismatch) {
<< "h4:1")
<< BSON("_id" << 5 << "host"
<< "h5:1"))
- << "settings"
- << BSON("replicaSetId" << replicaSetId)));
+ << "settings" << BSON("replicaSetId" << replicaSetId)));
const int myConfigIndex = 2;
const BSONObj hbRequest = makeHeartbeatRequest(rsConfig, myConfigIndex);
@@ -467,8 +438,8 @@ TEST_F(CheckQuorumForInitiate, QuorumCheckFailedDueToSetIdMismatch) {
ASSERT_EQUALS("admin", request.dbname);
ASSERT_BSONOBJ_EQ(hbRequest, request.cmdObj);
ASSERT_BSONOBJ_EQ(BSON(rpc::kReplSetMetadataFieldName << 1), request.metadata);
- ASSERT(seenHosts.insert(request.target).second) << "Already saw "
- << request.target.toString();
+ ASSERT(seenHosts.insert(request.target).second)
+ << "Already saw " << request.target.toString();
if (request.target == incompatibleHost) {
OpTime opTime{Timestamp{10, 10}, 10};
Date_t wallTime = Date_t();
@@ -499,10 +470,8 @@ 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");
@@ -518,11 +487,7 @@ TEST_F(CheckQuorumForInitiate, QuorumCheckFailedDueToInitializedNode) {
const ReplSetConfig rsConfig =
assertMakeRSConfig(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1:1")
<< BSON("_id" << 2 << "host"
@@ -546,8 +511,8 @@ TEST_F(CheckQuorumForInitiate, QuorumCheckFailedDueToInitializedNode) {
const RemoteCommandRequest& request = noi->getRequest();
ASSERT_EQUALS("admin", request.dbname);
ASSERT_BSONOBJ_EQ(hbRequest, request.cmdObj);
- ASSERT(seenHosts.insert(request.target).second) << "Already saw "
- << request.target.toString();
+ ASSERT(seenHosts.insert(request.target).second)
+ << "Already saw " << request.target.toString();
if (request.target == HostAndPort("h5", 1)) {
long long configVersion = 1;
getNet()->scheduleResponse(
@@ -582,11 +547,7 @@ TEST_F(CheckQuorumForInitiate, QuorumCheckFailedDueToInitializedNodeOnlyOneRespo
const ReplSetConfig rsConfig =
assertMakeRSConfig(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1:1")
<< BSON("_id" << 2 << "host"
@@ -610,8 +571,8 @@ TEST_F(CheckQuorumForInitiate, QuorumCheckFailedDueToInitializedNodeOnlyOneRespo
const RemoteCommandRequest& request = noi->getRequest();
ASSERT_EQUALS("admin", request.dbname);
ASSERT_BSONOBJ_EQ(hbRequest, request.cmdObj);
- ASSERT(seenHosts.insert(request.target).second) << "Already saw "
- << request.target.toString();
+ ASSERT(seenHosts.insert(request.target).second)
+ << "Already saw " << request.target.toString();
if (request.target == HostAndPort("h5", 1)) {
long long configVersion = 1;
getNet()->scheduleResponse(
@@ -642,11 +603,7 @@ TEST_F(CheckQuorumForReconfig, QuorumCheckVetoedDueToHigherConfigVersion) {
const ReplSetConfig rsConfig =
assertMakeRSConfig(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 2 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1:1")
<< BSON("_id" << 2 << "host"
@@ -666,8 +623,8 @@ TEST_F(CheckQuorumForReconfig, QuorumCheckVetoedDueToHigherConfigVersion) {
const RemoteCommandRequest& request = noi->getRequest();
ASSERT_EQUALS("admin", request.dbname);
ASSERT_BSONOBJ_EQ(hbRequest, request.cmdObj);
- ASSERT(seenHosts.insert(request.target).second) << "Already saw "
- << request.target.toString();
+ ASSERT(seenHosts.insert(request.target).second)
+ << "Already saw " << request.target.toString();
if (request.target == HostAndPort("h1", 1)) {
long long configVersion = 5;
getNet()->scheduleResponse(
@@ -696,11 +653,7 @@ TEST_F(CheckQuorumForReconfig, QuorumCheckVetoedDueToIncompatibleSetName) {
const ReplSetConfig rsConfig =
assertMakeRSConfig(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 2 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1:1")
<< BSON("_id" << 2 << "host"
@@ -720,8 +673,8 @@ TEST_F(CheckQuorumForReconfig, QuorumCheckVetoedDueToIncompatibleSetName) {
const RemoteCommandRequest& request = noi->getRequest();
ASSERT_EQUALS("admin", request.dbname);
ASSERT_BSONOBJ_EQ(hbRequest, request.cmdObj);
- ASSERT(seenHosts.insert(request.target).second) << "Already saw "
- << request.target.toString();
+ ASSERT(seenHosts.insert(request.target).second)
+ << "Already saw " << request.target.toString();
if (request.target == HostAndPort("h2", 1)) {
getNet()->scheduleResponse(
noi,
@@ -754,11 +707,7 @@ TEST_F(CheckQuorumForReconfig, QuorumCheckFailsDueToInsufficientVoters) {
const ReplSetConfig rsConfig =
assertMakeRSConfig(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 2 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1:1")
<< BSON("_id" << 2 << "host"
@@ -767,16 +716,10 @@ TEST_F(CheckQuorumForReconfig, QuorumCheckFailsDueToInsufficientVoters) {
<< "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);
@@ -790,8 +733,8 @@ TEST_F(CheckQuorumForReconfig, QuorumCheckFailsDueToInsufficientVoters) {
const RemoteCommandRequest& request = noi->getRequest();
ASSERT_EQUALS("admin", request.dbname);
ASSERT_BSONOBJ_EQ(hbRequest, request.cmdObj);
- ASSERT(seenHosts.insert(request.target).second) << "Already saw "
- << request.target.toString();
+ ASSERT(seenHosts.insert(request.target).second)
+ << "Already saw " << request.target.toString();
if (request.target == HostAndPort("h1", 1) || request.target == HostAndPort("h5", 1)) {
getNet()->scheduleResponse(noi,
startDate + Milliseconds(10),
@@ -820,11 +763,7 @@ TEST_F(CheckQuorumForReconfig, QuorumCheckFailsDueToNoElectableNodeResponding) {
const ReplSetConfig rsConfig =
assertMakeRSConfig(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 2 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1:1")
<< BSON("_id" << 2 << "host"
@@ -833,12 +772,10 @@ TEST_F(CheckQuorumForReconfig, QuorumCheckFailsDueToNoElectableNodeResponding) {
<< "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);
@@ -852,8 +789,8 @@ TEST_F(CheckQuorumForReconfig, QuorumCheckFailsDueToNoElectableNodeResponding) {
const RemoteCommandRequest& request = noi->getRequest();
ASSERT_EQUALS("admin", request.dbname);
ASSERT_BSONOBJ_EQ(hbRequest, request.cmdObj);
- ASSERT(seenHosts.insert(request.target).second) << "Already saw "
- << request.target.toString();
+ ASSERT(seenHosts.insert(request.target).second)
+ << "Already saw " << request.target.toString();
if (request.target == HostAndPort("h5", 1)) {
getNet()->scheduleResponse(noi,
startDate + Milliseconds(10),
@@ -878,11 +815,7 @@ TEST_F(CheckQuorumForReconfig, QuorumCheckSucceedsWithAsSoonAsPossible) {
const ReplSetConfig rsConfig =
assertMakeRSConfig(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 2 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1:1")
<< BSON("_id" << 2 << "host"
@@ -891,16 +824,10 @@ TEST_F(CheckQuorumForReconfig, QuorumCheckSucceedsWithAsSoonAsPossible) {
<< "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);
@@ -914,8 +841,8 @@ TEST_F(CheckQuorumForReconfig, QuorumCheckSucceedsWithAsSoonAsPossible) {
const RemoteCommandRequest& request = noi->getRequest();
ASSERT_EQUALS("admin", request.dbname);
ASSERT_BSONOBJ_EQ(hbRequest, request.cmdObj);
- ASSERT(seenHosts.insert(request.target).second) << "Already saw "
- << request.target.toString();
+ ASSERT(seenHosts.insert(request.target).second)
+ << "Already saw " << request.target.toString();
if (request.target == HostAndPort("h1", 1) || request.target == HostAndPort("h2", 1)) {
getNet()->scheduleResponse(noi,
startDate + Milliseconds(10),
@@ -938,11 +865,7 @@ TEST_F(CheckQuorumForReconfig, QuorumCheckProcessesCallbackCanceledResponse) {
const ReplSetConfig rsConfig =
assertMakeRSConfig(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 2 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1:1")
<< BSON("_id" << 2 << "host"
@@ -962,8 +885,8 @@ TEST_F(CheckQuorumForReconfig, QuorumCheckProcessesCallbackCanceledResponse) {
const RemoteCommandRequest& request = noi->getRequest();
ASSERT_EQUALS("admin", request.dbname);
ASSERT_BSONOBJ_EQ(hbRequest, request.cmdObj);
- ASSERT(seenHosts.insert(request.target).second) << "Already saw "
- << request.target.toString();
+ ASSERT(seenHosts.insert(request.target).second)
+ << "Already saw " << request.target.toString();
if (request.target == HostAndPort("h1", 1)) {
getNet()->scheduleResponse(
noi,
diff --git a/src/mongo/db/repl/collection_bulk_loader_impl.cpp b/src/mongo/db/repl/collection_bulk_loader_impl.cpp
index 393f41f11f2..cc7719d2374 100644
--- a/src/mongo/db/repl/collection_bulk_loader_impl.cpp
+++ b/src/mongo/db/repl/collection_bulk_loader_impl.cpp
@@ -76,42 +76,41 @@ CollectionBulkLoaderImpl::~CollectionBulkLoaderImpl() {
}
Status CollectionBulkLoaderImpl::init(const std::vector<BSONObj>& secondaryIndexSpecs) {
- return _runTaskReleaseResourcesOnFailure(
- [ coll = _autoColl->getCollection(), &secondaryIndexSpecs, this ]()->Status {
- // All writes in CollectionBulkLoaderImpl should be unreplicated.
- // The opCtx is accessed indirectly through _secondaryIndexesBlock.
- UnreplicatedWritesBlock uwb(_opCtx.get());
- // This enforces the buildIndexes setting in the replica set configuration.
- auto indexCatalog = coll->getIndexCatalog();
- auto specs =
- indexCatalog->removeExistingIndexesNoChecks(_opCtx.get(), secondaryIndexSpecs);
- if (specs.size()) {
- _secondaryIndexesBlock->ignoreUniqueConstraint();
- auto status =
- _secondaryIndexesBlock
- ->init(_opCtx.get(), _collection, specs, MultiIndexBlock::kNoopOnInitFn)
- .getStatus();
- if (!status.isOK()) {
- return status;
- }
- } else {
- _secondaryIndexesBlock.reset();
+ return _runTaskReleaseResourcesOnFailure([coll = _autoColl->getCollection(),
+ &secondaryIndexSpecs,
+ this]() -> Status {
+ // All writes in CollectionBulkLoaderImpl should be unreplicated.
+ // The opCtx is accessed indirectly through _secondaryIndexesBlock.
+ UnreplicatedWritesBlock uwb(_opCtx.get());
+ // This enforces the buildIndexes setting in the replica set configuration.
+ auto indexCatalog = coll->getIndexCatalog();
+ auto specs = indexCatalog->removeExistingIndexesNoChecks(_opCtx.get(), secondaryIndexSpecs);
+ if (specs.size()) {
+ _secondaryIndexesBlock->ignoreUniqueConstraint();
+ auto status =
+ _secondaryIndexesBlock
+ ->init(_opCtx.get(), _collection, specs, MultiIndexBlock::kNoopOnInitFn)
+ .getStatus();
+ if (!status.isOK()) {
+ return status;
}
- if (!_idIndexSpec.isEmpty()) {
- auto status =
- _idIndexBlock
- ->init(
- _opCtx.get(), _collection, _idIndexSpec, MultiIndexBlock::kNoopOnInitFn)
- .getStatus();
- if (!status.isOK()) {
- return status;
- }
- } else {
- _idIndexBlock.reset();
+ } else {
+ _secondaryIndexesBlock.reset();
+ }
+ if (!_idIndexSpec.isEmpty()) {
+ auto status =
+ _idIndexBlock
+ ->init(_opCtx.get(), _collection, _idIndexSpec, MultiIndexBlock::kNoopOnInitFn)
+ .getStatus();
+ if (!status.isOK()) {
+ return status;
}
+ } else {
+ _idIndexBlock.reset();
+ }
- return Status::OK();
- });
+ return Status::OK();
+ });
}
Status CollectionBulkLoaderImpl::_insertDocumentsForUncappedCollection(
diff --git a/src/mongo/db/repl/collection_cloner.cpp b/src/mongo/db/repl/collection_cloner.cpp
index facbf764d95..84c7273f001 100644
--- a/src/mongo/db/repl/collection_cloner.cpp
+++ b/src/mongo/db/repl/collection_cloner.cpp
@@ -132,8 +132,8 @@ CollectionCloner::CollectionCloner(executor::TaskExecutor* executor,
_sourceNss.db().toString(),
makeCommandWithUUIDorCollectionName("listIndexes", _options.uuid, sourceNss),
[this](const Fetcher::QueryResponseStatus& fetchResult,
- Fetcher::NextAction * nextAction,
- BSONObjBuilder * getMoreBob) {
+ Fetcher::NextAction* nextAction,
+ BSONObjBuilder* getMoreBob) {
_listIndexesCallback(fetchResult, nextAction, getMoreBob);
},
ReadPreferenceSetting::secondaryPreferredMetadata(),
@@ -332,9 +332,7 @@ void CollectionCloner::_countCallback(
_finishCallback(countStatus.withContext(
str::stream() << "There was an error parsing document count from count "
"command result on collection "
- << _sourceNss.ns()
- << " from "
- << _source.toString()));
+ << _sourceNss.ns() << " from " << _source.toString()));
return;
}
}
@@ -343,8 +341,7 @@ void CollectionCloner::_countCallback(
_finishCallback({ErrorCodes::BadValue,
str::stream() << "Count call on collection " << _sourceNss.ns() << " from "
<< _source.toString()
- << " returned negative document count: "
- << count});
+ << " returned negative document count: " << count});
return;
}
diff --git a/src/mongo/db/repl/collection_cloner_test.cpp b/src/mongo/db/repl/collection_cloner_test.cpp
index 420457bd703..5fb4970c183 100644
--- a/src/mongo/db/repl/collection_cloner_test.cpp
+++ b/src/mongo/db/repl/collection_cloner_test.cpp
@@ -260,15 +260,15 @@ void CollectionClonerTest::setUp() {
const BSONObj idIndexSpec,
const std::vector<BSONObj>& nonIdIndexSpecs)
-> StatusWith<std::unique_ptr<CollectionBulkLoaderMock>> {
- auto localLoader = std::make_unique<CollectionBulkLoaderMock>(collectionStats);
- Status result = localLoader->init(nonIdIndexSpecs);
- if (!result.isOK())
- return result;
+ auto localLoader = std::make_unique<CollectionBulkLoaderMock>(collectionStats);
+ Status result = localLoader->init(nonIdIndexSpecs);
+ if (!result.isOK())
+ return result;
- _loader = localLoader.get();
+ _loader = localLoader.get();
- return std::move(localLoader);
- };
+ return std::move(localLoader);
+ };
_server = std::make_unique<MockRemoteDBServer>(target.toString());
_server->assignCollectionUuid(nss.ns(), *options.uuid);
_client = new FailableMockDBClientConnection(_server.get(), getNet());
@@ -282,12 +282,10 @@ void CollectionClonerTest::setUp() {
std::vector<BSONObj> CollectionClonerTest::makeSecondaryIndexSpecs(const NamespaceString& nss) {
return {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())};
}
void CollectionClonerTest::tearDown() {
@@ -442,8 +440,7 @@ TEST_F(CollectionClonerTest, CollectionClonerPassesThroughCommandStatusErrorFrom
executor::NetworkInterfaceMock::InNetworkGuard guard(getNet());
processNetworkResponse(BSON("ok" << 0 << "errmsg"
<< "count error"
- << "code"
- << int(ErrorCodes::OperationFailed)));
+ << "code" << int(ErrorCodes::OperationFailed)));
}
collectionCloner->join();
ASSERT_EQUALS(ErrorCodes::OperationFailed, getStatus());
@@ -565,15 +562,15 @@ TEST_F(CollectionClonerNoAutoIndexTest, DoNotCreateIDIndexIfAutoIndexIdUsed) {
const BSONObj idIndexSpec,
const std::vector<BSONObj>& theIndexSpecs)
-> StatusWith<std::unique_ptr<CollectionBulkLoader>> {
- auto loader = std::make_unique<CollectionBulkLoaderMock>(collectionStats);
- collNss = theNss;
- collOptions = theOptions;
- collIndexSpecs = theIndexSpecs;
- const auto status = loader->init(theIndexSpecs);
- if (!status.isOK())
- return status;
- return std::move(loader);
- };
+ auto loader = std::make_unique<CollectionBulkLoaderMock>(collectionStats);
+ collNss = theNss;
+ collOptions = theOptions;
+ collIndexSpecs = theIndexSpecs;
+ const auto status = loader->init(theIndexSpecs);
+ if (!status.isOK())
+ return status;
+ return std::move(loader);
+ };
const BSONObj doc = BSON("_id" << 1);
_server->insert(nss.ns(), doc);
@@ -632,13 +629,14 @@ TEST_F(CollectionClonerTest, ListIndexesReturnedNamespaceNotFound) {
bool collectionCreated = false;
bool writesAreReplicatedOnOpCtx = false;
NamespaceString collNss;
- storageInterface->createCollFn = [&collNss, &collectionCreated, &writesAreReplicatedOnOpCtx](
- OperationContext* opCtx, const NamespaceString& nss, const CollectionOptions& options) {
- writesAreReplicatedOnOpCtx = opCtx->writesAreReplicated();
- collectionCreated = true;
- collNss = nss;
- return Status::OK();
- };
+ storageInterface->createCollFn =
+ [&collNss, &collectionCreated, &writesAreReplicatedOnOpCtx](
+ OperationContext* opCtx, const NamespaceString& nss, const CollectionOptions& options) {
+ writesAreReplicatedOnOpCtx = opCtx->writesAreReplicated();
+ collectionCreated = true;
+ collNss = nss;
+ return Status::OK();
+ };
// Using a non-zero cursor to ensure that
// the cloner stops the fetcher from retrieving more results.
{
@@ -687,9 +685,9 @@ TEST_F(CollectionClonerTest,
// status.
auto exec = &getExecutor();
collectionCloner->setScheduleDbWorkFn_forTest([exec](
- executor::TaskExecutor::CallbackFn workFn) {
+ executor::TaskExecutor::CallbackFn workFn) {
auto wrappedTask = [workFn = std::move(workFn)](
- const executor::TaskExecutor::CallbackArgs& cbd) {
+ const executor::TaskExecutor::CallbackArgs& cbd) {
workFn(executor::TaskExecutor::CallbackArgs(
cbd.executor, cbd.myHandle, Status(ErrorCodes::CallbackCanceled, ""), cbd.opCtx));
};
@@ -697,8 +695,9 @@ TEST_F(CollectionClonerTest,
});
bool collectionCreated = false;
- storageInterface->createCollFn = [&collectionCreated](
- OperationContext*, const NamespaceString& nss, const CollectionOptions&) {
+ storageInterface->createCollFn = [&collectionCreated](OperationContext*,
+ const NamespaceString& nss,
+ const CollectionOptions&) {
collectionCreated = true;
return Status::OK();
};
@@ -1401,8 +1400,7 @@ TEST_F(CollectionClonerRenamedBeforeStartTest, BeginCollectionWithUUID) {
BSONObj expectedIdIndexSpec = BSON("v" << 1 << "key" << BSON("_id" << 1) << "name"
<< "_id_"
- << "ns"
- << alternateNss.ns());
+ << "ns" << alternateNss.ns());
ASSERT_BSONOBJ_EQ(collIdIndexSpec, expectedIdIndexSpec);
auto expectedNonIdIndexSpecs = makeSecondaryIndexSpecs(alternateNss);
diff --git a/src/mongo/db/repl/database_cloner.cpp b/src/mongo/db/repl/database_cloner.cpp
index 5991744ccec..a0415918a54 100644
--- a/src/mongo/db/repl/database_cloner.cpp
+++ b/src/mongo/db/repl/database_cloner.cpp
@@ -117,8 +117,8 @@ DatabaseCloner::DatabaseCloner(executor::TaskExecutor* executor,
_dbname,
createListCollectionsCommandObject(_listCollectionsFilter),
[=](const StatusWith<Fetcher::QueryResponse>& result,
- Fetcher::NextAction * nextAction,
- BSONObjBuilder * getMoreBob) {
+ Fetcher::NextAction* nextAction,
+ BSONObjBuilder* getMoreBob) {
_listCollectionsCallback(result, nextAction, getMoreBob);
},
ReadPreferenceSetting::secondaryPreferredMetadata(),
@@ -263,9 +263,8 @@ void DatabaseCloner::_listCollectionsCallback(const StatusWith<Fetcher::QueryRes
BSONObjBuilder* getMoreBob) {
if (!result.isOK()) {
_finishCallback(result.getStatus().withContext(
- str::stream() << "Error issuing listCollections on db '" << _dbname << "' (host:"
- << _source.toString()
- << ")"));
+ str::stream() << "Error issuing listCollections on db '" << _dbname
+ << "' (host:" << _source.toString() << ")"));
return;
}
@@ -311,12 +310,11 @@ void DatabaseCloner::_listCollectionsCallback(const StatusWith<Fetcher::QueryRes
for (auto&& info : _collectionInfos) {
BSONElement nameElement = info.getField(kNameFieldName);
if (nameElement.eoo()) {
- _finishCallback_inlock(
- lk,
- {ErrorCodes::FailedToParse,
- str::stream() << "collection info must contain '" << kNameFieldName << "' "
- << "field : "
- << info});
+ _finishCallback_inlock(lk,
+ {ErrorCodes::FailedToParse,
+ str::stream() << "collection info must contain '"
+ << kNameFieldName << "' "
+ << "field : " << info});
return;
}
if (nameElement.type() != mongo::String) {
@@ -332,29 +330,24 @@ void DatabaseCloner::_listCollectionsCallback(const StatusWith<Fetcher::QueryRes
{ErrorCodes::Error(51005),
str::stream()
<< "collection info contains duplicate collection name "
- << "'"
- << collectionName
- << "': "
- << info});
+ << "'" << collectionName << "': " << info});
return;
}
BSONElement optionsElement = info.getField(kOptionsFieldName);
if (optionsElement.eoo()) {
- _finishCallback_inlock(
- lk,
- {ErrorCodes::FailedToParse,
- str::stream() << "collection info must contain '" << kOptionsFieldName << "' "
- << "field : "
- << info});
+ _finishCallback_inlock(lk,
+ {ErrorCodes::FailedToParse,
+ str::stream() << "collection info must contain '"
+ << kOptionsFieldName << "' "
+ << "field : " << info});
return;
}
if (!optionsElement.isABSONObj()) {
_finishCallback_inlock(lk,
Status(ErrorCodes::TypeMismatch,
str::stream() << "'" << kOptionsFieldName
- << "' field must be an object: "
- << info));
+ << "' field must be an object: " << info));
return;
}
const BSONObj optionsObj = optionsElement.Obj();
@@ -428,8 +421,8 @@ void DatabaseCloner::_collectionClonerCallback(const Status& status, const Names
// Record failure, but do not return just yet, in case we want to do some logging.
if (!status.isOK()) {
- collStatus = status.withContext(
- str::stream() << "Error cloning collection '" << nss.toString() << "'");
+ collStatus = status.withContext(str::stream()
+ << "Error cloning collection '" << nss.toString() << "'");
}
// Forward collection cloner result to caller.
diff --git a/src/mongo/db/repl/database_cloner_test.cpp b/src/mongo/db/repl/database_cloner_test.cpp
index e294c1fae64..74ec6e36711 100644
--- a/src/mongo/db/repl/database_cloner_test.cpp
+++ b/src/mongo/db/repl/database_cloner_test.cpp
@@ -125,16 +125,16 @@ void DatabaseClonerTest::setUp() {
const BSONObj& idIndexSpec,
const std::vector<BSONObj>& secondaryIndexSpecs)
-> StatusWith<std::unique_ptr<CollectionBulkLoaderMock>> {
- const auto collInfo = &_collections[nss];
+ const auto collInfo = &_collections[nss];
- auto localLoader = std::make_unique<CollectionBulkLoaderMock>(collInfo->stats);
- auto status = localLoader->init(secondaryIndexSpecs);
- if (!status.isOK())
- return status;
- collInfo->loader = localLoader.get();
+ auto localLoader = std::make_unique<CollectionBulkLoaderMock>(collInfo->stats);
+ auto status = localLoader->init(secondaryIndexSpecs);
+ if (!status.isOK())
+ return status;
+ collInfo->loader = localLoader.get();
- return std::move(localLoader);
- };
+ return std::move(localLoader);
+ };
}
void DatabaseClonerTest::tearDown() {
@@ -333,8 +333,7 @@ TEST_F(DatabaseClonerTest, InvalidListCollectionsFilter) {
executor::NetworkInterfaceMock::InNetworkGuard guard(getNet());
processNetworkResponse(BSON("ok" << 0 << "errmsg"
<< "unknown operator"
- << "code"
- << ErrorCodes::BadValue));
+ << "code" << ErrorCodes::BadValue));
}
ASSERT_EQUALS(ErrorCodes::BadValue, getStatus().code());
@@ -389,16 +388,13 @@ TEST_F(DatabaseClonerTest, ListCollectionsPredicate) {
const std::vector<BSONObj> sourceInfos = {BSON("name"
<< "a"
- << "options"
- << _options1.toBSON()),
+ << "options" << _options1.toBSON()),
BSON("name"
<< "b"
- << "options"
- << _options2.toBSON()),
+ << "options" << _options2.toBSON()),
BSON("name"
<< "c"
- << "options"
- << _options3.toBSON())};
+ << "options" << _options3.toBSON())};
{
executor::NetworkInterfaceMock::InNetworkGuard guard(getNet());
processNetworkResponse(createListCollectionsResponse(
@@ -423,12 +419,10 @@ TEST_F(DatabaseClonerTest, ListCollectionsMultipleBatches) {
const std::vector<BSONObj> sourceInfos = {BSON("name"
<< "a"
- << "options"
- << _options1.toBSON()),
+ << "options" << _options1.toBSON()),
BSON("name"
<< "b"
- << "options"
- << _options2.toBSON())};
+ << "options" << _options2.toBSON())};
{
executor::NetworkInterfaceMock::InNetworkGuard guard(getNet());
processNetworkResponse(createListCollectionsResponse(1, BSON_ARRAY(sourceInfos[0])));
@@ -510,8 +504,7 @@ TEST_F(DatabaseClonerTest, CollectionInfoNameEmpty) {
createListCollectionsResponse(0,
BSON_ARRAY(BSON("name"
<< ""
- << "options"
- << _options1.toBSON()))));
+ << "options" << _options1.toBSON()))));
}
ASSERT_EQUALS(ErrorCodes::BadValue, getStatus().code());
@@ -532,12 +525,10 @@ TEST_F(DatabaseClonerTest, CollectionInfoNameDuplicate) {
createListCollectionsResponse(0,
BSON_ARRAY(BSON("name"
<< "a"
- << "options"
- << _options1.toBSON())
+ << "options" << _options1.toBSON())
<< BSON("name"
<< "a"
- << "options"
- << _options2.toBSON()))));
+ << "options" << _options2.toBSON()))));
}
ASSERT_EQUALS(51005, getStatus().code());
@@ -573,11 +564,11 @@ TEST_F(DatabaseClonerTest, CollectionInfoOptionsNotAnObject) {
{
executor::NetworkInterfaceMock::InNetworkGuard guard(getNet());
- processNetworkResponse(createListCollectionsResponse(0,
- BSON_ARRAY(BSON("name"
- << "a"
- << "options"
- << 123))));
+ processNetworkResponse(
+ createListCollectionsResponse(0,
+ BSON_ARRAY(BSON("name"
+ << "a"
+ << "options" << 123))));
}
ASSERT_EQUALS(ErrorCodes::TypeMismatch, getStatus().code());
@@ -594,12 +585,11 @@ TEST_F(DatabaseClonerTest, InvalidCollectionOptions) {
{
executor::NetworkInterfaceMock::InNetworkGuard guard(getNet());
- processNetworkResponse(
- createListCollectionsResponse(0,
- BSON_ARRAY(BSON("name"
- << "a"
- << "options"
- << BSON("storageEngine" << 1)))));
+ processNetworkResponse(createListCollectionsResponse(
+ 0,
+ BSON_ARRAY(BSON("name"
+ << "a"
+ << "options" << BSON("storageEngine" << 1)))));
}
ASSERT_EQUALS(ErrorCodes::BadValue, getStatus().code());
@@ -615,11 +605,11 @@ TEST_F(DatabaseClonerTest, InvalidMissingUUID) {
{
executor::NetworkInterfaceMock::InNetworkGuard guard(getNet());
- processNetworkResponse(createListCollectionsResponse(0,
- BSON_ARRAY(BSON("name"
- << "a"
- << "options"
- << BSONObj()))));
+ processNetworkResponse(
+ createListCollectionsResponse(0,
+ BSON_ARRAY(BSON("name"
+ << "a"
+ << "options" << BSONObj()))));
}
ASSERT_EQUALS(50953, getStatus().code());
@@ -668,11 +658,11 @@ TEST_F(DatabaseClonerTest, ListCollectionsReturnsEmptyCollectionName) {
{
executor::NetworkInterfaceMock::InNetworkGuard guard(getNet());
- processNetworkResponse(createListCollectionsResponse(0,
- BSON_ARRAY(BSON("name"
- << ""
- << "options"
- << BSONObj()))));
+ processNetworkResponse(
+ createListCollectionsResponse(0,
+ BSON_ARRAY(BSON("name"
+ << ""
+ << "options" << BSONObj()))));
}
ASSERT_EQUALS(ErrorCodes::BadValue, getStatus().code());
@@ -698,8 +688,7 @@ TEST_F(DatabaseClonerTest, StartFirstCollectionClonerFailed) {
createListCollectionsResponse(0,
BSON_ARRAY(BSON("name"
<< "a"
- << "options"
- << _options1.toBSON()))));
+ << "options" << _options1.toBSON()))));
}
ASSERT_EQUALS(ErrorCodes::OperationFailed, getStatus().code());
@@ -730,12 +719,10 @@ TEST_F(DatabaseClonerTest, StartSecondCollectionClonerFailed) {
createListCollectionsResponse(0,
BSON_ARRAY(BSON("name"
<< "a"
- << "options"
- << _options1.toBSON())
+ << "options" << _options1.toBSON())
<< BSON("name"
<< "b"
- << "options"
- << _options2.toBSON()))));
+ << "options" << _options2.toBSON()))));
processNetworkResponse(createCountResponse(0));
processNetworkResponse(createListIndexesResponse(0, BSON_ARRAY(idIndexSpec)));
@@ -761,8 +748,7 @@ TEST_F(DatabaseClonerTest, ShutdownCancelsCollectionCloning) {
0,
BSON_ARRAY(BSON("name"
<< "a"
- << "options"
- << _options1.toBSON())))));
+ << "options" << _options1.toBSON())))));
net->runReadyNetworkOperations();
// CollectionCloner sends collection count request on startup.
@@ -795,12 +781,10 @@ TEST_F(DatabaseClonerTest, FirstCollectionListIndexesFailed) {
const std::vector<BSONObj> sourceInfos = {BSON("name"
<< "a"
- << "options"
- << _options1.toBSON()),
+ << "options" << _options1.toBSON()),
BSON("name"
<< "b"
- << "options"
- << _options2.toBSON())};
+ << "options" << _options2.toBSON())};
{
executor::NetworkInterfaceMock::InNetworkGuard guard(getNet());
processNetworkResponse(
@@ -816,8 +800,7 @@ TEST_F(DatabaseClonerTest, FirstCollectionListIndexesFailed) {
processNetworkResponse(createCountResponse(0));
processNetworkResponse(BSON("ok" << 0 << "errmsg"
<< "fake message"
- << "code"
- << ErrorCodes::CursorNotFound));
+ << "code" << ErrorCodes::CursorNotFound));
processNetworkResponse(createCountResponse(0));
processNetworkResponse(createListIndexesResponse(0, BSON_ARRAY(idIndexSpec)));
@@ -852,12 +835,10 @@ TEST_F(DatabaseClonerTest, CreateCollections) {
const std::vector<BSONObj> sourceInfos = {BSON("name"
<< "a"
- << "options"
- << _options1.toBSON()),
+ << "options" << _options1.toBSON()),
BSON("name"
<< "b"
- << "options"
- << _options2.toBSON())};
+ << "options" << _options2.toBSON())};
{
executor::NetworkInterfaceMock::InNetworkGuard guard(getNet());
processNetworkResponse(
diff --git a/src/mongo/db/repl/databases_cloner_test.cpp b/src/mongo/db/repl/databases_cloner_test.cpp
index dea8b12cbab..ba75f96c6e4 100644
--- a/src/mongo/db/repl/databases_cloner_test.cpp
+++ b/src/mongo/db/repl/databases_cloner_test.cpp
@@ -177,19 +177,19 @@ protected:
const BSONObj idIndexSpec,
const std::vector<BSONObj>& secondaryIndexSpecs)
-> StatusWith<std::unique_ptr<CollectionBulkLoaderMock>> {
- // Get collection info from map.
- const auto collInfo = &_collections[nss];
- if (collInfo->stats->initCalled) {
- log() << "reusing collection during test which may cause problems, ns:" << nss;
- }
- auto localLoader = std::make_unique<CollectionBulkLoaderMock>(collInfo->stats);
- auto status = localLoader->init(secondaryIndexSpecs);
- if (!status.isOK())
- return status;
- collInfo->loader = localLoader.get();
-
- return std::move(localLoader);
- };
+ // Get collection info from map.
+ const auto collInfo = &_collections[nss];
+ if (collInfo->stats->initCalled) {
+ log() << "reusing collection during test which may cause problems, ns:" << nss;
+ }
+ auto localLoader = std::make_unique<CollectionBulkLoaderMock>(collInfo->stats);
+ auto status = localLoader->init(secondaryIndexSpecs);
+ if (!status.isOK())
+ return status;
+ collInfo->loader = localLoader.get();
+
+ return std::move(localLoader);
+ };
_dbWorkThreadPool.startup();
_target = HostAndPort{"local:1234"};
@@ -924,13 +924,13 @@ TEST_F(DBsClonerTest, SingleDatabaseCopiesCompletely) {
{"listDatabases", fromjson("{ok:1, databases:[{name:'a'}]}")},
// listCollections for "a"
{"listCollections",
- BSON("ok" << 1 << "cursor" << BSON("id" << 0ll << "ns"
- << "a.$cmd.listCollections"
- << "firstBatch"
- << BSON_ARRAY(BSON("name"
- << "a"
- << "options"
- << options.toBSON()))))},
+ BSON("ok" << 1 << "cursor"
+ << BSON("id" << 0ll << "ns"
+ << "a.$cmd.listCollections"
+ << "firstBatch"
+ << BSON_ARRAY(BSON("name"
+ << "a"
+ << "options" << options.toBSON()))))},
// count:a
{"count", BSON("n" << 1 << "ok" << 1)},
// listIndexes:a
@@ -957,13 +957,13 @@ TEST_F(DBsClonerTest, TwoDatabasesCopiesCompletely) {
{"listDatabases", fromjson("{ok:1, databases:[{name:'a'}, {name:'b'}]}")},
// listCollections for "a"
{"listCollections",
- BSON("ok" << 1 << "cursor" << BSON("id" << 0ll << "ns"
- << "a.$cmd.listCollections"
- << "firstBatch"
- << BSON_ARRAY(BSON("name"
- << "a"
- << "options"
- << options1.toBSON()))))},
+ BSON("ok" << 1 << "cursor"
+ << BSON("id" << 0ll << "ns"
+ << "a.$cmd.listCollections"
+ << "firstBatch"
+ << BSON_ARRAY(BSON("name"
+ << "a"
+ << "options" << options1.toBSON()))))},
// count:a
{"count", BSON("n" << 1 << "ok" << 1)},
// listIndexes:a
@@ -974,13 +974,13 @@ TEST_F(DBsClonerTest, TwoDatabasesCopiesCompletely) {
<< ", key:{_id:1}, name:'_id_', ns:'a.a'}]}}")},
// listCollections for "b"
{"listCollections",
- BSON("ok" << 1 << "cursor" << BSON("id" << 0ll << "ns"
- << "b.$cmd.listCollections"
- << "firstBatch"
- << BSON_ARRAY(BSON("name"
- << "b"
- << "options"
- << options2.toBSON()))))},
+ BSON("ok" << 1 << "cursor"
+ << BSON("id" << 0ll << "ns"
+ << "b.$cmd.listCollections"
+ << "firstBatch"
+ << BSON_ARRAY(BSON("name"
+ << "b"
+ << "options" << options2.toBSON()))))},
// count:b
{"count", BSON("n" << 2 << "ok" << 1)},
// listIndexes:b
diff --git a/src/mongo/db/repl/dbcheck.cpp b/src/mongo/db/repl/dbcheck.cpp
index cd546957b8d..289b831b795 100644
--- a/src/mongo/db/repl/dbcheck.cpp
+++ b/src/mongo/db/repl/dbcheck.cpp
@@ -40,7 +40,6 @@
#include "mongo/db/operation_context.h"
#include "mongo/db/query/internal_plans.h"
#include "mongo/db/repl/dbcheck.h"
-#include "mongo/db/repl/dbcheck.h"
#include "mongo/db/repl/dbcheck_gen.h"
#include "mongo/db/repl/oplog.h"
#include "mongo/db/repl/optime.h"
@@ -132,7 +131,7 @@ std::unique_ptr<HealthLogEntry> dbCheckHealthLogEntry(const NamespaceString& nss
entry->setData(data);
return entry;
}
-}
+} // namespace
/**
* Get an error message if the check fails.
@@ -161,14 +160,9 @@ std::unique_ptr<HealthLogEntry> dbCheckBatchEntry(const NamespaceString& nss,
const repl::OpTime& optime) {
auto hashes = expectedFound(expectedHash, foundHash);
- auto data =
- BSON("success" << true << "count" << count << "bytes" << bytes << "md5" << hashes.second
- << "minKey"
- << minKey.elem()
- << "maxKey"
- << maxKey.elem()
- << "optime"
- << optime);
+ auto data = BSON("success" << true << "count" << count << "bytes" << bytes << "md5"
+ << hashes.second << "minKey" << minKey.elem() << "maxKey"
+ << maxKey.elem() << "optime" << optime);
auto severity = hashes.first ? SeverityEnum::Info : SeverityEnum::Error;
std::string msg =
@@ -284,19 +278,9 @@ std::unique_ptr<HealthLogEntry> dbCheckCollectionEntry(const NamespaceString& ns
std::string msg =
"dbCheck collection " + (match ? std::string("consistent") : std::string("inconsistent"));
auto data = BSON("success" << true << "uuid" << uuid.toString() << "found" << true << "name"
- << names.second
- << "prev"
- << prevs.second
- << "next"
- << nexts.second
- << "indexes"
- << indices.second
- << "options"
- << options.second
- << "md5"
- << md5s.second
- << "optime"
- << optime);
+ << names.second << "prev" << prevs.second << "next" << nexts.second
+ << "indexes" << indices.second << "options" << options.second
+ << "md5" << md5s.second << "optime" << optime);
return dbCheckHealthLogEntry(nss, severity, msg, OplogEntriesEnum::Collection, data);
}
@@ -520,7 +504,7 @@ Status dbCheckDatabaseOnSecondary(OperationContext* opCtx,
return Status::OK();
}
-}
+} // namespace
namespace repl {
diff --git a/src/mongo/db/repl/dbcheck.h b/src/mongo/db/repl/dbcheck.h
index dde6de369b8..457087a9365 100644
--- a/src/mongo/db/repl/dbcheck.h
+++ b/src/mongo/db/repl/dbcheck.h
@@ -228,5 +228,5 @@ Status dbCheckOplogCommand(OperationContext* opCtx,
const repl::OplogEntry& entry,
OplogApplication::Mode mode,
boost::optional<Timestamp> stableTimestampForRecovery);
-}
-}
+} // namespace repl
+} // namespace mongo
diff --git a/src/mongo/db/repl/dbcheck_idl.h b/src/mongo/db/repl/dbcheck_idl.h
index c49bff7a5b1..9e2d9c880e6 100644
--- a/src/mongo/db/repl/dbcheck_idl.h
+++ b/src/mongo/db/repl/dbcheck_idl.h
@@ -91,4 +91,4 @@ private:
explicit BSONKey(const BSONElement& elem);
BSONObj _obj;
};
-}
+} // namespace mongo
diff --git a/src/mongo/db/repl/drop_pending_collection_reaper_test.cpp b/src/mongo/db/repl/drop_pending_collection_reaper_test.cpp
index bf2df1aa0cf..43fb891728f 100644
--- a/src/mongo/db/repl/drop_pending_collection_reaper_test.cpp
+++ b/src/mongo/db/repl/drop_pending_collection_reaper_test.cpp
@@ -252,7 +252,7 @@ TEST_F(DropPendingCollectionReaperTest,
decltype(dpns) droppedNss;
bool writesAreReplicatedDuringDrop = true;
storageInterfaceMock.dropCollFn = [&droppedNss, &writesAreReplicatedDuringDrop](
- OperationContext* opCtx, const NamespaceString& nss) {
+ OperationContext* opCtx, const NamespaceString& nss) {
droppedNss = nss;
writesAreReplicatedDuringDrop = opCtx->writesAreReplicated();
return Status::OK();
diff --git a/src/mongo/db/repl/election_reason_counter.h b/src/mongo/db/repl/election_reason_counter.h
index 801d9855a45..89a8dac9b81 100644
--- a/src/mongo/db/repl/election_reason_counter.h
+++ b/src/mongo/db/repl/election_reason_counter.h
@@ -40,8 +40,8 @@ namespace repl {
class ElectionReasonCounter : public ElectionReasonCounterBase {
public:
using ElectionReasonCounterBase::getCalled;
- using ElectionReasonCounterBase::setCalled;
using ElectionReasonCounterBase::getSuccessful;
+ using ElectionReasonCounterBase::setCalled;
using ElectionReasonCounterBase::setSuccessful;
void incrementCalled() {
diff --git a/src/mongo/db/repl/idempotency_test_fixture.cpp b/src/mongo/db/repl/idempotency_test_fixture.cpp
index 97b3f86fa2d..8b99c794a90 100644
--- a/src/mongo/db/repl/idempotency_test_fixture.cpp
+++ b/src/mongo/db/repl/idempotency_test_fixture.cpp
@@ -662,12 +662,7 @@ template OplogEntry IdempotencyTest::update<const char*>(char const* _id, const
BSONObj makeInsertApplyOpsEntry(const NamespaceString& nss, const UUID& uuid, const BSONObj& doc) {
return BSON("op"
<< "i"
- << "ns"
- << nss.toString()
- << "ui"
- << uuid
- << "o"
- << doc);
+ << "ns" << nss.toString() << "ui" << uuid << "o" << doc);
}
} // namespace repl
} // namespace mongo
diff --git a/src/mongo/db/repl/initial_syncer.cpp b/src/mongo/db/repl/initial_syncer.cpp
index 683642a83d3..d4696f7f92a 100644
--- a/src/mongo/db/repl/initial_syncer.cpp
+++ b/src/mongo/db/repl/initial_syncer.cpp
@@ -482,8 +482,7 @@ void InitialSyncer::_startInitialSyncAttemptCallback(
auto status = _checkForShutdownAndConvertStatus_inlock(
callbackArgs,
str::stream() << "error while starting initial sync attempt " << (initialSyncAttempt + 1)
- << " of "
- << initialSyncMaxAttempts);
+ << " of " << initialSyncMaxAttempts);
if (!status.isOK()) {
_finishInitialSyncAttempt(status);
return;
@@ -747,11 +746,8 @@ void InitialSyncer::_getBeginFetchingOpTimeCallback(
Status(ErrorCodes::TooManyMatchingDocuments,
str::stream() << "Expected to receive one document for the oldest active "
"transaction entry, but received: "
- << docs.size()
- << ". First: "
- << redact(docs.front())
- << ". Last: "
- << redact(docs.back())));
+ << docs.size() << ". First: " << redact(docs.front())
+ << ". Last: " << redact(docs.back())));
return;
}
@@ -858,11 +854,8 @@ void InitialSyncer::_fcvFetcherCallback(const StatusWith<Fetcher::QueryResponse>
Status(ErrorCodes::TooManyMatchingDocuments,
str::stream() << "Expected to receive one feature compatibility version "
"document, but received: "
- << docs.size()
- << ". First: "
- << redact(docs.front())
- << ". Last: "
- << redact(docs.back())));
+ << docs.size() << ". First: " << redact(docs.front())
+ << ". Last: " << redact(docs.back())));
return;
}
const auto hasDoc = docs.begin() != docs.end();
@@ -1518,8 +1511,8 @@ void InitialSyncer::_finishCallback(StatusWith<OpTimeAndWallTime> lastApplied) {
}
Status InitialSyncer::_scheduleLastOplogEntryFetcher_inlock(Fetcher::CallbackFn callback) {
- 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);
_lastOplogEntryFetcher =
std::make_unique<Fetcher>(_exec,
@@ -1670,13 +1663,12 @@ Status InitialSyncer::_scheduleWorkAtAndSaveHandle_inlock(
if (_isShuttingDown_inlock()) {
return Status(ErrorCodes::CallbackCanceled,
str::stream() << "failed to schedule work " << name << " at "
- << when.toString()
- << ": initial syncer is shutting down");
+ << when.toString() << ": initial syncer is shutting down");
}
auto result = _exec->scheduleWorkAt(when, std::move(work));
if (!result.isOK()) {
- return result.getStatus().withContext(
- str::stream() << "failed to schedule work " << name << " at " << when.toString());
+ return result.getStatus().withContext(str::stream() << "failed to schedule work " << name
+ << " at " << when.toString());
}
*handle = result.getValue();
return Status::OK();
diff --git a/src/mongo/db/repl/initial_syncer_test.cpp b/src/mongo/db/repl/initial_syncer_test.cpp
index ff548abbe55..820c4147fa4 100644
--- a/src/mongo/db/repl/initial_syncer_test.cpp
+++ b/src/mongo/db/repl/initial_syncer_test.cpp
@@ -295,19 +295,19 @@ protected:
const BSONObj idIndexSpec,
const std::vector<BSONObj>& secondaryIndexSpecs)
-> StatusWith<std::unique_ptr<CollectionBulkLoaderMock>> {
- // Get collection info from map.
- const auto collInfo = &_collections[nss];
- if (collInfo->stats->initCalled) {
- log() << "reusing collection during test which may cause problems, ns:" << nss;
- }
- auto localLoader = std::make_unique<CollectionBulkLoaderMock>(collInfo->stats);
- auto status = localLoader->init(secondaryIndexSpecs);
- if (!status.isOK())
- return status;
- collInfo->loader = localLoader.get();
+ // Get collection info from map.
+ const auto collInfo = &_collections[nss];
+ if (collInfo->stats->initCalled) {
+ log() << "reusing collection during test which may cause problems, ns:" << nss;
+ }
+ auto localLoader = std::make_unique<CollectionBulkLoaderMock>(collInfo->stats);
+ auto status = localLoader->init(secondaryIndexSpecs);
+ if (!status.isOK())
+ return status;
+ collInfo->loader = localLoader.get();
- return std::move(localLoader);
- };
+ return std::move(localLoader);
+ };
_dbWorkThreadPool = std::make_unique<ThreadPool>(ThreadPool::Options());
_dbWorkThreadPool->startup();
@@ -355,17 +355,13 @@ protected:
dataReplicatorExternalState->lastCommittedOpTime = _myLastOpTime;
{
ReplSetConfig 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))));
dataReplicatorExternalState->replSetConfigResult = config;
}
_externalState = dataReplicatorExternalState.get();
@@ -1153,14 +1149,14 @@ TEST_F(InitialSyncerTest, InitialSyncerPassesThroughGetBeginFetchingOpTimeSchedu
// We reject the 'find' command for the begin fetching optime and save the request for
// inspection at the end of this test case.
executor::RemoteCommandRequest request;
- _executorProxy->shouldFailScheduleRemoteCommandRequest = [&request](
- const executor::RemoteCommandRequestOnAny& requestToSend) {
- request = {requestToSend, 0};
- auto elem = requestToSend.cmdObj.firstElement();
- return (
- ("find" == elem.fieldNameStringData()) &&
- (NamespaceString::kSessionTransactionsTableNamespace.coll() == elem.valueStringData()));
- };
+ _executorProxy->shouldFailScheduleRemoteCommandRequest =
+ [&request](const executor::RemoteCommandRequestOnAny& requestToSend) {
+ request = {requestToSend, 0};
+ auto elem = requestToSend.cmdObj.firstElement();
+ return (("find" == elem.fieldNameStringData()) &&
+ (NamespaceString::kSessionTransactionsTableNamespace.coll() ==
+ elem.valueStringData()));
+ };
HostAndPort syncSource("localhost", 12345);
_syncSourceSelector->setChooseNewSyncSourceResult_forTest(syncSource);
@@ -1243,12 +1239,13 @@ TEST_F(InitialSyncerTest, InitialSyncerPassesThroughLastOplogEntryFetcherSchedul
// We reject the 'find' command on the oplog and save the request for inspection at the end of
// this test case.
executor::RemoteCommandRequest request;
- _executorProxy->shouldFailScheduleRemoteCommandRequest = [&request](
- const executor::RemoteCommandRequestOnAny& requestToSend) {
- request = {requestToSend, 0};
- auto elem = requestToSend.cmdObj.firstElement();
- return (("find" == elem.fieldNameStringData()) && ("oplog.rs" == elem.valueStringData()));
- };
+ _executorProxy->shouldFailScheduleRemoteCommandRequest =
+ [&request](const executor::RemoteCommandRequestOnAny& requestToSend) {
+ request = {requestToSend, 0};
+ auto elem = requestToSend.cmdObj.firstElement();
+ return (("find" == elem.fieldNameStringData()) &&
+ ("oplog.rs" == elem.valueStringData()));
+ };
HostAndPort syncSource("localhost", 12345);
_syncSourceSelector->setChooseNewSyncSourceResult_forTest(syncSource);
@@ -1663,8 +1660,7 @@ TEST_F(InitialSyncerTest,
TEST_F(InitialSyncerTest,
InitialSyncerReturnsIncompatibleServerVersionWhenFCVFetcherReturnsUpgradeTargetVersion) {
auto docs = {BSON("_id" << FeatureCompatibilityVersionParser::kParameterName << "version"
- << FeatureCompatibilityVersionParser::kVersion40
- << "targetVersion"
+ << FeatureCompatibilityVersionParser::kVersion40 << "targetVersion"
<< FeatureCompatibilityVersionParser::kVersion42)};
runInitialSyncWithBadFCVResponse(docs, ErrorCodes::IncompatibleServerVersion);
}
@@ -1672,8 +1668,7 @@ TEST_F(InitialSyncerTest,
TEST_F(InitialSyncerTest,
InitialSyncerReturnsIncompatibleServerVersionWhenFCVFetcherReturnsDowngradeTargetVersion) {
auto docs = {BSON("_id" << FeatureCompatibilityVersionParser::kParameterName << "version"
- << FeatureCompatibilityVersionParser::kVersion40
- << "targetVersion"
+ << FeatureCompatibilityVersionParser::kVersion40 << "targetVersion"
<< FeatureCompatibilityVersionParser::kVersion40)};
runInitialSyncWithBadFCVResponse(docs, ErrorCodes::IncompatibleServerVersion);
}
@@ -2224,8 +2219,7 @@ TEST_F(InitialSyncerTest,
<< "dbinfo")
<< BSON("name"
<< "b"))
- << "ok"
- << 1)));
+ << "ok" << 1)));
net->runReadyNetworkOperations();
// Oplog tailing query.
@@ -2592,8 +2586,7 @@ TEST_F(
// Second last oplog entry fetcher.
processSuccessfulLastOplogEntryFetcherResponse({BSON("ts"
<< "not a timestamp"
- << "t"
- << 1)});
+ << "t" << 1)});
// _lastOplogEntryFetcherCallbackAfterCloningData() will shut down the OplogFetcher after
// setting the completion status.
@@ -3209,8 +3202,7 @@ TEST_F(InitialSyncerTest, LastOpTimeShouldBeSetEvenIfNoOperationsAreAppliedAfter
NamespaceString(nss.getCommandNS()),
{BSON("v" << OplogEntry::kOplogVersion << "key" << BSON("_id" << 1) << "name"
<< "_id_"
- << "ns"
- << nss.ns())})));
+ << "ns" << nss.ns())})));
ASSERT_EQUALS(*_options1.uuid, UUID::parse(request.cmdObj.firstElement()));
ASSERT_EQUALS(nss.db(), request.dbname);
@@ -3930,8 +3922,7 @@ TEST_F(InitialSyncerTest,
NamespaceString(nss.getCommandNS()),
{BSON("v" << OplogEntry::kOplogVersion << "key" << BSON("_id" << 1) << "name"
<< "_id_"
- << "ns"
- << nss.ns())}));
+ << "ns" << nss.ns())}));
assertRemoteCommandNameEquals("listIndexes", request);
ASSERT_EQUALS(*_options1.uuid, UUID::parse(request.cmdObj.firstElement()));
ASSERT_EQUALS(nss.db(), request.dbname);
@@ -4322,8 +4313,7 @@ TEST_F(InitialSyncerTest, GetInitialSyncProgressReturnsCorrectProgress) {
NamespaceString(nss.getCommandNS()),
{BSON("v" << OplogEntry::kOplogVersion << "key" << BSON("_id" << 1) << "name"
<< "_id_"
- << "ns"
- << nss.ns())}));
+ << "ns" << nss.ns())}));
assertRemoteCommandNameEquals("listIndexes", request);
ASSERT_EQUALS(*_options1.uuid, UUID::parse(request.cmdObj.firstElement()));
ASSERT_EQUALS(nss.db(), request.dbname);
diff --git a/src/mongo/db/repl/is_master_response.cpp b/src/mongo/db/repl/is_master_response.cpp
index e160054208b..06e0d1c1896 100644
--- a/src/mongo/db/repl/is_master_response.cpp
+++ b/src/mongo/db/repl/is_master_response.cpp
@@ -220,8 +220,7 @@ 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");
}
}
@@ -248,8 +247,7 @@ 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()));
@@ -269,8 +267,7 @@ 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()));
@@ -290,8 +287,7 @@ 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()));
@@ -364,8 +360,7 @@ 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();
@@ -397,8 +392,7 @@ 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());
@@ -418,8 +412,7 @@ 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) {
@@ -439,8 +432,7 @@ 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 =
@@ -461,8 +453,7 @@ 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 398367e6da3..b50a893efb8 100644
--- a/src/mongo/db/repl/isself.cpp
+++ b/src/mongo/db/repl/isself.cpp
@@ -273,8 +273,7 @@ std::vector<std::string> getBoundAddrs(const bool ipv6enabled) {
for (int tries = 0; tries < 3; ++tries) {
err = GetAdaptersAddresses(family,
GAA_FLAG_SKIP_ANYCAST | // only want unicast addrs
- GAA_FLAG_SKIP_MULTICAST |
- GAA_FLAG_SKIP_DNS_SERVER,
+ GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER,
nullptr,
adapters,
&adaptersLen);
diff --git a/src/mongo/db/repl/member_config.cpp b/src/mongo/db/repl/member_config.cpp
index 02fb978173e..5ab43763c8c 100644
--- a/src/mongo/db/repl/member_config.cpp
+++ b/src/mongo/db/repl/member_config.cpp
@@ -178,9 +178,9 @@ MemberConfig::MemberConfig(const BSONObj& mcfg, ReplSetTagConfig* tagConfig) {
for (auto&& tag : tagsElement.Obj()) {
if (tag.type() != String) {
uasserted(ErrorCodes::TypeMismatch,
- str::stream() << "tags." << tag.fieldName()
- << " field has non-string value of type "
- << typeName(tag.type()));
+ str::stream()
+ << "tags." << tag.fieldName()
+ << " field has non-string value of type " << typeName(tag.type()));
}
_tags.push_back(tagConfig->makeTag(tag.fieldNameStringData(), tag.valueStringData()));
}
@@ -240,9 +240,9 @@ Status MemberConfig::validate() const {
}
if (_slaveDelay < Seconds(0) || _slaveDelay > kMaxSlaveDelay) {
return Status(ErrorCodes::BadValue,
- str::stream() << kSlaveDelayFieldName << " field value of "
- << durationCount<Seconds>(_slaveDelay)
- << " seconds is out of range");
+ str::stream()
+ << kSlaveDelayFieldName << " field value of "
+ << durationCount<Seconds>(_slaveDelay) << " seconds is out of range");
}
// Check for additional electable requirements, when priority is non zero
if (_priority != 0) {
diff --git a/src/mongo/db/repl/member_config_test.cpp b/src/mongo/db/repl/member_config_test.cpp
index 6176d230463..cf84b37ccdc 100644
--- a/src/mongo/db/repl/member_config_test.cpp
+++ b/src/mongo/db/repl/member_config_test.cpp
@@ -60,8 +60,7 @@ TEST(MemberConfig, ParseFailsWithIllegalFieldName) {
ReplSetTagConfig tagConfig;
ASSERT_THROWS(MemberConfig(BSON("_id" << 0 << "host"
<< "localhost"
- << "frim"
- << 1),
+ << "frim" << 1),
&tagConfig),
ExceptionFor<ErrorCodes::BadValue>);
}
@@ -133,8 +132,7 @@ TEST(MemberConfig, ParseArbiterOnly) {
{
MemberConfig mc(BSON("_id" << 0 << "host"
<< "h"
- << "arbiterOnly"
- << 1.0),
+ << "arbiterOnly" << 1.0),
&tagConfig);
ASSERT_TRUE(mc.isArbiter());
ASSERT_EQUALS(0.0, mc.getPriority());
@@ -142,8 +140,7 @@ TEST(MemberConfig, ParseArbiterOnly) {
{
MemberConfig mc(BSON("_id" << 0 << "host"
<< "h"
- << "arbiterOnly"
- << false),
+ << "arbiterOnly" << false),
&tagConfig);
ASSERT_TRUE(!mc.isArbiter());
ASSERT_EQUALS(1.0, mc.getPriority());
@@ -155,16 +152,14 @@ TEST(MemberConfig, ParseHidden) {
{
MemberConfig mc(BSON("_id" << 0 << "host"
<< "h"
- << "hidden"
- << 1.0),
+ << "hidden" << 1.0),
&tagConfig);
ASSERT_TRUE(mc.isHidden());
}
{
MemberConfig mc(BSON("_id" << 0 << "host"
<< "h"
- << "hidden"
- << false),
+ << "hidden" << false),
&tagConfig);
ASSERT_TRUE(!mc.isHidden());
}
@@ -181,16 +176,14 @@ TEST(MemberConfig, ParseBuildIndexes) {
{
MemberConfig mc(BSON("_id" << 0 << "host"
<< "h"
- << "buildIndexes"
- << 1.0),
+ << "buildIndexes" << 1.0),
&tagConfig);
ASSERT_TRUE(mc.shouldBuildIndexes());
}
{
MemberConfig mc(BSON("_id" << 0 << "host"
<< "h"
- << "buildIndexes"
- << false),
+ << "buildIndexes" << false),
&tagConfig);
ASSERT_TRUE(!mc.shouldBuildIndexes());
}
@@ -201,18 +194,14 @@ TEST(MemberConfig, ParseVotes) {
{
MemberConfig mc(BSON("_id" << 0 << "host"
<< "h"
- << "votes"
- << 1.0),
+ << "votes" << 1.0),
&tagConfig);
ASSERT_TRUE(mc.isVoter());
}
{
MemberConfig mc(BSON("_id" << 0 << "host"
<< "h"
- << "votes"
- << 0
- << "priority"
- << 0),
+ << "votes" << 0 << "priority" << 0),
&tagConfig);
ASSERT_FALSE(mc.isVoter());
}
@@ -220,38 +209,33 @@ TEST(MemberConfig, ParseVotes) {
// For backwards compatibility, truncate 1.X to 1, and 0.X to 0 (and -0.X to 0).
MemberConfig mc(BSON("_id" << 0 << "host"
<< "h"
- << "votes"
- << 1.5),
+ << "votes" << 1.5),
&tagConfig);
ASSERT_TRUE(mc.isVoter());
}
{
MemberConfig mc(BSON("_id" << 0 << "host"
<< "h"
- << "votes"
- << 0.5),
+ << "votes" << 0.5),
&tagConfig);
ASSERT_FALSE(mc.isVoter());
}
{
MemberConfig mc(BSON("_id" << 0 << "host"
<< "h"
- << "votes"
- << -0.5),
+ << "votes" << -0.5),
&tagConfig);
ASSERT_FALSE(mc.isVoter());
}
{
MemberConfig mc(BSON("_id" << 0 << "host"
<< "h"
- << "votes"
- << 2),
+ << "votes" << 2),
&tagConfig);
}
ASSERT_THROWS(MemberConfig(BSON("_id" << 0 << "host"
<< "h"
- << "votes"
- << Date_t::fromMillisSinceEpoch(2)),
+ << "votes" << Date_t::fromMillisSinceEpoch(2)),
&tagConfig),
ExceptionFor<ErrorCodes::TypeMismatch>);
}
@@ -261,31 +245,27 @@ TEST(MemberConfig, ParsePriority) {
{
MemberConfig mc(BSON("_id" << 0 << "host"
<< "h"
- << "priority"
- << 1),
+ << "priority" << 1),
&tagConfig);
ASSERT_EQUALS(1.0, mc.getPriority());
}
{
MemberConfig mc(BSON("_id" << 0 << "host"
<< "h"
- << "priority"
- << 0),
+ << "priority" << 0),
&tagConfig);
ASSERT_EQUALS(0.0, mc.getPriority());
}
{
MemberConfig mc(BSON("_id" << 0 << "host"
<< "h"
- << "priority"
- << 100.8),
+ << "priority" << 100.8),
&tagConfig);
ASSERT_EQUALS(100.8, mc.getPriority());
}
ASSERT_THROWS(MemberConfig(BSON("_id" << 0 << "host"
<< "h"
- << "priority"
- << Date_t::fromMillisSinceEpoch(2)),
+ << "priority" << Date_t::fromMillisSinceEpoch(2)),
&tagConfig),
ExceptionFor<ErrorCodes::TypeMismatch>);
}
@@ -294,8 +274,7 @@ TEST(MemberConfig, ParseSlaveDelay) {
ReplSetTagConfig tagConfig;
MemberConfig mc(BSON("_id" << 0 << "host"
<< "h"
- << "slaveDelay"
- << 100),
+ << "slaveDelay" << 100),
&tagConfig);
ASSERT_EQUALS(Seconds(100), mc.getSlaveDelay());
}
@@ -365,14 +344,13 @@ TEST(MemberConfig, DuplicateHorizonNames) {
ASSERT_NOT_EQUALS(s.reason().find("Duplicate horizon name found"), std::string::npos);
}
try {
- MemberConfig(BSON("_id" << 0 << "host"
- << "h"
- << "horizons"
- << BSON("someUniqueHorizonName"
- << "a.host:43"
- << SplitHorizon::kDefaultHorizon
- << "b.host:256")),
- &tagConfig);
+ MemberConfig(
+ BSON("_id" << 0 << "host"
+ << "h"
+ << "horizons"
+ << BSON("someUniqueHorizonName"
+ << "a.host:43" << SplitHorizon::kDefaultHorizon << "b.host:256")),
+ &tagConfig);
ASSERT_TRUE(false); // Should not succeed.
} catch (const ExceptionFor<ErrorCodes::BadValue>& ex) {
const Status& s = ex.toStatus();
@@ -489,8 +467,7 @@ TEST(MemberConfig, ValidateVotes) {
{
MemberConfig mc(BSON("_id" << 0 << "host"
<< "h"
- << "votes"
- << 1.0),
+ << "votes" << 1.0),
&tagConfig);
ASSERT_OK(mc.validate());
ASSERT_TRUE(mc.isVoter());
@@ -498,10 +475,7 @@ TEST(MemberConfig, ValidateVotes) {
{
MemberConfig mc(BSON("_id" << 0 << "host"
<< "h"
- << "votes"
- << 0
- << "priority"
- << 0),
+ << "votes" << 0 << "priority" << 0),
&tagConfig);
ASSERT_OK(mc.validate());
ASSERT_FALSE(mc.isVoter());
@@ -510,8 +484,7 @@ TEST(MemberConfig, ValidateVotes) {
// For backwards compatibility, truncate 1.X to 1, and 0.X to 0 (and -0.X to 0).
MemberConfig mc(BSON("_id" << 0 << "host"
<< "h"
- << "votes"
- << 1.5),
+ << "votes" << 1.5),
&tagConfig);
ASSERT_OK(mc.validate());
ASSERT_TRUE(mc.isVoter());
@@ -519,10 +492,7 @@ TEST(MemberConfig, ValidateVotes) {
{
MemberConfig mc(BSON("_id" << 0 << "host"
<< "h"
- << "votes"
- << 0.5
- << "priority"
- << 0),
+ << "votes" << 0.5 << "priority" << 0),
&tagConfig);
ASSERT_OK(mc.validate());
ASSERT_FALSE(mc.isVoter());
@@ -530,10 +500,7 @@ TEST(MemberConfig, ValidateVotes) {
{
MemberConfig mc(BSON("_id" << 0 << "host"
<< "h"
- << "votes"
- << -0.5
- << "priority"
- << 0),
+ << "votes" << -0.5 << "priority" << 0),
&tagConfig);
ASSERT_OK(mc.validate());
ASSERT_FALSE(mc.isVoter());
@@ -542,16 +509,14 @@ TEST(MemberConfig, ValidateVotes) {
// Invalid values
MemberConfig mc(BSON("_id" << 0 << "host"
<< "h"
- << "votes"
- << 2),
+ << "votes" << 2),
&tagConfig);
ASSERT_EQUALS(ErrorCodes::BadValue, mc.validate());
}
{
MemberConfig mc(BSON("_id" << 0 << "host"
<< "h"
- << "votes"
- << -1),
+ << "votes" << -1),
&tagConfig);
ASSERT_EQUALS(ErrorCodes::BadValue, mc.validate());
}
@@ -562,32 +527,28 @@ TEST(MemberConfig, ValidatePriorityRanges) {
{
MemberConfig mc(BSON("_id" << 0 << "host"
<< "h"
- << "priority"
- << 0),
+ << "priority" << 0),
&tagConfig);
ASSERT_OK(mc.validate());
}
{
MemberConfig mc(BSON("_id" << 0 << "host"
<< "h"
- << "priority"
- << 1000),
+ << "priority" << 1000),
&tagConfig);
ASSERT_OK(mc.validate());
}
{
MemberConfig mc(BSON("_id" << 0 << "host"
<< "h"
- << "priority"
- << -1),
+ << "priority" << -1),
&tagConfig);
ASSERT_EQUALS(ErrorCodes::BadValue, mc.validate());
}
{
MemberConfig mc(BSON("_id" << 0 << "host"
<< "h"
- << "priority"
- << 1001),
+ << "priority" << 1001),
&tagConfig);
ASSERT_EQUALS(ErrorCodes::BadValue, mc.validate());
}
@@ -598,40 +559,28 @@ TEST(MemberConfig, ValidateSlaveDelays) {
{
MemberConfig mc(BSON("_id" << 0 << "host"
<< "h"
- << "priority"
- << 0
- << "slaveDelay"
- << 0),
+ << "priority" << 0 << "slaveDelay" << 0),
&tagConfig);
ASSERT_OK(mc.validate());
}
{
MemberConfig mc(BSON("_id" << 0 << "host"
<< "h"
- << "priority"
- << 0
- << "slaveDelay"
- << 3600 * 10),
+ << "priority" << 0 << "slaveDelay" << 3600 * 10),
&tagConfig);
ASSERT_OK(mc.validate());
}
{
MemberConfig mc(BSON("_id" << 0 << "host"
<< "h"
- << "priority"
- << 0
- << "slaveDelay"
- << -1),
+ << "priority" << 0 << "slaveDelay" << -1),
&tagConfig);
ASSERT_EQUALS(ErrorCodes::BadValue, mc.validate());
}
{
MemberConfig mc(BSON("_id" << 0 << "host"
<< "h"
- << "priority"
- << 0
- << "slaveDelay"
- << 3600 * 24 * 400),
+ << "priority" << 0 << "slaveDelay" << 3600 * 24 * 400),
&tagConfig);
ASSERT_EQUALS(ErrorCodes::BadValue, mc.validate());
}
@@ -641,10 +590,7 @@ TEST(MemberConfig, ValidatePriorityAndSlaveDelayRelationship) {
ReplSetTagConfig tagConfig;
MemberConfig mc(BSON("_id" << 0 << "host"
<< "h"
- << "priority"
- << 1
- << "slaveDelay"
- << 60),
+ << "priority" << 1 << "slaveDelay" << 60),
&tagConfig);
ASSERT_EQUALS(ErrorCodes::BadValue, mc.validate());
}
@@ -654,20 +600,14 @@ TEST(MemberConfig, ValidatePriorityAndHiddenRelationship) {
{
MemberConfig mc(BSON("_id" << 0 << "host"
<< "h"
- << "priority"
- << 1
- << "hidden"
- << true),
+ << "priority" << 1 << "hidden" << true),
&tagConfig);
ASSERT_EQUALS(ErrorCodes::BadValue, mc.validate());
}
{
MemberConfig mc(BSON("_id" << 0 << "host"
<< "h"
- << "priority"
- << 1
- << "hidden"
- << false),
+ << "priority" << 1 << "hidden" << false),
&tagConfig);
ASSERT_OK(mc.validate());
}
@@ -678,10 +618,7 @@ TEST(MemberConfig, ValidatePriorityAndBuildIndexesRelationship) {
{
MemberConfig mc(BSON("_id" << 0 << "host"
<< "h"
- << "priority"
- << 1
- << "buildIndexes"
- << false),
+ << "priority" << 1 << "buildIndexes" << false),
&tagConfig);
ASSERT_EQUALS(ErrorCodes::BadValue, mc.validate());
@@ -689,10 +626,7 @@ TEST(MemberConfig, ValidatePriorityAndBuildIndexesRelationship) {
{
MemberConfig mc(BSON("_id" << 0 << "host"
<< "h"
- << "priority"
- << 1
- << "buildIndexes"
- << true),
+ << "priority" << 1 << "buildIndexes" << true),
&tagConfig);
ASSERT_OK(mc.validate());
}
@@ -703,42 +637,28 @@ TEST(MemberConfig, ValidateArbiterVotesRelationship) {
{
MemberConfig mc(BSON("_id" << 0 << "host"
<< "h"
- << "votes"
- << 1
- << "arbiterOnly"
- << true),
+ << "votes" << 1 << "arbiterOnly" << true),
&tagConfig);
ASSERT_OK(mc.validate());
}
{
MemberConfig mc(BSON("_id" << 0 << "host"
<< "h"
- << "votes"
- << 0
- << "priority"
- << 0
- << "arbiterOnly"
- << false),
+ << "votes" << 0 << "priority" << 0 << "arbiterOnly" << false),
&tagConfig);
ASSERT_OK(mc.validate());
}
{
MemberConfig mc(BSON("_id" << 0 << "host"
<< "h"
- << "votes"
- << 1
- << "arbiterOnly"
- << false),
+ << "votes" << 1 << "arbiterOnly" << false),
&tagConfig);
ASSERT_OK(mc.validate());
}
{
MemberConfig mc(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/member_data.cpp b/src/mongo/db/repl/member_data.cpp
index 40a081ba6a2..247167bc150 100644
--- a/src/mongo/db/repl/member_data.cpp
+++ b/src/mongo/db/repl/member_data.cpp
@@ -141,8 +141,9 @@ void MemberData::setLastDurableOpTimeAndWallTime(OpTimeAndWallTime opTime, Date_
// TODO(russotto): We think this should never happen, rollback or no rollback. Make this an
// invariant and see what happens.
log() << "Durable progress (" << opTime.opTime << ") is ahead of the applied progress ("
- << _lastAppliedOpTime << ". This is likely due to a "
- "rollback."
+ << _lastAppliedOpTime
+ << ". This is likely due to a "
+ "rollback."
<< " memberid: " << _memberId << _hostAndPort.toString()
<< " previous durable progress: " << _lastDurableOpTime;
} else {
diff --git a/src/mongo/db/repl/mock_repl_coord_server_fixture.h b/src/mongo/db/repl/mock_repl_coord_server_fixture.h
index 9bac2e16d74..7f52f4a3f21 100644
--- a/src/mongo/db/repl/mock_repl_coord_server_fixture.h
+++ b/src/mongo/db/repl/mock_repl_coord_server_fixture.h
@@ -39,7 +39,7 @@ class OperationContext;
namespace repl {
class OplogEntry;
class StorageInterfaceMock;
-}
+} // namespace repl
/**
* This is a basic fixture that is backed by an ephemeral storage engine and a mock replication
diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp
index 097029946be..5757ddfc267 100644
--- a/src/mongo/db/repl/oplog.cpp
+++ b/src/mongo/db/repl/oplog.cpp
@@ -342,8 +342,7 @@ void _logOpsInner(OperationContext* opCtx,
// are logging within one WriteUnitOfWork.
invariant(finalOpTime.getTimestamp() <= *commitTime,
str::stream() << "Final OpTime: " << finalOpTime.toString()
- << ". Commit Time: "
- << commitTime->toString());
+ << ". Commit Time: " << commitTime->toString());
}
// Optionally hang before advancing lastApplied.
@@ -397,7 +396,7 @@ OpTime logOp(OperationContext* opCtx, MutableOplogEntry* oplogEntry) {
// again. For example, if the WUOW gets aborted within a writeConflictRetry loop, we need to
// reset the OpTime to null so a new OpTime will be assigned on retry.
OplogSlot slot = oplogEntry->getOpTime();
- auto resetOpTimeGuard = makeGuard([&, resetOpTimeOnExit = bool(slot.isNull()) ] {
+ auto resetOpTimeGuard = makeGuard([&, resetOpTimeOnExit = bool(slot.isNull())] {
if (resetOpTimeOnExit)
oplogEntry->setOpTime(OplogSlot());
});
@@ -540,7 +539,7 @@ long long getNewOplogSizeBytes(OperationContext* opCtx, const ReplSettings& repl
LOG(3) << "32bit system; choosing " << sz << " bytes oplog";
return sz;
}
-// First choose a minimum size.
+ // First choose a minimum size.
#if defined(__APPLE__)
// typically these are desktops (dev machines), so keep it smallish
@@ -670,8 +669,7 @@ std::pair<OptionalCollectionUUID, NamespaceString> parseCollModUUIDAndNss(Operat
const auto nsByUUID = catalog.lookupNSSByUUID(uuid);
uassert(ErrorCodes::NamespaceNotFound,
str::stream() << "Failed to apply operation due to missing collection (" << uuid
- << "): "
- << redact(cmd.toString()),
+ << "): " << redact(cmd.toString()),
nsByUUID);
return std::pair<OptionalCollectionUUID, NamespaceString>(uuid, *nsByUUID);
}
@@ -1225,8 +1223,7 @@ Status applyOperation_inlock(OperationContext* opCtx,
collection = catalog.lookupCollectionByUUID(uuid);
uassert(ErrorCodes::NamespaceNotFound,
str::stream() << "Failed to apply operation due to missing collection (" << uuid
- << "): "
- << redact(op.toString()),
+ << "): " << redact(op.toString()),
collection);
requestNss = collection->ns();
dassert(opCtx->lockState()->isCollectionLockedForMode(
diff --git a/src/mongo/db/repl/oplog_buffer_collection.cpp b/src/mongo/db/repl/oplog_buffer_collection.cpp
index 9cdc69823a8..642a1db0078 100644
--- a/src/mongo/db/repl/oplog_buffer_collection.cpp
+++ b/src/mongo/db/repl/oplog_buffer_collection.cpp
@@ -66,17 +66,16 @@ std::tuple<BSONObj, Timestamp, std::size_t> OplogBufferCollection::addIdToDocume
const BSONObj& orig, const Timestamp& lastTimestamp, std::size_t sentinelCount) {
if (orig.isEmpty()) {
return std::make_tuple(
- BSON(kIdFieldName << BSON(
- kTimestampFieldName << lastTimestamp << kSentinelFieldName
- << static_cast<long long>(sentinelCount + 1))),
+ BSON(kIdFieldName << BSON(kTimestampFieldName
+ << lastTimestamp << kSentinelFieldName
+ << static_cast<long long>(sentinelCount + 1))),
lastTimestamp,
sentinelCount + 1);
}
const auto ts = orig[kTimestampFieldName].timestamp();
invariant(!ts.isNull());
auto doc = BSON(kIdFieldName << BSON(kTimestampFieldName << ts << kSentinelFieldName << 0)
- << kOplogEntryFieldName
- << orig);
+ << kOplogEntryFieldName << orig);
return std::make_tuple(doc, ts, 0);
}
diff --git a/src/mongo/db/repl/oplog_buffer_collection_test.cpp b/src/mongo/db/repl/oplog_buffer_collection_test.cpp
index d50f214dfb9..ca8582fc754 100644
--- a/src/mongo/db/repl/oplog_buffer_collection_test.cpp
+++ b/src/mongo/db/repl/oplog_buffer_collection_test.cpp
@@ -118,12 +118,9 @@ NamespaceString makeNamespace(const T& t, const char* suffix = "") {
BSONObj makeOplogEntry(int t) {
return BSON("ts" << Timestamp(t, t) << "ns"
<< "a.a"
- << "v"
- << 2
- << "op"
+ << "v" << 2 << "op"
<< "i"
- << "o"
- << BSON("_id" << t << "a" << t));
+ << "o" << BSON("_id" << t << "a" << t));
}
TEST_F(OplogBufferCollectionTest, DefaultNamespace) {
@@ -603,7 +600,9 @@ TEST_F(OplogBufferCollectionTest, PopAndPeekReturnDocumentsInOrder) {
oplogBuffer.startup(_opCtx.get());
const std::vector<BSONObj> oplog = {
- makeOplogEntry(1), makeOplogEntry(2), makeOplogEntry(3),
+ makeOplogEntry(1),
+ makeOplogEntry(2),
+ makeOplogEntry(3),
};
ASSERT_EQUALS(oplogBuffer.getCount(), 0UL);
oplogBuffer.push(_opCtx.get(), oplog.begin(), oplog.end());
@@ -646,7 +645,9 @@ TEST_F(OplogBufferCollectionTest, LastObjectPushedReturnsNewestOplogEntry) {
oplogBuffer.startup(_opCtx.get());
const std::vector<BSONObj> oplog = {
- makeOplogEntry(1), makeOplogEntry(2), makeOplogEntry(3),
+ makeOplogEntry(1),
+ makeOplogEntry(2),
+ makeOplogEntry(3),
};
ASSERT_EQUALS(oplogBuffer.getCount(), 0UL);
oplogBuffer.push(_opCtx.get(), oplog.begin(), oplog.end());
@@ -682,7 +683,9 @@ TEST_F(OplogBufferCollectionTest,
oplogBuffer.startup(_opCtx.get());
const std::vector<BSONObj> oplog = {
- makeOplogEntry(3), makeOplogEntry(4), makeOplogEntry(5),
+ makeOplogEntry(3),
+ makeOplogEntry(4),
+ makeOplogEntry(5),
};
ASSERT_BSONOBJ_EQ(*oplogBuffer.lastObjectPushed(_opCtx.get()), secondDoc);
@@ -907,7 +910,12 @@ void _testPushSentinelsProperly(OperationContext* opCtx,
OplogBufferCollection oplogBuffer(storageInterface, nss);
oplogBuffer.startup(opCtx);
const std::vector<BSONObj> oplog = {
- BSONObj(), makeOplogEntry(1), BSONObj(), BSONObj(), makeOplogEntry(2), BSONObj(),
+ BSONObj(),
+ makeOplogEntry(1),
+ BSONObj(),
+ BSONObj(),
+ makeOplogEntry(2),
+ BSONObj(),
};
ASSERT_EQUALS(oplogBuffer.getCount(), 0UL);
pushDocsFn(opCtx, &oplogBuffer, oplog);
@@ -937,7 +945,8 @@ DEATH_TEST_F(
oplogBuffer.startup(_opCtx.get());
const std::vector<BSONObj> oplog = {
- makeOplogEntry(2), makeOplogEntry(1),
+ makeOplogEntry(2),
+ makeOplogEntry(1),
};
ASSERT_EQUALS(oplogBuffer.getCount(), 0UL);
oplogBuffer.push(_opCtx.get(), oplog.begin(), oplog.end());
@@ -949,7 +958,10 @@ TEST_F(OplogBufferCollectionTest, SentinelInMiddleIsReturnedInOrder) {
oplogBuffer.startup(_opCtx.get());
const std::vector<BSONObj> oplog = {
- makeOplogEntry(1), makeOplogEntry(2), BSONObj(), makeOplogEntry(3),
+ makeOplogEntry(1),
+ makeOplogEntry(2),
+ BSONObj(),
+ makeOplogEntry(3),
};
ASSERT_EQUALS(oplogBuffer.getCount(), 0UL);
oplogBuffer.push(_opCtx.get(), oplog.cbegin(), oplog.cend());
@@ -1066,7 +1078,12 @@ TEST_F(OplogBufferCollectionTest, MultipleSentinelsAreReturnedInOrder) {
oplogBuffer.startup(_opCtx.get());
const std::vector<BSONObj> oplog = {
- BSONObj(), makeOplogEntry(1), BSONObj(), BSONObj(), makeOplogEntry(2), BSONObj(),
+ BSONObj(),
+ makeOplogEntry(1),
+ BSONObj(),
+ BSONObj(),
+ makeOplogEntry(2),
+ BSONObj(),
};
ASSERT_EQUALS(oplogBuffer.getCount(), 0UL);
oplogBuffer.push(_opCtx.get(), oplog.cbegin(), oplog.cend());
diff --git a/src/mongo/db/repl/oplog_entry.cpp b/src/mongo/db/repl/oplog_entry.cpp
index 57a8eb033ba..f41558f2e4c 100644
--- a/src/mongo/db/repl/oplog_entry.cpp
+++ b/src/mongo/db/repl/oplog_entry.cpp
@@ -81,8 +81,7 @@ OplogEntry::CommandType parseCommandType(const BSONObj& objectField) {
} else {
uasserted(ErrorCodes::BadValue,
str::stream() << "Unknown oplog entry command type: " << commandString
- << " Object field: "
- << redact(objectField));
+ << " Object field: " << redact(objectField));
}
MONGO_UNREACHABLE;
}
@@ -202,7 +201,7 @@ StatusWith<MutableOplogEntry> MutableOplogEntry::parse(const BSONObj& object) {
MONGO_UNREACHABLE;
}
-void MutableOplogEntry::setOpTime(const OpTime& opTime)& {
+void MutableOplogEntry::setOpTime(const OpTime& opTime) & {
setTimestamp(opTime.getTimestamp());
if (opTime.getTerm() != OpTime::kUninitializedTerm)
setTerm(opTime.getTerm());
diff --git a/src/mongo/db/repl/oplog_entry.h b/src/mongo/db/repl/oplog_entry.h
index 7d98aee00f0..24c47432508 100644
--- a/src/mongo/db/repl/oplog_entry.h
+++ b/src/mongo/db/repl/oplog_entry.h
@@ -147,14 +147,15 @@ public:
class OplogEntry : private MutableOplogEntry {
public:
// Make field names accessible.
- using MutableOplogEntry::kDurableReplOperationFieldName;
- using MutableOplogEntry::kOperationSessionInfoFieldName;
using MutableOplogEntry::k_idFieldName;
+ using MutableOplogEntry::kDurableReplOperationFieldName;
using MutableOplogEntry::kFromMigrateFieldName;
using MutableOplogEntry::kHashFieldName;
using MutableOplogEntry::kNssFieldName;
- using MutableOplogEntry::kObjectFieldName;
using MutableOplogEntry::kObject2FieldName;
+ using MutableOplogEntry::kObjectFieldName;
+ using MutableOplogEntry::kOperationSessionInfoFieldName;
+ using MutableOplogEntry::kOplogVersion;
using MutableOplogEntry::kOpTypeFieldName;
using MutableOplogEntry::kPostImageOpTimeFieldName;
using MutableOplogEntry::kPreImageOpTimeFieldName;
@@ -168,38 +169,37 @@ public:
using MutableOplogEntry::kUuidFieldName;
using MutableOplogEntry::kVersionFieldName;
using MutableOplogEntry::kWallClockTimeFieldName;
- using MutableOplogEntry::kOplogVersion;
// Make serialize(), toBSON() and getters accessible.
- using MutableOplogEntry::serialize;
- using MutableOplogEntry::toBSON;
- using MutableOplogEntry::getOperationSessionInfo;
- using MutableOplogEntry::getSessionId;
- using MutableOplogEntry::getTxnNumber;
+ using MutableOplogEntry::get_id;
using MutableOplogEntry::getDurableReplOperation;
- using MutableOplogEntry::getOpType;
+ using MutableOplogEntry::getFromMigrate;
+ using MutableOplogEntry::getHash;
using MutableOplogEntry::getNss;
- using MutableOplogEntry::getUuid;
using MutableOplogEntry::getObject;
using MutableOplogEntry::getObject2;
- using MutableOplogEntry::getUpsert;
- using MutableOplogEntry::getTimestamp;
+ using MutableOplogEntry::getOperationSessionInfo;
+ using MutableOplogEntry::getOpType;
+ using MutableOplogEntry::getPostImageOpTime;
+ using MutableOplogEntry::getPreImageOpTime;
+ using MutableOplogEntry::getPrevWriteOpTimeInTransaction;
+ using MutableOplogEntry::getSessionId;
+ using MutableOplogEntry::getStatementId;
using MutableOplogEntry::getTerm;
- using MutableOplogEntry::getHash;
+ using MutableOplogEntry::getTimestamp;
+ using MutableOplogEntry::getTxnNumber;
+ using MutableOplogEntry::getUpsert;
+ using MutableOplogEntry::getUuid;
using MutableOplogEntry::getVersion;
- using MutableOplogEntry::getFromMigrate;
- using MutableOplogEntry::get_id;
using MutableOplogEntry::getWallClockTime;
- using MutableOplogEntry::getStatementId;
- using MutableOplogEntry::getPrevWriteOpTimeInTransaction;
- using MutableOplogEntry::getPreImageOpTime;
- using MutableOplogEntry::getPostImageOpTime;
+ using MutableOplogEntry::serialize;
+ using MutableOplogEntry::toBSON;
// Make helper functions accessible.
using MutableOplogEntry::getOpTime;
+ using MutableOplogEntry::makeDeleteOperation;
using MutableOplogEntry::makeInsertOperation;
using MutableOplogEntry::makeUpdateOperation;
- using MutableOplogEntry::makeDeleteOperation;
enum class CommandType {
kNotCommand,
diff --git a/src/mongo/db/repl/oplog_fetcher.cpp b/src/mongo/db/repl/oplog_fetcher.cpp
index 9c4df1a1bec..3162319ab2b 100644
--- a/src/mongo/db/repl/oplog_fetcher.cpp
+++ b/src/mongo/db/repl/oplog_fetcher.cpp
@@ -161,11 +161,10 @@ Status checkRemoteOplogStart(const Fetcher::Documents& documents,
// sync source is now behind us, choose a new sync source to prevent going into rollback.
if (remoteLastOpApplied && (*remoteLastOpApplied < lastFetched)) {
return Status(ErrorCodes::InvalidSyncSource,
- str::stream() << "Sync source's last applied OpTime "
- << remoteLastOpApplied->toString()
- << " is older than our last fetched OpTime "
- << lastFetched.toString()
- << ". Choosing new sync source.");
+ str::stream()
+ << "Sync source's last applied OpTime " << remoteLastOpApplied->toString()
+ << " is older than our last fetched OpTime " << lastFetched.toString()
+ << ". Choosing new sync source.");
}
// If 'requireFresherSyncSource' is true, we must check that the sync source's
@@ -181,8 +180,7 @@ Status checkRemoteOplogStart(const Fetcher::Documents& documents,
return Status(ErrorCodes::InvalidSyncSource,
str::stream()
<< "Sync source must be ahead of me. My last fetched oplog optime: "
- << lastFetched.toString()
- << ", latest oplog optime of sync source: "
+ << lastFetched.toString() << ", latest oplog optime of sync source: "
<< remoteLastOpApplied->toString());
}
@@ -202,9 +200,7 @@ Status checkRemoteOplogStart(const Fetcher::Documents& documents,
return Status(ErrorCodes::InvalidBSON,
str::stream() << "our last optime fetched: " << lastFetched.toString()
<< ". failed to parse optime from first oplog on source: "
- << o.toString()
- << ": "
- << opTimeResult.getStatus().toString());
+ << o.toString() << ": " << opTimeResult.getStatus().toString());
}
auto opTime = opTimeResult.getValue();
if (opTime != lastFetched) {
@@ -289,15 +285,9 @@ 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()
- << " in batch with "
- << info.networkDocumentCount
- << "docs; first-batch:"
- << first
- << ", doc:"
- << doc);
+ << lastTS.toString() << " outOfOrderTS:" << docTS.toString()
+ << " in batch with " << info.networkDocumentCount
+ << "docs; first-batch:" << first << ", doc:" << doc);
}
lastTS = docTS;
}
diff --git a/src/mongo/db/repl/oplog_interface_mock.cpp b/src/mongo/db/repl/oplog_interface_mock.cpp
index 6352fa7566a..95930bf6d62 100644
--- a/src/mongo/db/repl/oplog_interface_mock.cpp
+++ b/src/mongo/db/repl/oplog_interface_mock.cpp
@@ -90,8 +90,7 @@ public:
str::stream()
<< "oplog no longer contains the complete write history of this "
"transaction, log with opTime "
- << _nextOpTime.toBSON()
- << " cannot be found");
+ << _nextOpTime.toBSON() << " cannot be found");
}
// We shouldn't get any other error.
MONGO_UNREACHABLE;
diff --git a/src/mongo/db/repl/oplog_test.cpp b/src/mongo/db/repl/oplog_test.cpp
index 870cd21980e..a39208720ce 100644
--- a/src/mongo/db/repl/oplog_test.cpp
+++ b/src/mongo/db/repl/oplog_test.cpp
@@ -118,9 +118,9 @@ TEST_F(OplogTest, LogOpReturnsOpTimeOnSuccessfulInsertIntoOplogCollection) {
<< "OpTime returned from logOp() did not match that in the oplog entry written to the "
"oplog: "
<< oplogEntry.toBSON();
- ASSERT(OpTypeEnum::kNoop == oplogEntry.getOpType()) << "Expected 'n' op type but found '"
- << OpType_serializer(oplogEntry.getOpType())
- << "' instead: " << oplogEntry.toBSON();
+ ASSERT(OpTypeEnum::kNoop == oplogEntry.getOpType())
+ << "Expected 'n' op type but found '" << OpType_serializer(oplogEntry.getOpType())
+ << "' instead: " << oplogEntry.toBSON();
ASSERT_BSONOBJ_EQ(msgObj, oplogEntry.getObject());
// Ensure that the msg optime returned is the same as the last optime in the ReplClientInfo.
diff --git a/src/mongo/db/repl/optime_extract_test.cpp b/src/mongo/db/repl/optime_extract_test.cpp
index d1e2b0d7e49..9192738a31c 100644
--- a/src/mongo/db/repl/optime_extract_test.cpp
+++ b/src/mongo/db/repl/optime_extract_test.cpp
@@ -51,8 +51,7 @@ 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 89545a0fb4a..5ec5ae968c1 100644
--- a/src/mongo/db/repl/read_concern_args.cpp
+++ b/src/mongo/db/repl/read_concern_args.cpp
@@ -202,23 +202,20 @@ Status ReadConcernArgs::initialize(const BSONElement& readConcernElem) {
} else {
return Status(ErrorCodes::InvalidOptions,
str::stream() << "Unrecognized option in " << kReadConcernFieldName
- << ": "
- << fieldName);
+ << ": " << fieldName);
}
}
if (_afterClusterTime && _opTime) {
return Status(ErrorCodes::InvalidOptions,
str::stream() << "Can not specify both " << kAfterClusterTimeFieldName
- << " and "
- << kAfterOpTimeFieldName);
+ << " and " << kAfterOpTimeFieldName);
}
if (_afterClusterTime && _atClusterTime) {
return Status(ErrorCodes::InvalidOptions,
str::stream() << "Can not specify both " << kAfterClusterTimeFieldName
- << " and "
- << kAtClusterTimeFieldName);
+ << " and " << kAtClusterTimeFieldName);
}
// Note: 'available' should not be used with after cluster time, as cluster time can wait for
@@ -228,30 +225,24 @@ Status ReadConcernArgs::initialize(const BSONElement& readConcernElem) {
getLevel() != ReadConcernLevel::kLocalReadConcern &&
getLevel() != ReadConcernLevel::kSnapshotReadConcern) {
return Status(ErrorCodes::InvalidOptions,
- str::stream() << kAfterClusterTimeFieldName << " field can be set only if "
- << kLevelFieldName
- << " is equal to "
- << kMajorityReadConcernStr
- << ", "
- << kLocalReadConcernStr
- << ", or "
- << kSnapshotReadConcernStr);
+ str::stream()
+ << kAfterClusterTimeFieldName << " field can be set only if "
+ << kLevelFieldName << " is equal to " << kMajorityReadConcernStr << ", "
+ << kLocalReadConcernStr << ", or " << kSnapshotReadConcernStr);
}
if (_opTime && getLevel() == ReadConcernLevel::kSnapshotReadConcern) {
return Status(ErrorCodes::InvalidOptions,
- str::stream() << kAfterOpTimeFieldName << " field cannot be set if "
- << kLevelFieldName
- << " is equal to "
- << kSnapshotReadConcernStr);
+ str::stream()
+ << kAfterOpTimeFieldName << " field cannot be set if " << kLevelFieldName
+ << " is equal to " << kSnapshotReadConcernStr);
}
if (_atClusterTime && getLevel() != ReadConcernLevel::kSnapshotReadConcern) {
return Status(ErrorCodes::InvalidOptions,
- str::stream() << kAtClusterTimeFieldName << " field can be set only if "
- << kLevelFieldName
- << " is equal to "
- << kSnapshotReadConcernStr);
+ str::stream()
+ << kAtClusterTimeFieldName << " field can be set only if "
+ << kLevelFieldName << " is equal to " << kSnapshotReadConcernStr);
}
if (_afterClusterTime && _afterClusterTime == LogicalTime::kUninitialized) {
@@ -294,8 +285,7 @@ Status ReadConcernArgs::upconvertReadConcernLevelToSnapshot() {
if (_opTime) {
return Status(ErrorCodes::InvalidOptions,
str::stream() << "Cannot upconvert the readConcern level to 'snapshot' when '"
- << kAfterOpTimeFieldName
- << "' is provided");
+ << kAfterOpTimeFieldName << "' is provided");
}
_originalLevel = _level;
diff --git a/src/mongo/db/repl/read_concern_args_test.cpp b/src/mongo/db/repl/read_concern_args_test.cpp
index ed6ec48875c..d6907a31f26 100644
--- a/src/mongo/db/repl/read_concern_args_test.cpp
+++ b/src/mongo/db/repl/read_concern_args_test.cpp
@@ -39,13 +39,12 @@ namespace {
TEST(ReadAfterParse, OpTimeOnly) {
ReadConcernArgs readConcern;
- ASSERT_OK(readConcern.initialize(BSON(
- "find"
- << "test"
- << ReadConcernArgs::kReadConcernFieldName
- << BSON(ReadConcernArgs::kAfterOpTimeFieldName
- << BSON(OpTime::kTimestampFieldName << Timestamp(20, 30) << OpTime::kTermFieldName
- << 2)))));
+ ASSERT_OK(readConcern.initialize(BSON("find"
+ << "test" << ReadConcernArgs::kReadConcernFieldName
+ << BSON(ReadConcernArgs::kAfterOpTimeFieldName
+ << BSON(OpTime::kTimestampFieldName
+ << Timestamp(20, 30)
+ << OpTime::kTermFieldName << 2)))));
ASSERT_TRUE(readConcern.getArgsOpTime());
ASSERT_TRUE(!readConcern.getArgsAfterClusterTime());
@@ -59,8 +58,7 @@ TEST(ReadAfterParse, AfterClusterTimeOnly) {
ReadConcernArgs readConcern;
auto afterClusterTime = LogicalTime(Timestamp(20, 30));
ASSERT_OK(readConcern.initialize(BSON("find"
- << "test"
- << ReadConcernArgs::kReadConcernFieldName
+ << "test" << ReadConcernArgs::kReadConcernFieldName
<< BSON(ReadConcernArgs::kAfterClusterTimeFieldName
<< afterClusterTime.asTimestamp()))));
auto argsAfterClusterTime = readConcern.getArgsAfterClusterTime();
@@ -73,13 +71,12 @@ TEST(ReadAfterParse, AfterClusterTimeAndLevelLocal) {
ReadConcernArgs readConcern;
// Must have level=majority
auto afterClusterTime = LogicalTime(Timestamp(20, 30));
- ASSERT_OK(readConcern.initialize(BSON("find"
- << "test"
- << ReadConcernArgs::kReadConcernFieldName
- << BSON(ReadConcernArgs::kAfterClusterTimeFieldName
- << afterClusterTime.asTimestamp()
- << ReadConcernArgs::kLevelFieldName
- << "local"))));
+ ASSERT_OK(
+ readConcern.initialize(BSON("find"
+ << "test" << ReadConcernArgs::kReadConcernFieldName
+ << BSON(ReadConcernArgs::kAfterClusterTimeFieldName
+ << afterClusterTime.asTimestamp()
+ << ReadConcernArgs::kLevelFieldName << "local"))));
auto argsAfterClusterTime = readConcern.getArgsAfterClusterTime();
ASSERT_TRUE(argsAfterClusterTime);
ASSERT_TRUE(!readConcern.getArgsOpTime());
@@ -91,13 +88,12 @@ TEST(ReadAfterParse, AfterClusterTimeAndLevelMajority) {
ReadConcernArgs readConcern;
// Must have level=majority
auto afterClusterTime = LogicalTime(Timestamp(20, 30));
- ASSERT_OK(readConcern.initialize(BSON("find"
- << "test"
- << ReadConcernArgs::kReadConcernFieldName
- << BSON(ReadConcernArgs::kAfterClusterTimeFieldName
- << afterClusterTime.asTimestamp()
- << ReadConcernArgs::kLevelFieldName
- << "majority"))));
+ ASSERT_OK(
+ readConcern.initialize(BSON("find"
+ << "test" << ReadConcernArgs::kReadConcernFieldName
+ << BSON(ReadConcernArgs::kAfterClusterTimeFieldName
+ << afterClusterTime.asTimestamp()
+ << ReadConcernArgs::kLevelFieldName << "majority"))));
auto argsAfterClusterTime = readConcern.getArgsAfterClusterTime();
ASSERT_TRUE(argsAfterClusterTime);
ASSERT_TRUE(!readConcern.getArgsOpTime());
@@ -108,13 +104,12 @@ TEST(ReadAfterParse, AfterClusterTimeAndLevelMajority) {
TEST(ReadAfterParse, AfterClusterTimeAndLevelSnapshot) {
ReadConcernArgs readConcern;
auto afterClusterTime = LogicalTime(Timestamp(20, 30));
- ASSERT_OK(readConcern.initialize(BSON("find"
- << "test"
- << ReadConcernArgs::kReadConcernFieldName
- << BSON(ReadConcernArgs::kAfterClusterTimeFieldName
- << afterClusterTime.asTimestamp()
- << ReadConcernArgs::kLevelFieldName
- << "snapshot"))));
+ ASSERT_OK(
+ readConcern.initialize(BSON("find"
+ << "test" << ReadConcernArgs::kReadConcernFieldName
+ << BSON(ReadConcernArgs::kAfterClusterTimeFieldName
+ << afterClusterTime.asTimestamp()
+ << ReadConcernArgs::kLevelFieldName << "snapshot"))));
auto argsAfterClusterTime = readConcern.getArgsAfterClusterTime();
ASSERT_TRUE(argsAfterClusterTime);
ASSERT_TRUE(!readConcern.getArgsOpTime());
@@ -127,8 +122,7 @@ TEST(ReadAfterParse, AtClusterTimeOnly) {
auto atClusterTime = LogicalTime(Timestamp(20, 30));
ASSERT_EQ(ErrorCodes::InvalidOptions,
readConcern.initialize(BSON("find"
- << "test"
- << ReadConcernArgs::kReadConcernFieldName
+ << "test" << ReadConcernArgs::kReadConcernFieldName
<< BSON(ReadConcernArgs::kAtClusterTimeFieldName
<< atClusterTime.asTimestamp()))));
}
@@ -136,13 +130,12 @@ TEST(ReadAfterParse, AtClusterTimeOnly) {
TEST(ReadAfterParse, AtClusterTimeAndLevelSnapshot) {
ReadConcernArgs readConcern;
auto atClusterTime = LogicalTime(Timestamp(20, 30));
- ASSERT_OK(readConcern.initialize(BSON("find"
- << "test"
- << ReadConcernArgs::kReadConcernFieldName
- << BSON(ReadConcernArgs::kAtClusterTimeFieldName
- << atClusterTime.asTimestamp()
- << ReadConcernArgs::kLevelFieldName
- << "snapshot"))));
+ ASSERT_OK(
+ readConcern.initialize(BSON("find"
+ << "test" << ReadConcernArgs::kReadConcernFieldName
+ << BSON(ReadConcernArgs::kAtClusterTimeFieldName
+ << atClusterTime.asTimestamp()
+ << ReadConcernArgs::kLevelFieldName << "snapshot"))));
auto argsAtClusterTime = readConcern.getArgsAtClusterTime();
ASSERT_TRUE(argsAtClusterTime);
ASSERT_FALSE(readConcern.getArgsOpTime());
@@ -153,40 +146,37 @@ TEST(ReadAfterParse, AtClusterTimeAndLevelSnapshot) {
TEST(ReadAfterParse, AtClusterTimeAndLevelMajority) {
ReadConcernArgs readConcern;
auto atClusterTime = LogicalTime(Timestamp(20, 30));
- ASSERT_EQ(ErrorCodes::InvalidOptions,
- readConcern.initialize(BSON("find"
- << "test"
- << ReadConcernArgs::kReadConcernFieldName
- << BSON(ReadConcernArgs::kAtClusterTimeFieldName
- << atClusterTime.asTimestamp()
- << ReadConcernArgs::kLevelFieldName
- << "majority"))));
+ ASSERT_EQ(
+ ErrorCodes::InvalidOptions,
+ readConcern.initialize(BSON("find"
+ << "test" << ReadConcernArgs::kReadConcernFieldName
+ << BSON(ReadConcernArgs::kAtClusterTimeFieldName
+ << atClusterTime.asTimestamp()
+ << ReadConcernArgs::kLevelFieldName << "majority"))));
}
TEST(ReadAfterParse, AtClusterTimeAndLevelLocal) {
ReadConcernArgs readConcern;
auto atClusterTime = LogicalTime(Timestamp(20, 30));
- ASSERT_EQ(ErrorCodes::InvalidOptions,
- readConcern.initialize(BSON("find"
- << "test"
- << ReadConcernArgs::kReadConcernFieldName
- << BSON(ReadConcernArgs::kAtClusterTimeFieldName
- << atClusterTime.asTimestamp()
- << ReadConcernArgs::kLevelFieldName
- << "local"))));
+ ASSERT_EQ(
+ ErrorCodes::InvalidOptions,
+ readConcern.initialize(BSON("find"
+ << "test" << ReadConcernArgs::kReadConcernFieldName
+ << BSON(ReadConcernArgs::kAtClusterTimeFieldName
+ << atClusterTime.asTimestamp()
+ << ReadConcernArgs::kLevelFieldName << "local"))));
}
TEST(ReadAfterParse, AtClusterTimeAndLevelAvailable) {
ReadConcernArgs readConcern;
auto atClusterTime = LogicalTime(Timestamp(20, 30));
- ASSERT_EQ(ErrorCodes::InvalidOptions,
- readConcern.initialize(BSON("find"
- << "test"
- << ReadConcernArgs::kReadConcernFieldName
- << BSON(ReadConcernArgs::kAtClusterTimeFieldName
- << atClusterTime.asTimestamp()
- << ReadConcernArgs::kLevelFieldName
- << "available"))));
+ ASSERT_EQ(
+ ErrorCodes::InvalidOptions,
+ readConcern.initialize(BSON("find"
+ << "test" << ReadConcernArgs::kReadConcernFieldName
+ << BSON(ReadConcernArgs::kAtClusterTimeFieldName
+ << atClusterTime.asTimestamp()
+ << ReadConcernArgs::kLevelFieldName << "available"))));
}
TEST(ReadAfterParse, AtClusterTimeAndLevelLinearizable) {
@@ -194,8 +184,7 @@ TEST(ReadAfterParse, AtClusterTimeAndLevelLinearizable) {
auto atClusterTime = LogicalTime(Timestamp(20, 30));
ASSERT_EQ(ErrorCodes::InvalidOptions,
readConcern.initialize(BSON("find"
- << "test"
- << ReadConcernArgs::kReadConcernFieldName
+ << "test" << ReadConcernArgs::kReadConcernFieldName
<< BSON(ReadConcernArgs::kAtClusterTimeFieldName
<< atClusterTime.asTimestamp()
<< ReadConcernArgs::kLevelFieldName
@@ -206,8 +195,7 @@ TEST(ReadAfterParse, LevelMajorityOnly) {
ReadConcernArgs readConcern;
ASSERT_OK(
readConcern.initialize(BSON("find"
- << "test"
- << ReadConcernArgs::kReadConcernFieldName
+ << "test" << ReadConcernArgs::kReadConcernFieldName
<< BSON(ReadConcernArgs::kLevelFieldName << "majority"))));
ASSERT_TRUE(!readConcern.getArgsOpTime());
@@ -219,8 +207,7 @@ TEST(ReadAfterParse, LevelSnapshotOnly) {
ReadConcernArgs readConcern;
ASSERT_OK(
readConcern.initialize(BSON("find"
- << "test"
- << ReadConcernArgs::kReadConcernFieldName
+ << "test" << ReadConcernArgs::kReadConcernFieldName
<< BSON(ReadConcernArgs::kLevelFieldName << "snapshot"))));
ASSERT_TRUE(!readConcern.getArgsOpTime());
@@ -234,15 +221,12 @@ TEST(ReadAfterParse, ReadCommittedFullSpecification) {
auto afterClusterTime = LogicalTime(Timestamp(100, 200));
ASSERT_NOT_OK(readConcern.initialize(BSON(
"find"
- << "test"
- << ReadConcernArgs::kReadConcernFieldName
+ << "test" << ReadConcernArgs::kReadConcernFieldName
<< BSON(ReadConcernArgs::kAfterOpTimeFieldName
<< BSON(OpTime::kTimestampFieldName << Timestamp(20, 30) << OpTime::kTermFieldName
<< 2)
- << ReadConcernArgs::kAfterClusterTimeFieldName
- << afterClusterTime.asTimestamp()
- << ReadConcernArgs::kLevelFieldName
- << "majority"))));
+ << ReadConcernArgs::kAfterClusterTimeFieldName << afterClusterTime.asTimestamp()
+ << ReadConcernArgs::kLevelFieldName << "majority"))));
}
TEST(ReadAfterParse, Empty) {
@@ -257,58 +241,51 @@ TEST(ReadAfterParse, Empty) {
TEST(ReadAfterParse, BadRootType) {
ReadConcernArgs readConcern;
- ASSERT_NOT_OK(readConcern.initialize(BSON("find"
- << "test"
- << ReadConcernArgs::kReadConcernFieldName
- << "x")));
+ ASSERT_NOT_OK(
+ readConcern.initialize(BSON("find"
+ << "test" << ReadConcernArgs::kReadConcernFieldName << "x")));
}
TEST(ReadAfterParse, BadAtClusterTimeType) {
ReadConcernArgs readConcern;
ASSERT_EQ(ErrorCodes::TypeMismatch,
readConcern.initialize(BSON("find"
- << "test"
- << ReadConcernArgs::kReadConcernFieldName
+ << "test" << ReadConcernArgs::kReadConcernFieldName
<< BSON(ReadConcernArgs::kAtClusterTimeFieldName
- << 2
- << ReadConcernArgs::kLevelFieldName
+ << 2 << ReadConcernArgs::kLevelFieldName
<< "snapshot"))));
}
TEST(ReadAfterParse, BadAtClusterTimeValue) {
ReadConcernArgs readConcern;
- ASSERT_EQ(ErrorCodes::InvalidOptions,
- readConcern.initialize(BSON("find"
- << "test"
- << ReadConcernArgs::kReadConcernFieldName
- << BSON(ReadConcernArgs::kAtClusterTimeFieldName
- << LogicalTime::kUninitialized.asTimestamp()
- << ReadConcernArgs::kLevelFieldName
- << "snapshot"))));
+ ASSERT_EQ(
+ ErrorCodes::InvalidOptions,
+ readConcern.initialize(BSON("find"
+ << "test" << ReadConcernArgs::kReadConcernFieldName
+ << BSON(ReadConcernArgs::kAtClusterTimeFieldName
+ << LogicalTime::kUninitialized.asTimestamp()
+ << ReadConcernArgs::kLevelFieldName << "snapshot"))));
}
TEST(ReadAfterParse, BadOpTimeType) {
ReadConcernArgs readConcern;
ASSERT_NOT_OK(
readConcern.initialize(BSON("find"
- << "test"
- << ReadConcernArgs::kReadConcernFieldName
+ << "test" << ReadConcernArgs::kReadConcernFieldName
<< BSON(ReadConcernArgs::kAfterOpTimeFieldName << 2))));
}
TEST(ReadAfterParse, OpTimeNotNeededForValidReadConcern) {
ReadConcernArgs readConcern;
ASSERT_OK(readConcern.initialize(BSON("find"
- << "test"
- << ReadConcernArgs::kReadConcernFieldName
+ << "test" << ReadConcernArgs::kReadConcernFieldName
<< BSONObj())));
}
TEST(ReadAfterParse, NoOpTimeTS) {
ReadConcernArgs readConcern;
ASSERT_NOT_OK(readConcern.initialize(BSON("find"
- << "test"
- << ReadConcernArgs::kReadConcernFieldName
+ << "test" << ReadConcernArgs::kReadConcernFieldName
<< BSON(ReadConcernArgs::kAfterOpTimeFieldName
<< BSON(OpTime::kTimestampFieldName << 2)))));
}
@@ -316,40 +293,36 @@ TEST(ReadAfterParse, NoOpTimeTS) {
TEST(ReadAfterParse, NoOpTimeTerm) {
ReadConcernArgs readConcern;
ASSERT_NOT_OK(readConcern.initialize(BSON("find"
- << "test"
- << ReadConcernArgs::kReadConcernFieldName
+ << "test" << ReadConcernArgs::kReadConcernFieldName
<< BSON(ReadConcernArgs::kAfterOpTimeFieldName
<< BSON(OpTime::kTermFieldName << 2)))));
}
TEST(ReadAfterParse, BadOpTimeTSType) {
ReadConcernArgs readConcern;
- ASSERT_NOT_OK(readConcern.initialize(
- BSON("find"
- << "test"
- << ReadConcernArgs::kReadConcernFieldName
- << BSON(ReadConcernArgs::kAfterOpTimeFieldName
- << BSON(OpTime::kTimestampFieldName << BSON("x" << 1) << OpTime::kTermFieldName
- << 2)))));
+ ASSERT_NOT_OK(readConcern.initialize(BSON("find"
+ << "test" << ReadConcernArgs::kReadConcernFieldName
+ << BSON(ReadConcernArgs::kAfterOpTimeFieldName
+ << BSON(OpTime::kTimestampFieldName
+ << BSON("x" << 1)
+ << OpTime::kTermFieldName << 2)))));
}
TEST(ReadAfterParse, BadOpTimeTermType) {
ReadConcernArgs readConcern;
- ASSERT_NOT_OK(readConcern.initialize(BSON(
- "find"
- << "test"
- << ReadConcernArgs::kReadConcernFieldName
- << BSON(ReadConcernArgs::kAfterOpTimeFieldName
- << BSON(OpTime::kTimestampFieldName << Timestamp(1, 0) << OpTime::kTermFieldName
- << "y")))));
+ ASSERT_NOT_OK(readConcern.initialize(BSON("find"
+ << "test" << ReadConcernArgs::kReadConcernFieldName
+ << BSON(ReadConcernArgs::kAfterOpTimeFieldName
+ << BSON(OpTime::kTimestampFieldName
+ << Timestamp(1, 0)
+ << OpTime::kTermFieldName << "y")))));
}
TEST(ReadAfterParse, BadLevelType) {
ReadConcernArgs readConcern;
ASSERT_EQ(ErrorCodes::TypeMismatch,
readConcern.initialize(BSON("find"
- << "test"
- << ReadConcernArgs::kReadConcernFieldName
+ << "test" << ReadConcernArgs::kReadConcernFieldName
<< BSON(ReadConcernArgs::kLevelFieldName << 7))));
}
@@ -357,8 +330,7 @@ TEST(ReadAfterParse, BadLevelValue) {
ReadConcernArgs readConcern;
ASSERT_EQ(ErrorCodes::FailedToParse,
readConcern.initialize(BSON("find"
- << "test"
- << ReadConcernArgs::kReadConcernFieldName
+ << "test" << ReadConcernArgs::kReadConcernFieldName
<< BSON(ReadConcernArgs::kLevelFieldName
<< "seven is not a real level"))));
}
@@ -367,39 +339,35 @@ TEST(ReadAfterParse, BadOption) {
ReadConcernArgs readConcern;
ASSERT_EQ(ErrorCodes::InvalidOptions,
readConcern.initialize(BSON("find"
- << "test"
- << ReadConcernArgs::kReadConcernFieldName
+ << "test" << ReadConcernArgs::kReadConcernFieldName
<< BSON("asdf" << 1))));
}
TEST(ReadAfterParse, AtClusterTimeAndAfterClusterTime) {
ReadConcernArgs readConcern;
auto clusterTime = LogicalTime(Timestamp(20, 30));
- ASSERT_EQ(ErrorCodes::InvalidOptions,
- readConcern.initialize(BSON("find"
- << "test"
- << ReadConcernArgs::kReadConcernFieldName
- << BSON(ReadConcernArgs::kAtClusterTimeFieldName
- << clusterTime.asTimestamp()
- << ReadConcernArgs::kAfterClusterTimeFieldName
- << clusterTime.asTimestamp()
- << ReadConcernArgs::kLevelFieldName
- << "snapshot"))));
+ ASSERT_EQ(
+ ErrorCodes::InvalidOptions,
+ readConcern.initialize(BSON("find"
+ << "test" << ReadConcernArgs::kReadConcernFieldName
+ << BSON(ReadConcernArgs::kAtClusterTimeFieldName
+ << clusterTime.asTimestamp()
+ << ReadConcernArgs::kAfterClusterTimeFieldName
+ << clusterTime.asTimestamp()
+ << ReadConcernArgs::kLevelFieldName << "snapshot"))));
}
TEST(ReadAfterParse, AfterOpTimeAndLevelSnapshot) {
ReadConcernArgs readConcern;
- ASSERT_EQ(ErrorCodes::InvalidOptions,
- readConcern.initialize(BSON("find"
- << "test"
- << ReadConcernArgs::kReadConcernFieldName
- << BSON(ReadConcernArgs::kAfterOpTimeFieldName
- << BSON(OpTime::kTimestampFieldName
- << Timestamp(20, 30)
- << OpTime::kTermFieldName
- << 2)
- << ReadConcernArgs::kLevelFieldName
- << "snapshot"))));
+ ASSERT_EQ(
+ ErrorCodes::InvalidOptions,
+ readConcern.initialize(BSON("find"
+ << "test" << ReadConcernArgs::kReadConcernFieldName
+ << BSON(ReadConcernArgs::kAfterOpTimeFieldName
+ << BSON(OpTime::kTimestampFieldName
+ << Timestamp(20, 30) << OpTime::kTermFieldName
+ << 2)
+ << ReadConcernArgs::kLevelFieldName << "snapshot"))));
}
TEST(ReadAfterSerialize, Empty) {
@@ -430,10 +398,10 @@ TEST(ReadAfterSerialize, AfterOpTimeOnly) {
ReadConcernArgs readConcern(OpTime(Timestamp(20, 30), 2), boost::none);
readConcern.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_BSONOBJ_EQ(expectedObj, builder.done());
}
@@ -455,11 +423,10 @@ TEST(ReadAfterSerialize, iAfterCLusterTimeAndLevel) {
ReadConcernArgs readConcern(afterClusterTime, ReadConcernLevel::kMajorityReadConcern);
readConcern.appendInfo(&builder);
- BSONObj expectedObj(
- BSON(ReadConcernArgs::kReadConcernFieldName
- << BSON(ReadConcernArgs::kLevelFieldName << "majority"
- << ReadConcernArgs::kAfterClusterTimeFieldName
- << afterClusterTime.asTimestamp())));
+ BSONObj expectedObj(BSON(ReadConcernArgs::kReadConcernFieldName
+ << BSON(ReadConcernArgs::kLevelFieldName
+ << "majority" << ReadConcernArgs::kAfterClusterTimeFieldName
+ << afterClusterTime.asTimestamp())));
ASSERT_BSONOBJ_EQ(expectedObj, builder.done());
}
@@ -470,13 +437,11 @@ TEST(ReadAfterSerialize, AfterOpTimeAndLevel) {
ReadConcernLevel::kMajorityReadConcern);
readConcern.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_BSONOBJ_EQ(expectedObj, builder.done());
}
@@ -486,8 +451,7 @@ TEST(ReadAfterSerialize, AtClusterTimeAndLevelSnapshot) {
ReadConcernArgs readConcern;
auto atClusterTime = LogicalTime(Timestamp(20, 30));
ASSERT_OK(readConcern.initialize(BSON("find"
- << "test"
- << ReadConcernArgs::kReadConcernFieldName
+ << "test" << ReadConcernArgs::kReadConcernFieldName
<< BSON(ReadConcernArgs::kLevelFieldName
<< "snapshot"
<< ReadConcernArgs::kAtClusterTimeFieldName
@@ -495,11 +459,10 @@ TEST(ReadAfterSerialize, AtClusterTimeAndLevelSnapshot) {
readConcern.appendInfo(&builder);
- BSONObj expectedObj(
- BSON(ReadConcernArgs::kReadConcernFieldName
- << BSON(ReadConcernArgs::kLevelFieldName << "snapshot"
- << ReadConcernArgs::kAtClusterTimeFieldName
- << atClusterTime.asTimestamp())));
+ BSONObj expectedObj(BSON(ReadConcernArgs::kReadConcernFieldName
+ << BSON(ReadConcernArgs::kLevelFieldName
+ << "snapshot" << ReadConcernArgs::kAtClusterTimeFieldName
+ << atClusterTime.asTimestamp())));
ASSERT_BSONOBJ_EQ(expectedObj, builder.done());
}
@@ -516,8 +479,7 @@ TEST(UpconvertReadConcernLevelToSnapshot, EmptyLevel) {
TEST(UpconvertReadConcernLevelToSnapshot, LevelLocal) {
ReadConcernArgs readConcern;
ASSERT_OK(readConcern.initialize(BSON("find"
- << "test"
- << ReadConcernArgs::kReadConcernFieldName
+ << "test" << ReadConcernArgs::kReadConcernFieldName
<< BSON(ReadConcernArgs::kLevelFieldName << "local"))));
ASSERT(ReadConcernLevel::kLocalReadConcern == readConcern.getLevel());
@@ -530,8 +492,7 @@ TEST(UpconvertReadConcernLevelToSnapshot, LevelMajority) {
ReadConcernArgs readConcern;
ASSERT_OK(
readConcern.initialize(BSON("find"
- << "test"
- << ReadConcernArgs::kReadConcernFieldName
+ << "test" << ReadConcernArgs::kReadConcernFieldName
<< BSON(ReadConcernArgs::kLevelFieldName << "majority"))));
ASSERT(ReadConcernLevel::kMajorityReadConcern == readConcern.getLevel());
@@ -544,8 +505,7 @@ TEST(UpconvertReadConcernLevelToSnapshot, LevelSnapshot) {
ReadConcernArgs readConcern;
ASSERT_OK(
readConcern.initialize(BSON("find"
- << "test"
- << ReadConcernArgs::kReadConcernFieldName
+ << "test" << ReadConcernArgs::kReadConcernFieldName
<< BSON(ReadConcernArgs::kLevelFieldName << "snapshot"))));
ASSERT(ReadConcernLevel::kSnapshotReadConcern == readConcern.getLevel());
@@ -558,8 +518,7 @@ TEST(UpconvertReadConcernLevelToSnapshot, LevelSnapshotWithAtClusterTime) {
ReadConcernArgs readConcern;
auto atClusterTime = LogicalTime(Timestamp(20, 30));
ASSERT_OK(readConcern.initialize(BSON("find"
- << "test"
- << ReadConcernArgs::kReadConcernFieldName
+ << "test" << ReadConcernArgs::kReadConcernFieldName
<< BSON(ReadConcernArgs::kLevelFieldName
<< "snapshot"
<< ReadConcernArgs::kAtClusterTimeFieldName
@@ -577,8 +536,7 @@ TEST(UpconvertReadConcernLevelToSnapshot, AfterClusterTime) {
ReadConcernArgs readConcern;
auto afterClusterTime = LogicalTime(Timestamp(20, 30));
ASSERT_OK(readConcern.initialize(BSON("find"
- << "test"
- << ReadConcernArgs::kReadConcernFieldName
+ << "test" << ReadConcernArgs::kReadConcernFieldName
<< BSON(ReadConcernArgs::kAfterClusterTimeFieldName
<< afterClusterTime.asTimestamp()))));
ASSERT(ReadConcernLevel::kLocalReadConcern == readConcern.getLevel());
@@ -594,8 +552,7 @@ TEST(UpconvertReadConcernLevelToSnapshot, LevelAvailable) {
ReadConcernArgs readConcern;
ASSERT_OK(
readConcern.initialize(BSON("find"
- << "test"
- << ReadConcernArgs::kReadConcernFieldName
+ << "test" << ReadConcernArgs::kReadConcernFieldName
<< BSON(ReadConcernArgs::kLevelFieldName << "available"))));
ASSERT(ReadConcernLevel::kAvailableReadConcern == readConcern.getLevel());
@@ -608,8 +565,7 @@ TEST(UpconvertReadConcernLevelToSnapshot, LevelLinearizable) {
ReadConcernArgs readConcern;
ASSERT_OK(
readConcern.initialize(BSON("find"
- << "test"
- << ReadConcernArgs::kReadConcernFieldName
+ << "test" << ReadConcernArgs::kReadConcernFieldName
<< BSON(ReadConcernArgs::kLevelFieldName << "linearizable"))));
ASSERT(ReadConcernLevel::kLinearizableReadConcern == readConcern.getLevel());
@@ -620,13 +576,12 @@ TEST(UpconvertReadConcernLevelToSnapshot, LevelLinearizable) {
TEST(UpconvertReadConcernLevelToSnapshot, AfterOpTime) {
ReadConcernArgs readConcern;
- ASSERT_OK(readConcern.initialize(BSON(
- "find"
- << "test"
- << ReadConcernArgs::kReadConcernFieldName
- << BSON(ReadConcernArgs::kAfterOpTimeFieldName
- << BSON(OpTime::kTimestampFieldName << Timestamp(20, 30) << OpTime::kTermFieldName
- << 2)))));
+ ASSERT_OK(readConcern.initialize(BSON("find"
+ << "test" << ReadConcernArgs::kReadConcernFieldName
+ << BSON(ReadConcernArgs::kAfterOpTimeFieldName
+ << BSON(OpTime::kTimestampFieldName
+ << Timestamp(20, 30)
+ << OpTime::kTermFieldName << 2)))));
ASSERT(ReadConcernLevel::kLocalReadConcern == readConcern.getLevel());
ASSERT_TRUE(readConcern.getArgsOpTime());
diff --git a/src/mongo/db/repl/repl_set_commands.cpp b/src/mongo/db/repl/repl_set_commands.cpp
index 599244b583f..d614be0d7a9 100644
--- a/src/mongo/db/repl/repl_set_commands.cpp
+++ b/src/mongo/db/repl/repl_set_commands.cpp
@@ -330,12 +330,12 @@ public:
HostAndPort me = someHostAndPortForMe();
auto appendMember =
- [&members, serial = DecimalCounter<uint32_t>() ](const HostAndPort& host) mutable {
- members.append(
- StringData{serial},
- BSON("_id" << static_cast<int>(serial) << "host" << host.toString()));
- ++serial;
- };
+ [&members, serial = DecimalCounter<uint32_t>()](const HostAndPort& host) mutable {
+ members.append(
+ StringData{serial},
+ BSON("_id" << static_cast<int>(serial) << "host" << host.toString()));
+ ++serial;
+ };
appendMember(me);
result.append("me", me.toString());
for (const HostAndPort& seed : seeds) {
diff --git a/src/mongo/db/repl/repl_set_config.cpp b/src/mongo/db/repl/repl_set_config.cpp
index 5577064f455..0e753e5c654 100644
--- a/src/mongo/db/repl/repl_set_config.cpp
+++ b/src/mongo/db/repl/repl_set_config.cpp
@@ -138,17 +138,16 @@ Status ReplSetConfig::_initialize(const BSONObj& cfg, bool forInitiate, OID defa
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()));
}
const auto& memberBSON = memberElement.Obj();
try {
_members.emplace_back(memberBSON, &_tagConfig);
} catch (const DBException& ex) {
- return Status(
- ErrorCodes::InvalidReplicaSetConfig,
- str::stream() << ex.toStatus().toString() << " for member:" << memberBSON);
+ return Status(ErrorCodes::InvalidReplicaSetConfig,
+ str::stream()
+ << ex.toStatus().toString() << " for member:" << memberBSON);
}
}
@@ -348,43 +347,35 @@ Status ReplSetConfig::_parseSettingsSubdocument(const BSONObj& settings) {
if (_customWriteConcernModes.find(modeElement.fieldNameStringData()) !=
_customWriteConcernModes.end()) {
return Status(ErrorCodes::Error(51001),
- str::stream() << kSettingsFieldName << '.' << kGetLastErrorModesFieldName
- << " contains multiple fields named "
- << modeElement.fieldName());
+ str::stream()
+ << kSettingsFieldName << '.' << kGetLastErrorModesFieldName
+ << " contains multiple fields named " << modeElement.fieldName());
}
if (modeElement.type() != Object) {
return Status(ErrorCodes::TypeMismatch,
- str::stream() << "Expected " << kSettingsFieldName << '.'
- << kGetLastErrorModesFieldName
- << '.'
- << modeElement.fieldName()
- << " to be an Object, not "
- << typeName(modeElement.type()));
+ str::stream()
+ << "Expected " << kSettingsFieldName << '.'
+ << kGetLastErrorModesFieldName << '.' << modeElement.fieldName()
+ << " to be an Object, not " << typeName(modeElement.type()));
}
ReplSetTagPattern pattern = _tagConfig.makePattern();
for (auto&& constraintElement : modeElement.Obj()) {
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()
- << '.'
- << constraintElement.fieldName()
- << " must be positive, but found "
- << minCount);
+ str::stream()
+ << "Value of " << kSettingsFieldName << '.'
+ << kGetLastErrorModesFieldName << '.' << modeElement.fieldName()
+ << '.' << constraintElement.fieldName()
+ << " must be positive, but found " << minCount);
}
status = _tagConfig.addTagCountConstraintToPattern(
&pattern, constraintElement.fieldNameStringData(), minCount);
@@ -420,8 +411,7 @@ Status ReplSetConfig::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,
@@ -506,41 +496,22 @@ Status ReplSetConfig::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
- << "."
- << MemberConfig::kHostFieldName
- << " == "
- << memberI.getHostAndPort().toString());
+ str::stream()
+ << "Found two member configurations with same "
+ << MemberConfig::kHostFieldName << " field, " << kMembersFieldName
+ << "." << i << "." << MemberConfig::kHostFieldName
+ << " == " << kMembersFieldName << "." << j << "."
+ << MemberConfig::kHostFieldName
+ << " == " << memberI.getHostAndPort().toString());
}
}
}
@@ -593,9 +564,7 @@ Status ReplSetConfig::validate() const {
str::stream()
<< "Either all host names in a replica set configuration must be localhost "
"references, or none must be; found "
- << localhostCount
- << " out of "
- << _members.size());
+ << localhostCount << " out of " << _members.size());
}
if (voterCount > kMaxVotingMembers || voterCount == 0) {
@@ -636,9 +605,9 @@ Status ReplSetConfig::validate() const {
}
if (_protocolVersion != 1) {
return Status(ErrorCodes::BadValue,
- str::stream() << kProtocolVersionFieldName
- << " of 1 is the only supported value. Found: "
- << _protocolVersion);
+ str::stream()
+ << kProtocolVersionFieldName
+ << " of 1 is the only supported value. Found: " << _protocolVersion);
}
if (_configServer) {
@@ -708,8 +677,7 @@ Status ReplSetConfig::checkIfWriteConcernCanBeSatisfied(
// write concern mode.
return Status(ErrorCodes::UnsatisfiableWriteConcern,
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/repl_set_config_checks.cpp b/src/mongo/db/repl/repl_set_config_checks.cpp
index 14cc8e99e61..5c0eeecdb97 100644
--- a/src/mongo/db/repl/repl_set_config_checks.cpp
+++ b/src/mongo/db/repl/repl_set_config_checks.cpp
@@ -63,10 +63,8 @@ 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;
@@ -95,11 +93,9 @@ Status checkElectable(const ReplSetConfig& 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();
@@ -133,8 +129,7 @@ Status validateArbiterPriorities(const ReplSetConfig& config) {
if (iter->isArbiter() && iter->getPriority() != 0) {
return Status(ErrorCodes::InvalidReplicaSetConfig,
str::stream() << "Member " << iter->getHostAndPort().toString()
- << " is an arbiter but has priority "
- << iter->getPriority()
+ << " is an arbiter but has priority " << iter->getPriority()
<< ". Arbiter priority must be 0.");
}
}
@@ -164,10 +159,8 @@ Status validateOldAndNewConfigsCompatible(const ReplSetConfig& 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());
}
@@ -175,8 +168,7 @@ Status validateOldAndNewConfigsCompatible(const ReplSetConfig& oldConfig,
return Status(ErrorCodes::NewReplicaSetConfigurationIncompatible,
str::stream() << "New and old configurations differ in replica set name; "
"old was "
- << oldConfig.getReplSetName()
- << ", and new is "
+ << oldConfig.getReplSetName() << ", and new is "
<< newConfig.getReplSetName());
}
@@ -184,8 +176,7 @@ Status validateOldAndNewConfigsCompatible(const ReplSetConfig& oldConfig,
return Status(ErrorCodes::NewReplicaSetConfigurationIncompatible,
str::stream() << "New and old configurations differ in replica set ID; "
"old was "
- << oldConfig.getReplicaSetId()
- << ", and new is "
+ << oldConfig.getReplicaSetId() << ", and new is "
<< newConfig.getReplicaSetId());
}
@@ -216,18 +207,14 @@ Status validateOldAndNewConfigsCompatible(const ReplSetConfig& 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/repl_set_config_checks_test.cpp b/src/mongo/db/repl/repl_set_config_checks_test.cpp
index b8579f1f6e2..c887e11f69b 100644
--- a/src/mongo/db/repl/repl_set_config_checks_test.cpp
+++ b/src/mongo/db/repl/repl_set_config_checks_test.cpp
@@ -49,34 +49,28 @@ TEST_F(ServiceContextTest, ValidateConfigForInitiate_VersionMustBe1) {
rses.addSelf(HostAndPort("h1"));
ReplSetConfig config;
- ASSERT_OK(config.initializeForInitiate(BSON("_id"
- << "rs0"
- << "version"
- << 2
- << "protocolVersion"
- << 1
- << "members"
- << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "h1")))));
+ ASSERT_OK(
+ config.initializeForInitiate(BSON("_id"
+ << "rs0"
+ << "version" << 2 << "protocolVersion" << 1 << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "h1")))));
ASSERT_EQUALS(ErrorCodes::NewReplicaSetConfigurationIncompatible,
validateConfigForInitiate(&rses, config, getGlobalServiceContext()).getStatus());
}
TEST_F(ServiceContextTest, ValidateConfigForInitiate_MustFindSelf) {
ReplSetConfig config;
- ASSERT_OK(config.initializeForInitiate(BSON("_id"
- << "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
- << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "h1")
- << BSON("_id" << 2 << "host"
- << "h2")
- << BSON("_id" << 3 << "host"
- << "h3")))));
+ ASSERT_OK(
+ config.initializeForInitiate(BSON("_id"
+ << "rs0"
+ << "version" << 1 << "protocolVersion" << 1 << "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"));
@@ -99,21 +93,17 @@ TEST_F(ServiceContextTest, ValidateConfigForInitiate_MustFindSelf) {
TEST_F(ServiceContextTest, ValidateConfigForInitiate_SelfMustBeElectable) {
ReplSetConfig config;
- ASSERT_OK(config.initializeForInitiate(BSON("_id"
- << "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
- << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "h1")
- << BSON("_id" << 2 << "host"
- << "h2"
- << "priority"
- << 0)
- << BSON("_id" << 3 << "host"
- << "h3")))));
+ ASSERT_OK(
+ config.initializeForInitiate(BSON("_id"
+ << "rs0"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "h1")
+ << BSON("_id" << 2 << "host"
+ << "h2"
+ << "priority" << 0)
+ << BSON("_id" << 3 << "host"
+ << "h3")))));
ReplicationCoordinatorExternalStateMock presentOnceExternalState;
presentOnceExternalState.addSelf(HostAndPort("h2"));
@@ -128,11 +118,7 @@ TEST_F(ServiceContextTest, ValidateConfigForInitiate_WriteConcernMustBeSatisfiab
ASSERT_OK(
config.initializeForInitiate(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1"))
<< "settings"
@@ -152,55 +138,37 @@ TEST_F(ServiceContextTest, ValidateConfigForInitiate_ArbiterPriorityMustBeZeroOr
ReplSetConfig twoConfig;
ASSERT_OK(zeroConfig.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1")
<< BSON("_id" << 2 << "host"
<< "h2"
- << "priority"
- << 0
- << "arbiterOnly"
- << true)
+ << "priority" << 0
+ << "arbiterOnly" << true)
<< BSON("_id" << 3 << "host"
<< "h3")))));
ASSERT_OK(oneConfig.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1")
<< BSON("_id" << 2 << "host"
<< "h2"
- << "priority"
- << 1
- << "arbiterOnly"
- << true)
+ << "priority" << 1
+ << "arbiterOnly" << true)
<< BSON("_id" << 3 << "host"
<< "h3")))));
ASSERT_OK(twoConfig.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1")
<< BSON("_id" << 2 << "host"
<< "h2"
- << "priority"
- << 2
- << "arbiterOnly"
- << true)
+ << "priority" << 2
+ << "arbiterOnly" << true)
<< BSON("_id" << 3 << "host"
<< "h3")))));
ReplicationCoordinatorExternalStateMock presentOnceExternalState;
@@ -228,11 +196,7 @@ TEST_F(ServiceContextTest, ValidateConfigForReconfig_NewConfigVersionNumberMustB
// Two configurations, identical except for version.
ASSERT_OK(oldConfig.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1")
<< BSON("_id" << 2 << "host"
@@ -242,11 +206,7 @@ TEST_F(ServiceContextTest, ValidateConfigForReconfig_NewConfigVersionNumberMustB
ASSERT_OK(newConfig.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 3
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 3 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1")
<< BSON("_id" << 2 << "host"
@@ -296,11 +256,7 @@ TEST_F(ServiceContextTest, ValidateConfigForReconfig_NewConfigMustNotChangeSetNa
// Two configurations, compatible except for set name.
ASSERT_OK(oldConfig.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1")
<< BSON("_id" << 2 << "host"
@@ -310,11 +266,7 @@ TEST_F(ServiceContextTest, ValidateConfigForReconfig_NewConfigMustNotChangeSetNa
ASSERT_OK(newConfig.initialize(BSON("_id"
<< "rs1"
- << "version"
- << 3
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 3 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1")
<< BSON("_id" << 2 << "host"
@@ -345,35 +297,25 @@ TEST_F(ServiceContextTest, ValidateConfigForReconfig_NewConfigMustNotChangeSetId
// Two configurations, compatible except for set ID.
ASSERT_OK(oldConfig.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1")
<< BSON("_id" << 2 << "host"
<< "h2")
<< BSON("_id" << 3 << "host"
<< "h3"))
- << "settings"
- << BSON("replicaSetId" << OID::gen()))));
+ << "settings" << BSON("replicaSetId" << OID::gen()))));
ASSERT_OK(newConfig.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 3
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 3 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1")
<< BSON("_id" << 2 << "host"
<< "h2")
<< BSON("_id" << 3 << "host"
<< "h3"))
- << "settings"
- << BSON("replicaSetId" << OID::gen()))));
+ << "settings" << BSON("replicaSetId" << OID::gen()))));
ASSERT_OK(oldConfig.validate());
ASSERT_OK(newConfig.validate());
@@ -402,57 +344,40 @@ TEST_F(ServiceContextTest, ValidateConfigForReconfig_NewConfigMustNotFlipBuildIn
// The third, compatible with the first.
ASSERT_OK(oldConfig.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 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
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 3 << "protocolVersion" << 1 << "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
- << "protocolVersion"
- << 1
- << "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 << "protocolVersion" << 1 << "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());
@@ -484,51 +409,37 @@ TEST_F(ServiceContextTest, ValidateConfigForReconfig_NewConfigMustNotFlipArbiter
// The third, compatible with the first.
ASSERT_OK(oldConfig.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 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
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 3 << "protocolVersion" << 1 << "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
- << "protocolVersion"
- << 1
- << "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 << "protocolVersion" << 1 << "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());
@@ -562,11 +473,7 @@ TEST_F(ServiceContextTest, ValidateConfigForReconfig_HostAndIdRemappingRestricte
ASSERT_OK(oldConfig.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1")
<< BSON("_id" << 2 << "host"
@@ -582,10 +489,7 @@ TEST_F(ServiceContextTest, ValidateConfigForReconfig_HostAndIdRemappingRestricte
ASSERT_OK(
legalNewConfigWithNewHostAndId.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "protocolVersion"
- << 1
+ << "version" << 2 << "protocolVersion" << 1
<< "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1")
@@ -607,11 +511,8 @@ TEST_F(ServiceContextTest, ValidateConfigForReconfig_HostAndIdRemappingRestricte
//
ASSERT_OK(illegalNewConfigReusingHost.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 2 << "protocolVersion"
+ << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1")
<< BSON("_id" << 4 << "host"
@@ -638,10 +539,7 @@ TEST_F(ServiceContextTest, ValidateConfigForReconfig_HostAndIdRemappingRestricte
//
ASSERT_OK(illegalNewConfigReusingId.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "protocolVersion"
- << 1
+ << "version" << 2 << "protocolVersion" << 1
<< "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1")
@@ -662,11 +560,7 @@ TEST_F(ServiceContextTest, ValidateConfigForReconfig_MustFindSelf) {
ReplSetConfig oldConfig;
ASSERT_OK(oldConfig.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1")
<< BSON("_id" << 2 << "host"
@@ -677,11 +571,7 @@ TEST_F(ServiceContextTest, ValidateConfigForReconfig_MustFindSelf) {
ReplSetConfig newConfig;
ASSERT_OK(newConfig.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 2 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1")
<< BSON("_id" << 2 << "host"
@@ -738,69 +628,46 @@ TEST_F(ServiceContextTest, ValidateConfigForReconfig_ArbiterPriorityValueMustBeZ
ASSERT_OK(oldConfig.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1")
<< BSON("_id" << 2 << "host"
<< "h2"
- << "arbiterOnly"
- << true)
+ << "arbiterOnly" << true)
<< BSON("_id" << 3 << "host"
<< "h3")))));
ASSERT_OK(zeroConfig.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 2 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1")
<< BSON("_id" << 2 << "host"
<< "h2"
- << "priority"
- << 0
- << "arbiterOnly"
- << true)
+ << "priority" << 0
+ << "arbiterOnly" << true)
<< BSON("_id" << 3 << "host"
<< "h3")))));
ASSERT_OK(oneConfig.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 2 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1")
<< BSON("_id" << 2 << "host"
<< "h2"
- << "priority"
- << 1
- << "arbiterOnly"
- << true)
+ << "priority" << 1
+ << "arbiterOnly" << true)
<< BSON("_id" << 3 << "host"
<< "h3")))));
ASSERT_OK(twoConfig.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 2 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1")
<< BSON("_id" << 2 << "host"
<< "h2"
- << "priority"
- << 2
- << "arbiterOnly"
- << true)
+ << "priority" << 2
+ << "arbiterOnly" << true)
<< BSON("_id" << 3 << "host"
<< "h3")))));
@@ -831,11 +698,7 @@ TEST_F(ServiceContextTest, ValidateConfigForReconfig_SelfMustEndElectable) {
ReplSetConfig oldConfig;
ASSERT_OK(oldConfig.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h1")
<< BSON("_id" << 2 << "host"
@@ -846,17 +709,12 @@ TEST_F(ServiceContextTest, ValidateConfigForReconfig_SelfMustEndElectable) {
ReplSetConfig newConfig;
ASSERT_OK(newConfig.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 2 << "protocolVersion" << 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;
@@ -880,10 +738,7 @@ TEST_F(ServiceContextTest, ValidateConfigForInitiate_NewConfigInvalid) {
ReplSetConfig newConfig;
ASSERT_OK(newConfig.initializeForInitiate(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "protocolVersion"
- << 1
+ << "version" << 2 << "protocolVersion" << 1
<< "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "h2")
@@ -905,22 +760,14 @@ TEST_F(ServiceContextTest, ValidateConfigForReconfig_NewConfigInvalid) {
ReplSetConfig oldConfig;
ASSERT_OK(oldConfig.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "h2")))));
ReplSetConfig newConfig;
ASSERT_OK(newConfig.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 2 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "h2")
<< BSON("_id" << 0 << "host"
@@ -948,22 +795,14 @@ TEST_F(ServiceContextTest, ValidateConfigForReconfig_NewConfigWriteConcernNotSat
ReplSetConfig oldConfig;
ASSERT_OK(oldConfig.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "h2")))));
ReplSetConfig newConfig;
ASSERT_OK(newConfig.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "h2"))
<< "settings"
@@ -991,11 +830,7 @@ TEST_F(ServiceContextTest, ValidateConfigForStartUp_NewConfigInvalid) {
ReplSetConfig newConfig;
ASSERT_OK(newConfig.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 2 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "h2")
<< BSON("_id" << 0 << "host"
@@ -1015,15 +850,10 @@ TEST_F(ServiceContextTest, ValidateConfigForStartUp_NewConfigValid) {
ReplSetConfig newConfig;
ASSERT_OK(newConfig.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 2 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "h2"
- << "priority"
- << 3)
+ << "priority" << 3)
<< BSON("_id" << 1 << "host"
<< "h3")))));
@@ -1041,11 +871,7 @@ TEST_F(ServiceContextTest, ValidateConfigForStartUp_NewConfigWriteConcernNotSati
ReplSetConfig newConfig;
ASSERT_OK(newConfig.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 2 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "h2"))
<< "settings"
@@ -1065,11 +891,7 @@ TEST_F(ServiceContextTest, ValidateConfigForHeartbeatReconfig_NewConfigInvalid)
ReplSetConfig newConfig;
ASSERT_OK(newConfig.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 2 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "h2")
<< BSON("_id" << 0 << "host"
@@ -1089,11 +911,7 @@ TEST_F(ServiceContextTest, ValidateConfigForHeartbeatReconfig_NewConfigValid) {
ReplSetConfig newConfig;
ASSERT_OK(newConfig.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 2 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "h2")
<< BSON("_id" << 1 << "host"
@@ -1112,11 +930,7 @@ TEST_F(ServiceContextTest, ValidateConfigForHeartbeatReconfig_NewConfigWriteConc
ReplSetConfig newConfig;
ASSERT_OK(newConfig.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 2 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "h2")
<< BSON("_id" << 1 << "host"
@@ -1137,11 +951,7 @@ TEST_F(ServiceContextTest, ValidateForReconfig_ForceStillNeedsValidConfig) {
ReplSetConfig oldConfig;
ASSERT_OK(oldConfig.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "h2")
<< BSON("_id" << 1 << "host"
@@ -1151,11 +961,7 @@ TEST_F(ServiceContextTest, ValidateForReconfig_ForceStillNeedsValidConfig) {
ReplSetConfig newConfig;
ASSERT_OK(newConfig.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 2 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "h2")
<< BSON("_id" << 0 << "host"
@@ -1176,11 +982,7 @@ TEST_F(ServiceContextTest, ValidateForReconfig_ForceStillNeedsSelfPresent) {
ReplSetConfig oldConfig;
ASSERT_OK(oldConfig.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "h2")
<< BSON("_id" << 1 << "host"
@@ -1190,11 +992,7 @@ TEST_F(ServiceContextTest, ValidateForReconfig_ForceStillNeedsSelfPresent) {
ReplSetConfig newConfig;
ASSERT_OK(newConfig.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 2 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "h3")
<< BSON("_id" << 2 << "host"
diff --git a/src/mongo/db/repl/repl_set_config_test.cpp b/src/mongo/db/repl/repl_set_config_test.cpp
index c795d711aa3..88d36b1b174 100644
--- a/src/mongo/db/repl/repl_set_config_test.cpp
+++ b/src/mongo/db/repl/repl_set_config_test.cpp
@@ -63,11 +63,7 @@ TEST(ReplSetConfig, ParseMinimalConfigAndCheckDefaults) {
ReplSetConfig config;
ASSERT_OK(config.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345")))));
ASSERT_OK(config.validate());
@@ -92,32 +88,24 @@ TEST(ReplSetConfig, ParseMinimalConfigAndCheckDefaults) {
TEST(ReplSetConfig, ParseLargeConfigAndCheckAccessors) {
ReplSetConfig 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());
@@ -139,27 +127,20 @@ TEST(ReplSetConfig, ParseLargeConfigAndCheckAccessors) {
TEST(ReplSetConfig, GetConnectionStringFiltersHiddenNodes) {
ReplSetConfig config;
- ASSERT_OK(config.initialize(BSON("_id"
- << "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 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 << "protocolVersion" << 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"}})
@@ -169,31 +150,22 @@ TEST(ReplSetConfig, GetConnectionStringFiltersHiddenNodes) {
TEST(ReplSetConfig, MajorityCalculationThreeVotersNoArbiters) {
ReplSetConfig config;
- ASSERT_OK(config.initialize(BSON("_id"
- << "rs0"
- << "version"
- << 2
- << "protocolVersion"
- << 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"
- << "votes"
- << 0
- << "priority"
- << 0)
- << BSON("_id" << 5 << "host"
- << "h5:1"
- << "votes"
- << 0
- << "priority"
- << 0)))));
+ ASSERT_OK(
+ config.initialize(BSON("_id"
+ << "rs0"
+ << "version" << 2 << "protocolVersion" << 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"
+ << "votes" << 0 << "priority" << 0)
+ << BSON("_id" << 5 << "host"
+ << "h5:1"
+ << "votes" << 0 << "priority" << 0)))));
ASSERT_OK(config.validate());
ASSERT_EQUALS(2, config.getWriteMajority());
@@ -201,37 +173,25 @@ TEST(ReplSetConfig, MajorityCalculationThreeVotersNoArbiters) {
TEST(ReplSetConfig, MajorityCalculationNearlyHalfArbiters) {
ReplSetConfig config;
- ASSERT_OK(config.initialize(BSON("_id"
- << "mySet"
- << "version"
- << 2
- << "protocolVersion"
- << 1
- << "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 << "protocolVersion" << 1 << "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());
}
@@ -240,68 +200,45 @@ TEST(ReplSetConfig, MajorityCalculationEvenNumberOfMembers) {
ReplSetConfig config;
ASSERT_OK(config.initialize(BSON("_id"
<< "mySet"
- << "version"
- << 2
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 2 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id"
- << 0)
+ << "_id" << 0)
<< BSON("host"
<< "node2:12345"
- << "_id"
- << 1)
+ << "_id" << 1)
<< BSON("host"
<< "node3:12345"
- << "_id"
- << 2)
+ << "_id" << 2)
<< BSON("host"
<< "node4:12345"
- << "_id"
- << 3)))));
+ << "_id" << 3)))));
ASSERT_OK(config.validate());
ASSERT_EQUALS(3, config.getWriteMajority());
}
TEST(ReplSetConfig, MajorityCalculationNearlyHalfSecondariesNoVotes) {
ReplSetConfig config;
- ASSERT_OK(config.initialize(BSON("_id"
- << "mySet"
- << "version"
- << 2
- << "protocolVersion"
- << 1
- << "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 << "protocolVersion" << 1 << "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());
}
@@ -317,18 +254,14 @@ TEST(ReplSetConfig, ParseFailsWithBadOrMissingIdField) {
// Replica set name must be present.
ASSERT_EQUALS(
ErrorCodes::NoSuchKey,
- config.initialize(
- BSON("version" << 1 << "members" << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "localhost:12345")))));
+ config.initialize(BSON("version" << 1 << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "localhost:12345")))));
// Empty repl set name parses, but does not validate.
ASSERT_OK(config.initialize(BSON("_id"
<< ""
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345")))));
@@ -341,9 +274,7 @@ TEST(ReplSetConfig, ParseFailsWithBadOrMissingVersionField) {
ASSERT_EQUALS(ErrorCodes::NoSuchKey,
config.initialize(BSON("_id"
<< "rs0"
- << "protocolVersion"
- << 1
- << "members"
+ << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345")))));
ASSERT_EQUALS(ErrorCodes::TypeMismatch,
@@ -351,29 +282,19 @@ TEST(ReplSetConfig, ParseFailsWithBadOrMissingVersionField) {
<< "rs0"
<< "version"
<< "1"
- << "protocolVersion"
- << 1
- << "members"
+ << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345")))));
ASSERT_OK(config.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1.0
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1.0 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345")))));
ASSERT_OK(config.validate());
ASSERT_OK(config.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 0.0
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 0.0 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345")))));
ASSERT_EQUALS(ErrorCodes::BadValue, config.validate());
@@ -381,9 +302,7 @@ TEST(ReplSetConfig, ParseFailsWithBadOrMissingVersionField) {
<< "rs0"
<< "version"
<< static_cast<long long>(std::numeric_limits<int>::max()) + 1
- << "protocolVersion"
- << 1
- << "members"
+ << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345")))));
ASSERT_EQUALS(ErrorCodes::BadValue, config.validate());
@@ -394,21 +313,13 @@ TEST(ReplSetConfig, ParseFailsWithBadMembers) {
ASSERT_EQUALS(ErrorCodes::TypeMismatch,
config.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345")
<< "localhost:23456"))));
ASSERT_NOT_OK(config.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("host"
<< "localhost:12345")))));
}
@@ -417,11 +328,7 @@ TEST(ReplSetConfig, ParseFailsWithLocalNonLocalHostMix) {
ReplSetConfig config;
ASSERT_OK(config.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost")
<< BSON("_id" << 1 << "host"
@@ -433,15 +340,11 @@ TEST(ReplSetConfig, ParseFailsWithNoElectableNodes) {
ReplSetConfig config;
const BSONObj configBsonNoElectableNodes = BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
+ << "version" << 1 << "protocolVersion" << 1
<< "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:1"
- << "priority"
- << 0)
+ << "priority" << 0)
<< BSON("_id" << 1 << "host"
<< "localhost:2"
<< "priority"
@@ -450,57 +353,41 @@ TEST(ReplSetConfig, ParseFailsWithNoElectableNodes) {
ASSERT_OK(config.initialize(configBsonNoElectableNodes));
ASSERT_EQUALS(ErrorCodes::BadValue, config.validate());
- const BSONObj configBsonNoElectableNodesOneArbiter = BSON("_id"
- << "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 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 << "protocolVersion" << 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
- << "protocolVersion"
- << 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 << "protocolVersion" << 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
- << "protocolVersion"
- << 1
+ << "version" << 1 << "protocolVersion" << 1
<< "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:1"
- << "priority"
- << 0)
+ << "priority" << 0)
<< BSON("_id" << 1 << "host"
<< "localhost:2"
<< "priority"
@@ -511,46 +398,30 @@ TEST(ReplSetConfig, ParseFailsWithNoElectableNodes) {
TEST(ReplSetConfig, ParseFailsWithTooFewVoters) {
ReplSetConfig config;
- const BSONObj configBsonNoVoters = BSON("_id"
- << "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 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 << "protocolVersion" << 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
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 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());
}
@@ -567,11 +438,7 @@ TEST(ReplSetConfig, ParseFailsWithDuplicateHost) {
ReplSetConfig config;
const BSONObj configBson = BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:1")
<< BSON("_id" << 1 << "host"
@@ -621,14 +488,11 @@ TEST(ReplSetConfig, ParseFailsWithTooManyNodes) {
TEST(ReplSetConfig, ParseFailsWithUnexpectedField) {
ReplSetConfig config;
- Status status = config.initialize(BSON("_id"
- << "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "unexpectedfield"
- << "value"));
+ Status status =
+ config.initialize(BSON("_id"
+ << "rs0"
+ << "version" << 1 << "protocolVersion" << 1 << "unexpectedfield"
+ << "value"));
ASSERT_EQUALS(ErrorCodes::BadValue, status);
}
@@ -636,11 +500,7 @@ TEST(ReplSetConfig, ParseFailsWithNonArrayMembersField) {
ReplSetConfig config;
Status status = config.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< "value"));
ASSERT_EQUALS(ErrorCodes::TypeMismatch, status);
}
@@ -649,11 +509,7 @@ TEST(ReplSetConfig, ParseFailsWithNonNumericHeartbeatIntervalMillisField) {
ReplSetConfig config;
Status status = config.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"))
<< "settings"
@@ -671,11 +527,7 @@ TEST(ReplSetConfig, ParseFailsWithNonNumericElectionTimeoutMillisField) {
ReplSetConfig config;
Status status = config.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"))
<< "settings"
@@ -688,11 +540,7 @@ TEST(ReplSetConfig, ParseFailsWithNonNumericHeartbeatTimeoutSecsField) {
ReplSetConfig config;
Status status = config.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"))
<< "settings"
@@ -705,11 +553,7 @@ TEST(ReplSetConfig, ParseFailsWithNonBoolChainingAllowedField) {
ReplSetConfig config;
Status status = config.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"))
<< "settings"
@@ -722,11 +566,7 @@ TEST(ReplSetConfig, ParseFailsWithNonBoolConfigServerField) {
ReplSetConfig config;
Status status = config.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"))
<< "configsvr"
@@ -738,11 +578,7 @@ TEST(ReplSetConfig, ParseFailsWithNonObjectSettingsField) {
ReplSetConfig config;
Status status = config.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"))
<< "settings"
@@ -754,11 +590,7 @@ TEST(ReplSetConfig, ParseFailsWithGetLastErrorDefaultsFieldUnparseable) {
ReplSetConfig config;
Status status = config.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"))
<< "settings"
@@ -771,11 +603,7 @@ TEST(ReplSetConfig, ParseFailsWithNonObjectGetLastErrorDefaultsField) {
ReplSetConfig config;
Status status = config.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"))
<< "settings"
@@ -788,11 +616,7 @@ TEST(ReplSetConfig, ParseFailsWithNonObjectGetLastErrorModesField) {
ReplSetConfig config;
Status status = config.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"))
<< "settings"
@@ -805,11 +629,7 @@ TEST(ReplSetConfig, ParseFailsWithDuplicateGetLastErrorModesField) {
ReplSetConfig config;
Status status = config.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"
<< "tags"
@@ -824,20 +644,16 @@ TEST(ReplSetConfig, ParseFailsWithDuplicateGetLastErrorModesField) {
TEST(ReplSetConfig, ParseFailsWithNonObjectGetLastErrorModesEntryField) {
ReplSetConfig config;
- Status status = config.initialize(BSON("_id"
- << "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 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 << "protocolVersion" << 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);
}
@@ -846,11 +662,7 @@ TEST(ReplSetConfig, ParseFailsWithNonNumericGetLastErrorModesConstraintValue) {
Status status =
config.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"
<< "tags"
@@ -867,11 +679,7 @@ TEST(ReplSetConfig, ParseFailsWithNegativeGetLastErrorModesConstraintValue) {
Status status =
config.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"
<< "tags"
@@ -887,11 +695,7 @@ TEST(ReplSetConfig, ParseFailsWithNonExistentGetLastErrorModesConstraintTag) {
Status status =
config.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"
<< "tags"
@@ -906,13 +710,8 @@ TEST(ReplSetConfig, ParseFailsWithRepairField) {
ReplSetConfig config;
Status status = config.initialize(BSON("_id"
<< "rs0"
- << "repaired"
- << true
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "repaired" << true << "version" << 1
+ << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"))));
ASSERT_EQUALS(ErrorCodes::RepairedReplicaSetNode, status);
@@ -922,11 +721,7 @@ TEST(ReplSetConfig, ValidateFailsWithBadProtocolVersion) {
ReplSetConfig 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"
@@ -941,11 +736,7 @@ TEST(ReplSetConfig, ValidateFailsWithProtocolVersion0) {
ReplSetConfig config;
Status status = config.initialize(BSON("_id"
<< "rs0"
- << "protocolVersion"
- << 0
- << "version"
- << 1
- << "members"
+ << "protocolVersion" << 0 << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345")
<< BSON("_id" << 1 << "host"
@@ -960,11 +751,7 @@ TEST(ReplSetConfig, ValidateFailsWithDuplicateMemberId) {
ReplSetConfig config;
Status status = config.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345")
<< BSON("_id" << 0 << "host"
@@ -979,15 +766,10 @@ TEST(ReplSetConfig, ValidateFailsWithInvalidMember) {
ReplSetConfig config;
Status status = config.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"
- << "hidden"
- << true))));
+ << "hidden" << true))));
ASSERT_OK(status);
status = config.validate();
@@ -998,29 +780,19 @@ TEST(ReplSetConfig, ChainingAllowedField) {
ReplSetConfig config;
ASSERT_OK(config.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"))
- << "settings"
- << BSON("chainingAllowed" << true))));
+ << "settings" << BSON("chainingAllowed" << true))));
ASSERT_OK(config.validate());
ASSERT_TRUE(config.isChainingAllowed());
ASSERT_OK(config.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"))
- << "settings"
- << BSON("chainingAllowed" << false))));
+ << "settings" << BSON("chainingAllowed" << false))));
ASSERT_OK(config.validate());
ASSERT_FALSE(config.isChainingAllowed());
}
@@ -1029,13 +801,8 @@ TEST(ReplSetConfig, ConfigServerField) {
ReplSetConfig config;
ASSERT_OK(config.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")))));
ASSERT_TRUE(config.isConfigServer());
@@ -1043,13 +810,8 @@ TEST(ReplSetConfig, ConfigServerField) {
ReplSetConfig config2;
ASSERT_OK(config2.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "configsvr"
- << false
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "configsvr"
+ << false << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345")))));
ASSERT_FALSE(config2.isConfigServer());
@@ -1072,25 +834,18 @@ TEST(ReplSetConfig, ConfigServerFieldDefaults) {
ReplSetConfig 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());
ReplSetConfig 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;
@@ -1099,25 +854,18 @@ TEST(ReplSetConfig, ConfigServerFieldDefaults) {
ReplSetConfig 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());
ReplSetConfig 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());
}
@@ -1125,29 +873,19 @@ TEST(ReplSetConfig, HeartbeatIntervalField) {
ReplSetConfig config;
ASSERT_OK(config.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"))
- << "settings"
- << BSON("heartbeatIntervalMillis" << 5000))));
+ << "settings" << BSON("heartbeatIntervalMillis" << 5000))));
ASSERT_OK(config.validate());
ASSERT_EQUALS(Seconds(5), config.getHeartbeatInterval());
ASSERT_OK(config.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"))
- << "settings"
- << BSON("heartbeatIntervalMillis" << -5000))));
+ << "settings" << BSON("heartbeatIntervalMillis" << -5000))));
ASSERT_EQUALS(ErrorCodes::BadValue, config.validate());
}
@@ -1155,29 +893,19 @@ TEST(ReplSetConfig, ElectionTimeoutField) {
ReplSetConfig config;
ASSERT_OK(config.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"))
- << "settings"
- << BSON("electionTimeoutMillis" << 20))));
+ << "settings" << BSON("electionTimeoutMillis" << 20))));
ASSERT_OK(config.validate());
ASSERT_EQUALS(Milliseconds(20), config.getElectionTimeoutPeriod());
auto status = config.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 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");
}
@@ -1186,29 +914,19 @@ TEST(ReplSetConfig, HeartbeatTimeoutField) {
ReplSetConfig config;
ASSERT_OK(config.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"))
- << "settings"
- << BSON("heartbeatTimeoutSecs" << 20))));
+ << "settings" << BSON("heartbeatTimeoutSecs" << 20))));
ASSERT_OK(config.validate());
ASSERT_EQUALS(Seconds(20), config.getHeartbeatTimeoutPeriod());
auto status = config.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 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");
}
@@ -1217,11 +935,7 @@ TEST(ReplSetConfig, GleDefaultField) {
ReplSetConfig config;
ASSERT_OK(config.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"))
<< "settings"
@@ -1232,11 +946,7 @@ TEST(ReplSetConfig, GleDefaultField) {
ASSERT_OK(config.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"))
<< "settings"
@@ -1244,27 +954,19 @@ TEST(ReplSetConfig, GleDefaultField) {
<< "frim")))));
ASSERT_EQUALS(ErrorCodes::BadValue, config.validate());
- ASSERT_OK(config.initialize(BSON("_id"
- << "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "localhost:12345"))
- << "settings"
- << BSON("getLastErrorDefaults" << BSON("w" << 0)))));
+ ASSERT_OK(
+ config.initialize(BSON("_id"
+ << "rs0"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "localhost:12345"))
+ << "settings" << BSON("getLastErrorDefaults" << BSON("w" << 0)))));
ASSERT_EQUALS(ErrorCodes::BadValue, config.validate());
ASSERT_OK(
config.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"
<< "tags"
@@ -1352,19 +1054,15 @@ bool operator==(const ReplSetConfig& a, const ReplSetConfig& b) {
TEST(ReplSetConfig, toBSONRoundTripAbility) {
ReplSetConfig configA;
ReplSetConfig configB;
- ASSERT_OK(configA.initialize(BSON(
- "_id"
- << "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 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 << "protocolVersion" << 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);
}
@@ -1372,132 +1070,83 @@ TEST(ReplSetConfig, toBSONRoundTripAbility) {
TEST(ReplSetConfig, toBSONRoundTripAbilityWithHorizon) {
ReplSetConfig configA;
ReplSetConfig configB;
+ ASSERT_OK(configA.initialize(BSON("_id"
+ << "rs0"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "localhost:12345"
+ << "horizons"
+ << BSON("horizon"
+ << "example.com:42")))
+ << "settings"
+ << BSON("heartbeatIntervalMillis"
+ << 5000 << "heartbeatTimeoutSecs" << 20
+ << "replicaSetId" << OID::gen()))));
+ ASSERT_OK(configB.initialize(configA.toBSON()));
+ ASSERT_TRUE(configA == configB);
+}
+
+TEST(ReplSetConfig, toBSONRoundTripAbilityLarge) {
+ ReplSetConfig configA;
+ ReplSetConfig configB;
ASSERT_OK(configA.initialize(BSON(
"_id"
- << "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "asdf"
+ << "version" << 9 << "writeConcernMajorityJournalDefault" << true << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"
- << "horizons"
- << BSON("horizon"
- << "example.com:42")))
- << "settings"
- << BSON("heartbeatIntervalMillis" << 5000 << "heartbeatTimeoutSecs" << 20 << "replicaSetId"
- << OID::gen()))));
- ASSERT_OK(configB.initialize(configA.toBSON()));
+ << "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" << 1 << "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();
+ ASSERT_OK(configB.initialize(configObjA));
ASSERT_TRUE(configA == configB);
}
-TEST(ReplSetConfig, toBSONRoundTripAbilityLarge) {
+TEST(ReplSetConfig, toBSONRoundTripAbilityInvalid) {
ReplSetConfig configA;
ReplSetConfig configB;
ASSERT_OK(configA.initialize(
BSON("_id"
- << "asdf"
- << "version"
- << 9
- << "writeConcernMajorityJournalDefault"
- << true
- << "members"
+ << ""
+ << "version" << -3 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"
- << "arbiterOnly"
- << true
- << "votes"
- << 1)
- << BSON("_id" << 3 << "host"
+ << "arbiterOnly" << true << "votes" << 0 << "priority" << 0)
+ << BSON("_id" << 0 << "host"
<< "localhost:3828"
- << "arbiterOnly"
- << false
- << "hidden"
- << true
- << "buildIndexes"
- << false
- << "priority"
- << 0
- << "slaveDelay"
- << 17
- << "votes"
- << 0
- << "tags"
- << BSON("coast"
- << "east"
- << "ssd"
- << "true"))
+ << "arbiterOnly" << false << "buildIndexes" << false
+ << "priority" << 2)
<< BSON("_id" << 2 << "host"
- << "foo.com:3828"
- << "votes"
- << 0
- << "priority"
- << 0
- << "tags"
- << BSON("coast"
- << "west"
- << "hdd"
- << "true")))
- << "protocolVersion"
- << 1
+ << "localhost:3828"
+ << "votes" << 0 << "priority" << 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();
- ASSERT_OK(configB.initialize(configObjA));
- ASSERT_TRUE(configA == configB);
-}
-
-TEST(ReplSetConfig, toBSONRoundTripAbilityInvalid) {
- ReplSetConfig configA;
- ReplSetConfig configB;
- ASSERT_OK(
- configA.initialize(BSON("_id"
- << ""
- << "version"
- << -3
- << "protocolVersion"
- << 1
- << "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))));
+ << BSON("heartbeatIntervalMillis" << -5000 << "heartbeatTimeoutSecs" << 20
+ << "electionTimeoutMillis" << 2))));
ASSERT_OK(configB.initialize(configA.toBSON()));
ASSERT_NOT_OK(configA.validate());
ASSERT_NOT_OK(configB.validate());
@@ -1506,59 +1155,52 @@ TEST(ReplSetConfig, toBSONRoundTripAbilityInvalid) {
TEST(ReplSetConfig, CheckIfWriteConcernCanBeSatisfied) {
ReplSetConfig configA;
- ASSERT_OK(configA.initialize(BSON("_id"
- << "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 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 << "protocolVersion" << 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;
@@ -1619,19 +1261,13 @@ TEST(ReplSetConfig, CheckConfigServerCantHaveArbiters) {
ReplSetConfig 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");
@@ -1641,21 +1277,14 @@ TEST(ReplSetConfig, CheckConfigServerMustBuildIndexes) {
ReplSetConfig 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");
@@ -1665,20 +1294,13 @@ TEST(ReplSetConfig, CheckConfigServerCantHaveSlaveDelay) {
ReplSetConfig 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
- << "slaveDelay"
+ << "priority" << 0 << "slaveDelay"
<< 3)))));
Status status = configA.validate();
ASSERT_EQUALS(ErrorCodes::BadValue, status);
@@ -1691,19 +1313,13 @@ TEST(ReplSetConfig, CheckConfigServerMustHaveTrueForWriteConcernMajorityJournalD
ReplSetConfig 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"))
- << "writeConcernMajorityJournalDefault"
- << false)));
+ << "writeConcernMajorityJournalDefault" << false)));
Status status = configA.validate();
ASSERT_EQUALS(ErrorCodes::BadValue, status);
ASSERT_STRING_CONTAINS(status.reason(), " must be true in replica set configurations being ");
@@ -1713,33 +1329,23 @@ TEST(ReplSetConfig, GetPriorityTakeoverDelay) {
ReplSetConfig configA;
ASSERT_OK(configA.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 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"
- << BSON("electionTimeoutMillis" << 1000))));
+ << "priority" << 5))
+ << "settings" << BSON("electionTimeoutMillis" << 1000))));
ASSERT_OK(configA.validate());
ASSERT_EQUALS(Milliseconds(5000), configA.getPriorityTakeoverDelay(0));
ASSERT_EQUALS(Milliseconds(4000), configA.getPriorityTakeoverDelay(1));
@@ -1750,33 +1356,23 @@ TEST(ReplSetConfig, GetPriorityTakeoverDelay) {
ReplSetConfig configB;
ASSERT_OK(configB.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 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"
- << BSON("electionTimeoutMillis" << 1000))));
+ << "priority" << 3))
+ << "settings" << BSON("electionTimeoutMillis" << 1000))));
ASSERT_OK(configB.validate());
ASSERT_EQUALS(Milliseconds(5000), configB.getPriorityTakeoverDelay(0));
ASSERT_EQUALS(Milliseconds(3000), configB.getPriorityTakeoverDelay(1));
@@ -1789,29 +1385,20 @@ TEST(ReplSetConfig, GetCatchUpTakeoverDelay) {
ReplSetConfig config;
ASSERT_OK(config.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"))
- << "settings"
- << BSON("catchUpTakeoverDelayMillis" << 5000))));
+ << "settings" << BSON("catchUpTakeoverDelayMillis" << 5000))));
ASSERT_OK(config.validate());
ASSERT_EQUALS(Milliseconds(5000), config.getCatchUpTakeoverDelay());
- Status status = config.initialize(BSON("_id"
- << "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
- << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "localhost:12345"))
- << "settings"
- << BSON("catchUpTakeoverDelayMillis" << -5000)));
+ Status status =
+ config.initialize(BSON("_id"
+ << "rs0"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "localhost:12345"))
+ << "settings" << BSON("catchUpTakeoverDelayMillis" << -5000)));
ASSERT_EQUALS(ErrorCodes::BadValue, status);
ASSERT_STRING_CONTAINS(
status.reason(),
@@ -1822,23 +1409,16 @@ TEST(ReplSetConfig, GetCatchUpTakeoverDelayDefault) {
ReplSetConfig config;
ASSERT_OK(config.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 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)))));
ASSERT_OK(config.validate());
ASSERT_EQUALS(Milliseconds(30000), config.getCatchUpTakeoverDelay());
}
@@ -1849,11 +1429,7 @@ TEST(ReplSetConfig, ConfirmDefaultValuesOfAndAbilityToSetWriteConcernMajorityJou
// 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());
@@ -1863,15 +1439,10 @@ TEST(ReplSetConfig, ConfirmDefaultValuesOfAndAbilityToSetWriteConcernMajorityJou
// 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"));
@@ -1881,11 +1452,7 @@ TEST(ReplSetConfig, HorizonConsistency) {
ReplSetConfig 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"
<< "horizons"
@@ -1914,8 +1481,7 @@ TEST(ReplSetConfig, HorizonConsistency) {
<< "delta"
<< "c.host3:44")))
- << "writeConcernMajorityJournalDefault"
- << false)));
+ << "writeConcernMajorityJournalDefault" << false)));
Status status = config.validate();
ASSERT_NOT_OK(status);
@@ -1929,11 +1495,7 @@ TEST(ReplSetConfig, HorizonConsistency) {
// in the member-config code path.
status = config.initialize(BSON("_id"
<< "rs0"
- << "protocolVersion"
- << 1
- << "version"
- << 1
- << "members"
+ << "protocolVersion" << 1 << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "same1"
<< "horizons"
@@ -1978,8 +1540,7 @@ TEST(ReplSetConfig, HorizonConsistency) {
<< "d.host3:44"
<< "delta"
<< "d.host4:44")))
- << "writeConcernMajorityJournalDefault"
- << false));
+ << "writeConcernMajorityJournalDefault" << false));
ASSERT_OK(status) << " failing status was: " << status.reason();
status = config.validate();
@@ -2003,15 +1564,11 @@ TEST(ReplSetConfig, ReplSetId) {
auto status =
ReplSetConfig().initializeForInitiate(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
+ << "version" << 1 << "protocolVersion" << 1
<< "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"
- << "priority"
- << 1))
+ << "priority" << 1))
<< "settings"
<< BSON("replicaSetId" << OID::gen())));
ASSERT_EQUALS(ErrorCodes::InvalidReplicaSetConfig, status);
@@ -2025,15 +1582,11 @@ TEST(ReplSetConfig, ReplSetId) {
ASSERT_OK(
configInitiate.initializeForInitiate(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
+ << "version" << 1 << "protocolVersion" << 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();
@@ -2042,17 +1595,11 @@ TEST(ReplSetConfig, ReplSetId) {
ReplSetConfig configLocal;
ASSERT_OK(configLocal.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 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());
@@ -2061,15 +1608,10 @@ TEST(ReplSetConfig, ReplSetId) {
OID defaultReplicaSetId = OID::gen();
ASSERT_OK(configLocal.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"
- << "priority"
- << 1))),
+ << "priority" << 1))),
defaultReplicaSetId));
ASSERT_OK(configLocal.validate());
ASSERT_TRUE(configLocal.hasReplicaSetId());
@@ -2078,34 +1620,22 @@ TEST(ReplSetConfig, ReplSetId) {
// 'replicaSetId' field cannot be null.
status = configLocal.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"
- << "priority"
- << 1))
- << "settings"
- << BSON("replicaSetId" << OID())));
+ << "priority" << 1))
+ << "settings" << BSON("replicaSetId" << OID())));
ASSERT_EQUALS(ErrorCodes::BadValue, status);
ASSERT_STRING_CONTAINS(status.reason(), "replicaSetId field value cannot be null");
// 'replicaSetId' field must be an OID.
status = configLocal.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345"
- << "priority"
- << 1))
- << "settings"
- << BSON("replicaSetId" << 12345)));
+ << "priority" << 1))
+ << "settings" << BSON("replicaSetId" << 12345)));
ASSERT_EQUALS(ErrorCodes::TypeMismatch, status);
ASSERT_STRING_CONTAINS(status.reason(),
"\"replicaSetId\" had the wrong type. Expected objectId, found int");
diff --git a/src/mongo/db/repl/repl_set_heartbeat_args_v1.cpp b/src/mongo/db/repl/repl_set_heartbeat_args_v1.cpp
index 3b79768db8d..a7cc785995e 100644
--- a/src/mongo/db/repl/repl_set_heartbeat_args_v1.cpp
+++ b/src/mongo/db/repl/repl_set_heartbeat_args_v1.cpp
@@ -78,10 +78,9 @@ Status ReplSetHeartbeatArgsV1::initialize(const BSONObj& argsObj) {
if (status.isOK()) {
if (tempHeartbeatVersion != 1) {
return Status(ErrorCodes::Error(40666),
- str::stream() << "Found invalid value for field "
- << kHeartbeatVersionFieldName
- << ": "
- << tempHeartbeatVersion);
+ str::stream()
+ << "Found invalid value for field " << kHeartbeatVersionFieldName
+ << ": " << tempHeartbeatVersion);
}
_heartbeatVersion = tempHeartbeatVersion;
_hasHeartbeatVersion = true;
diff --git a/src/mongo/db/repl/repl_set_heartbeat_response.cpp b/src/mongo/db/repl/repl_set_heartbeat_response.cpp
index 4b16c88e389..5c43a35c71b 100644
--- a/src/mongo/db/repl/repl_set_heartbeat_response.cpp
+++ b/src/mongo/db/repl/repl_set_heartbeat_response.cpp
@@ -193,18 +193,18 @@ Status ReplSetHeartbeatResponse::initialize(const BSONObj& doc,
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);
@@ -217,8 +217,7 @@ Status ReplSetHeartbeatResponse::initialize(const BSONObj& doc,
if (configVersionElement.eoo()) {
return Status(ErrorCodes::NoSuchKey,
str::stream() << "Response to replSetHeartbeat missing required \""
- << kConfigVersionFieldName
- << "\" field");
+ << kConfigVersionFieldName << "\" field");
}
if (configVersionElement.type() != NumberInt) {
return Status(ErrorCodes::TypeMismatch,
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 f3f0f1ce8bb..352456c929d 100644
--- a/src/mongo/db/repl/repl_set_heartbeat_response_test.cpp
+++ b/src/mongo/db/repl/repl_set_heartbeat_response_test.cpp
@@ -166,19 +166,16 @@ TEST(ReplSetHeartbeatResponse, InitializeNoDurableWallTime) {
TEST(ReplSetHeartbeatResponse, InitializeWrongAppliedOpTimeType) {
ReplSetHeartbeatResponse hbResponse;
- BSONObj initializerObj = BSON(
- "ok" << 1.0 << "durableOpTime" << OpTime(Timestamp(100, 0), 0).toBSON() << "durableWallTime"
- << Date_t() + Seconds(100)
- << "opTime"
- << "hello");
+ BSONObj initializerObj =
+ BSON("ok" << 1.0 << "durableOpTime" << OpTime(Timestamp(100, 0), 0).toBSON()
+ << "durableWallTime" << Date_t() + Seconds(100) << "opTime"
+ << "hello");
Status result = hbResponse.initialize(initializerObj, 0, /*requireWallTime*/ true);
ASSERT_EQUALS(ErrorCodes::TypeMismatch, result);
ASSERT_EQUALS("\"opTime\" had the wrong type. Expected object, found string", result.reason());
initializerObj = BSON("ok" << 1.0 << "durableOpTime" << OpTime(Timestamp(100, 0), 0).toBSON()
- << "durableWallTime"
- << Date_t() + Seconds(100)
- << "opTime"
+ << "durableWallTime" << Date_t() + Seconds(100) << "opTime"
<< OpTime().getTimestamp());
result = hbResponse.initialize(initializerObj, 0, /*requireWallTime*/ true);
ASSERT_EQUALS(ErrorCodes::TypeMismatch, result);
@@ -190,9 +187,7 @@ TEST(ReplSetHeartbeatResponse, InitializeNoAppliedWallTime) {
ReplSetHeartbeatResponse hbResponse;
BSONObj initializerObj = BSON(
"ok" << 1.0 << "durableOpTime" << OpTime(Timestamp(100, 0), 0).toBSON() << "durableWallTime"
- << Date_t() + Seconds(100)
- << "opTime"
- << OpTime(Timestamp(100, 0), 0).toBSON());
+ << Date_t() + Seconds(100) << "opTime" << OpTime(Timestamp(100, 0), 0).toBSON());
Status result = hbResponse.initialize(initializerObj, 0, /*requireWallTime*/ true);
ASSERT_EQUALS(ErrorCodes::NoSuchKey, result);
ASSERT_EQUALS("Missing expected field \"wallTime\"", result.reason());
@@ -202,12 +197,8 @@ TEST(ReplSetHeartbeatResponse, InitializeMemberStateWrongType) {
ReplSetHeartbeatResponse hbResponse;
BSONObj initializerObj = BSON(
"ok" << 1.0 << "durableOpTime" << OpTime(Timestamp(100, 0), 0).toBSON() << "durableWallTime"
- << Date_t() + Seconds(100)
- << "opTime"
- << OpTime(Timestamp(100, 0), 0).toBSON()
- << "wallTime"
- << Date_t() + Seconds(100)
- << "state"
+ << Date_t() + Seconds(100) << "opTime" << OpTime(Timestamp(100, 0), 0).toBSON()
+ << "wallTime" << Date_t() + Seconds(100) << "state"
<< "hello");
Status result = hbResponse.initialize(initializerObj, 0, /*requireWallTime*/ true);
ASSERT_EQUALS(ErrorCodes::TypeMismatch, result);
@@ -221,13 +212,8 @@ TEST(ReplSetHeartbeatResponse, InitializeMemberStateTooLow) {
ReplSetHeartbeatResponse hbResponse;
BSONObj initializerObj = BSON(
"ok" << 1.0 << "durableOpTime" << OpTime(Timestamp(100, 0), 0).toBSON() << "durableWallTime"
- << Date_t() + Seconds(100)
- << "opTime"
- << OpTime(Timestamp(100, 0), 0).toBSON()
- << "wallTime"
- << Date_t() + Seconds(100)
- << "state"
- << -1);
+ << Date_t() + Seconds(100) << "opTime" << OpTime(Timestamp(100, 0), 0).toBSON()
+ << "wallTime" << Date_t() + Seconds(100) << "state" << -1);
Status result = hbResponse.initialize(initializerObj, 0, /*requireWallTime*/ true);
ASSERT_EQUALS(ErrorCodes::BadValue, result);
ASSERT_EQUALS(
@@ -240,13 +226,8 @@ TEST(ReplSetHeartbeatResponse, InitializeMemberStateTooHigh) {
ReplSetHeartbeatResponse hbResponse;
BSONObj initializerObj = BSON(
"ok" << 1.0 << "durableOpTime" << OpTime(Timestamp(100, 0), 0).toBSON() << "durableWallTime"
- << Date_t() + Seconds(100)
- << "opTime"
- << OpTime(Timestamp(100, 0), 0).toBSON()
- << "wallTime"
- << Date_t() + Seconds(100)
- << "state"
- << 11);
+ << Date_t() + Seconds(100) << "opTime" << OpTime(Timestamp(100, 0), 0).toBSON()
+ << "wallTime" << Date_t() + Seconds(100) << "state" << 11);
Status result = hbResponse.initialize(initializerObj, 0, /*requireWallTime*/ true);
ASSERT_EQUALS(ErrorCodes::BadValue, result);
ASSERT_EQUALS(
@@ -259,12 +240,8 @@ TEST(ReplSetHeartbeatResponse, InitializeVersionWrongType) {
ReplSetHeartbeatResponse hbResponse;
BSONObj initializerObj = BSON(
"ok" << 1.0 << "durableOpTime" << OpTime(Timestamp(100, 0), 0).toBSON() << "durableWallTime"
- << Date_t() + Seconds(100)
- << "opTime"
- << OpTime(Timestamp(100, 0), 0).toBSON()
- << "wallTime"
- << Date_t() + Seconds(100)
- << "v"
+ << Date_t() + Seconds(100) << "opTime" << OpTime(Timestamp(100, 0), 0).toBSON()
+ << "wallTime" << Date_t() + Seconds(100) << "v"
<< "hello");
Status result = hbResponse.initialize(initializerObj, 0, /*requireWallTime*/ true);
ASSERT_EQUALS(ErrorCodes::TypeMismatch, result);
@@ -276,17 +253,12 @@ TEST(ReplSetHeartbeatResponse, InitializeVersionWrongType) {
TEST(ReplSetHeartbeatResponse, InitializeReplSetNameWrongType) {
ReplSetHeartbeatResponse hbResponse;
- BSONObj initializerObj = BSON(
- "ok" << 1.0 << "durableOpTime" << OpTime(Timestamp(100, 0), 0).toBSON() << "durableWallTime"
- << Date_t() + Seconds(100)
- << "opTime"
- << OpTime(Timestamp(100, 0), 0).toBSON()
- << "wallTime"
- << Date_t() + Seconds(100)
- << "v"
- << 2 // needs a version to get this far in initialize()
- << "set"
- << 4);
+ BSONObj initializerObj =
+ BSON("ok" << 1.0 << "durableOpTime" << OpTime(Timestamp(100, 0), 0).toBSON()
+ << "durableWallTime" << Date_t() + Seconds(100) << "opTime"
+ << OpTime(Timestamp(100, 0), 0).toBSON() << "wallTime" << Date_t() + Seconds(100)
+ << "v" << 2 // needs a version to get this far in initialize()
+ << "set" << 4);
Status result = hbResponse.initialize(initializerObj, 0, /*requireWallTime*/ true);
ASSERT_EQUALS(ErrorCodes::TypeMismatch, result);
ASSERT_EQUALS(
@@ -297,17 +269,12 @@ TEST(ReplSetHeartbeatResponse, InitializeReplSetNameWrongType) {
TEST(ReplSetHeartbeatResponse, InitializeSyncingToWrongType) {
ReplSetHeartbeatResponse hbResponse;
- BSONObj initializerObj = BSON(
- "ok" << 1.0 << "durableOpTime" << OpTime(Timestamp(100, 0), 0).toBSON() << "durableWallTime"
- << Date_t() + Seconds(100)
- << "opTime"
- << OpTime(Timestamp(100, 0), 0).toBSON()
- << "wallTime"
- << Date_t() + Seconds(100)
- << "v"
- << 2 // needs a version to get this far in initialize()
- << "syncingTo"
- << 4);
+ BSONObj initializerObj =
+ BSON("ok" << 1.0 << "durableOpTime" << OpTime(Timestamp(100, 0), 0).toBSON()
+ << "durableWallTime" << Date_t() + Seconds(100) << "opTime"
+ << OpTime(Timestamp(100, 0), 0).toBSON() << "wallTime" << Date_t() + Seconds(100)
+ << "v" << 2 // needs a version to get this far in initialize()
+ << "syncingTo" << 4);
Status result = hbResponse.initialize(initializerObj, 0, /*requireWallTime*/ true);
ASSERT_EQUALS(ErrorCodes::TypeMismatch, result);
ASSERT_EQUALS(
@@ -318,17 +285,12 @@ TEST(ReplSetHeartbeatResponse, InitializeSyncingToWrongType) {
TEST(ReplSetHeartbeatResponse, InitializeConfigWrongType) {
ReplSetHeartbeatResponse hbResponse;
- BSONObj initializerObj = BSON(
- "ok" << 1.0 << "durableOpTime" << OpTime(Timestamp(100, 0), 0).toBSON() << "durableWallTime"
- << Date_t() + Seconds(100)
- << "opTime"
- << OpTime(Timestamp(100, 0), 0).toBSON()
- << "wallTime"
- << Date_t() + Seconds(100)
- << "v"
- << 2 // needs a version to get this far in initialize()
- << "config"
- << 4);
+ BSONObj initializerObj =
+ BSON("ok" << 1.0 << "durableOpTime" << OpTime(Timestamp(100, 0), 0).toBSON()
+ << "durableWallTime" << Date_t() + Seconds(100) << "opTime"
+ << OpTime(Timestamp(100, 0), 0).toBSON() << "wallTime" << Date_t() + Seconds(100)
+ << "v" << 2 // needs a version to get this far in initialize()
+ << "config" << 4);
Status result = hbResponse.initialize(initializerObj, 0, /*requireWallTime*/ true);
ASSERT_EQUALS(ErrorCodes::TypeMismatch, result);
ASSERT_EQUALS(
@@ -339,17 +301,12 @@ TEST(ReplSetHeartbeatResponse, InitializeConfigWrongType) {
TEST(ReplSetHeartbeatResponse, InitializeBadConfig) {
ReplSetHeartbeatResponse hbResponse;
- BSONObj initializerObj = BSON(
- "ok" << 1.0 << "durableOpTime" << OpTime(Timestamp(100, 0), 0).toBSON() << "durableWallTime"
- << Date_t() + Seconds(100)
- << "opTime"
- << OpTime(Timestamp(100, 0), 0).toBSON()
- << "wallTime"
- << Date_t() + Seconds(100)
- << "v"
- << 2 // needs a version to get this far in initialize()
- << "config"
- << BSON("illegalFieldName" << 2));
+ BSONObj initializerObj =
+ BSON("ok" << 1.0 << "durableOpTime" << OpTime(Timestamp(100, 0), 0).toBSON()
+ << "durableWallTime" << Date_t() + Seconds(100) << "opTime"
+ << OpTime(Timestamp(100, 0), 0).toBSON() << "wallTime" << Date_t() + Seconds(100)
+ << "v" << 2 // needs a version to get this far in initialize()
+ << "config" << BSON("illegalFieldName" << 2));
Status result = hbResponse.initialize(initializerObj, 0, /*requireWallTime*/ true);
ASSERT_EQUALS(ErrorCodes::BadValue, result);
ASSERT_EQUALS("Unexpected field illegalFieldName in replica set configuration",
@@ -371,12 +328,9 @@ TEST(ReplSetHeartbeatResponse, InvalidResponseOpTimeMissesConfigVersion) {
ReplSetHeartbeatResponse hbResp;
Status result = hbResp.initialize(BSON("ok" << 1.0 << "durableOpTime"
<< OpTime(Timestamp(100, 0), 0).toBSON()
- << "durableWallTime"
- << Date_t() + Seconds(100)
- << "opTime"
- << OpTime(Timestamp(100, 0), 0).toBSON()
- << "wallTime"
- << Date_t() + Seconds(100)),
+ << "durableWallTime" << Date_t() + Seconds(100)
+ << "opTime" << OpTime(Timestamp(100, 0), 0).toBSON()
+ << "wallTime" << Date_t() + Seconds(100)),
0,
/*requireWallTime*/ true);
ASSERT_EQUALS(ErrorCodes::NoSuchKey, result.code());
diff --git a/src/mongo/db/repl/replication_consistency_markers_impl.cpp b/src/mongo/db/repl/replication_consistency_markers_impl.cpp
index f2127b70518..a57b7e35ceb 100644
--- a/src/mongo/db/repl/replication_consistency_markers_impl.cpp
+++ b/src/mongo/db/repl/replication_consistency_markers_impl.cpp
@@ -100,8 +100,7 @@ void ReplicationConsistencyMarkersImpl::initializeMinValidDocument(OperationCont
// will always be greater than the provided ones.
TimestampedBSONObj upsert;
upsert.obj = BSON("$max" << BSON(MinValidDocument::kMinValidTimestampFieldName
- << Timestamp()
- << MinValidDocument::kMinValidTermFieldName
+ << Timestamp() << MinValidDocument::kMinValidTermFieldName
<< OpTime::kUninitializedTerm));
// The initialization write should go into the first checkpoint taken, so we provide no
@@ -153,10 +152,8 @@ void ReplicationConsistencyMarkersImpl::clearInitialSyncFlag(OperationContext* o
update.obj = BSON("$unset" << kInitialSyncFlag << "$set"
<< BSON(MinValidDocument::kMinValidTimestampFieldName
<< time.getTimestamp()
- << MinValidDocument::kMinValidTermFieldName
- << time.getTerm()
- << MinValidDocument::kAppliedThroughFieldName
- << time));
+ << MinValidDocument::kMinValidTermFieldName << time.getTerm()
+ << MinValidDocument::kAppliedThroughFieldName << time));
// We clear the initial sync flag at the 'lastAppliedOpTime'. This is unnecessary, since there
// should not be any stable checkpoints being taken that this write could inadvertantly enter.
@@ -194,10 +191,10 @@ void ReplicationConsistencyMarkersImpl::setMinValid(OperationContext* opCtx,
LOG(3) << "setting minvalid to exactly: " << minValid.toString() << "(" << minValid.toBSON()
<< ")";
TimestampedBSONObj update;
- update.obj = BSON("$set" << BSON(MinValidDocument::kMinValidTimestampFieldName
- << minValid.getTimestamp()
- << MinValidDocument::kMinValidTermFieldName
- << minValid.getTerm()));
+ update.obj =
+ BSON("$set" << BSON(MinValidDocument::kMinValidTimestampFieldName
+ << minValid.getTimestamp() << MinValidDocument::kMinValidTermFieldName
+ << minValid.getTerm()));
// This method is only used with storage engines that do not support recover to stable
// timestamp. As a result, their timestamps do not matter.
@@ -346,8 +343,8 @@ Status ReplicationConsistencyMarkersImpl::createInternalCollections(OperationCon
auto status = _storageInterface->createCollection(opCtx, nss, CollectionOptions());
if (!status.isOK() && status.code() != ErrorCodes::NamespaceExists) {
return {ErrorCodes::CannotCreateCollection,
- str::stream() << "Failed to create collection. Ns: " << nss.ns() << " Error: "
- << status.toString()};
+ str::stream() << "Failed to create collection. Ns: " << nss.ns()
+ << " Error: " << status.toString()};
}
}
diff --git a/src/mongo/db/repl/replication_coordinator.h b/src/mongo/db/repl/replication_coordinator.h
index b9eee2a78a9..8b767924eac 100644
--- a/src/mongo/db/repl/replication_coordinator.h
+++ b/src/mongo/db/repl/replication_coordinator.h
@@ -774,12 +774,12 @@ public:
virtual std::vector<MemberData> getMemberData() const = 0;
/*
- * Handles an incoming replSetRequestVotes command.
- *
- * Populates the given 'response' object with the result of the request. If there is a failure
- * processing the vote request, returns an error status. If an error is returned, the value of
- * the populated 'response' object is invalid.
- */
+ * Handles an incoming replSetRequestVotes command.
+ *
+ * Populates the given 'response' object with the result of the request. If there is a failure
+ * processing the vote request, returns an error status. If an error is returned, the value of
+ * the populated 'response' object is invalid.
+ */
virtual Status processReplSetRequestVotes(OperationContext* opCtx,
const ReplSetRequestVotesArgs& args,
ReplSetRequestVotesResponse* response) = 0;
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 c2744e2bb5a..65cb2744ec4 100644
--- a/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp
@@ -171,13 +171,13 @@ auto makeTaskExecutor(ServiceContext* service, const std::string& poolName) {
* down.
*/
void scheduleWork(executor::TaskExecutor* executor, executor::TaskExecutor::CallbackFn work) {
- auto cbh = executor->scheduleWork([work = std::move(work)](
- const executor::TaskExecutor::CallbackArgs& args) {
- if (args.status == ErrorCodes::CallbackCanceled) {
- return;
- }
- work(args);
- });
+ auto cbh = executor->scheduleWork(
+ [work = std::move(work)](const executor::TaskExecutor::CallbackArgs& args) {
+ if (args.status == ErrorCodes::CallbackCanceled) {
+ return;
+ }
+ work(args);
+ });
if (cbh == ErrorCodes::ShutdownInProgress) {
return;
}
@@ -529,9 +529,7 @@ Status ReplicationCoordinatorExternalStateImpl::createLocalLastVoteCollection(
if (!status.isOK() && status.code() != ErrorCodes::NamespaceExists) {
return {ErrorCodes::CannotCreateCollection,
str::stream() << "Failed to create local last vote collection. Ns: "
- << lastVoteCollectionName
- << " Error: "
- << status.toString()};
+ << lastVoteCollectionName << " Error: " << status.toString()};
}
// Make sure there's always a last vote document.
@@ -659,9 +657,7 @@ StatusWith<OpTimeAndWallTime> ReplicationCoordinatorExternalStateImpl::loadLastO
return StatusWith<OpTimeAndWallTime>(
ErrorCodes::NoSuchKey,
str::stream() << "Most recent entry in " << NamespaceString::kRsOplogNamespace.ns()
- << " missing \""
- << tsFieldName
- << "\" field");
+ << " missing \"" << tsFieldName << "\" field");
}
if (tsElement.type() != bsonTimestamp) {
return StatusWith<OpTimeAndWallTime>(
diff --git a/src/mongo/db/repl/replication_coordinator_external_state_impl.h b/src/mongo/db/repl/replication_coordinator_external_state_impl.h
index c7ea74e610a..645ac39e28b 100644
--- a/src/mongo/db/repl/replication_coordinator_external_state_impl.h
+++ b/src/mongo/db/repl/replication_coordinator_external_state_impl.h
@@ -132,11 +132,11 @@ private:
void _shardingOnTransitionToPrimaryHook(OperationContext* opCtx);
/**
- * Drops all temporary collections on all databases except "local".
- *
- * The implementation may assume that the caller has acquired the global exclusive lock
- * for "opCtx".
- */
+ * Drops all temporary collections on all databases except "local".
+ *
+ * The implementation may assume that the caller has acquired the global exclusive lock
+ * for "opCtx".
+ */
void _dropAllTempCollections(OperationContext* opCtx);
ServiceContext* _service;
diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp
index 3f56ada6698..b23082ecb55 100644
--- a/src/mongo/db/repl/replication_coordinator_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl.cpp
@@ -930,10 +930,9 @@ Status ReplicationCoordinatorImpl::waitForMemberState(MemberState expectedState,
auto pred = [this, expectedState]() { return _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 "
- << _memberState.toString());
+ str::stream()
+ << "Timed out waiting for state to become " << expectedState.toString()
+ << ". Current state is " << _memberState.toString());
}
return Status::OK();
}
@@ -1645,8 +1644,9 @@ bool ReplicationCoordinatorImpl::_doneWaitingForReplication_inlock(
"'committed' optime "
<< opTime
<< ". There are still drop pending collections (earliest drop optime: "
- << *dropOpTime << ") that have to be removed from storage before we can "
- "satisfy the write concern "
+ << *dropOpTime
+ << ") that have to be removed from storage before we can "
+ "satisfy the write concern "
<< writeConcern.toBSON();
return false;
}
diff --git a/src/mongo/db/repl/replication_coordinator_impl.h b/src/mongo/db/repl/replication_coordinator_impl.h
index d7000f33f35..57daa9385a7 100644
--- a/src/mongo/db/repl/replication_coordinator_impl.h
+++ b/src/mongo/db/repl/replication_coordinator_impl.h
@@ -546,7 +546,7 @@ private:
* Loops continuously to kill all conflicting operations. And, aborts all stashed (inactive)
* transactions.
* Terminates once killSignaled is set true.
- */
+ */
void _killOpThreadFn();
/*
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 d3ed5c96e6d..baf79108edf 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
@@ -60,11 +60,7 @@ using ApplierState = ReplicationCoordinator::ApplierState;
TEST_F(ReplCoordTest, RandomizedElectionOffsetWithinProperBounds) {
BSONObj configObj = BSON("_id"
<< "mySet"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -91,18 +87,14 @@ TEST_F(ReplCoordTest, RandomizedElectionOffsetWithinProperBounds) {
TEST_F(ReplCoordTest, RandomizedElectionOffsetAvoidsDivideByZero) {
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"
- << 1
- << "settings"
+ << "protocolVersion" << 1 << "settings"
<< BSON("electionTimeoutMillis" << 1));
assertStartSuccess(configObj, HostAndPort("node1", 12345));
@@ -113,24 +105,17 @@ TEST_F(ReplCoordTest, RandomizedElectionOffsetAvoidsDivideByZero) {
}
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));
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
@@ -185,15 +170,12 @@ 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"
- << 1),
+ << "protocolVersion" << 1),
HostAndPort("node1", 12345));
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_RECOVERING));
@@ -213,13 +195,10 @@ 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),
+ << "protocolVersion" << 1),
HostAndPort("node1", 12345));
replCoordSetMyLastAppliedOpTime(OpTime(Timestamp(10, 1), 0), Date_t() + Seconds(10));
@@ -247,17 +226,14 @@ 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"
- << 1);
+ << "protocolVersion" << 1);
assertStartSuccess(configObj, HostAndPort("node1", 12345));
OperationContextNoop opCtx;
replCoordSetMyLastAppliedOpTime(OpTime(Timestamp(100, 1), 0), Date_t() + Seconds(100));
@@ -296,9 +272,7 @@ TEST_F(ReplCoordTest, ElectionSucceedsWhenAllNodesVoteYea) {
TEST_F(ReplCoordTest, ElectionSucceedsWhenMaxSevenNodesVoteYea) {
BSONObj configObj = BSON("_id"
<< "mySet"
- << "version"
- << 1
- << "members"
+ << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -313,8 +287,7 @@ TEST_F(ReplCoordTest, ElectionSucceedsWhenMaxSevenNodesVoteYea) {
<< "node6:12345")
<< BSON("_id" << 7 << "host"
<< "node7:12345"))
- << "protocolVersion"
- << 1);
+ << "protocolVersion" << 1);
assertStartSuccess(configObj, HostAndPort("node1", 12345));
OperationContextNoop opCtx;
replCoordSetMyLastAppliedOpTime(OpTime(Timestamp(100, 1), 0), Date_t() + Seconds(100));
@@ -338,17 +311,14 @@ 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"
- << 1);
+ << "protocolVersion" << 1);
assertStartSuccess(configObj, HostAndPort("node1", 12345));
ReplSetConfig config = assertMakeRSConfig(configObj);
@@ -380,9 +350,9 @@ TEST_F(ReplCoordTest, ElectionFailsWhenInsufficientVotesAreReceivedDuringDryRun)
} else if (request.cmdObj.firstElement().fieldNameStringData() == "replSetRequestVotes") {
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++;
} else {
net->blackHole(noi);
@@ -399,17 +369,14 @@ 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"
- << 1);
+ << "protocolVersion" << 1);
assertStartSuccess(configObj, HostAndPort("node1", 12345));
ReplSetConfig config = assertMakeRSConfig(configObj);
@@ -443,9 +410,7 @@ 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++;
} else {
@@ -466,9 +431,7 @@ TEST_F(ReplCoordTest, NodeWillNotStandForElectionDuringHeartbeatReconfig) {
OperationContextNoop opCtx;
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -479,8 +442,7 @@ TEST_F(ReplCoordTest, NodeWillNotStandForElectionDuringHeartbeatReconfig) {
<< "node4:12345")
<< BSON("_id" << 5 << "host"
<< "node5:12345"))
- << "protocolVersion"
- << 1),
+ << "protocolVersion" << 1),
HostAndPort("node1", 12345));
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
replCoordSetMyLastAppliedOpTime(OpTime(Timestamp(100, 1), 0), Date_t() + Seconds(100));
@@ -498,15 +460,12 @@ TEST_F(ReplCoordTest, NodeWillNotStandForElectionDuringHeartbeatReconfig) {
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"
- << 1))
+ << "protocolVersion" << 1))
.transitional_ignore();
hbResp2.setConfig(config);
hbResp2.setConfigVersion(3);
@@ -593,17 +552,14 @@ 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"
- << 1);
+ << "protocolVersion" << 1);
assertStartSuccess(configObj, HostAndPort("node1", 12345));
ReplSetConfig config = assertMakeRSConfig(configObj);
@@ -627,9 +583,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();
}
@@ -644,17 +600,14 @@ TEST_F(ReplCoordTest, ElectionFailsWhenInsufficientVotesAreReceivedDuringRequest
TEST_F(ReplCoordTest, TransitionToRollbackFailsWhenElectionInProgress) {
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"
- << 1);
+ << "protocolVersion" << 1);
assertStartSuccess(configObj, HostAndPort("node1", 12345));
ReplSetConfig config = assertMakeRSConfig(configObj);
@@ -683,17 +636,14 @@ 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"
- << 1);
+ << "protocolVersion" << 1);
assertStartSuccess(configObj, HostAndPort("node1", 12345));
ReplSetConfig config = assertMakeRSConfig(configObj);
@@ -719,9 +669,7 @@ 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();
@@ -738,17 +686,14 @@ 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"
- << 1);
+ << "protocolVersion" << 1);
assertStartSuccess(configObj, HostAndPort("node1", 12345));
ReplSetConfig config = assertMakeRSConfig(configObj);
@@ -779,17 +724,14 @@ 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"
- << 1);
+ << "protocolVersion" << 1);
assertStartSuccess(configObj, HostAndPort("node1", 12345));
ReplSetConfig config = assertMakeRSConfig(configObj);
@@ -816,10 +758,9 @@ 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();
}
@@ -982,18 +923,14 @@ private:
TEST_F(TakeoverTest, DoesntScheduleCatchupTakeoverIfCatchupDisabledButTakeoverDelaySet) {
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"
- << 1
- << "settings"
+ << "protocolVersion" << 1 << "settings"
<< BSON("catchUpTimeoutMillis" << 0 << "catchUpTakeoverDelay"
<< 10000));
assertStartSuccess(configObj, HostAndPort("node1", 12345));
@@ -1024,17 +961,14 @@ TEST_F(TakeoverTest, DoesntScheduleCatchupTakeoverIfCatchupDisabledButTakeoverDe
TEST_F(TakeoverTest, SchedulesCatchupTakeoverIfNodeIsFresherThanCurrentPrimary) {
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"
- << 1);
+ << "protocolVersion" << 1);
assertStartSuccess(configObj, HostAndPort("node1", 12345));
ReplSetConfig config = assertMakeRSConfig(configObj);
@@ -1071,21 +1005,16 @@ TEST_F(TakeoverTest, SchedulesCatchupTakeoverIfNodeIsFresherThanCurrentPrimary)
TEST_F(TakeoverTest, SchedulesCatchupTakeoverIfBothTakeoversAnOption) {
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"
- << "priority"
- << 3))
- << "protocolVersion"
- << 1);
+ << "priority" << 3))
+ << "protocolVersion" << 1);
assertStartSuccess(configObj, HostAndPort("node1", 12345));
ReplSetConfig config = assertMakeRSConfig(configObj);
@@ -1123,19 +1052,15 @@ TEST_F(TakeoverTest, SchedulesCatchupTakeoverIfBothTakeoversAnOption) {
TEST_F(TakeoverTest, PrefersPriorityToCatchupTakeoverIfNodeHasHighestPriority) {
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"
- << 1);
+ << "protocolVersion" << 1);
logger::globalLogDomain()->setMinimumLoggedSeverity(logger::LogSeverity::Debug(2));
startCapturingLogMessages();
@@ -1179,17 +1104,14 @@ TEST_F(TakeoverTest, PrefersPriorityToCatchupTakeoverIfNodeHasHighestPriority) {
TEST_F(TakeoverTest, CatchupTakeoverNotScheduledTwice) {
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"
- << 1);
+ << "protocolVersion" << 1);
assertStartSuccess(configObj, HostAndPort("node1", 12345));
ReplSetConfig config = assertMakeRSConfig(configObj);
@@ -1236,21 +1158,16 @@ TEST_F(TakeoverTest, CatchupTakeoverNotScheduledTwice) {
TEST_F(TakeoverTest, CatchupAndPriorityTakeoverNotScheduledAtSameTime) {
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"
- << "priority"
- << 3))
- << "protocolVersion"
- << 1);
+ << "priority" << 3))
+ << "protocolVersion" << 1);
// In order for node 1 to first schedule a catchup takeover, then a priority takeover
// once the first gets canceled, it must have a higher priority than the current primary
// (node 2). But, it must not have the highest priority in the replica set. Otherwise,
@@ -1302,17 +1219,14 @@ TEST_F(TakeoverTest, CatchupAndPriorityTakeoverNotScheduledAtSameTime) {
TEST_F(TakeoverTest, CatchupTakeoverCallbackCanceledIfElectionTimeoutRuns) {
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"
- << 1);
+ << "protocolVersion" << 1);
assertStartSuccess(configObj, HostAndPort("node1", 12345));
ReplSetConfig config = assertMakeRSConfig(configObj);
@@ -1376,17 +1290,14 @@ TEST_F(TakeoverTest, CatchupTakeoverCallbackCanceledIfElectionTimeoutRuns) {
TEST_F(TakeoverTest, CatchupTakeoverCanceledIfTransitionToRollback) {
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"
- << 1);
+ << "protocolVersion" << 1);
assertStartSuccess(configObj, HostAndPort("node1", 12345));
ReplSetConfig config = assertMakeRSConfig(configObj);
@@ -1439,17 +1350,14 @@ TEST_F(TakeoverTest, CatchupTakeoverCanceledIfTransitionToRollback) {
TEST_F(TakeoverTest, SuccessfulCatchupTakeover) {
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"
- << 1);
+ << "protocolVersion" << 1);
assertStartSuccess(configObj, HostAndPort("node1", 12345));
ReplSetConfig config = assertMakeRSConfig(configObj);
HostAndPort primaryHostAndPort("node2", 12345);
@@ -1522,9 +1430,7 @@ TEST_F(TakeoverTest, CatchupTakeoverDryRunFailsPrimarySaysNo) {
startCapturingLogMessages();
BSONObj configObj = BSON("_id"
<< "mySet"
- << "version"
- << 1
- << "members"
+ << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -1535,8 +1441,7 @@ TEST_F(TakeoverTest, CatchupTakeoverDryRunFailsPrimarySaysNo) {
<< "node4:12345")
<< BSON("_id" << 5 << "host"
<< "node5:12345"))
- << "protocolVersion"
- << 1);
+ << "protocolVersion" << 1);
assertStartSuccess(configObj, HostAndPort("node1", 12345));
ReplSetConfig config = assertMakeRSConfig(configObj);
HostAndPort primaryHostAndPort("node2", 12345);
@@ -1598,12 +1503,11 @@ TEST_F(TakeoverTest, CatchupTakeoverDryRunFailsPrimarySaysNo) {
net->blackHole(noi);
} else {
bool voteGranted = request.target != primaryHostAndPort;
- net->scheduleResponse(
- noi,
- until,
- makeResponseStatus(BSON("ok" << 1 << "term" << 1 << "voteGranted" << voteGranted
- << "reason"
- << "")));
+ net->scheduleResponse(noi,
+ until,
+ makeResponseStatus(BSON("ok" << 1 << "term" << 1 << "voteGranted"
+ << voteGranted << "reason"
+ << "")));
voteRequests++;
}
net->runReadyNetworkOperations();
@@ -1631,17 +1535,14 @@ TEST_F(TakeoverTest, CatchupTakeoverDryRunFailsPrimarySaysNo) {
TEST_F(TakeoverTest, PrimaryCatchesUpBeforeCatchupTakeover) {
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"
- << 1);
+ << "protocolVersion" << 1);
assertStartSuccess(configObj, HostAndPort("node1", 12345));
ReplSetConfig config = assertMakeRSConfig(configObj);
@@ -1692,21 +1593,16 @@ TEST_F(TakeoverTest, PrimaryCatchesUpBeforeCatchupTakeover) {
TEST_F(TakeoverTest, PrimaryCatchesUpBeforeHighPriorityNodeCatchupTakeover) {
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"
- << "priority"
- << 3))
- << "protocolVersion"
- << 1);
+ << "priority" << 3))
+ << "protocolVersion" << 1);
assertStartSuccess(configObj, HostAndPort("node1", 12345));
ReplSetConfig config = assertMakeRSConfig(configObj);
@@ -1776,19 +1672,15 @@ TEST_F(TakeoverTest, PrimaryCatchesUpBeforeHighPriorityNodeCatchupTakeover) {
TEST_F(TakeoverTest, SchedulesPriorityTakeoverIfNodeHasHigherPriorityThanCurrentPrimary) {
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"
- << 1);
+ << "protocolVersion" << 1);
assertStartSuccess(configObj, HostAndPort("node1", 12345));
ReplSetConfig config = assertMakeRSConfig(configObj);
@@ -1823,19 +1715,15 @@ TEST_F(TakeoverTest, SchedulesPriorityTakeoverIfNodeHasHigherPriorityThanCurrent
TEST_F(TakeoverTest, SuccessfulPriorityTakeover) {
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"
- << 1);
+ << "protocolVersion" << 1);
assertStartSuccess(configObj, HostAndPort("node1", 12345));
ReplSetConfig config = assertMakeRSConfig(configObj);
@@ -1894,19 +1782,15 @@ TEST_F(TakeoverTest, SuccessfulPriorityTakeover) {
TEST_F(TakeoverTest, DontCallForPriorityTakeoverWhenLaggedSameSecond) {
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"
- << 1);
+ << "protocolVersion" << 1);
assertStartSuccess(configObj, HostAndPort("node1", 12345));
ReplSetConfig config = assertMakeRSConfig(configObj);
HostAndPort primaryHostAndPort("node2", 12345);
@@ -1973,19 +1857,15 @@ TEST_F(TakeoverTest, DontCallForPriorityTakeoverWhenLaggedSameSecond) {
TEST_F(TakeoverTest, DontCallForPriorityTakeoverWhenLaggedDifferentSecond) {
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"
- << 1);
+ << "protocolVersion" << 1);
assertStartSuccess(configObj, HostAndPort("node1", 12345));
ReplSetConfig config = assertMakeRSConfig(configObj);
HostAndPort primaryHostAndPort("node2", 12345);
@@ -2053,19 +1933,14 @@ TEST_F(ReplCoordTest, NodeCancelsElectionUponReceivingANewConfigDuringDryRun) {
// Start up and become electable.
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 2
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 2 << "protocolVersion" << 1 << "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)),
+ << "settings" << BSON("heartbeatIntervalMillis" << 100)),
HostAndPort("node1", 12345));
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
replCoordSetMyLastAppliedOpTime(OpTime(Timestamp(100, 1), 0), Date_t() + Seconds(100));
@@ -2093,11 +1968,7 @@ TEST_F(ReplCoordTest, NodeCancelsElectionUponReceivingANewConfigDuringDryRun) {
ReplicationCoordinatorImpl::ReplSetReconfigArgs config = {
BSON("_id"
<< "mySet"
- << "version"
- << 4
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 4 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -2118,19 +1989,14 @@ TEST_F(ReplCoordTest, NodeCancelsElectionUponReceivingANewConfigDuringVotePhase)
// Start up and become electable.
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 2
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 2 << "protocolVersion" << 1 << "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)),
+ << "settings" << BSON("heartbeatIntervalMillis" << 100)),
HostAndPort("node1", 12345));
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
replCoordSetMyLastAppliedOpTime(OpTime(Timestamp(100, 1), 0), Date_t() + Seconds(100));
@@ -2143,11 +2009,7 @@ TEST_F(ReplCoordTest, NodeCancelsElectionUponReceivingANewConfigDuringVotePhase)
ReplicationCoordinatorImpl::ReplSetReconfigArgs config = {
BSON("_id"
<< "mySet"
- << "version"
- << 4
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 4 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -2209,14 +2071,13 @@ protected:
net->getNextReadyRequest(), net->now(), makeHeartbeatResponse(opTime));
} else if (request.cmdObj.firstElement().fieldNameStringData() ==
"replSetRequestVotes") {
- net->scheduleResponse(net->getNextReadyRequest(),
- net->now(),
- makeResponseStatus(BSON("ok" << 1 << "reason"
- << ""
- << "term"
- << request.cmdObj["term"].Long()
- << "voteGranted"
- << true)));
+ net->scheduleResponse(
+ net->getNextReadyRequest(),
+ net->now(),
+ makeResponseStatus(BSON("ok" << 1 << "reason"
+ << ""
+ << "term" << request.cmdObj["term"].Long()
+ << "voteGranted" << true)));
} else {
// Stop the loop and let the caller handle unexpected requests.
net->exitNetwork();
@@ -2230,18 +2091,14 @@ protected:
ReplSetConfig setUp3NodeReplSetAndRunForElection(OpTime opTime, long long timeout = 5000) {
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"
- << 1
- << "settings"
+ << "protocolVersion" << 1 << "settings"
<< BSON("heartbeatTimeoutSecs" << 1 << "catchUpTimeoutMillis"
<< timeout));
assertStartSuccess(configObj, HostAndPort("node1", 12345));
diff --git a/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp b/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp
index 1a6804a68c1..eff5d557e1f 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp
@@ -174,11 +174,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;
}
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 80ac8e0e2b7..3099894bcfb 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
@@ -90,17 +90,14 @@ TEST_F(ReplCoordHBV1Test,
logger::globalLogDomain()->setMinimumLoggedSeverity(logger::LogSeverity::Debug(3));
ReplSetConfig rsConfig = assertMakeRSConfig(BSON("_id"
<< "mySet"
- << "version"
- << 3
- << "members"
+ << "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));
+ << "protocolVersion" << 1));
init("mySet");
addSelf(HostAndPort("h2", 1));
const Date_t startDate = getNet()->now();
@@ -160,21 +157,18 @@ TEST_F(ReplCoordHBV1Test,
TEST_F(ReplCoordHBV1Test,
ArbiterJoinsExistingReplSetWhenReceivingAConfigContainingTheArbiterViaHeartbeat) {
logger::globalLogDomain()->setMinimumLoggedSeverity(logger::LogSeverity::Debug(3));
- ReplSetConfig 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));
+ ReplSetConfig 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();
@@ -238,17 +232,14 @@ TEST_F(ReplCoordHBV1Test,
logger::globalLogDomain()->setMinimumLoggedSeverity(logger::LogSeverity::Debug(3));
ReplSetConfig rsConfig = assertMakeRSConfig(BSON("_id"
<< "mySet"
- << "version"
- << 3
- << "members"
+ << "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));
+ << "protocolVersion" << 1));
init("mySet");
addSelf(HostAndPort("h4", 1));
const Date_t startDate = getNet()->now();
@@ -323,9 +314,7 @@ 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"
@@ -338,12 +327,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") {
@@ -364,15 +353,11 @@ 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_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
@@ -444,10 +429,9 @@ 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));
}
TEST_F(ReplCoordHBV1Test,
@@ -455,19 +439,14 @@ TEST_F(ReplCoordHBV1Test,
// Ensure that the metadata is processed if it is contained in a heartbeat response.
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))
- << "protocolVersion"
- << 1),
+ << "_id" << 1))
+ << "protocolVersion" << 1),
HostAndPort("node1", 12345));
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
ASSERT_EQUALS(OpTime(), getReplCoord()->getLastCommittedOpTime());
@@ -538,19 +517,14 @@ TEST_F(ReplCoordHBV1Test, LastCommittedOpTimeOnlyUpdatesFromHeartbeatInFCV42) {
// Ensure that the metadata is processed if it is contained in a heartbeat response.
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))
- << "protocolVersion"
- << 1),
+ << "_id" << 1))
+ << "protocolVersion" << 1),
HostAndPort("node1", 12345));
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
ASSERT_EQUALS(OpTime(), getReplCoord()->getLastCommittedOpTime());
@@ -620,19 +594,14 @@ TEST_F(ReplCoordHBV1Test, LastCommittedOpTimeOnlyUpdatesFromHeartbeatIfNotInStar
// if we are in STARTUP2.
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))
- << "protocolVersion"
- << 1),
+ << "_id" << 1))
+ << "protocolVersion" << 1),
HostAndPort("node1", 12345));
ASSERT_EQUALS(OpTime(), getReplCoord()->getLastCommittedOpTime());
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 3fad34dfe2a..738ff86ef87 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp
@@ -73,9 +73,7 @@ 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"
@@ -99,9 +97,7 @@ TEST_F(ReplCoordTest, NodeReturnsInvalidReplicaSetConfigWhenReconfigReceivedWith
// start up, become primary, receive uninitializable config
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -117,21 +113,14 @@ TEST_F(ReplCoordTest, NodeReturnsInvalidReplicaSetConfigWhenReconfigReceivedWith
args.force = false;
args.newConfigObj = BSON("_id"
<< "mySet"
- << "version"
- << 2
- << "protocolVersion"
- << 1
- << "invalidlyNamedField"
- << 3
- << "members"
+ << "version" << 2 << "protocolVersion" << 1 << "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)));
const auto opCtx = makeOperationContext();
// ErrorCodes::BadValue should be propagated from ReplSetConfig::initialize()
ASSERT_EQUALS(ErrorCodes::InvalidReplicaSetConfig,
@@ -143,9 +132,7 @@ TEST_F(ReplCoordTest, NodeReturnsInvalidReplicaSetConfigWhenReconfigReceivedWith
// start up, become primary, receive config with incorrect replset name
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -161,11 +148,7 @@ TEST_F(ReplCoordTest, NodeReturnsInvalidReplicaSetConfigWhenReconfigReceivedWith
args.force = false;
args.newConfigObj = BSON("_id"
<< "notMySet"
- << "version"
- << 3
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 3 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -181,15 +164,12 @@ TEST_F(ReplCoordTest, NodeReturnsInvalidReplicaSetConfigWhenReconfigReceivedWith
// start up, become primary, receive config with incorrect replset name
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"
- << BSON("replicaSetId" << OID::gen())),
+ << "settings" << BSON("replicaSetId" << OID::gen())),
HostAndPort("node1", 12345));
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
replCoordSetMyLastAppliedOpTime(OpTime(Timestamp(100, 1), 0), Date_t() + Seconds(100));
@@ -201,17 +181,12 @@ TEST_F(ReplCoordTest, NodeReturnsInvalidReplicaSetConfigWhenReconfigReceivedWith
args.force = false;
args.newConfigObj = BSON("_id"
<< "mySet"
- << "version"
- << 3
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 3 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
<< "node2:12345"))
- << "settings"
- << BSON("replicaSetId" << OID::gen()));
+ << "settings" << BSON("replicaSetId" << OID::gen()));
const auto opCtx = makeOperationContext();
ASSERT_EQUALS(ErrorCodes::NewReplicaSetConfigurationIncompatible,
@@ -224,9 +199,7 @@ TEST_F(ReplCoordTest,
// start up, become primary, validate fails
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -242,11 +215,7 @@ TEST_F(ReplCoordTest,
args.force = false;
args.newConfigObj = BSON("_id"
<< "mySet"
- << "version"
- << -3
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << -3 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -266,9 +235,7 @@ void doReplSetInitiate(ReplicationCoordinatorImpl* replCoord,
replCoord->processReplSetInitiate(opCtx,
BSON("_id"
<< "mySet"
- << "version"
- << 1
- << "members"
+ << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -285,17 +252,12 @@ void doReplSetReconfig(ReplicationCoordinatorImpl* replCoord,
// Replica set id will be copied from existing configuration.
args.newConfigObj = BSON("_id"
<< "mySet"
- << "version"
- << 3
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 3 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
<< "node2:12345"
- << "priority"
- << 3)));
+ << "priority" << 3)));
*status = replCoord->processReplSetReconfig(opCtx, args, &garbage);
}
@@ -305,9 +267,7 @@ TEST_F(ReplCoordTest,
// containing a higher config version
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -348,9 +308,7 @@ TEST_F(ReplCoordTest, NodeReturnsOutOfDiskSpaceWhenSavingANewConfigFailsDuringRe
// start up, become primary, saving the config fails
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -377,9 +335,7 @@ TEST_F(ReplCoordTest,
// start up, become primary, reconfig, then before that reconfig concludes, reconfig again
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -404,11 +360,7 @@ TEST_F(ReplCoordTest,
args.force = false;
args.newConfigObj = BSON("_id"
<< "mySet"
- << "version"
- << 3
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 3 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -443,11 +395,7 @@ TEST_F(ReplCoordTest, NodeReturnsConfigurationInProgressWhenReceivingAReconfigWh
args.force = false;
args.newConfigObj = BSON("_id"
<< "mySet"
- << "version"
- << 3
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 3 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -464,15 +412,12 @@ TEST_F(ReplCoordTest, PrimaryNodeAcceptsNewConfigWhenReceivingAReconfigWithAComp
// start up, become primary, reconfig successfully
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"
- << BSON("replicaSetId" << OID::gen())),
+ << "settings" << BSON("replicaSetId" << OID::gen())),
HostAndPort("node1", 12345));
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
replCoordSetMyLastAppliedOpTime(OpTime(Timestamp(100, 1), 0), Date_t() + Seconds(100));
@@ -512,9 +457,7 @@ TEST_F(
// from reconfig
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -538,11 +481,7 @@ TEST_F(
config
.initialize(BSON("_id"
<< "mySet"
- << "version"
- << 3
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 3 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -581,9 +520,7 @@ TEST_F(ReplCoordTest, NodeDoesNotAcceptHeartbeatReconfigWhileInTheMidstOfReconfi
// start up, become primary, reconfig, while reconfigging receive reconfig via heartbeat
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -614,9 +551,7 @@ TEST_F(ReplCoordTest, NodeDoesNotAcceptHeartbeatReconfigWhileInTheMidstOfReconfi
config
.initialize(BSON("_id"
<< "mySet"
- << "version"
- << 4
- << "members"
+ << "version" << 4 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -652,9 +587,7 @@ 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"
@@ -670,11 +603,7 @@ TEST_F(ReplCoordTest, NodeAcceptsConfigFromAReconfigWithForceTrueWhileNotPrimary
args.force = false;
args.newConfigObj = BSON("_id"
<< "mySet"
- << "version"
- << 3
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 3 << "protocolVersion" << 1 << "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 f355d04bba0..c387e99bec6 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_test.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_test.cpp
@@ -121,15 +121,12 @@ void killOperation(OperationContext* opCtx) {
TEST_F(ReplCoordTest, IsMasterIsFalseDuringStepdown) {
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"))
- << "protocolVersion"
- << 1);
+ << "protocolVersion" << 1);
assertStartSuccess(configObj, HostAndPort("node1", 12345));
ReplSetConfig config = assertMakeRSConfig(configObj);
auto replCoord = getReplCoord();
@@ -163,9 +160,7 @@ TEST_F(ReplCoordTest, IsMasterIsFalseDuringStepdown) {
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));
@@ -176,13 +171,10 @@ 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));
@@ -194,9 +186,7 @@ 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"
@@ -213,9 +203,7 @@ 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));
@@ -256,9 +244,7 @@ TEST_F(ReplCoordTest,
getReplCoord()->processReplSetInitiate(opCtx.get(),
BSON("_id"
<< "mySet"
- << "version"
- << 1
- << "members"
+ << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "node1:12345"))),
&result1));
@@ -272,9 +258,7 @@ TEST_F(ReplCoordTest,
getReplCoord()->processReplSetInitiate(opCtx.get(),
BSON("_id"
<< "mySet"
- << "version"
- << 1
- << "members"
+ << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "node1:12345"))),
&result2));
@@ -297,9 +281,7 @@ TEST_F(ReplCoordTest,
getReplCoord()->processReplSetInitiate(opCtx.get(),
BSON("_id"
<< "mySet"
- << "version"
- << 1
- << "members"
+ << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "node1:12345"
<< "arbiterOnly"
@@ -328,9 +310,7 @@ TEST_F(ReplCoordTest,
getReplCoord()->processReplSetInitiate(opCtx.get(),
BSON("_id"
<< "mySet"
- << "version"
- << 1
- << "members"
+ << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "node1:12345"))),
&result1));
@@ -348,9 +328,7 @@ TEST_F(ReplCoordTest,
getReplCoord()->processReplSetInitiate(opCtx.get(),
BSON("_id"
<< "mySet"
- << "version"
- << 1
- << "members"
+ << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "node4"))),
&result));
@@ -364,9 +342,7 @@ void doReplSetInitiate(ReplicationCoordinatorImpl* replCoord, Status* status) {
replCoord->processReplSetInitiate(opCtx.get(),
BSON("_id"
<< "mySet"
- << "version"
- << 1
- << "members"
+ << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "node1:12345")
<< BSON("_id" << 1 << "host"
@@ -461,9 +437,7 @@ TEST_F(ReplCoordTest,
getReplCoord()->processReplSetInitiate(opCtx.get(),
BSON("_id"
<< "wrongSet"
- << "version"
- << 1
- << "members"
+ << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "node1:12345"))),
&result1));
@@ -492,8 +466,9 @@ TEST_F(ReplCoordTest, NodeReturnsInvalidReplicaSetConfigWhenInitiatingWithoutAn_
BSONObjBuilder result1;
auto status = getReplCoord()->processReplSetInitiate(
opCtx.get(),
- BSON("version" << 1 << "members" << BSON_ARRAY(BSON("_id" << 0 << "host"
- << "node1:12345"))),
+ BSON("version" << 1 << "members"
+ << BSON_ARRAY(BSON("_id" << 0 << "host"
+ << "node1:12345"))),
&result1);
ASSERT_EQUALS(ErrorCodes::InvalidReplicaSetConfig, status);
ASSERT_STRING_CONTAINS(status.reason(), "Missing expected field \"_id\"");
@@ -512,9 +487,7 @@ TEST_F(ReplCoordTest,
getReplCoord()->processReplSetInitiate(opCtx.get(),
BSON("_id"
<< "mySet"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "node1:12345"))),
&result1);
@@ -535,9 +508,7 @@ TEST_F(ReplCoordTest, InitiateFailsWithoutReplSetFlag) {
getReplCoord()->processReplSetInitiate(opCtx.get(),
BSON("_id"
<< "mySet"
- << "version"
- << 1
- << "members"
+ << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "node1:12345"))),
&result1));
@@ -558,9 +529,7 @@ TEST_F(ReplCoordTest, NodeReturnsOutOfDiskSpaceWhenInitiateCannotWriteConfigToDi
getReplCoord()->processReplSetInitiate(opCtx.get(),
BSON("_id"
<< "mySet"
- << "version"
- << 1
- << "members"
+ << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "node1:12345"))),
&result1));
@@ -612,13 +581,10 @@ TEST_F(
TEST_F(ReplCoordTest, NodeReturnsOkWhenCheckReplEnabledForCommandAfterReceivingAConfig) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id"
- << 0))),
+ << "_id" << 0))),
HostAndPort("node1", 12345));
// check status OK and result is empty
@@ -648,21 +614,16 @@ TEST_F(ReplCoordTest, NodeReturnsImmediatelyWhenAwaitReplicationIsRanAgainstASta
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)
+ << "_id" << 1)
<< BSON("host"
<< "node3:12345"
- << "_id"
- << 2))),
+ << "_id" << 2))),
HostAndPort("node1", 12345));
auto opCtx = makeOperationContext();
@@ -683,21 +644,16 @@ TEST_F(ReplCoordTest, NodeReturnsNotMasterWhenRunningAwaitReplicationAgainstASec
TEST_F(ReplCoordTest, NodeReturnsOkWhenRunningAwaitReplicationAgainstPrimaryWithWTermOne) {
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)
+ << "_id" << 1)
<< BSON("host"
<< "node3:12345"
- << "_id"
- << 2))),
+ << "_id" << 2))),
HostAndPort("node1", 12345));
OpTimeWithTermOne time(100, 1);
@@ -725,25 +681,19 @@ TEST_F(ReplCoordTest,
NodeReturnsWriteConcernFailedUntilASufficientNumberOfNodesHaveTheWriteDurable) {
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)
+ << "_id" << 1)
<< BSON("host"
<< "node3:12345"
- << "_id"
- << 2)
+ << "_id" << 2)
<< BSON("host"
<< "node4:12345"
- << "_id"
- << 3))),
+ << "_id" << 3))),
HostAndPort("node1", 12345));
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
replCoordSetMyLastAppliedOpTime(OpTimeWithTermOne(100, 1), Date_t() + Seconds(100));
@@ -805,25 +755,19 @@ TEST_F(ReplCoordTest,
TEST_F(ReplCoordTest, NodeReturnsWriteConcernFailedUntilASufficientNumberOfNodesHaveTheWrite) {
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)
+ << "_id" << 1)
<< BSON("host"
<< "node3:12345"
- << "_id"
- << 2)
+ << "_id" << 2)
<< BSON("host"
<< "node4:12345"
- << "_id"
- << 3))),
+ << "_id" << 3))),
HostAndPort("node1", 12345));
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
replCoordSetMyLastAppliedOpTime(OpTimeWithTermOne(100, 1), Date_t() + Seconds(100));
@@ -882,9 +826,7 @@ TEST_F(ReplCoordTest,
NodeReturnsUnknownReplWriteConcernWhenAwaitReplicationReceivesAnInvalidWriteConcernMode) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "node0")
<< BSON("_id" << 1 << "host"
@@ -921,9 +863,7 @@ TEST_F(
assertStartSuccess(
BSON("_id"
<< "mySet"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "node0"
<< "tags"
@@ -1103,21 +1043,16 @@ private:
TEST_F(ReplCoordTest, NodeReturnsOkWhenAWriteConcernWithNoTimeoutHasBeenSatisfied) {
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)
+ << "_id" << 1)
<< BSON("host"
<< "node3:12345"
- << "_id"
- << 2))),
+ << "_id" << 2))),
HostAndPort("node1", 12345));
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
replCoordSetMyLastAppliedOpTime(OpTimeWithTermOne(100, 1), Date_t() + Seconds(100));
@@ -1167,21 +1102,16 @@ TEST_F(ReplCoordTest, NodeReturnsOkWhenAWriteConcernWithNoTimeoutHasBeenSatisfie
TEST_F(ReplCoordTest, NodeReturnsWriteConcernFailedWhenAWriteConcernTimesOutBeforeBeingSatisified) {
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)
+ << "_id" << 1)
<< BSON("host"
<< "node3:12345"
- << "_id"
- << 2))),
+ << "_id" << 2))),
HostAndPort("node1", 12345));
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
replCoordSetMyLastAppliedOpTime(OpTimeWithTermOne(100, 1), Date_t() + Seconds(100));
@@ -1218,21 +1148,16 @@ TEST_F(ReplCoordTest,
NodeReturnsShutDownInProgressWhenANodeShutsDownPriorToSatisfyingAWriteConcern) {
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)
+ << "_id" << 1)
<< BSON("host"
<< "node3:12345"
- << "_id"
- << 2))),
+ << "_id" << 2))),
HostAndPort("node1", 12345));
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
replCoordSetMyLastAppliedOpTime(OpTimeWithTermOne(100, 1), Date_t() + Seconds(100));
@@ -1268,21 +1193,16 @@ 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)
+ << "_id" << 1)
<< BSON("host"
<< "node3:12345"
- << "_id"
- << 2))),
+ << "_id" << 2))),
HostAndPort("node1", 12345));
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
replCoordSetMyLastAppliedOpTime(OpTimeWithTermOne(100, 1), Date_t() + Seconds(100));
@@ -1316,9 +1236,7 @@ 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"
@@ -1436,9 +1354,7 @@ private:
init("mySet/test1:1234,test2:1234,test3:1234");
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 1
- << "members"
+ << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "test1:1234")
<< BSON("_id" << 1 << "host"
@@ -1463,9 +1379,7 @@ TEST_F(ReplCoordTest, UpdatePositionArgsAdvancesWallTimes) {
init("mySet/test1:1234,test2:1234,test3:1234");
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 1
- << "members"
+ << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "test1:1234")
<< BSON("_id" << 1 << "host"
@@ -1499,33 +1413,27 @@ TEST_F(ReplCoordTest, UpdatePositionArgsAdvancesWallTimes) {
ASSERT_OK(updatePositionArgsInitialize(
updatePositionArgs,
- BSON(UpdatePositionArgs::kCommandFieldName
- << 1
- << UpdatePositionArgs::kUpdateArrayFieldName
- << BSON_ARRAY(BSON(UpdatePositionArgs::kConfigVersionFieldName
- << configVersion
- << UpdatePositionArgs::kMemberIdFieldName
- << 1
- << UpdatePositionArgs::kAppliedOpTimeFieldName
- << opTime2.asOpTime().toBSON()
- << UpdatePositionArgs::kAppliedWallTimeFieldName
- << memberOneAppliedWallTime
- << UpdatePositionArgs::kDurableOpTimeFieldName
- << opTime2.asOpTime().toBSON()
- << UpdatePositionArgs::kDurableWallTimeFieldName
- << memberOneDurableWallTime)
- << BSON(UpdatePositionArgs::kConfigVersionFieldName
- << configVersion
- << UpdatePositionArgs::kMemberIdFieldName
- << 2
- << UpdatePositionArgs::kAppliedOpTimeFieldName
- << opTime2.asOpTime().toBSON()
- << UpdatePositionArgs::kAppliedWallTimeFieldName
- << memberTwoAppliedWallTime
- << UpdatePositionArgs::kDurableOpTimeFieldName
- << opTime2.asOpTime().toBSON()
- << UpdatePositionArgs::kDurableWallTimeFieldName
- << memberTwoDurableWallTime)))));
+ BSON(
+ UpdatePositionArgs::kCommandFieldName
+ << 1 << UpdatePositionArgs::kUpdateArrayFieldName
+ << BSON_ARRAY(
+ BSON(
+ UpdatePositionArgs::kConfigVersionFieldName
+ << configVersion << UpdatePositionArgs::kMemberIdFieldName << 1
+ << UpdatePositionArgs::kAppliedOpTimeFieldName << opTime2.asOpTime().toBSON()
+ << UpdatePositionArgs::kAppliedWallTimeFieldName << memberOneAppliedWallTime
+ << UpdatePositionArgs::kDurableOpTimeFieldName << opTime2.asOpTime().toBSON()
+ << UpdatePositionArgs::kDurableWallTimeFieldName << memberOneDurableWallTime)
+ << BSON(UpdatePositionArgs::kConfigVersionFieldName
+ << configVersion << UpdatePositionArgs::kMemberIdFieldName << 2
+ << UpdatePositionArgs::kAppliedOpTimeFieldName
+ << opTime2.asOpTime().toBSON()
+ << UpdatePositionArgs::kAppliedWallTimeFieldName
+ << memberTwoAppliedWallTime
+ << UpdatePositionArgs::kDurableOpTimeFieldName
+ << opTime2.asOpTime().toBSON()
+ << UpdatePositionArgs::kDurableWallTimeFieldName
+ << memberTwoDurableWallTime)))));
ASSERT_OK(repl->processReplSetUpdatePosition(updatePositionArgs, &configVersion));
@@ -1547,17 +1455,14 @@ TEST_F(ReplCoordTest, ElectionIdTracksTermInPV1) {
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),
+ << "protocolVersion" << 1),
HostAndPort("test1", 1234));
replCoordSetMyLastAppliedOpTime(OpTime(Timestamp(100, 1), 0), Date_t() + Seconds(100));
replCoordSetMyLastDurableOpTime(OpTime(Timestamp(100, 1), 0), Date_t() + Seconds(100));
@@ -1611,17 +1516,14 @@ TEST_F(ReplCoordTest, NodeChangesTermAndStepsDownWhenAndOnlyWhenUpdateTermSuppli
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),
+ << "protocolVersion" << 1),
HostAndPort("test1", 1234));
replCoordSetMyLastAppliedOpTime(OpTime(Timestamp(100, 1), 0), Date_t() + Seconds(100));
replCoordSetMyLastDurableOpTime(OpTime(Timestamp(100, 1), 0), Date_t() + Seconds(100));
@@ -1666,17 +1568,14 @@ TEST_F(ReplCoordTest, ConcurrentStepDownShouldNotSignalTheSameFinishEventMoreTha
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),
+ << "protocolVersion" << 1),
HostAndPort("test1", 1234));
replCoordSetMyLastAppliedOpTime(OpTime(Timestamp(100, 1), 0), Date_t() + Seconds(100));
replCoordSetMyLastDurableOpTime(OpTime(Timestamp(100, 1), 0), Date_t() + Seconds(100));
@@ -1732,17 +1631,14 @@ TEST_F(ReplCoordTest, DrainCompletionMidStepDown) {
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),
+ << "protocolVersion" << 1),
HostAndPort("test1", 1234));
replCoordSetMyLastAppliedOpTime(OpTime(Timestamp(100, 1), 0), Date_t() + Seconds(100));
replCoordSetMyLastDurableOpTime(OpTime(Timestamp(100, 1), 0), Date_t() + Seconds(100));
@@ -1804,12 +1700,9 @@ TEST_F(StepDownTest, StepDownCanCompleteBasedOnReplSetUpdatePositionAlone) {
ASSERT_OK(updatePositionArgsInitialize(
updatePositionArgs,
BSON(UpdatePositionArgs::kCommandFieldName
- << 1
- << UpdatePositionArgs::kUpdateArrayFieldName
+ << 1 << UpdatePositionArgs::kUpdateArrayFieldName
<< BSON_ARRAY(BSON(UpdatePositionArgs::kConfigVersionFieldName
- << configVersion
- << UpdatePositionArgs::kMemberIdFieldName
- << 1
+ << configVersion << UpdatePositionArgs::kMemberIdFieldName << 1
<< UpdatePositionArgs::kAppliedOpTimeFieldName
<< opTime2.asOpTime().toBSON()
<< UpdatePositionArgs::kAppliedWallTimeFieldName
@@ -1819,9 +1712,7 @@ TEST_F(StepDownTest, StepDownCanCompleteBasedOnReplSetUpdatePositionAlone) {
<< UpdatePositionArgs::kDurableWallTimeFieldName
<< Date_t() + Seconds(opTime2.asOpTime().getSecs()))
<< BSON(UpdatePositionArgs::kConfigVersionFieldName
- << configVersion
- << UpdatePositionArgs::kMemberIdFieldName
- << 2
+ << configVersion << UpdatePositionArgs::kMemberIdFieldName << 2
<< UpdatePositionArgs::kAppliedOpTimeFieldName
<< opTime1.asOpTime().toBSON()
<< UpdatePositionArgs::kAppliedWallTimeFieldName
@@ -1906,17 +1797,12 @@ private:
init("mySet/test1:1234,test2:1234,test3:1234");
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "test1:1234")
<< BSON("_id" << 1 << "host"
<< "test2:1234"
- << "priority"
- << 0)
+ << "priority" << 0)
<< BSON("_id" << 2 << "host"
<< "test3:1234"))),
HostAndPort("test1", 1234));
@@ -1956,12 +1842,9 @@ TEST_F(StepDownTestWithUnelectableNode,
ASSERT_OK(updatePositionArgsInitialize(
catchupFirstSecondary,
BSON(UpdatePositionArgs::kCommandFieldName
- << 1
- << UpdatePositionArgs::kUpdateArrayFieldName
+ << 1 << UpdatePositionArgs::kUpdateArrayFieldName
<< BSON_ARRAY(BSON(UpdatePositionArgs::kConfigVersionFieldName
- << configVersion
- << UpdatePositionArgs::kMemberIdFieldName
- << 1
+ << configVersion << UpdatePositionArgs::kMemberIdFieldName << 1
<< UpdatePositionArgs::kAppliedOpTimeFieldName
<< opTime2.asOpTime().toBSON()
<< UpdatePositionArgs::kAppliedWallTimeFieldName
@@ -1971,9 +1854,7 @@ TEST_F(StepDownTestWithUnelectableNode,
<< UpdatePositionArgs::kDurableWallTimeFieldName
<< Date_t() + Seconds(opTime2.asOpTime().getSecs()))
<< BSON(UpdatePositionArgs::kConfigVersionFieldName
- << configVersion
- << UpdatePositionArgs::kMemberIdFieldName
- << 2
+ << configVersion << UpdatePositionArgs::kMemberIdFieldName << 2
<< UpdatePositionArgs::kAppliedOpTimeFieldName
<< opTime1.asOpTime().toBSON()
<< UpdatePositionArgs::kAppliedWallTimeFieldName
@@ -1995,12 +1876,9 @@ TEST_F(StepDownTestWithUnelectableNode,
ASSERT_OK(updatePositionArgsInitialize(
catchupOtherSecondary,
BSON(UpdatePositionArgs::kCommandFieldName
- << 1
- << UpdatePositionArgs::kUpdateArrayFieldName
+ << 1 << UpdatePositionArgs::kUpdateArrayFieldName
<< BSON_ARRAY(BSON(UpdatePositionArgs::kConfigVersionFieldName
- << configVersion
- << UpdatePositionArgs::kMemberIdFieldName
- << 1
+ << configVersion << UpdatePositionArgs::kMemberIdFieldName << 1
<< UpdatePositionArgs::kAppliedOpTimeFieldName
<< opTime2.asOpTime().toBSON()
<< UpdatePositionArgs::kAppliedWallTimeFieldName
@@ -2010,9 +1888,7 @@ TEST_F(StepDownTestWithUnelectableNode,
<< UpdatePositionArgs::kDurableWallTimeFieldName
<< Date_t() + Seconds(opTime2.asOpTime().getSecs()))
<< BSON(UpdatePositionArgs::kConfigVersionFieldName
- << configVersion
- << UpdatePositionArgs::kMemberIdFieldName
- << 2
+ << configVersion << UpdatePositionArgs::kMemberIdFieldName << 2
<< UpdatePositionArgs::kAppliedOpTimeFieldName
<< opTime2.asOpTime().toBSON()
<< UpdatePositionArgs::kAppliedWallTimeFieldName
@@ -2141,9 +2017,7 @@ private:
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 1
- << "members"
+ << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "test1:1234")
<< BSON("_id" << 1 << "host"
@@ -2240,14 +2114,10 @@ TEST_F(ReplCoordTest, SingleNodeReplSetStepDownTimeoutAndElectionTimeoutExpiresA
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 1
- << "members"
+ << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "test1:1234"))
- << "protocolVersion"
- << 1
- << "settings"
+ << "protocolVersion" << 1 << "settings"
<< BSON("electionTimeoutMillis" << 1000)),
HostAndPort("test1", 1234));
auto opCtx = makeOperationContext();
@@ -2276,14 +2146,10 @@ TEST_F(ReplCoordTest, SingleNodeReplSetUnfreeze) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 1
- << "members"
+ << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "test1:1234"))
- << "protocolVersion"
- << 1
- << "settings"
+ << "protocolVersion" << 1 << "settings"
<< BSON("electionTimeoutMillis" << 10000)),
HostAndPort("test1", 1234));
auto opCtx = makeOperationContext();
@@ -2341,9 +2207,7 @@ 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));
@@ -2406,9 +2270,7 @@ TEST_F(
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 1
- << "members"
+ << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "test1:1234"))),
HostAndPort("test1", 1234));
@@ -2762,13 +2624,10 @@ TEST_F(ReplCoordTest,
ASSERT_EQUALS(MemberState::RS_STARTUP, getReplCoord()->getMemberState().s);
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id"
- << 0))),
+ << "_id" << 0))),
HostAndPort("node1", 12345));
}
@@ -2776,9 +2635,7 @@ TEST_F(ReplCoordTest, NodeIncludesOtherMembersProgressInUpdatePositionCommand) {
init("mySet/test1:1234,test2:1234,test3:1234");
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 1
- << "members"
+ << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "test1:1234")
<< BSON("_id" << 1 << "host"
@@ -2855,11 +2712,7 @@ TEST_F(ReplCoordTest,
init("mySet/test1:1234,test2:1234,test3:1234");
assertStartSuccess(BSON("_id"
<< "mySet"
- << "protocolVersion"
- << 1
- << "version"
- << 1
- << "members"
+ << "protocolVersion" << 1 << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "test1:1234")
<< BSON("_id" << 1 << "host"
@@ -2882,11 +2735,7 @@ TEST_F(ReplCoordTest,
init("mySet/test1:1234,test2:1234,test3:1234");
assertStartSuccess(BSON("_id"
<< "mySet"
- << "protocolVersion"
- << 1
- << "version"
- << 1
- << "members"
+ << "protocolVersion" << 1 << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "test1:1234")
<< BSON("_id" << 1 << "host"
@@ -2918,11 +2767,7 @@ TEST_F(ReplCoordTest, AllowAsManyUnsetMaintenanceModesAsThereHaveBeenSetMaintena
init("mySet/test1:1234,test2:1234,test3:1234");
assertStartSuccess(BSON("_id"
<< "mySet"
- << "protocolVersion"
- << 1
- << "version"
- << 1
- << "members"
+ << "protocolVersion" << 1 << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "test1:1234")
<< BSON("_id" << 1 << "host"
@@ -2952,11 +2797,7 @@ TEST_F(ReplCoordTest, SettingAndUnsettingMaintenanceModeShouldNotAffectRollbackS
init("mySet/test1:1234,test2:1234,test3:1234");
assertStartSuccess(BSON("_id"
<< "mySet"
- << "protocolVersion"
- << 1
- << "version"
- << 1
- << "members"
+ << "protocolVersion" << 1 << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "test1:1234")
<< BSON("_id" << 1 << "host"
@@ -2998,11 +2839,7 @@ TEST_F(ReplCoordTest, DoNotAllowMaintenanceModeWhilePrimary) {
init("mySet/test1:1234,test2:1234,test3:1234");
assertStartSuccess(BSON("_id"
<< "mySet"
- << "protocolVersion"
- << 1
- << "version"
- << 1
- << "members"
+ << "protocolVersion" << 1 << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "test1:1234")
<< BSON("_id" << 1 << "host"
@@ -3037,11 +2874,7 @@ TEST_F(ReplCoordTest, DoNotAllowSettingMaintenanceModeWhileConductingAnElection)
init("mySet/test1:1234,test2:1234,test3:1234");
assertStartSuccess(BSON("_id"
<< "mySet"
- << "protocolVersion"
- << 1
- << "version"
- << 1
- << "members"
+ << "protocolVersion" << 1 << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "test1:1234")
<< BSON("_id" << 1 << "host"
@@ -3109,9 +2942,7 @@ 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()))),
@@ -3154,9 +2985,7 @@ 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()))),
@@ -3192,19 +3021,14 @@ 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();
@@ -3242,9 +3066,7 @@ TEST_F(ReplCoordTest, IsMaster) {
BSON(
"_id"
<< "mySet"
- << "version"
- << 2
- << "members"
+ << "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)
@@ -3307,9 +3129,7 @@ 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));
@@ -3339,9 +3159,7 @@ TEST_F(ReplCoordTest, IsMasterInShutdown) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 1
- << "members"
+ << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "test1:1234"))),
HostAndPort("test1", 1234));
@@ -3377,21 +3195,16 @@ TEST_F(ReplCoordTest, LogAMessageWhenShutDownBeforeReplicationStartUpFinished) {
TEST_F(ReplCoordTest, DoNotProcessSelfWhenUpdatePositionContainsInfoAboutSelf) {
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)
+ << "_id" << 1)
<< BSON("host"
<< "node3:12345"
- << "_id"
- << 2))),
+ << "_id" << 2))),
HostAndPort("node1", 12345));
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
replCoordSetMyLastAppliedOpTime(OpTimeWithTermOne(100, 1), Date_t() + Seconds(100));
@@ -3418,18 +3231,13 @@ TEST_F(ReplCoordTest, DoNotProcessSelfWhenUpdatePositionContainsInfoAboutSelf) {
ASSERT_OK(updatePositionArgsInitialize(
args,
BSON(UpdatePositionArgs::kCommandFieldName
- << 1
- << UpdatePositionArgs::kUpdateArrayFieldName
+ << 1 << UpdatePositionArgs::kUpdateArrayFieldName
<< BSON_ARRAY(BSON(UpdatePositionArgs::kConfigVersionFieldName
- << 2
- << UpdatePositionArgs::kMemberIdFieldName
- << 0
- << UpdatePositionArgs::kDurableOpTimeFieldName
- << time2.toBSON()
+ << 2 << UpdatePositionArgs::kMemberIdFieldName << 0
+ << UpdatePositionArgs::kDurableOpTimeFieldName << time2.toBSON()
<< UpdatePositionArgs::kDurableWallTimeFieldName
<< Date_t() + Seconds(time2.getSecs())
- << UpdatePositionArgs::kAppliedOpTimeFieldName
- << time2.toBSON()
+ << UpdatePositionArgs::kAppliedOpTimeFieldName << time2.toBSON()
<< UpdatePositionArgs::kAppliedWallTimeFieldName
<< Date_t() + Seconds(time2.getSecs()))))));
@@ -3441,21 +3249,16 @@ TEST_F(ReplCoordTest, DoNotProcessSelfWhenUpdatePositionContainsInfoAboutSelf) {
TEST_F(ReplCoordTest, DoNotProcessUpdatePositionWhenItsConfigVersionIsIncorrect) {
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)
+ << "_id" << 1)
<< BSON("host"
<< "node3:12345"
- << "_id"
- << 2))),
+ << "_id" << 2))),
HostAndPort("node1", 12345));
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
replCoordSetMyLastAppliedOpTime(OpTimeWithTermOne(100, 1), Date_t() + Seconds(100));
@@ -3476,18 +3279,13 @@ TEST_F(ReplCoordTest, DoNotProcessUpdatePositionWhenItsConfigVersionIsIncorrect)
ASSERT_OK(updatePositionArgsInitialize(
args,
BSON(UpdatePositionArgs::kCommandFieldName
- << 1
- << UpdatePositionArgs::kUpdateArrayFieldName
+ << 1 << UpdatePositionArgs::kUpdateArrayFieldName
<< BSON_ARRAY(BSON(UpdatePositionArgs::kConfigVersionFieldName
- << 3
- << UpdatePositionArgs::kMemberIdFieldName
- << 1
- << UpdatePositionArgs::kDurableOpTimeFieldName
- << time2.toBSON()
+ << 3 << UpdatePositionArgs::kMemberIdFieldName << 1
+ << UpdatePositionArgs::kDurableOpTimeFieldName << time2.toBSON()
<< UpdatePositionArgs::kDurableWallTimeFieldName
<< Date_t() + Seconds(time2.getSecs())
- << UpdatePositionArgs::kAppliedOpTimeFieldName
- << time2.toBSON()
+ << UpdatePositionArgs::kAppliedOpTimeFieldName << time2.toBSON()
<< UpdatePositionArgs::kAppliedWallTimeFieldName
<< Date_t() + Seconds(time2.getSecs()))))));
@@ -3504,21 +3302,16 @@ TEST_F(ReplCoordTest, DoNotProcessUpdatePositionWhenItsConfigVersionIsIncorrect)
TEST_F(ReplCoordTest, DoNotProcessUpdatePositionOfMembersWhoseIdsAreNotInTheConfig) {
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)
+ << "_id" << 1)
<< BSON("host"
<< "node3:12345"
- << "_id"
- << 2))),
+ << "_id" << 2))),
HostAndPort("node1", 12345));
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
replCoordSetMyLastAppliedOpTime(OpTimeWithTermOne(100, 1), Date_t() + Seconds(100));
@@ -3539,18 +3332,13 @@ TEST_F(ReplCoordTest, DoNotProcessUpdatePositionOfMembersWhoseIdsAreNotInTheConf
ASSERT_OK(updatePositionArgsInitialize(
args,
BSON(UpdatePositionArgs::kCommandFieldName
- << 1
- << UpdatePositionArgs::kUpdateArrayFieldName
+ << 1 << UpdatePositionArgs::kUpdateArrayFieldName
<< BSON_ARRAY(BSON(UpdatePositionArgs::kConfigVersionFieldName
- << 2
- << UpdatePositionArgs::kMemberIdFieldName
- << 9
- << UpdatePositionArgs::kDurableOpTimeFieldName
- << time2.toBSON()
+ << 2 << UpdatePositionArgs::kMemberIdFieldName << 9
+ << UpdatePositionArgs::kDurableOpTimeFieldName << time2.toBSON()
<< UpdatePositionArgs::kDurableWallTimeFieldName
<< Date_t() + Seconds(time2.getSecs())
- << UpdatePositionArgs::kAppliedOpTimeFieldName
- << time2.toBSON()
+ << UpdatePositionArgs::kAppliedOpTimeFieldName << time2.toBSON()
<< UpdatePositionArgs::kAppliedWallTimeFieldName
<< Date_t() + Seconds(time2.getSecs()))))));
@@ -3567,21 +3355,16 @@ TEST_F(ReplCoordTest,
ProcessUpdateWhenUpdatePositionContainsOnlyConfigVersionAndMemberIdsWithoutRIDs) {
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)
+ << "_id" << 1)
<< BSON("host"
<< "node3:12345"
- << "_id"
- << 2))),
+ << "_id" << 2))),
HostAndPort("node1", 12345));
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
replCoordSetMyLastAppliedOpTime(OpTimeWithTermOne(100, 1), Date_t() + Seconds(100));
@@ -3605,32 +3388,26 @@ TEST_F(ReplCoordTest,
ASSERT_OK(updatePositionArgsInitialize(
args,
BSON(UpdatePositionArgs::kCommandFieldName
- << 1
- << UpdatePositionArgs::kUpdateArrayFieldName
- << BSON_ARRAY(BSON(UpdatePositionArgs::kConfigVersionFieldName
- << 2
- << UpdatePositionArgs::kMemberIdFieldName
- << 1
- << UpdatePositionArgs::kAppliedOpTimeFieldName
- << time2.asOpTime().toBSON()
- << UpdatePositionArgs::kAppliedWallTimeFieldName
- << Date_t() + Seconds(time2.asOpTime().getSecs())
- << UpdatePositionArgs::kDurableOpTimeFieldName
- << time2.asOpTime().toBSON()
- << UpdatePositionArgs::kDurableWallTimeFieldName
- << Date_t() + Seconds(time2.asOpTime().getSecs()))
- << BSON(UpdatePositionArgs::kConfigVersionFieldName
- << 2
- << UpdatePositionArgs::kMemberIdFieldName
- << 2
- << UpdatePositionArgs::kAppliedOpTimeFieldName
- << time2.asOpTime().toBSON()
- << UpdatePositionArgs::kAppliedWallTimeFieldName
- << Date_t() + Seconds(time2.asOpTime().getSecs())
- << UpdatePositionArgs::kDurableOpTimeFieldName
- << time2.asOpTime().toBSON()
- << UpdatePositionArgs::kDurableWallTimeFieldName
- << Date_t() + Seconds(time2.asOpTime().getSecs()))))));
+ << 1 << UpdatePositionArgs::kUpdateArrayFieldName
+ << BSON_ARRAY(
+ BSON(UpdatePositionArgs::kConfigVersionFieldName
+ << 2 << UpdatePositionArgs::kMemberIdFieldName << 1
+ << UpdatePositionArgs::kAppliedOpTimeFieldName << time2.asOpTime().toBSON()
+ << UpdatePositionArgs::kAppliedWallTimeFieldName
+ << Date_t() + Seconds(time2.asOpTime().getSecs())
+ << UpdatePositionArgs::kDurableOpTimeFieldName << time2.asOpTime().toBSON()
+ << UpdatePositionArgs::kDurableWallTimeFieldName
+ << Date_t() + Seconds(time2.asOpTime().getSecs()))
+ << BSON(UpdatePositionArgs::kConfigVersionFieldName
+ << 2 << UpdatePositionArgs::kMemberIdFieldName << 2
+ << UpdatePositionArgs::kAppliedOpTimeFieldName
+ << time2.asOpTime().toBSON()
+ << UpdatePositionArgs::kAppliedWallTimeFieldName
+ << Date_t() + Seconds(time2.asOpTime().getSecs())
+ << UpdatePositionArgs::kDurableOpTimeFieldName
+ << time2.asOpTime().toBSON()
+ << UpdatePositionArgs::kDurableWallTimeFieldName
+ << Date_t() + Seconds(time2.asOpTime().getSecs()))))));
auto opCtx = makeOperationContext();
@@ -3651,15 +3428,10 @@ void doReplSetReconfig(ReplicationCoordinatorImpl* replCoord, Status* status) {
args.force = false;
args.newConfigObj = BSON("_id"
<< "mySet"
- << "version"
- << 3
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 3 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "node1:12345"
- << "priority"
- << 3)
+ << "priority" << 3)
<< BSON("_id" << 1 << "host"
<< "node2:12345")
<< BSON("_id" << 2 << "host"
@@ -3670,21 +3442,16 @@ void doReplSetReconfig(ReplicationCoordinatorImpl* replCoord, Status* status) {
TEST_F(ReplCoordTest, AwaitReplicationShouldResolveAsNormalDuringAReconfig) {
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)
+ << "_id" << 1)
<< BSON("host"
<< "node3:12345"
- << "_id"
- << 2))),
+ << "_id" << 2))),
HostAndPort("node1", 12345));
// Turn off readconcern majority support, and snapshots.
@@ -3751,11 +3518,7 @@ void doReplSetReconfigToFewer(ReplicationCoordinatorImpl* replCoord, Status* sta
args.force = false;
args.newConfigObj = BSON("_id"
<< "mySet"
- << "version"
- << 3
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 3 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "node1:12345")
<< BSON("_id" << 2 << "host"
@@ -3768,21 +3531,16 @@ TEST_F(
NodeReturnsUnsatisfiableWriteConcernWhenReconfiggingToAClusterThatCannotSatisfyTheWriteConcern) {
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)
+ << "_id" << 1)
<< BSON("host"
<< "node3:12345"
- << "_id"
- << 2))),
+ << "_id" << 2))),
HostAndPort("node1", 12345));
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
replCoordSetMyLastAppliedOpTime(OpTimeWithTermOne(100, 2), Date_t() + Seconds(100));
@@ -3829,29 +3587,22 @@ TEST_F(ReplCoordTest,
NodeReturnsOKFromAwaitReplicationWhenReconfiggingToASetWhereMajorityIsSmallerAndSatisfied) {
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)
+ << "_id" << 1)
<< BSON("host"
<< "node3:12345"
- << "_id"
- << 2)
+ << "_id" << 2)
<< BSON("host"
<< "node4:12345"
- << "_id"
- << 3)
+ << "_id" << 3)
<< BSON("host"
<< "node5:12345"
- << "_id"
- << 4))),
+ << "_id" << 4))),
HostAndPort("node1", 12345));
// Turn off readconcern majority support, and snapshots.
@@ -3912,35 +3663,22 @@ TEST_F(ReplCoordTest,
// satisfied by voting data-bearing members.
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)
+ << "_id" << 1)
<< BSON("host"
<< "node3:12345"
- << "_id"
- << 2)
+ << "_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_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
OpTime time(Timestamp(100, 1), 1);
@@ -3980,35 +3718,22 @@ TEST_F(ReplCoordTest,
// Test that the commit level advances properly.
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)
+ << "_id" << 1)
<< BSON("host"
<< "node3:12345"
- << "_id"
- << 2)
+ << "_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_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
OpTime zero(Timestamp(0, 0), 0);
@@ -4240,11 +3965,7 @@ TEST_F(StableOpTimeTest, SetMyLastAppliedSetsStableOpTimeForStorage) {
init("mySet/test1:1234,test2:1234,test3:1234");
assertStartSuccess(BSON("_id"
<< "mySet"
- << "protocolVersion"
- << 1
- << "version"
- << 1
- << "members"
+ << "protocolVersion" << 1 << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "test1:1234")
<< BSON("_id" << 1 << "host"
@@ -4308,11 +4029,7 @@ TEST_F(StableOpTimeTest, SetMyLastAppliedSetsStableOpTimeForStorageDisableMajori
init("mySet/test1:1234,test2:1234,test3:1234");
assertStartSuccess(BSON("_id"
<< "mySet"
- << "protocolVersion"
- << 1
- << "version"
- << 1
- << "members"
+ << "protocolVersion" << 1 << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "test1:1234")
<< BSON("_id" << 1 << "host"
@@ -4345,11 +4062,7 @@ TEST_F(StableOpTimeTest, AdvanceCommitPointSetsStableOpTimeForStorage) {
init("mySet/test1:1234,test2:1234,test3:1234");
assertStartSuccess(BSON("_id"
<< "mySet"
- << "protocolVersion"
- << 1
- << "version"
- << 1
- << "members"
+ << "protocolVersion" << 1 << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "test1:1234")
<< BSON("_id" << 1 << "host"
@@ -4407,15 +4120,11 @@ TEST_F(StableOpTimeTest, ClearOpTimeCandidatesPastCommonPointAfterRollback) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 1
- << "members"
+ << "version" << 1 << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id"
- << 0))
- << "protocolVersion"
- << 1),
+ << "_id" << 0))
+ << "protocolVersion" << 1),
HostAndPort("node1", 12345));
auto repl = getReplCoord();
@@ -4511,13 +4220,10 @@ TEST_F(StableOpTimeTest, OpTimeCandidatesAreNotAddedWhenStateIsNotConsistent) {
TEST_F(ReplCoordTest, NodeReturnsShutdownInProgressWhenWaitingUntilAnOpTimeDuringShutdown) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id"
- << 0))),
+ << "_id" << 0))),
HostAndPort("node1", 12345));
replCoordSetMyLastAppliedOpTime(OpTimeWithTermOne(10, 1), Date_t() + Seconds(100));
@@ -4536,13 +4242,10 @@ TEST_F(ReplCoordTest, NodeReturnsShutdownInProgressWhenWaitingUntilAnOpTimeDurin
TEST_F(ReplCoordTest, NodeReturnsInterruptedWhenWaitingUntilAnOpTimeIsInterrupted) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id"
- << 0))),
+ << "_id" << 0))),
HostAndPort("node1", 12345));
replCoordSetMyLastAppliedOpTime(OpTimeWithTermOne(10, 1), Date_t() + Seconds(100));
@@ -4560,13 +4263,10 @@ TEST_F(ReplCoordTest, NodeReturnsInterruptedWhenWaitingUntilAnOpTimeIsInterrupte
TEST_F(ReplCoordTest, NodeReturnsOkImmediatelyWhenWaitingUntilOpTimePassesNoOpTime) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id"
- << 0))),
+ << "_id" << 0))),
HostAndPort("node1", 12345));
auto opCtx = makeOperationContext();
@@ -4577,13 +4277,10 @@ TEST_F(ReplCoordTest, NodeReturnsOkImmediatelyWhenWaitingUntilOpTimePassesNoOpTi
TEST_F(ReplCoordTest, NodeReturnsOkImmediatelyWhenWaitingUntilOpTimePassesAnOpTimePriorToOurLast) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id"
- << 0))),
+ << "_id" << 0))),
HostAndPort("node1", 12345));
replCoordSetMyLastAppliedOpTime(OpTimeWithTermOne(100, 1), Date_t() + Seconds(100));
@@ -4599,13 +4296,10 @@ TEST_F(ReplCoordTest, NodeReturnsOkImmediatelyWhenWaitingUntilOpTimePassesAnOpTi
TEST_F(ReplCoordTest, NodeReturnsOkImmediatelyWhenWaitingUntilOpTimePassesAnOpTimeEqualToOurLast) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id"
- << 0))),
+ << "_id" << 0))),
HostAndPort("node1", 12345));
@@ -4646,13 +4340,10 @@ TEST_F(ReplCoordTest, NodeReturnsNotAReplicaSetWhenWaitUntilOpTimeIsRunAgainstAS
TEST_F(ReplCoordTest, ReadAfterCommittedWhileShutdown) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id"
- << 0))),
+ << "_id" << 0))),
HostAndPort("node1", 12345));
auto opCtx = makeOperationContext();
@@ -4672,13 +4363,10 @@ TEST_F(ReplCoordTest, ReadAfterCommittedWhileShutdown) {
TEST_F(ReplCoordTest, ReadAfterCommittedInterrupted) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id"
- << 0))),
+ << "_id" << 0))),
HostAndPort("node1", 12345));
const auto opCtx = makeOperationContext();
runSingleNodeElection(opCtx.get());
@@ -4695,13 +4383,10 @@ TEST_F(ReplCoordTest, ReadAfterCommittedInterrupted) {
TEST_F(ReplCoordTest, ReadAfterCommittedGreaterOpTime) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id"
- << 0))),
+ << "_id" << 0))),
HostAndPort("node1", 12345));
auto opCtx = makeOperationContext();
runSingleNodeElection(opCtx.get());
@@ -4717,13 +4402,10 @@ TEST_F(ReplCoordTest, ReadAfterCommittedGreaterOpTime) {
TEST_F(ReplCoordTest, ReadAfterCommittedEqualOpTime) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id"
- << 0))),
+ << "_id" << 0))),
HostAndPort("node1", 12345));
auto opCtx = makeOperationContext();
runSingleNodeElection(opCtx.get());
@@ -4739,13 +4421,10 @@ TEST_F(ReplCoordTest, ReadAfterCommittedEqualOpTime) {
TEST_F(ReplCoordTest, ReadAfterCommittedDeferredGreaterOpTime) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id"
- << 0))),
+ << "_id" << 0))),
HostAndPort("node1", 12345));
auto opCtx = makeOperationContext();
@@ -4767,13 +4446,10 @@ TEST_F(ReplCoordTest, ReadAfterCommittedDeferredGreaterOpTime) {
TEST_F(ReplCoordTest, ReadAfterCommittedDeferredEqualOpTime) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id"
- << 0))),
+ << "_id" << 0))),
HostAndPort("node1", 12345));
auto opCtx = makeOperationContext();
runSingleNodeElection(opCtx.get());
@@ -4797,13 +4473,10 @@ TEST_F(ReplCoordTest, ReadAfterCommittedDeferredEqualOpTime) {
TEST_F(ReplCoordTest, WaitUntilOpTimeforReadRejectsUnsupportedMajorityReadConcern) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id"
- << 0))),
+ << "_id" << 0))),
HostAndPort("node1", 12345));
auto opCtx = makeOperationContext();
@@ -4829,21 +4502,16 @@ 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)
+ << "_id" << 1)
<< BSON("host"
<< "node3:12345"
- << "_id"
- << 2))),
+ << "_id" << 2))),
HostAndPort("node1", 12345));
ASSERT_EQUALS(OpTime(Timestamp(0, 0), 0), getReplCoord()->getLastCommittedOpTime());
@@ -4851,35 +4519,20 @@ TEST_F(ReplCoordTest, IgnoreTheContentsOfMetadataWhenItsConfigVersionDoesNotMatc
StatusWith<rpc::ReplSetMetadata> metadata = replReadFromMetadata(BSON(
rpc::kReplSetMetadataFieldName << BSON(
"lastOpCommitted" << BSON("ts" << Timestamp(10, 0) << "t" << 2) << "lastCommittedWall"
- << Date_t() + Seconds(100)
- << "lastOpVisible"
- << BSON("ts" << Timestamp(10, 0) << "t" << 2)
- << "configVersion"
- << 1
- << "primaryIndex"
- << 2
- << "term"
- << 2
- << "syncSourceIndex"
- << 1)));
+ << Date_t() + Seconds(100) << "lastOpVisible"
+ << BSON("ts" << Timestamp(10, 0) << "t" << 2) << "configVersion" << 1
+ << "primaryIndex" << 2 << "term" << 2 << "syncSourceIndex" << 1)));
getReplCoord()->processReplSetMetadata(metadata.getValue());
ASSERT_EQUALS(0, getReplCoord()->getTerm());
// higher configVersion
- StatusWith<rpc::ReplSetMetadata> metadata2 = replReadFromMetadata(BSON(
- rpc::kReplSetMetadataFieldName << BSON(
- "lastOpCommitted" << BSON("ts" << Timestamp(10, 0) << "t" << 2) << "lastCommittedWall"
- << Date_t() + Seconds(100)
- << "lastOpVisible"
- << BSON("ts" << Timestamp(10, 0) << "t" << 2)
- << "configVersion"
- << 100
- << "primaryIndex"
- << 2
- << "term"
- << 2
- << "syncSourceIndex"
- << 1)));
+ StatusWith<rpc::ReplSetMetadata> metadata2 = replReadFromMetadata(
+ BSON(rpc::kReplSetMetadataFieldName
+ << BSON("lastOpCommitted"
+ << BSON("ts" << Timestamp(10, 0) << "t" << 2) << "lastCommittedWall"
+ << Date_t() + Seconds(100) << "lastOpVisible"
+ << BSON("ts" << Timestamp(10, 0) << "t" << 2) << "configVersion" << 100
+ << "primaryIndex" << 2 << "term" << 2 << "syncSourceIndex" << 1)));
getReplCoord()->processReplSetMetadata(metadata2.getValue());
ASSERT_EQUALS(0, getReplCoord()->getTerm());
}
@@ -4889,23 +4542,17 @@ TEST_F(ReplCoordTest, UpdateLastCommittedOpTimeWhenTheLastCommittedOpTimeIsNewer
// 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)
+ << "_id" << 1)
<< BSON("host"
<< "node3:12345"
- << "_id"
- << 2))
- << "protocolVersion"
- << 1),
+ << "_id" << 2))
+ << "protocolVersion" << 1),
HostAndPort("node1", 12345));
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
ASSERT_EQUALS(OpTime(Timestamp(0, 0), 0), getReplCoord()->getLastCommittedOpTime());
@@ -4935,23 +4582,17 @@ 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)
+ << "_id" << 1)
<< BSON("host"
<< "node3:12345"
- << "_id"
- << 2))
- << "protocolVersion"
- << 1),
+ << "_id" << 2))
+ << "protocolVersion" << 1),
HostAndPort("node1", 12345));
ASSERT_EQUALS(OpTime(Timestamp(0, 0), 0), getReplCoord()->getLastCommittedOpTime());
auto opCtx = makeOperationContext();
@@ -4962,17 +4603,9 @@ TEST_F(ReplCoordTest, UpdateTermWhenTheTermFromMetadataIsNewerButNeverUpdateCurr
StatusWith<rpc::ReplSetMetadata> metadata = replReadFromMetadata(BSON(
rpc::kReplSetMetadataFieldName << BSON(
"lastOpCommitted" << BSON("ts" << Timestamp(10, 0) << "t" << 3) << "lastCommittedWall"
- << Date_t() + Seconds(100)
- << "lastOpVisible"
- << BSON("ts" << Timestamp(10, 0) << "t" << 3)
- << "configVersion"
- << 2
- << "primaryIndex"
- << 2
- << "term"
- << 3
- << "syncSourceIndex"
- << 1)));
+ << Date_t() + Seconds(100) << "lastOpVisible"
+ << BSON("ts" << Timestamp(10, 0) << "t" << 3) << "configVersion" << 2
+ << "primaryIndex" << 2 << "term" << 3 << "syncSourceIndex" << 1)));
getReplCoord()->processReplSetMetadata(metadata.getValue());
ASSERT_EQUALS(3, getReplCoord()->getTerm());
ASSERT_EQUALS(-1, getTopoCoord().getCurrentPrimaryIndex());
@@ -4982,17 +4615,9 @@ TEST_F(ReplCoordTest, UpdateTermWhenTheTermFromMetadataIsNewerButNeverUpdateCurr
StatusWith<rpc::ReplSetMetadata> metadata2 = replReadFromMetadata(BSON(
rpc::kReplSetMetadataFieldName << BSON(
"lastOpCommitted" << BSON("ts" << Timestamp(11, 0) << "t" << 3) << "lastCommittedWall"
- << Date_t() + Seconds(100)
- << "lastOpVisible"
- << BSON("ts" << Timestamp(11, 0) << "t" << 3)
- << "configVersion"
- << 2
- << "primaryIndex"
- << 1
- << "term"
- << 2
- << "syncSourceIndex"
- << 1)));
+ << Date_t() + Seconds(100) << "lastOpVisible"
+ << BSON("ts" << Timestamp(11, 0) << "t" << 3) << "configVersion" << 2
+ << "primaryIndex" << 1 << "term" << 2 << "syncSourceIndex" << 1)));
getReplCoord()->processReplSetMetadata(metadata2.getValue());
ASSERT_EQUALS(3, getReplCoord()->getTerm());
ASSERT_EQUALS(-1, getTopoCoord().getCurrentPrimaryIndex());
@@ -5002,17 +4627,9 @@ TEST_F(ReplCoordTest, UpdateTermWhenTheTermFromMetadataIsNewerButNeverUpdateCurr
StatusWith<rpc::ReplSetMetadata> metadata3 = replReadFromMetadata(BSON(
rpc::kReplSetMetadataFieldName << BSON(
"lastOpCommitted" << BSON("ts" << Timestamp(11, 0) << "t" << 3) << "lastCommittedWall"
- << Date_t() + Seconds(100)
- << "lastOpVisible"
- << BSON("ts" << Timestamp(11, 0) << "t" << 3)
- << "configVersion"
- << 2
- << "primaryIndex"
- << 1
- << "term"
- << 3
- << "syncSourceIndex"
- << 1)));
+ << Date_t() + Seconds(100) << "lastOpVisible"
+ << BSON("ts" << Timestamp(11, 0) << "t" << 3) << "configVersion" << 2
+ << "primaryIndex" << 1 << "term" << 3 << "syncSourceIndex" << 1)));
getReplCoord()->processReplSetMetadata(metadata3.getValue());
ASSERT_EQUALS(3, getReplCoord()->getTerm());
ASSERT_EQUALS(-1, getTopoCoord().getCurrentPrimaryIndex());
@@ -5024,19 +4641,14 @@ TEST_F(ReplCoordTest,
// Ensure that the metadata is processed if it is contained in a heartbeat response.
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))
- << "protocolVersion"
- << 1),
+ << "_id" << 1))
+ << "protocolVersion" << 1),
HostAndPort("node1", 12345));
ASSERT_EQUALS(OpTime(Timestamp(0, 0), 0), getReplCoord()->getLastCommittedOpTime());
auto opCtx = makeOperationContext();
@@ -5048,19 +4660,12 @@ TEST_F(ReplCoordTest,
// Higher term - should update term but not last committed optime.
StatusWith<rpc::ReplSetMetadata> metadata = replReadFromMetadata(BSON(
- rpc::kReplSetMetadataFieldName << BSON(
- "lastOpCommitted" << BSON("ts" << Timestamp(10, 0) << "t" << 3) << "lastCommittedWall"
- << Date_t() + Seconds(100)
- << "lastOpVisible"
- << BSON("ts" << Timestamp(10, 0) << "t" << 3)
- << "configVersion"
- << config.getConfigVersion()
- << "primaryIndex"
- << 1
- << "term"
- << 3
- << "syncSourceIndex"
- << 1)));
+ rpc::kReplSetMetadataFieldName
+ << BSON("lastOpCommitted" << BSON("ts" << Timestamp(10, 0) << "t" << 3)
+ << "lastCommittedWall" << Date_t() + Seconds(100)
+ << "lastOpVisible" << BSON("ts" << Timestamp(10, 0) << "t" << 3)
+ << "configVersion" << config.getConfigVersion() << "primaryIndex"
+ << 1 << "term" << 3 << "syncSourceIndex" << 1)));
BSONObjBuilder responseBuilder;
ASSERT_OK(metadata.getValue().writeToMetadata(&responseBuilder));
@@ -5090,19 +4695,14 @@ TEST_F(ReplCoordTest,
TEST_F(ReplCoordTest, AdvanceCommitPointFromSyncSourceCanSetCommitPointToLastAppliedIgnoringTerm) {
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))
- << "protocolVersion"
- << 1),
+ << "_id" << 1))
+ << "protocolVersion" << 1),
HostAndPort("node1", 12345));
ASSERT_EQUALS(OpTime(), getReplCoord()->getLastCommittedOpTime());
@@ -5120,23 +4720,17 @@ TEST_F(ReplCoordTest, AdvanceCommitPointFromSyncSourceCanSetCommitPointToLastApp
TEST_F(ReplCoordTest, PrepareOplogQueryMetadata) {
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)
+ << "_id" << 1)
<< BSON("host"
<< "node3:12345"
- << "_id"
- << 2))
- << "protocolVersion"
- << 1),
+ << "_id" << 2))
+ << "protocolVersion" << 1),
HostAndPort("node1", 12345));
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
@@ -5184,21 +4778,14 @@ TEST_F(ReplCoordTest, TermAndLastCommittedOpTimeUpdatedFromHeartbeatWhenArbiter)
// Ensure that the metadata is processed if it is contained in a heartbeat response.
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id"
- << 0
- << "arbiterOnly"
- << true)
+ << "_id" << 0 << "arbiterOnly" << true)
<< BSON("host"
<< "node2:12345"
- << "_id"
- << 1))
- << "protocolVersion"
- << 1),
+ << "_id" << 1))
+ << "protocolVersion" << 1),
HostAndPort("node1", 12345));
ASSERT_EQUALS(OpTime(Timestamp(0, 0), 0), getReplCoord()->getLastCommittedOpTime());
auto opCtx = makeOperationContext();
@@ -5211,19 +4798,12 @@ TEST_F(ReplCoordTest, TermAndLastCommittedOpTimeUpdatedFromHeartbeatWhenArbiter)
// Higher term - should update term and lastCommittedOpTime since arbiters learn of the
// commit point via heartbeats.
StatusWith<rpc::ReplSetMetadata> metadata = replReadFromMetadata(BSON(
- rpc::kReplSetMetadataFieldName << BSON(
- "lastOpCommitted" << BSON("ts" << Timestamp(10, 1) << "t" << 3) << "lastCommittedWall"
- << Date_t() + Seconds(100)
- << "lastOpVisible"
- << BSON("ts" << Timestamp(10, 1) << "t" << 3)
- << "configVersion"
- << config.getConfigVersion()
- << "primaryIndex"
- << 1
- << "term"
- << 3
- << "syncSourceIndex"
- << 1)));
+ rpc::kReplSetMetadataFieldName
+ << BSON("lastOpCommitted" << BSON("ts" << Timestamp(10, 1) << "t" << 3)
+ << "lastCommittedWall" << Date_t() + Seconds(100)
+ << "lastOpVisible" << BSON("ts" << Timestamp(10, 1) << "t" << 3)
+ << "configVersion" << config.getConfigVersion() << "primaryIndex"
+ << 1 << "term" << 3 << "syncSourceIndex" << 1)));
BSONObjBuilder responseBuilder;
ASSERT_OK(metadata.getValue().writeToMetadata(&responseBuilder));
@@ -5254,19 +4834,13 @@ 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();
@@ -5305,19 +4879,13 @@ TEST_F(ReplCoordTest,
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();
@@ -5336,23 +4904,13 @@ 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_OK(replCoord->setFollowerMode(MemberState::RS_SECONDARY));
@@ -5367,19 +4925,13 @@ 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();
@@ -5405,15 +4957,10 @@ TEST_F(ReplCoordTest,
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))))
.transitional_ignore();
hbResp.setConfig(config);
hbResp.setConfigVersion(3);
@@ -5437,19 +4984,13 @@ TEST_F(ReplCoordTest,
RescheduleElectionTimeoutWhenProcessingHeartbeatResponseFromPrimaryInSameTerm) {
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();
@@ -5494,19 +5035,13 @@ TEST_F(ReplCoordTest,
DontRescheduleElectionTimeoutWhenProcessingHeartbeatResponseFromPrimaryInDiffertTerm) {
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();
@@ -5548,19 +5083,13 @@ 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();
@@ -5600,9 +5129,7 @@ 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));
@@ -5636,9 +5163,7 @@ 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));
@@ -5668,9 +5193,7 @@ 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));
@@ -5693,13 +5216,10 @@ TEST_F(ReplCoordTest,
NodeChangesMyLastOpTimeWhenAndOnlyWhensetMyLastDurableOpTimeReceivesANewerOpTime4DurableSE) {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id"
- << 0))),
+ << "_id" << 0))),
HostAndPort("node1", 12345));
@@ -5723,13 +5243,10 @@ DEATH_TEST_F(ReplCoordTest,
"opTime.getTimestamp() > myLastAppliedOpTime.getTimestamp()") {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id"
- << 0))),
+ << "_id" << 0))),
HostAndPort("node1", 12345));
@@ -5749,13 +5266,10 @@ DEATH_TEST_F(ReplCoordTest,
"opTime.getTimestamp() > myLastAppliedOpTime.getTimestamp()") {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id"
- << 0))),
+ << "_id" << 0))),
HostAndPort("node1", 12345));
@@ -5775,13 +5289,10 @@ DEATH_TEST_F(ReplCoordTest,
"opTime.getTimestamp() < myLastAppliedOpTime.getTimestamp()") {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id"
- << 0))),
+ << "_id" << 0))),
HostAndPort("node1", 12345));
@@ -5801,13 +5312,10 @@ DEATH_TEST_F(ReplCoordTest,
"opTime.getTimestamp() < myLastAppliedOpTime.getTimestamp()") {
assertStartSuccess(BSON("_id"
<< "mySet"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("host"
<< "node1:12345"
- << "_id"
- << 0))),
+ << "_id" << 0))),
HostAndPort("node1", 12345));
@@ -5826,18 +5334,14 @@ 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"
+ << "protocolVersion" << 1 << "settings"
<< BSON("electionTimeoutMillis" << 2000 << "heartbeatIntervalMillis" << 40000)),
HostAndPort("test1", 1234));
OpTime optime(Timestamp(100, 2), 0);
@@ -5900,18 +5404,14 @@ TEST_F(ReplCoordTest, UpdatePositionCmdHasMetadata) {
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"
+ << "protocolVersion" << 1 << "settings"
<< BSON("electionTimeoutMillis" << 2000 << "heartbeatIntervalMillis" << 40000)),
HostAndPort("test1", 1234));
OpTime optime(Timestamp(100, 2), 0);
@@ -5941,32 +5441,23 @@ 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)
+ << "_id" << 1)
<< BSON("host"
<< "node3:12345"
- << "_id"
- << 2)
+ << "_id" << 2)
<< BSON("host"
<< "node4:12345"
- << "_id"
- << 3)
+ << "_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_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
@@ -5978,57 +5469,42 @@ TEST_F(ReplCoordTest, StepDownWhenHandleLivenessTimeoutMarksAMajorityOfVotingNod
UpdatePositionArgs args;
ASSERT_OK(updatePositionArgsInitialize(
args,
- BSON(UpdatePositionArgs::kCommandFieldName
- << 1
- << UpdatePositionArgs::kUpdateArrayFieldName
- << BSON_ARRAY(BSON(UpdatePositionArgs::kConfigVersionFieldName
- << 2
- << UpdatePositionArgs::kMemberIdFieldName
- << 1
- << UpdatePositionArgs::kAppliedOpTimeFieldName
- << startingOpTime.toBSON()
- << UpdatePositionArgs::kAppliedWallTimeFieldName
- << Date_t() + Seconds(startingOpTime.getSecs())
- << UpdatePositionArgs::kDurableOpTimeFieldName
- << startingOpTime.toBSON()
- << UpdatePositionArgs::kDurableWallTimeFieldName
- << Date_t() + Seconds(startingOpTime.getSecs()))
- << BSON(UpdatePositionArgs::kConfigVersionFieldName
- << 2
- << UpdatePositionArgs::kMemberIdFieldName
- << 2
- << UpdatePositionArgs::kAppliedOpTimeFieldName
- << startingOpTime.toBSON()
- << UpdatePositionArgs::kAppliedWallTimeFieldName
- << Date_t() + Seconds(startingOpTime.getSecs())
- << UpdatePositionArgs::kDurableOpTimeFieldName
- << startingOpTime.toBSON()
- << UpdatePositionArgs::kDurableWallTimeFieldName
- << Date_t() + Seconds(startingOpTime.getSecs()))
- << BSON(UpdatePositionArgs::kConfigVersionFieldName
- << 2
- << UpdatePositionArgs::kMemberIdFieldName
- << 3
- << UpdatePositionArgs::kAppliedOpTimeFieldName
- << startingOpTime.toBSON()
- << UpdatePositionArgs::kAppliedWallTimeFieldName
- << Date_t() + Seconds(startingOpTime.getSecs())
- << UpdatePositionArgs::kDurableOpTimeFieldName
- << startingOpTime.toBSON()
- << UpdatePositionArgs::kDurableWallTimeFieldName
- << Date_t() + Seconds(startingOpTime.getSecs()))
- << BSON(UpdatePositionArgs::kConfigVersionFieldName
- << 2
- << UpdatePositionArgs::kMemberIdFieldName
- << 4
- << UpdatePositionArgs::kAppliedOpTimeFieldName
- << startingOpTime.toBSON()
- << UpdatePositionArgs::kAppliedWallTimeFieldName
- << Date_t() + Seconds(startingOpTime.getSecs())
- << UpdatePositionArgs::kDurableOpTimeFieldName
- << startingOpTime.toBSON()
- << UpdatePositionArgs::kDurableWallTimeFieldName
- << Date_t() + Seconds(startingOpTime.getSecs()))))));
+ BSON(
+ UpdatePositionArgs::kCommandFieldName
+ << 1 << UpdatePositionArgs::kUpdateArrayFieldName
+ << BSON_ARRAY(
+ BSON(UpdatePositionArgs::kConfigVersionFieldName
+ << 2 << UpdatePositionArgs::kMemberIdFieldName << 1
+ << UpdatePositionArgs::kAppliedOpTimeFieldName << startingOpTime.toBSON()
+ << UpdatePositionArgs::kAppliedWallTimeFieldName
+ << Date_t() + Seconds(startingOpTime.getSecs())
+ << UpdatePositionArgs::kDurableOpTimeFieldName << startingOpTime.toBSON()
+ << UpdatePositionArgs::kDurableWallTimeFieldName
+ << Date_t() + Seconds(startingOpTime.getSecs()))
+ << BSON(UpdatePositionArgs::kConfigVersionFieldName
+ << 2 << UpdatePositionArgs::kMemberIdFieldName << 2
+ << UpdatePositionArgs::kAppliedOpTimeFieldName << startingOpTime.toBSON()
+ << UpdatePositionArgs::kAppliedWallTimeFieldName
+ << Date_t() + Seconds(startingOpTime.getSecs())
+ << UpdatePositionArgs::kDurableOpTimeFieldName << startingOpTime.toBSON()
+ << UpdatePositionArgs::kDurableWallTimeFieldName
+ << Date_t() + Seconds(startingOpTime.getSecs()))
+ << BSON(UpdatePositionArgs::kConfigVersionFieldName
+ << 2 << UpdatePositionArgs::kMemberIdFieldName << 3
+ << UpdatePositionArgs::kAppliedOpTimeFieldName << startingOpTime.toBSON()
+ << UpdatePositionArgs::kAppliedWallTimeFieldName
+ << Date_t() + Seconds(startingOpTime.getSecs())
+ << UpdatePositionArgs::kDurableOpTimeFieldName << startingOpTime.toBSON()
+ << UpdatePositionArgs::kDurableWallTimeFieldName
+ << Date_t() + Seconds(startingOpTime.getSecs()))
+ << BSON(UpdatePositionArgs::kConfigVersionFieldName
+ << 2 << UpdatePositionArgs::kMemberIdFieldName << 4
+ << UpdatePositionArgs::kAppliedOpTimeFieldName << startingOpTime.toBSON()
+ << UpdatePositionArgs::kAppliedWallTimeFieldName
+ << Date_t() + Seconds(startingOpTime.getSecs())
+ << UpdatePositionArgs::kDurableOpTimeFieldName << startingOpTime.toBSON()
+ << UpdatePositionArgs::kDurableWallTimeFieldName
+ << Date_t() + Seconds(startingOpTime.getSecs()))))));
ASSERT_OK(getReplCoord()->processReplSetUpdatePosition(args, nullptr));
// Become PRIMARY.
@@ -6038,33 +5514,26 @@ TEST_F(ReplCoordTest, StepDownWhenHandleLivenessTimeoutMarksAMajorityOfVotingNod
UpdatePositionArgs args1;
ASSERT_OK(updatePositionArgsInitialize(
args1,
- BSON(UpdatePositionArgs::kCommandFieldName
- << 1
- << UpdatePositionArgs::kUpdateArrayFieldName
- << BSON_ARRAY(BSON(UpdatePositionArgs::kConfigVersionFieldName
- << 2
- << UpdatePositionArgs::kMemberIdFieldName
- << 1
- << UpdatePositionArgs::kAppliedOpTimeFieldName
- << startingOpTime.toBSON()
- << UpdatePositionArgs::kAppliedWallTimeFieldName
- << Date_t() + Seconds(startingOpTime.getSecs())
- << UpdatePositionArgs::kDurableOpTimeFieldName
- << startingOpTime.toBSON()
- << UpdatePositionArgs::kDurableWallTimeFieldName
- << Date_t() + Seconds(startingOpTime.getSecs()))
- << BSON(UpdatePositionArgs::kConfigVersionFieldName
- << 2
- << UpdatePositionArgs::kMemberIdFieldName
- << 2
- << UpdatePositionArgs::kAppliedOpTimeFieldName
- << startingOpTime.toBSON()
- << UpdatePositionArgs::kAppliedWallTimeFieldName
- << Date_t() + Seconds(startingOpTime.getSecs())
- << UpdatePositionArgs::kDurableOpTimeFieldName
- << startingOpTime.toBSON()
- << UpdatePositionArgs::kDurableWallTimeFieldName
- << Date_t() + Seconds(startingOpTime.getSecs())))),
+ BSON(
+ UpdatePositionArgs::kCommandFieldName
+ << 1 << UpdatePositionArgs::kUpdateArrayFieldName
+ << BSON_ARRAY(
+ BSON(UpdatePositionArgs::kConfigVersionFieldName
+ << 2 << UpdatePositionArgs::kMemberIdFieldName << 1
+ << UpdatePositionArgs::kAppliedOpTimeFieldName << startingOpTime.toBSON()
+ << UpdatePositionArgs::kAppliedWallTimeFieldName
+ << Date_t() + Seconds(startingOpTime.getSecs())
+ << UpdatePositionArgs::kDurableOpTimeFieldName << startingOpTime.toBSON()
+ << UpdatePositionArgs::kDurableWallTimeFieldName
+ << Date_t() + Seconds(startingOpTime.getSecs()))
+ << BSON(UpdatePositionArgs::kConfigVersionFieldName
+ << 2 << UpdatePositionArgs::kMemberIdFieldName << 2
+ << UpdatePositionArgs::kAppliedOpTimeFieldName << startingOpTime.toBSON()
+ << UpdatePositionArgs::kAppliedWallTimeFieldName
+ << Date_t() + Seconds(startingOpTime.getSecs())
+ << UpdatePositionArgs::kDurableOpTimeFieldName << startingOpTime.toBSON()
+ << UpdatePositionArgs::kDurableWallTimeFieldName
+ << Date_t() + Seconds(startingOpTime.getSecs())))),
/*requireWallTime*/ true));
const Date_t startDate = getNet()->now();
getNet()->enterNetwork();
@@ -6106,20 +5575,16 @@ TEST_F(ReplCoordTest, StepDownWhenHandleLivenessTimeoutMarksAMajorityOfVotingNod
ASSERT_OK(updatePositionArgsInitialize(
args2,
BSON(UpdatePositionArgs::kCommandFieldName
- << 1
- << UpdatePositionArgs::kUpdateArrayFieldName
- << BSON_ARRAY(BSON(UpdatePositionArgs::kConfigVersionFieldName
- << 2
- << UpdatePositionArgs::kMemberIdFieldName
- << 1
- << UpdatePositionArgs::kDurableOpTimeFieldName
- << startingOpTime.toBSON()
- << UpdatePositionArgs::kDurableWallTimeFieldName
- << Date_t() + Seconds(startingOpTime.getSecs())
- << UpdatePositionArgs::kAppliedOpTimeFieldName
- << startingOpTime.toBSON()
- << UpdatePositionArgs::kAppliedWallTimeFieldName
- << Date_t() + Seconds(startingOpTime.getSecs()))))));
+ << 1 << UpdatePositionArgs::kUpdateArrayFieldName
+ << BSON_ARRAY(
+ BSON(UpdatePositionArgs::kConfigVersionFieldName
+ << 2 << UpdatePositionArgs::kMemberIdFieldName << 1
+ << UpdatePositionArgs::kDurableOpTimeFieldName << startingOpTime.toBSON()
+ << UpdatePositionArgs::kDurableWallTimeFieldName
+ << Date_t() + Seconds(startingOpTime.getSecs())
+ << UpdatePositionArgs::kAppliedOpTimeFieldName << startingOpTime.toBSON()
+ << UpdatePositionArgs::kAppliedWallTimeFieldName
+ << Date_t() + Seconds(startingOpTime.getSecs()))))));
ASSERT_OK(getReplCoord()->processReplSetUpdatePosition(args2, nullptr));
hbArgs.setSetName("mySet");
@@ -6149,9 +5614,7 @@ 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));
@@ -6186,9 +5649,7 @@ 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));
@@ -6227,13 +5688,10 @@ 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;
@@ -6250,13 +5708,10 @@ 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;
@@ -6271,13 +5726,10 @@ 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;
@@ -6299,13 +5751,10 @@ 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;
@@ -6322,21 +5771,16 @@ TEST_F(ReplCoordTest, PopulateUnsetWriteConcernOptionsSyncModeReturnsInputIfWMod
TEST_F(ReplCoordTest, NodeStoresElectionVotes) {
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)
+ << "_id" << 1)
<< BSON("host"
<< "node3:12345"
- << "_id"
- << 2))),
+ << "_id" << 2))),
HostAndPort("node1", 12345));
auto time = OpTimeWithTermOne(100, 1);
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
@@ -6349,15 +5793,9 @@ TEST_F(ReplCoordTest, NodeStoresElectionVotes) {
ReplSetRequestVotesArgs args;
ASSERT_OK(args.initialize(BSON("replSetRequestVotes" << 1 << "setName"
<< "mySet"
- << "term"
- << 7LL
- << "candidateIndex"
- << 2LL
- << "configVersion"
- << 2LL
- << "dryRun"
- << false
- << "lastCommittedOp"
+ << "term" << 7LL << "candidateIndex" << 2LL
+ << "configVersion" << 2LL << "dryRun"
+ << false << "lastCommittedOp"
<< time.asOpTime().toBSON())));
ReplSetRequestVotesResponse response;
@@ -6376,21 +5814,16 @@ TEST_F(ReplCoordTest, NodeStoresElectionVotes) {
TEST_F(ReplCoordTest, NodeDoesNotStoreDryRunVotes) {
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)
+ << "_id" << 1)
<< BSON("host"
<< "node3:12345"
- << "_id"
- << 2))),
+ << "_id" << 2))),
HostAndPort("node1", 12345));
auto time = OpTimeWithTermOne(100, 1);
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
@@ -6403,15 +5836,9 @@ TEST_F(ReplCoordTest, NodeDoesNotStoreDryRunVotes) {
ReplSetRequestVotesArgs args;
ASSERT_OK(args.initialize(BSON("replSetRequestVotes" << 1 << "setName"
<< "mySet"
- << "term"
- << 7LL
- << "candidateIndex"
- << 2LL
- << "configVersion"
- << 2LL
- << "dryRun"
- << true
- << "lastCommittedOp"
+ << "term" << 7LL << "candidateIndex" << 2LL
+ << "configVersion" << 2LL << "dryRun"
+ << true << "lastCommittedOp"
<< time.asOpTime().toBSON())));
ReplSetRequestVotesResponse response;
@@ -6432,17 +5859,13 @@ TEST_F(ReplCoordTest, NodeFailsVoteRequestIfItFailsToStoreLastVote) {
// Set up a 2-node replica set config.
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))),
+ << "_id" << 1))),
HostAndPort("node1", 12345));
auto time = OpTimeWithTermOne(100, 1);
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
@@ -6457,18 +5880,12 @@ TEST_F(ReplCoordTest, NodeFailsVoteRequestIfItFailsToStoreLastVote) {
auto opCtx = makeOperationContext();
ReplSetRequestVotesArgs args;
- ASSERT_OK(args.initialize(BSON("replSetRequestVotes" << 1 << "setName"
- << "mySet"
- << "term"
- << initTerm + 1 // term of new candidate.
- << "candidateIndex"
- << 1LL
- << "configVersion"
- << 2LL
- << "dryRun"
- << false
- << "lastCommittedOp"
- << time.asOpTime().toBSON())));
+ ASSERT_OK(args.initialize(BSON("replSetRequestVotes"
+ << 1 << "setName"
+ << "mySet"
+ << "term" << initTerm + 1 // term of new candidate.
+ << "candidateIndex" << 1LL << "configVersion" << 2LL << "dryRun"
+ << false << "lastCommittedOp" << time.asOpTime().toBSON())));
ReplSetRequestVotesResponse response;
// Simulate a failure to write the 'last vote' document. The specific error code isn't
@@ -6493,17 +5910,13 @@ TEST_F(ReplCoordTest, NodeNodesNotGrantVoteIfInTerminalShutdown) {
// Set up a 2-node replica set config.
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))),
+ << "_id" << 1))),
HostAndPort("node1", 12345));
auto time = OpTimeWithTermOne(100, 1);
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
@@ -6518,18 +5931,12 @@ TEST_F(ReplCoordTest, NodeNodesNotGrantVoteIfInTerminalShutdown) {
auto opCtx = makeOperationContext();
ReplSetRequestVotesArgs args;
- ASSERT_OK(args.initialize(BSON("replSetRequestVotes" << 1 << "setName"
- << "mySet"
- << "term"
- << initTerm + 1 // term of new candidate.
- << "candidateIndex"
- << 1LL
- << "configVersion"
- << 2LL
- << "dryRun"
- << false
- << "lastCommittedOp"
- << time.asOpTime().toBSON())));
+ ASSERT_OK(args.initialize(BSON("replSetRequestVotes"
+ << 1 << "setName"
+ << "mySet"
+ << "term" << initTerm + 1 // term of new candidate.
+ << "candidateIndex" << 1LL << "configVersion" << 2LL << "dryRun"
+ << false << "lastCommittedOp" << time.asOpTime().toBSON())));
ReplSetRequestVotesResponse response;
getReplCoord()->enterTerminalShutdown();
diff --git a/src/mongo/db/repl/replication_coordinator_test_fixture.cpp b/src/mongo/db/repl/replication_coordinator_test_fixture.cpp
index 058d841d597..a2e5e2d9e8a 100644
--- a/src/mongo/db/repl/replication_coordinator_test_fixture.cpp
+++ b/src/mongo/db/repl/replication_coordinator_test_fixture.cpp
@@ -277,14 +277,13 @@ 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 if (consumeHeartbeatV1(noi)) {
// The heartbeat has been consumed.
@@ -346,14 +345,13 @@ void ReplCoordTest::simulateSuccessfulV1ElectionWithoutExitingDrainMode(Date_t e
hbResp.setConfigVersion(rsConfig.getConfigVersion());
net->scheduleResponse(noi, net->now(), makeResponseStatus(hbResp.toBSON()));
} 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;
diff --git a/src/mongo/db/repl/replication_info.cpp b/src/mongo/db/repl/replication_info.cpp
index 7a1fcbd0e0f..c20aa0c87d4 100644
--- a/src/mongo/db/repl/replication_info.cpp
+++ b/src/mongo/db/repl/replication_info.cpp
@@ -67,10 +67,10 @@ namespace mongo {
MONGO_FAIL_POINT_DEFINE(waitInIsMaster);
-using std::unique_ptr;
using std::list;
using std::string;
using std::stringstream;
+using std::unique_ptr;
namespace repl {
namespace {
@@ -330,8 +330,7 @@ public:
} else {
uasserted(ErrorCodes::BadValue,
str::stream() << "Unrecognized field of 'internalClient': '"
- << fieldName
- << "'");
+ << fieldName << "'");
}
}
diff --git a/src/mongo/db/repl/replication_recovery.cpp b/src/mongo/db/repl/replication_recovery.cpp
index b7e57eb1742..6b533d42cb1 100644
--- a/src/mongo/db/repl/replication_recovery.cpp
+++ b/src/mongo/db/repl/replication_recovery.cpp
@@ -398,8 +398,7 @@ void ReplicationRecoveryImpl::_applyToEndOfOplog(OperationContext* opCtx,
invariant(applyThroughOpTime.getTimestamp() == topOfOplog,
str::stream() << "Did not apply to top of oplog. Applied through: "
<< applyThroughOpTime.toString()
- << ". Top of oplog: "
- << topOfOplog.toString());
+ << ". Top of oplog: " << topOfOplog.toString());
oplogBuffer.shutdown(opCtx);
// We may crash before setting appliedThrough. If we have a stable checkpoint, we will recover
diff --git a/src/mongo/db/repl/replication_recovery_test.cpp b/src/mongo/db/repl/replication_recovery_test.cpp
index f8e65db8228..84d31b48a9a 100644
--- a/src/mongo/db/repl/replication_recovery_test.cpp
+++ b/src/mongo/db/repl/replication_recovery_test.cpp
@@ -1125,9 +1125,7 @@ TEST_F(ReplicationRecoveryTest, CommitTransactionOplogEntryCorrectlyUpdatesConfi
const auto txnOperations = BSON_ARRAY(BSON("op"
<< "i"
- << "ns"
- << testNs.toString()
- << "o"
+ << "ns" << testNs.toString() << "o"
<< BSON("_id" << 1)));
const auto prepareDate = Date_t::now();
const auto prepareOp =
@@ -1202,9 +1200,7 @@ TEST_F(ReplicationRecoveryTest,
const auto txnOperations = BSON_ARRAY(BSON("op"
<< "i"
- << "ns"
- << testNs.toString()
- << "o"
+ << "ns" << testNs.toString() << "o"
<< BSON("_id" << 1)));
const auto prepareDate = Date_t::now();
const auto prepareOp =
diff --git a/src/mongo/db/repl/reporter_test.cpp b/src/mongo/db/repl/reporter_test.cpp
index de8b60edfa4..f4538c6c6fa 100644
--- a/src/mongo/db/repl/reporter_test.cpp
+++ b/src/mongo/db/repl/reporter_test.cpp
@@ -380,8 +380,7 @@ 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();
@@ -400,8 +399,7 @@ 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();
@@ -417,8 +415,7 @@ TEST_F(ReporterTest,
processNetworkResponse(BSON("ok" << 0 << "code" << int(ErrorCodes::InvalidReplicaSetConfig)
<< "errmsg"
<< "newer config"
- << "configVersion"
- << posUpdater->getConfigVersion() + 1));
+ << "configVersion" << posUpdater->getConfigVersion() + 1));
ASSERT_TRUE(reporter->isActive());
}
diff --git a/src/mongo/db/repl/roll_back_local_operations.cpp b/src/mongo/db/repl/roll_back_local_operations.cpp
index 09047074164..1e5b102a595 100644
--- a/src/mongo/db/repl/roll_back_local_operations.cpp
+++ b/src/mongo/db/repl/roll_back_local_operations.cpp
@@ -123,14 +123,11 @@ StatusWith<RollBackLocalOperations::RollbackCommonPoint> RollBackLocalOperations
auto result = _localOplogIterator->next();
if (!result.isOK()) {
return Status(ErrorCodes::NoMatchingDocument,
- str::stream() << "reached beginning of local oplog: {"
- << "scanned: "
- << _scanned
- << ", theirTime: "
- << getTimestamp(operation).toString()
- << ", ourTime: "
- << getTimestamp(_localOplogValue).toString()
- << "}");
+ str::stream()
+ << "reached beginning of local oplog: {"
+ << "scanned: " << _scanned
+ << ", theirTime: " << getTimestamp(operation).toString()
+ << ", ourTime: " << getTimestamp(_localOplogValue).toString() << "}");
}
opAfterCurrentEntry = _localOplogValue.first;
_localOplogValue = result.getValue();
@@ -200,11 +197,8 @@ StatusWith<RollBackLocalOperations::RollbackCommonPoint> syncRollBackLocalOperat
}
return Status(ErrorCodes::NoMatchingDocument,
str::stream() << "reached beginning of remote oplog: {"
- << "them: "
- << remoteOplog.toString()
- << ", theirTime: "
- << theirTime.toString()
- << "}");
+ << "them: " << remoteOplog.toString()
+ << ", theirTime: " << theirTime.toString() << "}");
}
} // namespace repl
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 1f8a933b67c..67fff417d0a 100644
--- a/src/mongo/db/repl/roll_back_local_operations_test.cpp
+++ b/src/mongo/db/repl/roll_back_local_operations_test.cpp
@@ -50,26 +50,18 @@ BSONObj makeOp(long long seconds, long long term = 1LL) {
auto uuid = unittest::assertGet(UUID::parse("b4c66a44-c1ca-4d86-8d25-12e82fa2de5b"));
return BSON("ts" << Timestamp(seconds, seconds) << "t" << term << "op"
<< "n"
- << "o"
- << BSONObj()
- << "ns"
+ << "o" << BSONObj() << "ns"
<< "roll_back_local_operations.test"
- << "ui"
- << uuid);
+ << "ui" << uuid);
}
BSONObj makeOpWithWallClockTime(long count, long wallClockMillis, long long term = 1LL) {
auto uuid = unittest::assertGet(UUID::parse("b4c66a44-c1ca-4d86-8d25-12e82fa2de5b"));
return BSON("ts" << Timestamp(count, count) << "t" << term << "op"
<< "n"
- << "o"
- << BSONObj()
- << "ns"
+ << "o" << BSONObj() << "ns"
<< "roll_back_local_operations.test"
- << "ui"
- << uuid
- << "wall"
- << Date_t::fromMillisSinceEpoch(wallClockMillis));
+ << "ui" << uuid << "wall" << Date_t::fromMillisSinceEpoch(wallClockMillis));
};
int recordId = 0;
@@ -150,7 +142,8 @@ TEST(RollBackLocalOperationsTest, RollbackMultipleLocalOperations) {
TEST(RollBackLocalOperationsTest, RollbackOperationFailed) {
auto commonOperation = makeOpAndRecordId(1);
OplogInterfaceMock::Operations localOperations({
- makeOpAndRecordId(2), commonOperation,
+ makeOpAndRecordId(2),
+ commonOperation,
});
OplogInterfaceMock localOplog(localOperations);
auto rollbackOperation = [&](const BSONObj& operation) {
@@ -175,7 +168,10 @@ TEST(RollBackLocalOperationsTest, EndOfLocalOplog) {
TEST(RollBackLocalOperationsTest, SkipRemoteOperations) {
auto commonOperation = makeOpAndRecordId(1);
OplogInterfaceMock::Operations localOperations({
- makeOpAndRecordId(5), makeOpAndRecordId(4), makeOpAndRecordId(2), commonOperation,
+ makeOpAndRecordId(5),
+ makeOpAndRecordId(4),
+ makeOpAndRecordId(2),
+ commonOperation,
});
OplogInterfaceMock localOplog(localOperations);
auto i = localOperations.cbegin();
@@ -209,7 +205,8 @@ TEST(RollBackLocalOperationsTest, SkipRemoteOperations) {
TEST(RollBackLocalOperationsTest, SameTimestampDifferentTermsRollbackNoSuchKey) {
auto commonOperation = makeOpAndRecordId(1, 1);
OplogInterfaceMock::Operations localOperations({
- makeOpAndRecordId(2, 3), commonOperation,
+ makeOpAndRecordId(2, 3),
+ commonOperation,
});
OplogInterfaceMock localOplog(localOperations);
auto rollbackOperation = [&](const BSONObj& operation) {
@@ -242,7 +239,9 @@ TEST(SyncRollBackLocalOperationsTest, RollbackTwoOperations) {
auto commonOperation = makeOpWithWallClockTimeAndRecordId(1, 1 * 5000);
auto firstOpAfterCommonPoint = makeOpWithWallClockTimeAndRecordId(2, 2 * 60 * 60 * 24 * 1000);
OplogInterfaceMock::Operations localOperations({
- makeOpAndRecordId(3), firstOpAfterCommonPoint, commonOperation,
+ makeOpAndRecordId(3),
+ firstOpAfterCommonPoint,
+ commonOperation,
});
auto i = localOperations.cbegin();
auto result = syncRollBackLocalOperations(OplogInterfaceMock(localOperations),
diff --git a/src/mongo/db/repl/rollback_impl.cpp b/src/mongo/db/repl/rollback_impl.cpp
index b6aca140721..73c484ec452 100644
--- a/src/mongo/db/repl/rollback_impl.cpp
+++ b/src/mongo/db/repl/rollback_impl.cpp
@@ -100,8 +100,9 @@ boost::optional<long long> _parseDroppedCollectionCount(const OplogEntry& oplogE
auto obj2 = oplogEntry.getObject2();
if (!obj2) {
- warning() << "Unable to get collection count from " << desc << " without the o2 "
- "field. oplog op: "
+ warning() << "Unable to get collection count from " << desc
+ << " without the o2 "
+ "field. oplog op: "
<< redact(oplogEntry.toBSON());
return boost::none;
}
@@ -324,10 +325,10 @@ Status RollbackImpl::_transitionToRollback(OperationContext* opCtx) {
auto status =
_replicationCoordinator->setFollowerModeStrict(opCtx, MemberState::RS_ROLLBACK);
if (!status.isOK()) {
- status.addContext(str::stream() << "Cannot transition from "
- << _replicationCoordinator->getMemberState().toString()
- << " to "
- << MemberState(MemberState::RS_ROLLBACK).toString());
+ status.addContext(str::stream()
+ << "Cannot transition from "
+ << _replicationCoordinator->getMemberState().toString() << " to "
+ << MemberState(MemberState::RS_ROLLBACK).toString());
log() << status;
return status;
}
@@ -416,9 +417,9 @@ StatusWith<std::set<NamespaceString>> RollbackImpl::_namespacesForOp(const Oplog
// These commands do not need to be supported by rollback. 'convertToCapped' should
// always be converted to lower level DDL operations, and 'emptycapped' is a
// testing-only command.
- std::string message = str::stream() << "Encountered unsupported command type '"
- << firstElem.fieldName()
- << "' during rollback.";
+ std::string message = str::stream()
+ << "Encountered unsupported command type '" << firstElem.fieldName()
+ << "' during rollback.";
return Status(ErrorCodes::UnrecoverableRollbackError, message);
}
case OplogEntry::CommandType::kCreate:
@@ -594,8 +595,7 @@ void RollbackImpl::_correctRecordStoreCounts(OperationContext* opCtx) {
auto collToScan = autoCollToScan.getCollection();
invariant(coll == collToScan,
str::stream() << "Catalog returned invalid collection: " << nss.ns() << " ("
- << uuid.toString()
- << ")");
+ << uuid.toString() << ")");
auto exec = collToScan->makePlanExecutor(
opCtx, PlanExecutor::INTERRUPT_ONLY, Collection::ScanDirection::kForward);
long long countFromScan = 0;
@@ -816,8 +816,7 @@ Status RollbackImpl::_processRollbackOp(OperationContext* opCtx, const OplogEntr
const auto uuid = oplogEntry.getUuid().get();
invariant(_countDiffs.find(uuid) == _countDiffs.end(),
str::stream() << "Unexpected existing count diff for " << uuid.toString()
- << " op: "
- << redact(oplogEntry.toBSON()));
+ << " op: " << redact(oplogEntry.toBSON()));
if (auto countResult = _parseDroppedCollectionCount(oplogEntry)) {
PendingDropInfo info;
info.count = *countResult;
@@ -843,10 +842,9 @@ Status RollbackImpl::_processRollbackOp(OperationContext* opCtx, const OplogEntr
<< "Oplog entry to roll back is unexpectedly missing dropTarget UUID: "
<< redact(oplogEntry.toBSON()));
invariant(_countDiffs.find(dropTargetUUID) == _countDiffs.end(),
- str::stream() << "Unexpected existing count diff for "
- << dropTargetUUID.toString()
- << " op: "
- << redact(oplogEntry.toBSON()));
+ str::stream()
+ << "Unexpected existing count diff for " << dropTargetUUID.toString()
+ << " op: " << redact(oplogEntry.toBSON()));
if (auto countResult = _parseDroppedCollectionCount(oplogEntry)) {
PendingDropInfo info;
info.count = *countResult;
@@ -1012,9 +1010,7 @@ Status RollbackImpl::_checkAgainstTimeLimit(
if (diff > timeLimit) {
return Status(ErrorCodes::UnrecoverableRollbackError,
str::stream() << "not willing to roll back more than " << timeLimit
- << " seconds of data. Have: "
- << diff
- << " seconds.");
+ << " seconds of data. Have: " << diff << " seconds.");
}
} else {
@@ -1044,8 +1040,7 @@ Timestamp RollbackImpl::_findTruncateTimestamp(
invariant(commonPointTime.getStatus());
invariant(commonPointTime.getValue() == commonPointOpTime,
str::stream() << "Common point: " << commonPointOpTime.toString()
- << ", record found: "
- << commonPointTime.getValue().toString());
+ << ", record found: " << commonPointTime.getValue().toString());
// Get the next document, which will be the first document to truncate.
auto truncatePointRecord = oplogCursor->next();
diff --git a/src/mongo/db/repl/rollback_impl.h b/src/mongo/db/repl/rollback_impl.h
index ef1e1985cb5..00ca82d3fef 100644
--- a/src/mongo/db/repl/rollback_impl.h
+++ b/src/mongo/db/repl/rollback_impl.h
@@ -285,7 +285,7 @@ public:
virtual const std::vector<BSONObj>& docsDeletedForNamespace_forTest(UUID uuid) const& {
MONGO_UNREACHABLE;
}
- void docsDeletedForNamespace_forTest(UUID)&& = delete;
+ void docsDeletedForNamespace_forTest(UUID) && = delete;
protected:
/**
diff --git a/src/mongo/db/repl/rollback_impl_test.cpp b/src/mongo/db/repl/rollback_impl_test.cpp
index 77a28bfbe1c..e7fa22eef19 100644
--- a/src/mongo/db/repl/rollback_impl_test.cpp
+++ b/src/mongo/db/repl/rollback_impl_test.cpp
@@ -69,37 +69,21 @@ std::string kGenericUUIDStr = "b4c66a44-c1ca-4d86-8d25-12e82fa2de5b";
BSONObj makeInsertOplogEntry(long long time, BSONObj obj, StringData ns, UUID uuid) {
return BSON("ts" << Timestamp(time, time) << "t" << time << "op"
<< "i"
- << "o"
- << obj
- << "ns"
- << ns
- << "ui"
- << uuid);
+ << "o" << obj << "ns" << ns << "ui" << uuid);
}
BSONObj makeUpdateOplogEntry(
long long time, BSONObj query, BSONObj update, StringData ns, UUID uuid) {
return BSON("ts" << Timestamp(time, time) << "t" << time << "op"
<< "u"
- << "ns"
- << ns
- << "ui"
- << uuid
- << "o2"
- << query
- << "o"
+ << "ns" << ns << "ui" << uuid << "o2" << query << "o"
<< BSON("$set" << update));
}
BSONObj makeDeleteOplogEntry(long long time, BSONObj id, StringData ns, UUID uuid) {
return BSON("ts" << Timestamp(time, time) << "t" << time << "op"
<< "d"
- << "ns"
- << ns
- << "ui"
- << uuid
- << "o"
- << id);
+ << "ns" << ns << "ui" << uuid << "o" << id);
}
class RollbackImplForTest final : public RollbackImpl {
@@ -380,12 +364,7 @@ BSONObj makeOp(OpTime time) {
auto kGenericUUID = unittest::assertGet(UUID::parse(kGenericUUIDStr));
return BSON("ts" << time.getTimestamp() << "t" << time.getTerm() << "op"
<< "n"
- << "o"
- << BSONObj()
- << "ns"
- << nss.ns()
- << "ui"
- << kGenericUUID);
+ << "o" << BSONObj() << "ns" << nss.ns() << "ui" << kGenericUUID);
}
BSONObj makeOp(int count) {
@@ -400,13 +379,9 @@ auto makeOpWithWallClockTime(long count, long wallClockMillis) {
auto kGenericUUID = unittest::assertGet(UUID::parse(kGenericUUIDStr));
return BSON("ts" << Timestamp(count, count) << "t" << (long long)count << "op"
<< "n"
- << "o"
- << BSONObj()
- << "ns"
+ << "o" << BSONObj() << "ns"
<< "top"
- << "ui"
- << kGenericUUID
- << "wall"
+ << "ui" << kGenericUUID << "wall"
<< Date_t::fromMillisSinceEpoch(wallClockMillis));
};
@@ -955,14 +930,10 @@ TEST_F(RollbackImplTest, RollbackDoesNotWriteRollbackFilesIfNoInsertsOrUpdatesAf
const auto uuid = UUID::gen();
const auto nss = NamespaceString("db.coll");
const auto coll = _initializeCollection(_opCtx.get(), uuid, nss);
- const auto oplogEntry = BSON("ts" << Timestamp(3, 3) << "t" << 3LL << "op"
- << "c"
- << "o"
- << BSON("create" << nss.coll())
- << "ns"
- << nss.ns()
- << "ui"
- << uuid);
+ const auto oplogEntry =
+ BSON("ts" << Timestamp(3, 3) << "t" << 3LL << "op"
+ << "c"
+ << "o" << BSON("create" << nss.coll()) << "ns" << nss.ns() << "ui" << uuid);
ASSERT_OK(_insertOplogEntry(oplogEntry));
ASSERT_OK(_rollback->runRollback(_opCtx.get()));
@@ -1183,12 +1154,7 @@ TEST_F(RollbackImplTest, RollbackProperlySavesFilesWhenInsertsAndDropOfCollectio
const auto oplogEntry =
BSON("ts" << dropOpTime.getTimestamp() << "t" << dropOpTime.getTerm() << "op"
<< "c"
- << "o"
- << BSON("drop" << nss.coll())
- << "ns"
- << nss.ns()
- << "ui"
- << uuid);
+ << "o" << BSON("drop" << nss.coll()) << "ns" << nss.ns() << "ui" << uuid);
ASSERT_OK(_insertOplogEntry(oplogEntry));
ASSERT_OK(_rollback->runRollback(_opCtx.get()));
@@ -1213,14 +1179,10 @@ TEST_F(RollbackImplTest, RollbackProperlySavesFilesWhenCreateCollAndInsertsAreRo
const auto nss = NamespaceString("db.people");
const auto uuid = UUID::gen();
const auto coll = _initializeCollection(_opCtx.get(), uuid, nss);
- const auto oplogEntry = BSON("ts" << Timestamp(3, 3) << "t" << 3LL << "op"
- << "c"
- << "o"
- << BSON("create" << nss.coll())
- << "ns"
- << nss.ns()
- << "ui"
- << uuid);
+ const auto oplogEntry =
+ BSON("ts" << Timestamp(3, 3) << "t" << 3LL << "op"
+ << "c"
+ << "o" << BSON("create" << nss.coll()) << "ns" << nss.ns() << "ui" << uuid);
ASSERT_OK(_insertOplogEntry(oplogEntry));
// Insert documents into the collection.
@@ -1584,14 +1546,14 @@ public:
void assertRollbackInfoContainsObjectForUUID(UUID uuid, BSONObj bson) {
const auto& uuidToIdMap = _rbInfo.rollbackDeletedIdsMap;
auto search = uuidToIdMap.find(uuid);
- ASSERT(search != uuidToIdMap.end()) << "map is unexpectedly missing an entry for uuid "
- << uuid.toString() << " containing object "
- << bson.jsonString();
+ ASSERT(search != uuidToIdMap.end())
+ << "map is unexpectedly missing an entry for uuid " << uuid.toString()
+ << " containing object " << bson.jsonString();
const auto& idObjSet = search->second;
const auto iter = idObjSet.find(bson);
- ASSERT(iter != idObjSet.end()) << "_id object set is unexpectedly missing object "
- << bson.jsonString() << " in namespace with uuid "
- << uuid.toString();
+ ASSERT(iter != idObjSet.end())
+ << "_id object set is unexpectedly missing object " << bson.jsonString()
+ << " in namespace with uuid " << uuid.toString();
}
@@ -1675,12 +1637,12 @@ TEST_F(RollbackImplObserverInfoTest, NamespacesForOpsExtractsNamespaceOfDropColl
TEST_F(RollbackImplObserverInfoTest, NamespacesForOpsExtractsNamespaceOfCreateIndexOplogEntry) {
auto nss = NamespaceString("test", "coll");
- auto indexObj = BSON("createIndexes" << nss.coll() << "ns" << nss.toString() << "v"
- << static_cast<int>(IndexDescriptor::IndexVersion::kV2)
- << "key"
- << "x"
- << "name"
- << "x_1");
+ auto indexObj =
+ BSON("createIndexes" << nss.coll() << "ns" << nss.toString() << "v"
+ << static_cast<int>(IndexDescriptor::IndexVersion::kV2) << "key"
+ << "x"
+ << "name"
+ << "x_1");
auto cmdOp =
makeCommandOp(Timestamp(2, 2), UUID::gen(), nss.getCommandNS().toString(), indexObj, 2);
diff --git a/src/mongo/db/repl/rollback_source_impl.cpp b/src/mongo/db/repl/rollback_source_impl.cpp
index aecd404f865..7d893f0c4fb 100644
--- a/src/mongo/db/repl/rollback_source_impl.cpp
+++ b/src/mongo/db/repl/rollback_source_impl.cpp
@@ -107,9 +107,7 @@ StatusWith<BSONObj> RollbackSourceImpl::getCollectionInfoByUUID(const std::strin
return StatusWith<BSONObj>(ErrorCodes::NoSuchKey,
str::stream()
<< "No collection info found for collection with uuid: "
- << uuid.toString()
- << " in db: "
- << db);
+ << uuid.toString() << " in db: " << db);
}
invariant(info.size() == 1U);
return info.front();
diff --git a/src/mongo/db/repl/rollback_test_fixture.cpp b/src/mongo/db/repl/rollback_test_fixture.cpp
index a157dcf76df..b5824819380 100644
--- a/src/mongo/db/repl/rollback_test_fixture.cpp
+++ b/src/mongo/db/repl/rollback_test_fixture.cpp
@@ -295,12 +295,9 @@ void RollbackResyncsCollectionOptionsTest::resyncCollectionOptionsTest(
auto commonOpUuid = unittest::assertGet(UUID::parse("f005ba11-cafe-bead-f00d-123456789abc"));
auto commonOpBson = BSON("ts" << Timestamp(1, 1) << "t" << 1LL << "op"
<< "n"
- << "o"
- << BSONObj()
- << "ns"
+ << "o" << BSONObj() << "ns"
<< "rollback_test.test"
- << "ui"
- << commonOpUuid);
+ << "ui" << commonOpUuid);
auto commonOperation = std::make_pair(commonOpBson, RecordId(1));
diff --git a/src/mongo/db/repl/rs_rollback.cpp b/src/mongo/db/repl/rs_rollback.cpp
index a94dc1c42fb..491ace5de8b 100644
--- a/src/mongo/db/repl/rs_rollback.cpp
+++ b/src/mongo/db/repl/rs_rollback.cpp
@@ -83,13 +83,13 @@
namespace mongo {
-using std::shared_ptr;
-using std::unique_ptr;
using std::list;
using std::map;
+using std::pair;
using std::set;
+using std::shared_ptr;
using std::string;
-using std::pair;
+using std::unique_ptr;
namespace repl {
@@ -199,10 +199,10 @@ Status FixUpInfo::recordDropTargetInfo(const BSONElement& dropTarget,
OpTime opTime) {
StatusWith<UUID> dropTargetUUIDStatus = UUID::parse(dropTarget);
if (!dropTargetUUIDStatus.isOK()) {
- std::string message = str::stream() << "Unable to roll back renameCollection. Cannot parse "
- "dropTarget UUID. Returned status: "
- << redact(dropTargetUUIDStatus.getStatus())
- << ", oplog entry: " << redact(obj);
+ std::string message = str::stream()
+ << "Unable to roll back renameCollection. Cannot parse "
+ "dropTarget UUID. Returned status: "
+ << redact(dropTargetUUIDStatus.getStatus()) << ", oplog entry: " << redact(obj);
error() << message;
return dropTargetUUIDStatus.getStatus();
}
@@ -227,8 +227,8 @@ Status rollback_internal::updateFixUpInfoFromLocalOplogEntry(OperationContext* o
// Checks that the oplog entry is smaller than 512 MB. We do not roll back if the
// oplog entry is larger than 512 MB.
if (ourObj.objsize() > 512 * 1024 * 1024)
- throw RSFatalException(str::stream() << "Rollback too large, oplog size: "
- << ourObj.objsize());
+ throw RSFatalException(str::stream()
+ << "Rollback too large, oplog size: " << ourObj.objsize());
// If required fields are not present in the BSONObj for an applyOps entry, create these fields
// and populate them with dummy values before parsing ourObj as an oplog entry.
@@ -1235,8 +1235,9 @@ void rollback_internal::syncFixUp(OperationContext* opCtx,
// is rolled back upstream and we restart, we expect to still have the
// collection.
- log() << nss->ns() << " not found on remote host, so we do not roll back collmod "
- "operation. Instead, we will drop the collection soon.";
+ log() << nss->ns()
+ << " not found on remote host, so we do not roll back collmod "
+ "operation. Instead, we will drop the collection soon.";
continue;
}
@@ -1246,18 +1247,18 @@ void rollback_internal::syncFixUp(OperationContext* opCtx,
// Updates the collection flags.
if (auto optionsField = info["options"]) {
if (optionsField.type() != Object) {
- throw RSFatalException(str::stream() << "Failed to parse options " << info
- << ": expected 'options' to be an "
- << "Object, got "
- << typeName(optionsField.type()));
+ throw RSFatalException(str::stream()
+ << "Failed to parse options " << info
+ << ": expected 'options' to be an "
+ << "Object, got " << typeName(optionsField.type()));
}
auto statusWithCollectionOptions = CollectionOptions::parse(
optionsField.Obj(), CollectionOptions::parseForCommand);
if (!statusWithCollectionOptions.isOK()) {
- throw RSFatalException(
- str::stream() << "Failed to parse options " << info << ": "
- << statusWithCollectionOptions.getStatus().toString());
+ throw RSFatalException(str::stream()
+ << "Failed to parse options " << info << ": "
+ << statusWithCollectionOptions.getStatus().toString());
}
options = statusWithCollectionOptions.getValue();
} else {
@@ -1275,13 +1276,10 @@ void rollback_internal::syncFixUp(OperationContext* opCtx,
auto validatorStatus = collection->updateValidator(
opCtx, options.validator, options.validationLevel, options.validationAction);
if (!validatorStatus.isOK()) {
- throw RSFatalException(
- str::stream() << "Failed to update validator for " << nss->toString() << " ("
- << uuid
- << ") with "
- << redact(info)
- << ". Got: "
- << validatorStatus.toString());
+ throw RSFatalException(str::stream()
+ << "Failed to update validator for " << nss->toString()
+ << " (" << uuid << ") with " << redact(info)
+ << ". Got: " << validatorStatus.toString());
}
wuow.commit();
@@ -1371,8 +1369,7 @@ void rollback_internal::syncFixUp(OperationContext* opCtx,
<< " to archive file: " << redact(status);
throw RSFatalException(str::stream()
<< "Rollback cannot write document in namespace "
- << nss->ns()
- << " to archive file.");
+ << nss->ns() << " to archive file.");
}
} else {
error() << "Rollback cannot find object: " << pattern << " in namespace "
diff --git a/src/mongo/db/repl/rs_rollback_test.cpp b/src/mongo/db/repl/rs_rollback_test.cpp
index a49055ba339..3d12a5bac28 100644
--- a/src/mongo/db/repl/rs_rollback_test.cpp
+++ b/src/mongo/db/repl/rs_rollback_test.cpp
@@ -81,21 +81,16 @@ OplogInterfaceMock::Operation makeDropIndexOplogEntry(Collection* collection,
BSONObj key,
std::string indexName,
int time) {
- auto indexSpec =
- BSON("ns" << collection->ns().ns() << "key" << key << "name" << indexName << "v"
- << static_cast<int>(kIndexVersion));
+ auto indexSpec = BSON("ns" << collection->ns().ns() << "key" << key << "name" << indexName
+ << "v" << static_cast<int>(kIndexVersion));
return std::make_pair(
BSON("ts" << Timestamp(Seconds(time), 0) << "op"
<< "c"
- << "ui"
- << collection->uuid()
- << "ns"
+ << "ui" << collection->uuid() << "ns"
<< "test.$cmd"
- << "o"
- << BSON("dropIndexes" << collection->ns().coll() << "index" << indexName)
- << "o2"
- << indexSpec),
+ << "o" << BSON("dropIndexes" << collection->ns().coll() << "index" << indexName)
+ << "o2" << indexSpec),
RecordId(time));
}
@@ -103,22 +98,15 @@ OplogInterfaceMock::Operation makeCreateIndexOplogEntry(Collection* collection,
BSONObj key,
std::string indexName,
int time) {
- auto indexSpec =
- BSON("createIndexes" << collection->ns().coll() << "ns" << collection->ns().ns() << "v"
- << static_cast<int>(kIndexVersion)
- << "key"
- << key
- << "name"
- << indexName);
+ auto indexSpec = BSON(
+ "createIndexes" << collection->ns().coll() << "ns" << collection->ns().ns() << "v"
+ << static_cast<int>(kIndexVersion) << "key" << key << "name" << indexName);
return std::make_pair(BSON("ts" << Timestamp(Seconds(time), 0) << "op"
<< "c"
<< "ns"
<< "test.$cmd"
- << "ui"
- << collection->uuid()
- << "o"
- << indexSpec),
+ << "ui" << collection->uuid() << "o" << indexSpec),
RecordId(time));
}
@@ -140,11 +128,7 @@ OplogInterfaceMock::Operation makeRenameCollectionOplogEntry(const NamespaceStri
}
return std::make_pair(BSON("ts" << opTime.getTimestamp() << "t" << opTime.getTerm() << "op"
<< "c"
- << "ui"
- << collectionUUID
- << "ns"
- << renameFrom.ns()
- << "o"
+ << "ui" << collectionUUID << "ns" << renameFrom.ns() << "o"
<< obj),
RecordId(opTime.getTimestamp().getSecs()));
}
@@ -153,12 +137,9 @@ BSONObj makeOp(long long seconds) {
auto uuid = unittest::assertGet(UUID::parse("f005ba11-cafe-bead-f00d-123456789abc"));
return BSON("ts" << Timestamp(seconds, seconds) << "t" << seconds << "op"
<< "n"
- << "o"
- << BSONObj()
- << "ns"
+ << "o" << BSONObj() << "ns"
<< "rs_rollback.test"
- << "ui"
- << uuid);
+ << "ui" << uuid);
}
int recordId = 0;
@@ -294,12 +275,9 @@ int _testRollbackDelete(OperationContext* opCtx,
auto commonOperation = makeOpAndRecordId(1);
auto deleteOperation = std::make_pair(BSON("ts" << Timestamp(Seconds(2), 0) << "op"
<< "d"
- << "ui"
- << uuid
- << "ns"
+ << "ui" << uuid << "ns"
<< "test.t"
- << "o"
- << BSON("_id" << 0)),
+ << "o" << BSON("_id" << 0)),
RecordId(2));
class RollbackSourceLocal : public RollbackSourceMock {
public:
@@ -421,12 +399,9 @@ TEST_F(RSRollbackTest, RollbackInsertDocumentWithNoId) {
auto commonOperation = makeOpAndRecordId(1);
auto insertDocumentOperation = std::make_pair(BSON("ts" << Timestamp(Seconds(2), 0) << "op"
<< "i"
- << "ui"
- << UUID::gen()
- << "ns"
+ << "ui" << UUID::gen() << "ns"
<< "test.t"
- << "o"
- << BSON("a" << 1)),
+ << "o" << BSON("a" << 1)),
RecordId(2));
class RollbackSourceLocal : public RollbackSourceMock {
public:
@@ -465,8 +440,7 @@ TEST_F(RSRollbackTest, RollbackCreateIndexCommand) {
NamespaceString nss("test", "coll");
auto collection = _createCollection(_opCtx.get(), nss.toString(), options);
auto indexSpec = BSON("ns" << nss.toString() << "v" << static_cast<int>(kIndexVersion) << "key"
- << BSON("a" << 1)
- << "name"
+ << BSON("a" << 1) << "name"
<< "a_1");
int numIndexes = _createIndexOnEmptyCollection(_opCtx.get(), collection, nss, indexSpec);
@@ -490,13 +464,11 @@ TEST_F(RSRollbackTest, RollbackCreateIndexCommand) {
_coordinator,
_replicationProcess.get()));
stopCapturingLogMessages();
- ASSERT_EQUALS(1,
- countLogLinesContaining(str::stream()
- << "Dropped index in rollback for collection: "
- << nss.toString()
- << ", UUID: "
- << options.uuid->toString()
- << ", index: a_1"));
+ ASSERT_EQUALS(
+ 1,
+ countLogLinesContaining(str::stream()
+ << "Dropped index in rollback for collection: " << nss.toString()
+ << ", UUID: " << options.uuid->toString() << ", index: a_1"));
{
Lock::DBLock dbLock(_opCtx.get(), nss.db(), MODE_S);
auto indexCatalog = collection->getIndexCatalog();
@@ -512,9 +484,7 @@ TEST_F(RSRollbackTest, RollbackCreateIndexCommandIndexNotInCatalog) {
auto collection = _createCollection(_opCtx.get(), "test.t", options);
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.
{
@@ -663,9 +633,7 @@ TEST_F(RSRollbackTest, RollingBackCreateIndexAndRenameWithLongName) {
auto longName = std::string(115, 'a');
auto indexSpec = BSON("ns" << nss.toString() << "v" << static_cast<int>(kIndexVersion) << "key"
- << BSON("b" << 1)
- << "name"
- << longName);
+ << BSON("b" << 1) << "name" << longName);
int numIndexes = _createIndexOnEmptyCollection(_opCtx.get(), collection, nss, indexSpec);
ASSERT_EQUALS(2, numIndexes);
@@ -713,8 +681,7 @@ TEST_F(RSRollbackTest, RollingBackDropAndCreateOfSameIndexNameWithDifferentSpecs
auto collection = _createCollection(_opCtx.get(), nss.toString(), options);
auto indexSpec = BSON("ns" << nss.toString() << "v" << static_cast<int>(kIndexVersion) << "key"
- << BSON("b" << 1)
- << "name"
+ << BSON("b" << 1) << "name"
<< "a_1");
int numIndexes = _createIndexOnEmptyCollection(_opCtx.get(), collection, nss, indexSpec);
@@ -745,19 +712,15 @@ TEST_F(RSRollbackTest, RollingBackDropAndCreateOfSameIndexNameWithDifferentSpecs
ASSERT(indexCatalog);
ASSERT_EQUALS(2, indexCatalog->numIndexesReady(_opCtx.get()));
ASSERT_EQUALS(1,
- countLogLinesContaining(str::stream()
- << "Dropped index in rollback for collection: "
- << nss.toString()
- << ", UUID: "
- << options.uuid->toString()
- << ", index: a_1"));
+ countLogLinesContaining(
+ str::stream()
+ << "Dropped index in rollback for collection: " << nss.toString()
+ << ", UUID: " << options.uuid->toString() << ", index: a_1"));
ASSERT_EQUALS(1,
- countLogLinesContaining(str::stream()
- << "Created index in rollback for collection: "
- << nss.toString()
- << ", UUID: "
- << options.uuid->toString()
- << ", index: a_1"));
+ countLogLinesContaining(
+ str::stream()
+ << "Created index in rollback for collection: " << nss.toString()
+ << ", UUID: " << options.uuid->toString() << ", index: a_1"));
std::vector<const IndexDescriptor*> indexes;
indexCatalog->findIndexesByKeyPattern(_opCtx.get(), BSON("a" << 1), false, &indexes);
ASSERT(indexes.size() == 1);
@@ -779,20 +742,15 @@ TEST_F(RSRollbackTest, RollbackCreateIndexCommandMissingIndexName) {
<< "t"
<< "ns"
<< "test.t"
- << "v"
- << static_cast<int>(kIndexVersion)
- << "key"
- << BSON("a" << 1));
-
- auto createIndexOperation = std::make_pair(BSON("ts" << Timestamp(Seconds(2), 0) << "op"
- << "c"
- << "ns"
- << "test.$cmd"
- << "ui"
- << collection->uuid()
- << "o"
- << command),
- RecordId(2));
+ << "v" << static_cast<int>(kIndexVersion) << "key" << BSON("a" << 1));
+
+ auto createIndexOperation =
+ std::make_pair(BSON("ts" << Timestamp(Seconds(2), 0) << "op"
+ << "c"
+ << "ns"
+ << "test.$cmd"
+ << "ui" << collection->uuid() << "o" << command),
+ RecordId(2));
RollbackSourceMock rollbackSource(std::unique_ptr<OplogInterface>(new OplogInterfaceMock({
commonOperation,
})));
@@ -822,9 +780,7 @@ std::string idxName(std::string id) {
// Create an index spec object given the namespace and the index 'id'.
BSONObj idxSpec(NamespaceString nss, std::string id) {
return BSON("ns" << nss.toString() << "v" << static_cast<int>(kIndexVersion) << "key"
- << BSON(idxKey(id) << 1)
- << "name"
- << idxName(id));
+ << BSON(idxKey(id) << 1) << "name" << idxName(id));
}
// Returns the number of indexes that exist on the given collection.
@@ -947,9 +903,7 @@ TEST_F(RSRollbackTest, RollbackCreateDropRecreateIndexOnCollection) {
// Create the necessary indexes. Index 0 is created, dropped, and created again in the
// sequence of ops, so we create that index.
auto indexSpec = BSON("ns" << nss.toString() << "v" << static_cast<int>(kIndexVersion) << "key"
- << BSON(idxKey("0") << 1)
- << "name"
- << idxName("0"));
+ << BSON(idxKey("0") << 1) << "name" << idxName("0"));
int numIndexes = _createIndexOnEmptyCollection(_opCtx.get(), coll, nss, indexSpec);
ASSERT_EQUALS(2, numIndexes);
@@ -984,9 +938,7 @@ TEST_F(RSRollbackTest, RollbackUnknownCommand) {
auto commonOperation = makeOpAndRecordId(1);
auto unknownCommandOperation = std::make_pair(BSON("ts" << Timestamp(Seconds(2), 0) << "op"
<< "c"
- << "ui"
- << UUID::gen()
- << "ns"
+ << "ui" << UUID::gen() << "ns"
<< "test.t"
<< "o"
<< BSON("convertToCapped"
@@ -1020,9 +972,7 @@ TEST_F(RSRollbackTest, RollbackDropCollectionCommand) {
auto dropCollectionOperation =
std::make_pair(BSON("ts" << dropTime.getTimestamp() << "t" << dropTime.getTerm() << "op"
<< "c"
- << "ui"
- << coll->uuid()
- << "ns"
+ << "ui" << coll->uuid() << "ns"
<< "test.t"
<< "o"
<< BSON("drop"
@@ -1344,9 +1294,7 @@ TEST_F(RSRollbackTest, RollbackDropCollectionThenRenameCollectionToDroppedCollec
auto dropCollectionOperation =
std::make_pair(BSON("ts" << dropTime.getTimestamp() << "t" << dropTime.getTerm() << "op"
<< "c"
- << "ui"
- << droppedCollectionUUID
- << "ns"
+ << "ui" << droppedCollectionUUID << "ns"
<< "test.x"
<< "o"
<< BSON("drop"
@@ -1416,16 +1364,15 @@ TEST_F(RSRollbackTest, RollbackRenameCollectionThenCreateNewCollectionWithOldNam
false,
OpTime(Timestamp(2, 0), 5));
- auto createCollectionOperation = std::make_pair(BSON("ts" << Timestamp(Seconds(3), 0) << "op"
- << "c"
- << "ui"
- << createdCollectionUUID
- << "ns"
- << "test.x"
- << "o"
- << BSON("create"
- << "x")),
- RecordId(3));
+ auto createCollectionOperation =
+ std::make_pair(BSON("ts" << Timestamp(Seconds(3), 0) << "op"
+ << "c"
+ << "ui" << createdCollectionUUID << "ns"
+ << "test.x"
+ << "o"
+ << BSON("create"
+ << "x")),
+ RecordId(3));
RollbackSourceMock rollbackSource(std::unique_ptr<OplogInterface>(new OplogInterfaceMock({
@@ -1466,9 +1413,7 @@ TEST_F(RSRollbackTest, RollbackCollModCommandFailsIfRBIDChangesWhileSyncingColle
auto commonOperation = makeOpAndRecordId(1);
auto collModOperation = std::make_pair(BSON("ts" << Timestamp(Seconds(2), 0) << "op"
<< "c"
- << "ui"
- << coll->uuid()
- << "ns"
+ << "ui" << coll->uuid() << "ns"
<< "test.t"
<< "o"
<< BSON("collMod"
@@ -1512,8 +1457,7 @@ TEST_F(RSRollbackTest, RollbackDropDatabaseCommand) {
<< "c"
<< "ns"
<< "test.$cmd"
- << "o"
- << BSON("dropDatabase" << 1)),
+ << "o" << BSON("dropDatabase" << 1)),
RecordId(2));
RollbackSourceMock rollbackSource(std::unique_ptr<OplogInterface>(new OplogInterfaceMock({
commonOperation,
@@ -1581,93 +1525,47 @@ TEST_F(RSRollbackTest, RollbackApplyOpsCommand) {
UUID uuid = coll->uuid();
const auto commonOperation = makeOpAndRecordId(1);
const auto applyOpsOperation =
- std::make_pair(makeApplyOpsOplogEntry(Timestamp(Seconds(2), 0),
- {BSON("op"
- << "u"
- << "ui"
- << uuid
- << "ts"
- << Timestamp(1, 1)
- << "t"
- << 1LL
- << "ns"
- << "test.t"
- << "o2"
- << BSON("_id" << 1)
- << "o"
- << BSON("_id" << 1 << "v" << 2)),
- BSON("op"
- << "u"
- << "ui"
- << uuid
- << "ts"
- << Timestamp(2, 1)
- << "t"
- << 1LL
- << "ns"
- << "test.t"
- << "o2"
- << BSON("_id" << 2)
- << "o"
- << BSON("_id" << 2 << "v" << 4)),
- BSON("op"
- << "d"
- << "ui"
- << uuid
- << "ts"
- << Timestamp(3, 1)
- << "t"
- << 1LL
- << "ns"
- << "test.t"
- << "o"
- << BSON("_id" << 3)),
- BSON("op"
- << "i"
- << "ui"
- << uuid
- << "ts"
- << Timestamp(4, 1)
- << "t"
- << 1LL
- << "ns"
- << "test.t"
- << "o"
- << BSON("_id" << 4)),
- // applyOps internal oplog entries are not required
- // to have a timestamp.
- BSON("op"
- << "i"
- << "ui"
- << uuid
- << "ts"
- << Timestamp(4, 1)
- << "t"
- << 1LL
- << "ns"
- << "test.t"
- << "o"
- << BSON("_id" << 4)),
- BSON("op"
- << "i"
- << "ui"
- << uuid
- << "t"
- << 1LL
- << "ns"
- << "test.t"
- << "o"
- << BSON("_id" << 4)),
- BSON("op"
- << "i"
- << "ui"
- << uuid
- << "t"
- << 1LL
- << "ns"
- << "test.t"
- << "o"
- << BSON("_id" << 4))}),
+ std::make_pair(makeApplyOpsOplogEntry(
+ Timestamp(Seconds(2), 0),
+ {BSON("op"
+ << "u"
+ << "ui" << uuid << "ts" << Timestamp(1, 1) << "t" << 1LL << "ns"
+ << "test.t"
+ << "o2" << BSON("_id" << 1) << "o"
+ << BSON("_id" << 1 << "v" << 2)),
+ BSON("op"
+ << "u"
+ << "ui" << uuid << "ts" << Timestamp(2, 1) << "t" << 1LL << "ns"
+ << "test.t"
+ << "o2" << BSON("_id" << 2) << "o"
+ << BSON("_id" << 2 << "v" << 4)),
+ BSON("op"
+ << "d"
+ << "ui" << uuid << "ts" << Timestamp(3, 1) << "t" << 1LL << "ns"
+ << "test.t"
+ << "o" << BSON("_id" << 3)),
+ BSON("op"
+ << "i"
+ << "ui" << uuid << "ts" << Timestamp(4, 1) << "t" << 1LL << "ns"
+ << "test.t"
+ << "o" << BSON("_id" << 4)),
+ // applyOps internal oplog entries are not required
+ // to have a timestamp.
+ BSON("op"
+ << "i"
+ << "ui" << uuid << "ts" << Timestamp(4, 1) << "t" << 1LL << "ns"
+ << "test.t"
+ << "o" << BSON("_id" << 4)),
+ BSON("op"
+ << "i"
+ << "ui" << uuid << "t" << 1LL << "ns"
+ << "test.t"
+ << "o" << BSON("_id" << 4)),
+ BSON("op"
+ << "i"
+ << "ui" << uuid << "t" << 1LL << "ns"
+ << "test.t"
+ << "o" << BSON("_id" << 4))}),
RecordId(2));
class RollbackSourceLocal : public RollbackSourceMock {
@@ -1735,9 +1633,7 @@ TEST_F(RSRollbackTest, RollbackCreateCollectionCommand) {
auto commonOperation = makeOpAndRecordId(1);
auto createCollectionOperation = std::make_pair(BSON("ts" << Timestamp(Seconds(2), 0) << "op"
<< "c"
- << "ui"
- << coll->uuid()
- << "ns"
+ << "ui" << coll->uuid() << "ns"
<< "test.t"
<< "o"
<< BSON("create"
@@ -1965,31 +1861,19 @@ TEST_F(RSRollbackTest, RollbackCollectionModificationCommandInvalidCollectionOpt
TEST(RSRollbackTest, LocalEntryWithoutNsIsFatal) {
const auto validOplogEntry = BSON("op"
<< "i"
- << "ui"
- << UUID::gen()
- << "ts"
- << Timestamp(1, 1)
- << "t"
- << 1LL
- << "ns"
+ << "ui" << UUID::gen() << "ts" << Timestamp(1, 1) << "t"
+ << 1LL << "ns"
<< "test.t"
- << "o"
- << BSON("_id" << 1 << "a" << 1));
+ << "o" << BSON("_id" << 1 << "a" << 1));
FixUpInfo fui;
ASSERT_OK(updateFixUpInfoFromLocalOplogEntry(
nullptr /* opCtx */, OplogInterfaceMock(), fui, validOplogEntry, false));
const auto invalidOplogEntry = BSON("op"
<< "i"
- << "ui"
- << UUID::gen()
- << "ts"
- << Timestamp(1, 1)
- << "t"
- << 1LL
- << "ns"
+ << "ui" << UUID::gen() << "ts" << Timestamp(1, 1) << "t"
+ << 1LL << "ns"
<< ""
- << "o"
- << BSON("_id" << 1 << "a" << 1));
+ << "o" << BSON("_id" << 1 << "a" << 1));
ASSERT_THROWS(updateFixUpInfoFromLocalOplogEntry(
nullptr /* opCtx */, OplogInterfaceMock(), fui, invalidOplogEntry, false),
RSFatalException);
@@ -1998,31 +1882,19 @@ TEST(RSRollbackTest, LocalEntryWithoutNsIsFatal) {
TEST(RSRollbackTest, LocalEntryWithoutOIsFatal) {
const auto validOplogEntry = BSON("op"
<< "i"
- << "ui"
- << UUID::gen()
- << "ts"
- << Timestamp(1, 1)
- << "t"
- << 1LL
- << "ns"
+ << "ui" << UUID::gen() << "ts" << Timestamp(1, 1) << "t"
+ << 1LL << "ns"
<< "test.t"
- << "o"
- << BSON("_id" << 1 << "a" << 1));
+ << "o" << BSON("_id" << 1 << "a" << 1));
FixUpInfo fui;
ASSERT_OK(updateFixUpInfoFromLocalOplogEntry(
nullptr /* opCtx */, OplogInterfaceMock(), fui, validOplogEntry, false));
const auto invalidOplogEntry = BSON("op"
<< "i"
- << "ui"
- << UUID::gen()
- << "ts"
- << Timestamp(1, 1)
- << "t"
- << 1LL
- << "ns"
+ << "ui" << UUID::gen() << "ts" << Timestamp(1, 1) << "t"
+ << 1LL << "ns"
<< "test.t"
- << "o"
- << BSONObj());
+ << "o" << BSONObj());
ASSERT_THROWS(updateFixUpInfoFromLocalOplogEntry(
nullptr /* opCtx */, OplogInterfaceMock(), fui, invalidOplogEntry, false),
RSFatalException);
@@ -2031,16 +1903,10 @@ TEST(RSRollbackTest, LocalEntryWithoutOIsFatal) {
DEATH_TEST_F(RSRollbackTest, LocalUpdateEntryWithoutO2IsFatal, "Fatal Assertion") {
const auto invalidOplogEntry = BSON("op"
<< "u"
- << "ui"
- << UUID::gen()
- << "ts"
- << Timestamp(1, 1)
- << "t"
- << 1LL
- << "ns"
+ << "ui" << UUID::gen() << "ts" << Timestamp(1, 1) << "t"
+ << 1LL << "ns"
<< "test.t"
- << "o"
- << BSON("_id" << 1 << "a" << 1));
+ << "o" << BSON("_id" << 1 << "a" << 1));
FixUpInfo fui;
updateFixUpInfoFromLocalOplogEntry(
nullptr /* opCtx */, OplogInterfaceMock(), fui, invalidOplogEntry, false)
@@ -2050,34 +1916,20 @@ DEATH_TEST_F(RSRollbackTest, LocalUpdateEntryWithoutO2IsFatal, "Fatal Assertion"
TEST(RSRollbackTest, LocalUpdateEntryWithEmptyO2IsFatal) {
const auto validOplogEntry = BSON("op"
<< "u"
- << "ui"
- << UUID::gen()
- << "ts"
- << Timestamp(1, 1)
- << "t"
- << 1LL
- << "ns"
+ << "ui" << UUID::gen() << "ts" << Timestamp(1, 1) << "t"
+ << 1LL << "ns"
<< "test.t"
- << "o"
- << BSON("_id" << 1 << "a" << 1)
- << "o2"
+ << "o" << BSON("_id" << 1 << "a" << 1) << "o2"
<< BSON("_id" << 1));
FixUpInfo fui;
ASSERT_OK(updateFixUpInfoFromLocalOplogEntry(
nullptr /* opCtx */, OplogInterfaceMock(), fui, validOplogEntry, false));
const auto invalidOplogEntry = BSON("op"
<< "u"
- << "ui"
- << UUID::gen()
- << "ts"
- << Timestamp(1, 1)
- << "t"
- << 1LL
- << "ns"
+ << "ui" << UUID::gen() << "ts" << Timestamp(1, 1) << "t"
+ << 1LL << "ns"
<< "test.t"
- << "o"
- << BSON("_id" << 1 << "a" << 1)
- << "o2"
+ << "o" << BSON("_id" << 1 << "a" << 1) << "o2"
<< BSONObj());
ASSERT_THROWS(updateFixUpInfoFromLocalOplogEntry(
nullptr /* opCtx */, OplogInterfaceMock(), fui, invalidOplogEntry, false),
@@ -2087,12 +1939,9 @@ TEST(RSRollbackTest, LocalUpdateEntryWithEmptyO2IsFatal) {
DEATH_TEST_F(RSRollbackTest, LocalEntryWithTxnNumberWithoutSessionIdIsFatal, "invariant") {
auto validOplogEntry = BSON("ts" << Timestamp(Seconds(1), 0) << "t" << 1LL << "op"
<< "i"
- << "ui"
- << UUID::gen()
- << "ns"
+ << "ui" << UUID::gen() << "ns"
<< "test.t"
- << "o"
- << BSON("_id" << 1 << "a" << 1));
+ << "o" << BSON("_id" << 1 << "a" << 1));
FixUpInfo fui;
ASSERT_OK(updateFixUpInfoFromLocalOplogEntry(
nullptr /* opCtx */, OplogInterfaceMock(), fui, validOplogEntry, false));
@@ -2113,18 +1962,10 @@ TEST_F(RSRollbackTest, LocalEntryWithTxnNumberWithoutTxnTableUUIDIsFatal) {
auto lsid = makeLogicalSessionIdForTest();
auto entryWithTxnNumber = BSON("ts" << Timestamp(Seconds(1), 0) << "t" << 1LL << "op"
<< "i"
- << "ui"
- << uuid
- << "ns"
+ << "ui" << uuid << "ns"
<< "test.t"
- << "o"
- << BSON("_id" << 1 << "a" << 1)
- << "txnNumber"
- << 1LL
- << "stmtId"
- << 1
- << "lsid"
- << lsid.toBSON());
+ << "o" << BSON("_id" << 1 << "a" << 1) << "txnNumber" << 1LL
+ << "stmtId" << 1 << "lsid" << lsid.toBSON());
FixUpInfo fui;
ASSERT_THROWS(updateFixUpInfoFromLocalOplogEntry(
@@ -2138,12 +1979,9 @@ TEST_F(RSRollbackTest, LocalEntryWithTxnNumberAddsTransactionTableDocToBeRefetch
// With no txnNumber present, no extra documents need to be refetched.
auto entryWithoutTxnNumber = BSON("ts" << Timestamp(Seconds(1), 0) << "t" << 1LL << "op"
<< "i"
- << "ui"
- << UUID::gen()
- << "ns"
+ << "ui" << UUID::gen() << "ns"
<< "test.t2"
- << "o"
- << BSON("_id" << 2 << "a" << 2));
+ << "o" << BSON("_id" << 2 << "a" << 2));
ASSERT_OK(updateFixUpInfoFromLocalOplogEntry(
nullptr /* opCtx */, OplogInterfaceMock(), fui, entryWithoutTxnNumber, false));
@@ -2156,18 +1994,10 @@ TEST_F(RSRollbackTest, LocalEntryWithTxnNumberAddsTransactionTableDocToBeRefetch
auto lsid = makeLogicalSessionIdForTest();
auto entryWithTxnNumber = BSON("ts" << Timestamp(Seconds(1), 0) << "t" << 1LL << "op"
<< "i"
- << "ui"
- << uuid
- << "ns"
+ << "ui" << uuid << "ns"
<< "test.t"
- << "o"
- << BSON("_id" << 1 << "a" << 1)
- << "txnNumber"
- << 1LL
- << "stmtId"
- << 1
- << "lsid"
- << lsid.toBSON());
+ << "o" << BSON("_id" << 1 << "a" << 1) << "txnNumber" << 1LL
+ << "stmtId" << 1 << "lsid" << lsid.toBSON());
UUID transactionTableUUID = UUID::gen();
fui.transactionTableUUID = transactionTableUUID;
@@ -2197,20 +2027,11 @@ TEST_F(RSRollbackTest, LocalEntryWithPartialTxnAddsTransactionTableDocToBeRefetc
<< "o"
<< BSON("applyOps" << BSON_ARRAY(BSON("op"
<< "i"
- << "ui"
- << uuid
- << "ns"
+ << "ui" << uuid << "ns"
<< "test.t"
- << "o"
- << BSON("_id" << 1 << "a" << 1)))
- << "partialTxn"
- << true)
- << "txnNumber"
- << 1LL
- << "stmtId"
- << 1
- << "lsid"
- << lsid.toBSON());
+ << "o" << BSON("_id" << 1 << "a" << 1)))
+ << "partialTxn" << true)
+ << "txnNumber" << 1LL << "stmtId" << 1 << "lsid" << lsid.toBSON());
UUID transactionTableUUID = UUID::gen();
fui.transactionTableUUID = transactionTableUUID;
@@ -2233,15 +2054,8 @@ TEST_F(RSRollbackTest, LocalAbortTxnRefetchesTransactionTableEntry) {
<< "c"
<< "ns"
<< "admin.$cmd"
- << "o"
- << BSON("abortTransaction" << 1)
- << "txnNumber"
- << 1LL
- << "stmtId"
- << 1
- << "lsid"
- << lsid.toBSON()
- << "prevOpTime"
+ << "o" << BSON("abortTransaction" << 1) << "txnNumber" << 1LL
+ << "stmtId" << 1 << "lsid" << lsid.toBSON() << "prevOpTime"
<< BSON("ts" << Timestamp(Seconds(1), 0) << "t" << 1LL));
UUID transactionTableUUID = UUID::gen();
@@ -2269,15 +2083,8 @@ TEST_F(RSRollbackTest, LocalEntryWithAbortedPartialTxnRefetchesOnlyTransactionTa
<< "c"
<< "ns"
<< "admin.$cmd"
- << "o"
- << BSON("abortTransaction" << 1)
- << "txnNumber"
- << 1LL
- << "stmtId"
- << 1
- << "lsid"
- << lsid.toBSON()
- << "prevOpTime"
+ << "o" << BSON("abortTransaction" << 1) << "txnNumber" << 1LL
+ << "stmtId" << 1 << "lsid" << lsid.toBSON() << "prevOpTime"
<< BSON("ts" << Timestamp(Seconds(1), 1) << "t" << 1LL));
auto entryWithTxnNumber =
@@ -2288,20 +2095,11 @@ TEST_F(RSRollbackTest, LocalEntryWithAbortedPartialTxnRefetchesOnlyTransactionTa
<< "o"
<< BSON("applyOps" << BSON_ARRAY(BSON("op"
<< "i"
- << "ui"
- << uuid
- << "ns"
+ << "ui" << uuid << "ns"
<< "test.t"
- << "o"
- << BSON("_id" << 1 << "a" << 1)))
- << "partialTxn"
- << true)
- << "txnNumber"
- << 1LL
- << "stmtId"
- << 1
- << "lsid"
- << lsid.toBSON());
+ << "o" << BSON("_id" << 1 << "a" << 1)))
+ << "partialTxn" << true)
+ << "txnNumber" << 1LL << "stmtId" << 1 << "lsid" << lsid.toBSON());
UUID transactionTableUUID = UUID::gen();
fui.transactionTableUUID = transactionTableUUID;
@@ -2328,21 +2126,11 @@ TEST_F(RSRollbackTest, LocalEntryWithCommittedTxnRefetchesDocsAndTransactionTabl
<< "o"
<< BSON("applyOps" << BSON_ARRAY(BSON("op"
<< "i"
- << "ui"
- << uuid
- << "ns"
+ << "ui" << uuid << "ns"
<< "test.t"
- << "o"
- << BSON("_id" << 2 << "a" << 2)))
- << "count"
- << 2)
- << "txnNumber"
- << 1LL
- << "stmtId"
- << 2
- << "lsid"
- << lsid.toBSON()
- << "prevOpTime"
+ << "o" << BSON("_id" << 2 << "a" << 2)))
+ << "count" << 2)
+ << "txnNumber" << 1LL << "stmtId" << 2 << "lsid" << lsid.toBSON() << "prevOpTime"
<< BSON("ts" << Timestamp(Seconds(1), 1) << "t" << 1LL));
auto commitTxnOperation = std::make_pair(commitTxnEntry, RecordId(2));
@@ -2354,21 +2142,11 @@ TEST_F(RSRollbackTest, LocalEntryWithCommittedTxnRefetchesDocsAndTransactionTabl
<< "o"
<< BSON("applyOps" << BSON_ARRAY(BSON("op"
<< "i"
- << "ui"
- << uuid
- << "ns"
+ << "ui" << uuid << "ns"
<< "test.t"
- << "o"
- << BSON("_id" << 1 << "a" << 1)))
- << "partialTxn"
- << true)
- << "txnNumber"
- << 1LL
- << "stmtId"
- << 1
- << "lsid"
- << lsid.toBSON()
- << "prevOpTime"
+ << "o" << BSON("_id" << 1 << "a" << 1)))
+ << "partialTxn" << true)
+ << "txnNumber" << 1LL << "stmtId" << 1 << "lsid" << lsid.toBSON() << "prevOpTime"
<< BSON("ts" << Timestamp(0, 0) << "t" << -1LL));
auto partialTxnOperation = std::make_pair(partialTxnEntry, RecordId(1));
@@ -2421,21 +2199,11 @@ TEST_F(RSRollbackTest, RollbackFetchesTransactionOperationBeforeCommonPoint) {
<< "o"
<< BSON("applyOps" << BSON_ARRAY(BSON("op"
<< "i"
- << "ui"
- << uuid
- << "ns"
+ << "ui" << uuid << "ns"
<< "test.t"
- << "o"
- << BSON("_id" << 0 << "a" << 0)))
- << "count"
- << 3)
- << "txnNumber"
- << 1LL
- << "stmtId"
- << 3
- << "lsid"
- << lsid.toBSON()
- << "prevOpTime"
+ << "o" << BSON("_id" << 0 << "a" << 0)))
+ << "count" << 3)
+ << "txnNumber" << 1LL << "stmtId" << 3 << "lsid" << lsid.toBSON() << "prevOpTime"
<< BSON("ts" << Timestamp(Seconds(10), 11) << "t" << 10LL));
auto commitTxnOperation = std::make_pair(commitTxnEntry, RecordId(12));
@@ -2447,21 +2215,11 @@ TEST_F(RSRollbackTest, RollbackFetchesTransactionOperationBeforeCommonPoint) {
<< "o"
<< BSON("applyOps" << BSON_ARRAY(BSON("op"
<< "i"
- << "ui"
- << uuid
- << "ns"
+ << "ui" << uuid << "ns"
<< "test.t"
- << "o"
- << BSON("_id" << 1 << "a" << 1)))
- << "partialTxn"
- << true)
- << "txnNumber"
- << 1LL
- << "stmtId"
- << 2
- << "lsid"
- << lsid.toBSON()
- << "prevOpTime"
+ << "o" << BSON("_id" << 1 << "a" << 1)))
+ << "partialTxn" << true)
+ << "txnNumber" << 1LL << "stmtId" << 2 << "lsid" << lsid.toBSON() << "prevOpTime"
<< BSON("ts" << Timestamp(Seconds(10), 9) << "t" << 10LL));
auto operationAfterCommonPoint = std::make_pair(entryAfterCommonPoint, RecordId(11));
@@ -2473,21 +2231,11 @@ TEST_F(RSRollbackTest, RollbackFetchesTransactionOperationBeforeCommonPoint) {
<< "o"
<< BSON("applyOps" << BSON_ARRAY(BSON("op"
<< "i"
- << "ui"
- << uuid
- << "ns"
+ << "ui" << uuid << "ns"
<< "test.t"
- << "o"
- << BSON("_id" << 2 << "a" << 2)))
- << "partialTxn"
- << true)
- << "txnNumber"
- << 1LL
- << "stmtId"
- << 1
- << "lsid"
- << lsid.toBSON()
- << "prevOpTime"
+ << "o" << BSON("_id" << 2 << "a" << 2)))
+ << "partialTxn" << true)
+ << "txnNumber" << 1LL << "stmtId" << 1 << "lsid" << lsid.toBSON() << "prevOpTime"
<< BSON("ts" << Timestamp(0, 0) << "t" << -1LL));
auto operationBeforeCommonPoint = std::make_pair(entryBeforeCommonPoint, RecordId(9));
@@ -2565,19 +2313,11 @@ TEST_F(RSRollbackTest, RollbackIncompleteTransactionReturnsUnrecoverableRollback
<< "o"
<< BSON("applyOps" << BSON_ARRAY(BSON("op"
<< "i"
- << "ui"
- << uuid
- << "ns"
+ << "ui" << uuid << "ns"
<< "test.t"
- << "o"
- << BSON("_id" << 0 << "a" << 0)))
- << "count"
- << 3)
- << "stmtId"
- << 3
- << "lsid"
- << lsid.toBSON()
- << "prevOpTime"
+ << "o" << BSON("_id" << 0 << "a" << 0)))
+ << "count" << 3)
+ << "stmtId" << 3 << "lsid" << lsid.toBSON() << "prevOpTime"
<< BSON("ts" << Timestamp(Seconds(10), 11) << "t" << 10LL));
auto commitTxnOperation = std::make_pair(commitTxnEntry, RecordId(12));
@@ -2589,21 +2329,11 @@ TEST_F(RSRollbackTest, RollbackIncompleteTransactionReturnsUnrecoverableRollback
<< "o"
<< BSON("applyOps" << BSON_ARRAY(BSON("op"
<< "i"
- << "ui"
- << uuid
- << "ns"
+ << "ui" << uuid << "ns"
<< "test.t"
- << "o"
- << BSON("_id" << 1 << "a" << 1)))
- << "partialTxn"
- << true)
- << "txnNumber"
- << 1LL
- << "stmtId"
- << 2
- << "lsid"
- << lsid.toBSON()
- << "prevOpTime"
+ << "o" << BSON("_id" << 1 << "a" << 1)))
+ << "partialTxn" << true)
+ << "txnNumber" << 1LL << "stmtId" << 2 << "lsid" << lsid.toBSON() << "prevOpTime"
<< BSON("ts" << Timestamp(Seconds(10), 9) << "t" << 10LL));
auto operationAfterCommonPoint = std::make_pair(entryAfterCommonPoint, RecordId(11));
@@ -2646,20 +2376,13 @@ TEST_F(RSRollbackTest, RollbackFailsIfTransactionDocumentRefetchReturnsDifferent
// transaction number and session id.
FixUpInfo fui;
- auto entryWithTxnNumber = BSON("ts" << Timestamp(Seconds(2), 1) << "t" << 1LL << "op"
- << "i"
- << "ui"
- << UUID::gen()
- << "ns"
- << "test.t"
- << "o"
- << BSON("_id" << 1 << "a" << 1)
- << "txnNumber"
- << 1LL
- << "stmtId"
- << 1
- << "lsid"
- << makeLogicalSessionIdForTest().toBSON());
+ auto entryWithTxnNumber =
+ BSON("ts" << Timestamp(Seconds(2), 1) << "t" << 1LL << "op"
+ << "i"
+ << "ui" << UUID::gen() << "ns"
+ << "test.t"
+ << "o" << BSON("_id" << 1 << "a" << 1) << "txnNumber" << 1LL << "stmtId" << 1
+ << "lsid" << makeLogicalSessionIdForTest().toBSON());
UUID transactionTableUUID = UUID::gen();
fui.transactionTableUUID = transactionTableUUID;
diff --git a/src/mongo/db/repl/split_horizon_test.cpp b/src/mongo/db/repl/split_horizon_test.cpp
index 0a3a655ccaf..95b2df2ad36 100644
--- a/src/mongo/db/repl/split_horizon_test.cpp
+++ b/src/mongo/db/repl/split_horizon_test.cpp
@@ -300,8 +300,7 @@ TEST(SplitHorizonTesting, BSONConstruction) {
// Two horizons with duplicate host and ports.
{BSON("horizonWithDuplicateHost1" << matchingHostAndPort << "horizonWithDuplicateHost2"
- << matchingHostAndPort
- << "uniqueHorizon"
+ << matchingHostAndPort << "uniqueHorizon"
<< nonmatchingHost),
defaultHostAndPort,
{},
diff --git a/src/mongo/db/repl/storage_interface_impl.cpp b/src/mongo/db/repl/storage_interface_impl.cpp
index 03d8bc66e55..7145bb15560 100644
--- a/src/mongo/db/repl/storage_interface_impl.cpp
+++ b/src/mongo/db/repl/storage_interface_impl.cpp
@@ -503,20 +503,16 @@ Status StorageInterfaceImpl::renameCollection(OperationContext* opCtx,
if (fromNS.db() != toNS.db()) {
return Status(ErrorCodes::InvalidNamespace,
str::stream() << "Cannot rename collection between databases. From NS: "
- << fromNS.ns()
- << "; to NS: "
- << toNS.ns());
+ << fromNS.ns() << "; to NS: " << toNS.ns());
}
return writeConflictRetry(opCtx, "StorageInterfaceImpl::renameCollection", fromNS.ns(), [&] {
AutoGetDb autoDB(opCtx, fromNS.db(), MODE_X);
if (!autoDB.getDb()) {
return Status(ErrorCodes::NamespaceNotFound,
- str::stream() << "Cannot rename collection from " << fromNS.ns() << " to "
- << toNS.ns()
- << ". Database "
- << fromNS.db()
- << " not found.");
+ str::stream()
+ << "Cannot rename collection from " << fromNS.ns() << " to "
+ << toNS.ns() << ". Database " << fromNS.db() << " not found.");
}
WriteUnitOfWork wunit(opCtx);
const auto status = autoDB.getDb()->renameCollection(opCtx, fromNS, toNS, stayTemp);
@@ -559,8 +555,7 @@ Status StorageInterfaceImpl::setIndexIsMultikey(OperationContext* opCtx,
if (!idx) {
return Status(ErrorCodes::IndexNotFound,
str::stream() << "Could not find index " << indexName << " in "
- << nss.ns()
- << " to set to multikey.");
+ << nss.ns() << " to set to multikey.");
}
collection->getIndexCatalog()->setMultikeyPaths(opCtx, idx, paths);
wunit.commit();
@@ -648,16 +643,13 @@ StatusWith<std::vector<BSONObj>> _findOrDeleteDocuments(
if (!indexDescriptor) {
return Result(ErrorCodes::IndexNotFound,
str::stream() << "Index not found, ns:" << nsOrUUID.toString()
- << ", index: "
- << *indexName);
+ << ", index: " << *indexName);
}
if (indexDescriptor->isPartial()) {
return Result(ErrorCodes::IndexOptionsConflict,
str::stream()
<< "Partial index is not allowed for this operation, ns:"
- << nsOrUUID.toString()
- << ", index: "
- << *indexName);
+ << nsOrUUID.toString() << ", index: " << *indexName);
}
KeyPattern keyPattern(indexDescriptor->keyPattern());
@@ -857,11 +849,11 @@ Status _updateWithQuery(OperationContext* opCtx,
}
AutoGetCollection autoColl(opCtx, nss, MODE_IX);
- auto collectionResult = getCollection(
- autoColl,
- nss,
- str::stream() << "Unable to update documents in " << nss.ns() << " using query "
- << request.getQuery());
+ auto collectionResult =
+ getCollection(autoColl,
+ nss,
+ str::stream() << "Unable to update documents in " << nss.ns()
+ << " using query " << request.getQuery());
if (!collectionResult.isOK()) {
return collectionResult.getStatus();
}
@@ -990,11 +982,11 @@ Status StorageInterfaceImpl::deleteByFilter(OperationContext* opCtx,
}
AutoGetCollection autoColl(opCtx, nss, MODE_IX);
- auto collectionResult = getCollection(
- autoColl,
- nss,
- str::stream() << "Unable to delete documents in " << nss.ns() << " using filter "
- << filter);
+ auto collectionResult =
+ getCollection(autoColl,
+ nss,
+ str::stream() << "Unable to delete documents in " << nss.ns()
+ << " using filter " << filter);
if (!collectionResult.isOK()) {
return collectionResult.getStatus();
}
diff --git a/src/mongo/db/repl/storage_interface_impl_test.cpp b/src/mongo/db/repl/storage_interface_impl_test.cpp
index 912599d9e9c..aa021037cc8 100644
--- a/src/mongo/db/repl/storage_interface_impl_test.cpp
+++ b/src/mongo/db/repl/storage_interface_impl_test.cpp
@@ -68,11 +68,7 @@ const auto kIndexVersion = IndexDescriptor::IndexVersion::kV2;
BSONObj makeIdIndexSpec(const NamespaceString& nss) {
return BSON("ns" << nss.toString() << "name"
<< "_id_"
- << "key"
- << BSON("_id" << 1)
- << "unique"
- << true
- << "v"
+ << "key" << BSON("_id" << 1) << "unique" << true << "v"
<< static_cast<int>(kIndexVersion));
}
@@ -297,8 +293,7 @@ void _assertRollbackIDDocument(OperationContext* opCtx, int id) {
opCtx,
NamespaceString(StorageInterfaceImpl::kDefaultRollbackIdNamespace),
{BSON("_id" << StorageInterfaceImpl::kRollbackIdDocumentId
- << StorageInterfaceImpl::kRollbackIdFieldName
- << id)});
+ << StorageInterfaceImpl::kRollbackIdFieldName << id)});
}
TEST_F(StorageInterfaceImplTest, RollbackIdInitializesIncrementsAndReadsProperly) {
@@ -378,8 +373,7 @@ TEST_F(StorageInterfaceImplTest, GetRollbackIDReturnsBadStatusIfRollbackIDIsNotI
std::vector<TimestampedBSONObj> badDoc = {
TimestampedBSONObj{BSON("_id" << StorageInterfaceImpl::kRollbackIdDocumentId
- << StorageInterfaceImpl::kRollbackIdFieldName
- << "bad id"),
+ << StorageInterfaceImpl::kRollbackIdFieldName << "bad id"),
Timestamp::min()}};
ASSERT_OK(storage.insertDocuments(opCtx, nss, transformInserts(badDoc)));
ASSERT_EQUALS(ErrorCodes::TypeMismatch, storage.getRollbackID(opCtx).getStatus());
@@ -623,8 +617,7 @@ TEST_F(StorageInterfaceImplTest, DestroyingUncommittedCollectionBulkLoaderDropsI
auto nss = makeNamespace(_agent);
std::vector<BSONObj> indexes = {BSON("v" << 1 << "key" << BSON("x" << 1) << "name"
<< "x_1"
- << "ns"
- << nss.ns())};
+ << "ns" << nss.ns())};
auto destroyLoaderFn = [](std::unique_ptr<CollectionBulkLoader> loader) {
// Destroy 'loader' by letting it go out of scope.
};
@@ -648,8 +641,7 @@ TEST_F(StorageInterfaceImplTest,
auto nss = makeNamespace(_agent);
std::vector<BSONObj> indexes = {BSON("v" << 1 << "key" << BSON("x" << 1) << "name"
<< "x_1"
- << "ns"
- << nss.ns())};
+ << "ns" << nss.ns())};
auto destroyLoaderFn = [](std::unique_ptr<CollectionBulkLoader> loader) {
// Destroy 'loader' in a new thread that does not have a Client.
stdx::thread([&loader]() { loader.reset(); }).join();
@@ -912,9 +904,7 @@ TEST_F(StorageInterfaceImplTest, FindDocumentsReturnsIndexOptionsConflictIfIndex
auto nss = makeNamespace(_agent);
std::vector<BSONObj> indexes = {BSON("v" << 1 << "key" << BSON("x" << 1) << "name"
<< "x_1"
- << "ns"
- << nss.ns()
- << "partialFilterExpression"
+ << "ns" << nss.ns() << "partialFilterExpression"
<< BSON("y" << 1))};
auto loader = unittest::assertGet(storage.createCollectionForBulkLoading(
nss, generateOptionsWithUuid(), makeIdIndexSpec(nss), indexes));
@@ -973,8 +963,8 @@ void _assertDocumentsEqual(const StatusWith<std::vector<BSONObj>>& statusWithDoc
const std::vector<BSONObj>& expectedDocs) {
const auto actualDocs = unittest::assertGet(statusWithDocs);
auto iter = actualDocs.cbegin();
- std::string msg = str::stream() << "expected: " << _toString(expectedDocs)
- << "; actual: " << _toString(actualDocs);
+ std::string msg = str::stream()
+ << "expected: " << _toString(expectedDocs) << "; actual: " << _toString(actualDocs);
for (const auto& doc : expectedDocs) {
ASSERT_TRUE(iter != actualDocs.cend()) << msg;
ASSERT_BSONOBJ_EQ(doc, *(iter++));
@@ -2262,9 +2252,7 @@ TEST_F(StorageInterfaceImplTest, DeleteByFilterReturnsNamespaceNotFoundWhenDatab
ASSERT_EQUALS(ErrorCodes::NamespaceNotFound, status);
ASSERT_EQUALS(std::string(str::stream()
<< "Database [nosuchdb] not found. Unable to delete documents in "
- << nss.ns()
- << " using filter "
- << filter),
+ << nss.ns() << " using filter " << filter),
status.reason());
}
@@ -2360,9 +2348,7 @@ TEST_F(StorageInterfaceImplTest, DeleteByFilterReturnsNamespaceNotFoundWhenColle
ASSERT_EQUALS(std::string(
str::stream()
<< "Collection [mydb.wrongColl] not found. Unable to delete documents in "
- << wrongColl.ns()
- << " using filter "
- << filter),
+ << wrongColl.ns() << " using filter " << filter),
status.reason());
}
@@ -2482,8 +2468,7 @@ TEST_F(StorageInterfaceImplTest,
CollectionOptions options = generateOptionsWithUuid();
options.collation = BSON("locale"
<< "en_US"
- << "strength"
- << 2);
+ << "strength" << 2);
ASSERT_OK(storage.createCollection(opCtx, nss, options));
auto doc1 = BSON("_id" << 1 << "x"
@@ -2658,9 +2643,8 @@ TEST_F(StorageInterfaceImplTest, SetIndexIsMultikeySucceeds) {
ASSERT_OK(storage.createCollection(opCtx, nss, CollectionOptions()));
auto indexName = "a_b_1";
- auto indexSpec =
- BSON("name" << indexName << "ns" << nss.ns() << "key" << BSON("a.b" << 1) << "v"
- << static_cast<int>(kIndexVersion));
+ auto indexSpec = BSON("name" << indexName << "ns" << nss.ns() << "key" << BSON("a.b" << 1)
+ << "v" << static_cast<int>(kIndexVersion));
ASSERT_EQUALS(_createIndexOnEmptyCollection(opCtx, nss, indexSpec), 2);
MultikeyPaths paths = {{1}};
diff --git a/src/mongo/db/repl/storage_interface_mock.h b/src/mongo/db/repl/storage_interface_mock.h
index f4ac2aa763c..ec32c6dc059 100644
--- a/src/mongo/db/repl/storage_interface_mock.h
+++ b/src/mongo/db/repl/storage_interface_mock.h
@@ -345,8 +345,8 @@ public:
[](const NamespaceString& nss,
const CollectionOptions& options,
const BSONObj idIndexSpec,
- const std::vector<BSONObj>&
- secondaryIndexSpecs) -> StatusWith<std::unique_ptr<CollectionBulkLoader>> {
+ const std::vector<BSONObj>& secondaryIndexSpecs)
+ -> StatusWith<std::unique_ptr<CollectionBulkLoader>> {
return Status{ErrorCodes::IllegalOperation, "CreateCollectionForBulkFn not implemented."};
};
InsertDocumentFn insertDocumentFn = [](OperationContext* opCtx,
@@ -397,8 +397,9 @@ public:
IsAdminDbValidFn isAdminDbValidFn = [](OperationContext*) {
return Status{ErrorCodes::IllegalOperation, "IsAdminDbValidFn not implemented."};
};
- GetCollectionUUIDFn getCollectionUUIDFn = [](
- OperationContext* opCtx, const NamespaceString& nss) -> StatusWith<OptionalCollectionUUID> {
+ GetCollectionUUIDFn getCollectionUUIDFn =
+ [](OperationContext* opCtx,
+ const NamespaceString& nss) -> StatusWith<OptionalCollectionUUID> {
return Status{ErrorCodes::IllegalOperation, "GetCollectionUUIDFn not implemented."};
};
diff --git a/src/mongo/db/repl/sync_source_resolver.cpp b/src/mongo/db/repl/sync_source_resolver.cpp
index 865654622e9..45364e05bf7 100644
--- a/src/mongo/db/repl/sync_source_resolver.cpp
+++ b/src/mongo/db/repl/sync_source_resolver.cpp
@@ -75,8 +75,7 @@ SyncSourceResolver::SyncSourceResolver(executor::TaskExecutor* taskExecutor,
str::stream() << "required optime (if provided) must be more recent than last "
"fetched optime. requiredOpTime: "
<< requiredOpTime.toString()
- << ", lastOpTimeFetched: "
- << lastOpTimeFetched.toString(),
+ << ", lastOpTimeFetched: " << lastOpTimeFetched.toString(),
requiredOpTime.isNull() || requiredOpTime > lastOpTimeFetched);
uassert(ErrorCodes::BadValue, "callback function cannot be null", onCompletion);
}
@@ -172,9 +171,8 @@ std::unique_ptr<Fetcher> SyncSourceResolver::_makeFirstOplogEntryFetcher(
kLocalOplogNss.db().toString(),
BSON("find" << kLocalOplogNss.coll() << "limit" << 1 << "sort" << BSON("$natural" << 1)
<< "projection"
- << BSON(OplogEntryBase::kTimestampFieldName << 1
- << OplogEntryBase::kTermFieldName
- << 1)),
+ << BSON(OplogEntryBase::kTimestampFieldName
+ << 1 << OplogEntryBase::kTermFieldName << 1)),
[=](const StatusWith<Fetcher::QueryResponse>& response,
Fetcher::NextAction*,
BSONObjBuilder*) {
@@ -414,12 +412,11 @@ Status SyncSourceResolver::_compareRequiredOpTimeWithQueryResponse(
const auto opTime = oplogEntry.getOpTime();
if (_requiredOpTime != opTime) {
return Status(ErrorCodes::BadValue,
- str::stream() << "remote oplog contain entry with matching timestamp "
- << opTime.getTimestamp().toString()
- << " but optime "
- << opTime.toString()
- << " does not "
- "match our required optime");
+ str::stream()
+ << "remote oplog contain entry with matching timestamp "
+ << opTime.getTimestamp().toString() << " but optime " << opTime.toString()
+ << " does not "
+ "match our required optime");
}
if (_requiredOpTime.getTerm() != opTime.getTerm()) {
return Status(ErrorCodes::BadValue,
@@ -440,8 +437,7 @@ void SyncSourceResolver::_requiredOpTimeFetcherCallback(
str::stream() << "sync source resolver shut down while looking for "
"required optime "
<< _requiredOpTime.toString()
- << " in candidate's oplog: "
- << candidate))
+ << " in candidate's oplog: " << candidate))
.transitional_ignore();
return;
}
diff --git a/src/mongo/db/repl/sync_source_selector.h b/src/mongo/db/repl/sync_source_selector.h
index 0a620d691a2..c21a5e82a14 100644
--- a/src/mongo/db/repl/sync_source_selector.h
+++ b/src/mongo/db/repl/sync_source_selector.h
@@ -41,7 +41,7 @@ class Timestamp;
namespace rpc {
class ReplSetMetadata;
class OplogQueryMetadata;
-}
+} // namespace rpc
namespace repl {
diff --git a/src/mongo/db/repl/sync_tail.cpp b/src/mongo/db/repl/sync_tail.cpp
index 4781dc71500..ef05c77289a 100644
--- a/src/mongo/db/repl/sync_tail.cpp
+++ b/src/mongo/db/repl/sync_tail.cpp
@@ -779,8 +779,7 @@ void SyncTail::_oplogApplication(ReplicationCoordinator* replCoord,
str::stream() << "Attempted to apply an oplog entry ("
<< firstOpTimeInBatch.toString()
<< ") which is not greater than our last applied OpTime ("
- << lastAppliedOpTimeAtStartOfBatch.toString()
- << ")."));
+ << lastAppliedOpTimeAtStartOfBatch.toString() << ")."));
}
// Don't allow the fsync+lock thread to see intermediate states of batch application.
@@ -810,8 +809,7 @@ void SyncTail::_oplogApplication(ReplicationCoordinator* replCoord,
const auto lastAppliedOpTimeAtEndOfBatch = replCoord->getMyLastAppliedOpTime();
invariant(lastAppliedOpTimeAtStartOfBatch == lastAppliedOpTimeAtEndOfBatch,
str::stream() << "the last known applied OpTime has changed from "
- << lastAppliedOpTimeAtStartOfBatch.toString()
- << " to "
+ << lastAppliedOpTimeAtStartOfBatch.toString() << " to "
<< lastAppliedOpTimeAtEndOfBatch.toString()
<< " in the middle of batch application");
@@ -1282,23 +1280,23 @@ void SyncTail::_applyOps(std::vector<MultiApplier::OperationPtrs>& writerVectors
if (writerVectors[i].empty())
continue;
- _writerPool->schedule([
- this,
- &writer = writerVectors.at(i),
- &status = statusVector->at(i),
- &workerMultikeyPathInfo = workerMultikeyPathInfo->at(i)
- ](auto scheduleStatus) {
- invariant(scheduleStatus);
+ _writerPool->schedule(
+ [this,
+ &writer = writerVectors.at(i),
+ &status = statusVector->at(i),
+ &workerMultikeyPathInfo = workerMultikeyPathInfo->at(i)](auto scheduleStatus) {
+ invariant(scheduleStatus);
- auto opCtx = cc().makeOperationContext();
+ auto opCtx = cc().makeOperationContext();
- // This code path is only executed on secondaries and initial syncing nodes, so it is
- // safe to exclude any writes from Flow Control.
- opCtx->setShouldParticipateInFlowControl(false);
+ // This code path is only executed on secondaries and initial syncing nodes, so it
+ // is safe to exclude any writes from Flow Control.
+ opCtx->setShouldParticipateInFlowControl(false);
- status = opCtx->runWithoutInterruptionExceptAtGlobalShutdown(
- [&] { return _applyFunc(opCtx.get(), &writer, this, &workerMultikeyPathInfo); });
- });
+ status = opCtx->runWithoutInterruptionExceptAtGlobalShutdown([&] {
+ return _applyFunc(opCtx.get(), &writer, this, &workerMultikeyPathInfo);
+ });
+ });
}
}
diff --git a/src/mongo/db/repl/sync_tail_test.cpp b/src/mongo/db/repl/sync_tail_test.cpp
index 90f18f7eb49..933f23f4667 100644
--- a/src/mongo/db/repl/sync_tail_test.cpp
+++ b/src/mongo/db/repl/sync_tail_test.cpp
@@ -355,14 +355,8 @@ TEST_F(SyncTailTest, SyncApplyCommand) {
NamespaceString nss("test.t");
auto op = BSON("op"
<< "c"
- << "ns"
- << nss.getCommandNS().ns()
- << "o"
- << BSON("create" << nss.coll())
- << "ts"
- << Timestamp(1, 1)
- << "ui"
- << UUID::gen());
+ << "ns" << nss.getCommandNS().ns() << "o" << BSON("create" << nss.coll()) << "ts"
+ << Timestamp(1, 1) << "ui" << UUID::gen());
bool applyCmdCalled = false;
_opObserver->onCreateCollectionFn = [&](OperationContext* opCtx,
Collection*,
@@ -387,13 +381,10 @@ TEST_F(SyncTailTest, SyncApplyCommand) {
TEST_F(SyncTailTest, SyncApplyCommandThrowsException) {
const BSONObj op = BSON("op"
<< "c"
- << "ns"
- << 12345
- << "o"
+ << "ns" << 12345 << "o"
<< BSON("create"
<< "t")
- << "ts"
- << Timestamp(1, 1));
+ << "ts" << Timestamp(1, 1));
// This test relies on the namespace type check of IDL.
ASSERT_THROWS(
SyncTail::syncApply(_opCtx.get(), op, OplogApplication::Mode::kInitialSync, boost::none),
@@ -503,14 +494,9 @@ protected:
cmdNss,
BSON("applyOps" << BSON_ARRAY(BSON("op"
<< "i"
- << "ns"
- << _nss1.ns()
- << "ui"
- << *_uuid1
- << "o"
+ << "ns" << _nss1.ns() << "ui" << *_uuid1 << "o"
<< BSON("_id" << 1)))
- << "partialTxn"
- << true),
+ << "partialTxn" << true),
_lsid,
_txnNum,
StmtId(0),
@@ -520,14 +506,9 @@ protected:
cmdNss,
BSON("applyOps" << BSON_ARRAY(BSON("op"
<< "i"
- << "ns"
- << _nss2.ns()
- << "ui"
- << *_uuid2
- << "o"
+ << "ns" << _nss2.ns() << "ui" << *_uuid2 << "o"
<< BSON("_id" << 2)))
- << "partialTxn"
- << true),
+ << "partialTxn" << true),
_lsid,
_txnNum,
StmtId(1),
@@ -537,11 +518,7 @@ protected:
cmdNss,
BSON("applyOps" << BSON_ARRAY(BSON("op"
<< "i"
- << "ns"
- << _nss2.ns()
- << "ui"
- << *_uuid2
- << "o"
+ << "ns" << _nss2.ns() << "ui" << *_uuid2 << "o"
<< BSON("_id" << 3)))),
_lsid,
_txnNum,
@@ -696,14 +673,10 @@ TEST_F(MultiOplogEntrySyncTailTest, MultiApplyUnpreparedTransactionTwoBatches) {
cmdNss,
BSON("applyOps" << BSON_ARRAY(BSON("op"
<< "i"
- << "ns"
- << (i == 1 ? _nss2.ns() : _nss1.ns())
- << "ui"
- << (i == 1 ? *_uuid2 : *_uuid1)
- << "o"
+ << "ns" << (i == 1 ? _nss2.ns() : _nss1.ns()) << "ui"
+ << (i == 1 ? *_uuid2 : *_uuid1) << "o"
<< insertDocs.back()))
- << "partialTxn"
- << true),
+ << "partialTxn" << true),
_lsid,
_txnNum,
StmtId(i),
@@ -774,14 +747,9 @@ TEST_F(MultiOplogEntrySyncTailTest, MultiApplyTwoTransactionsOneBatch) {
cmdNss,
BSON("applyOps" << BSON_ARRAY(BSON("op"
<< "i"
- << "ns"
- << _nss1.ns()
- << "ui"
- << *_uuid1
- << "o"
+ << "ns" << _nss1.ns() << "ui" << *_uuid1 << "o"
<< BSON("_id" << 1)))
- << "partialTxn"
- << true),
+ << "partialTxn" << true),
_lsid,
txnNum1,
StmtId(0),
@@ -791,14 +759,9 @@ TEST_F(MultiOplogEntrySyncTailTest, MultiApplyTwoTransactionsOneBatch) {
cmdNss,
BSON("applyOps" << BSON_ARRAY(BSON("op"
<< "i"
- << "ns"
- << _nss1.ns()
- << "ui"
- << *_uuid1
- << "o"
+ << "ns" << _nss1.ns() << "ui" << *_uuid1 << "o"
<< BSON("_id" << 2)))
- << "partialTxn"
- << true),
+ << "partialTxn" << true),
_lsid,
txnNum1,
@@ -809,14 +772,9 @@ TEST_F(MultiOplogEntrySyncTailTest, MultiApplyTwoTransactionsOneBatch) {
cmdNss,
BSON("applyOps" << BSON_ARRAY(BSON("op"
<< "i"
- << "ns"
- << _nss1.ns()
- << "ui"
- << *_uuid1
- << "o"
+ << "ns" << _nss1.ns() << "ui" << *_uuid1 << "o"
<< BSON("_id" << 3)))
- << "partialTxn"
- << true),
+ << "partialTxn" << true),
_lsid,
txnNum2,
StmtId(0),
@@ -826,14 +784,9 @@ TEST_F(MultiOplogEntrySyncTailTest, MultiApplyTwoTransactionsOneBatch) {
cmdNss,
BSON("applyOps" << BSON_ARRAY(BSON("op"
<< "i"
- << "ns"
- << _nss1.ns()
- << "ui"
- << *_uuid1
- << "o"
+ << "ns" << _nss1.ns() << "ui" << *_uuid1 << "o"
<< BSON("_id" << 4)))
- << "partialTxn"
- << true),
+ << "partialTxn" << true),
_lsid,
txnNum2,
StmtId(1),
@@ -897,14 +850,9 @@ protected:
_nss1,
BSON("applyOps" << BSON_ARRAY(BSON("op"
<< "i"
- << "ns"
- << _nss2.ns()
- << "ui"
- << *_uuid2
- << "o"
+ << "ns" << _nss2.ns() << "ui" << *_uuid2 << "o"
<< BSON("_id" << 3)))
- << "prepare"
- << true),
+ << "prepare" << true),
_lsid,
_txnNum,
StmtId(2),
@@ -914,14 +862,9 @@ protected:
_nss1,
BSON("applyOps" << BSON_ARRAY(BSON("op"
<< "i"
- << "ns"
- << _nss1.ns()
- << "ui"
- << *_uuid1
- << "o"
+ << "ns" << _nss1.ns() << "ui" << *_uuid1 << "o"
<< BSON("_id" << 0)))
- << "prepare"
- << true),
+ << "prepare" << true),
_lsid,
_txnNum,
StmtId(0),
@@ -2240,28 +2183,18 @@ TEST_F(IdempotencyTest, CreateCollectionWithCollation) {
auto insertOp2 = insert(fromjson("{ _id: 'Foo', x: 1 }"));
auto updateOp = update("foo", BSON("$set" << BSON("x" << 2)));
auto dropColl = makeCommandOplogEntry(nextOpTime(), nss, BSON("drop" << nss.coll()));
- auto options = BSON("collation" << BSON("locale"
- << "en"
- << "caseLevel"
- << false
- << "caseFirst"
- << "off"
- << "strength"
- << 1
- << "numericOrdering"
- << false
- << "alternate"
- << "non-ignorable"
- << "maxVariable"
- << "punct"
- << "normalization"
- << false
- << "backwards"
- << false
- << "version"
- << "57.1")
- << "uuid"
- << uuid);
+ auto options = BSON("collation"
+ << BSON("locale"
+ << "en"
+ << "caseLevel" << false << "caseFirst"
+ << "off"
+ << "strength" << 1 << "numericOrdering" << false << "alternate"
+ << "non-ignorable"
+ << "maxVariable"
+ << "punct"
+ << "normalization" << false << "backwards" << false << "version"
+ << "57.1")
+ << "uuid" << uuid);
auto createColl = makeCreateCollectionOplogEntry(nextOpTime(), nss, options);
// We don't drop and re-create the collection since we don't have ways
@@ -2285,12 +2218,8 @@ TEST_F(IdempotencyTest, CreateCollectionWithIdIndex) {
auto options1 = BSON("idIndex" << BSON("key" << fromjson("{_id: 1}") << "name"
<< "_id_"
- << "v"
- << 2
- << "ns"
- << nss.ns())
- << "uuid"
- << uuid);
+ << "v" << 2 << "ns" << nss.ns())
+ << "uuid" << uuid);
auto createColl1 = makeCreateCollectionOplogEntry(nextOpTime(), nss, options1);
ASSERT_OK(runOpInitialSync(createColl1));
@@ -2324,9 +2253,8 @@ TEST_F(IdempotencyTest, CreateCollectionWithView) {
ASSERT_OK(
runOpInitialSync(makeCreateCollectionOplogEntry(nextOpTime(), viewNss, options.toBSON())));
- auto viewDoc =
- BSON("_id" << NamespaceString(nss.db(), "view").ns() << "viewOn" << nss.coll() << "pipeline"
- << fromjson("[ { '$project' : { 'x' : 1 } } ]"));
+ auto viewDoc = BSON("_id" << NamespaceString(nss.db(), "view").ns() << "viewOn" << nss.coll()
+ << "pipeline" << fromjson("[ { '$project' : { 'x' : 1 } } ]"));
auto insertViewOp = makeInsertDocumentOplogEntry(nextOpTime(), viewNss, viewDoc);
auto dropColl = makeCommandOplogEntry(nextOpTime(), nss, BSON("drop" << nss.coll()));
@@ -2764,14 +2692,9 @@ TEST_F(SyncTailTxnTableTest, RetryableWriteThenMultiStatementTxnWriteOnSameSessi
cmdNss,
BSON("applyOps" << BSON_ARRAY(BSON("op"
<< "i"
- << "ns"
- << nss().ns()
- << "ui"
- << uuid
- << "o"
+ << "ns" << nss().ns() << "ui" << uuid << "o"
<< BSON("_id" << 2)))
- << "partialTxn"
- << true),
+ << "partialTxn" << true),
sessionId,
*sessionInfo.getTxnNumber(),
StmtId(0),
@@ -2823,14 +2746,9 @@ TEST_F(SyncTailTxnTableTest, MultiStatementTxnWriteThenRetryableWriteOnSameSessi
cmdNss,
BSON("applyOps" << BSON_ARRAY(BSON("op"
<< "i"
- << "ns"
- << nss().ns()
- << "ui"
- << uuid
- << "o"
+ << "ns" << nss().ns() << "ui" << uuid << "o"
<< BSON("_id" << 2)))
- << "partialTxn"
- << true),
+ << "partialTxn" << true),
sessionId,
*sessionInfo.getTxnNumber(),
StmtId(0),
diff --git a/src/mongo/db/repl/task_runner.cpp b/src/mongo/db/repl/task_runner.cpp
index a79cdfa7faa..4c53b558aa1 100644
--- a/src/mongo/db/repl/task_runner.cpp
+++ b/src/mongo/db/repl/task_runner.cpp
@@ -182,7 +182,6 @@ void TaskRunner::_runTasks() {
"this task has been canceled by a previously invoked task"));
}
tasks.clear();
-
};
cancelTasks();
diff --git a/src/mongo/db/repl/topology_coordinator.cpp b/src/mongo/db/repl/topology_coordinator.cpp
index 5aeb5f11741..1aa98b65c8a 100644
--- a/src/mongo/db/repl/topology_coordinator.cpp
+++ b/src/mongo/db/repl/topology_coordinator.cpp
@@ -249,8 +249,8 @@ HostAndPort TopologyCoordinator::chooseNewSyncSource(Date_t now,
_syncSource = _rsConfig.getMemberAt(_forceSyncSourceIndex).getHostAndPort();
_forceSyncSourceIndex = -1;
log() << "choosing sync source candidate by request: " << _syncSource;
- std::string msg(str::stream() << "syncing from: " << _syncSource.toString()
- << " by request");
+ std::string msg(str::stream()
+ << "syncing from: " << _syncSource.toString() << " by request");
setMyHeartbeatMessage(now, msg);
return _syncSource;
}
@@ -572,8 +572,7 @@ Status TopologyCoordinator::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();
@@ -782,8 +781,9 @@ HeartbeatResponseAction TopologyCoordinator::processHeartbeatResponse(
}
const int memberIndex = _rsConfig.findMemberIndexByHostAndPort(target);
if (memberIndex == -1) {
- LOG(1) << "Could not find " << target << " in current config so ignoring --"
- " current config: "
+ LOG(1) << "Could not find " << target
+ << " in current config so ignoring --"
+ " current config: "
<< _rsConfig.toBSON();
HeartbeatResponseAction nextAction = HeartbeatResponseAction::makeNoAction();
nextAction.setNextHeartbeatStartDate(nextHeartbeatStartDate);
@@ -1131,8 +1131,9 @@ HeartbeatResponseAction TopologyCoordinator::_updatePrimaryFromHBDataV1(
bool scheduleCatchupTakeover = false;
bool schedulePriorityTakeover = false;
- if (!catchupTakeoverDisabled && (_memberData.at(primaryIndex).getLastAppliedOpTime() <
- _memberData.at(_selfIndex).getLastAppliedOpTime())) {
+ if (!catchupTakeoverDisabled &&
+ (_memberData.at(primaryIndex).getLastAppliedOpTime() <
+ _memberData.at(_selfIndex).getLastAppliedOpTime())) {
LOG_FOR_ELECTION(2) << "I can take over the primary due to fresher data."
<< " Current primary index: " << primaryIndex << " in term "
<< _memberData.at(primaryIndex).getTerm() << "."
@@ -2712,38 +2713,30 @@ void TopologyCoordinator::processReplSetRequestVotes(const ReplSetRequestVotesAr
if (args.getTerm() < _term) {
response->setVoteGranted(false);
response->setReason(str::stream() << "candidate's term (" << args.getTerm()
- << ") is lower than mine ("
- << _term
- << ")");
+ << ") is lower than mine (" << _term << ")");
} else if (args.getConfigVersion() != _rsConfig.getConfigVersion()) {
response->setVoteGranted(false);
- response->setReason(str::stream() << "candidate's config version ("
- << args.getConfigVersion()
- << ") differs from mine ("
- << _rsConfig.getConfigVersion()
- << ")");
+ response->setReason(str::stream()
+ << "candidate's config version (" << args.getConfigVersion()
+ << ") differs from mine (" << _rsConfig.getConfigVersion() << ")");
} else if (args.getSetName() != _rsConfig.getReplSetName()) {
response->setVoteGranted(false);
- response->setReason(str::stream() << "candidate's set name (" << args.getSetName()
- << ") differs from mine ("
- << _rsConfig.getReplSetName()
- << ")");
+ response->setReason(str::stream()
+ << "candidate's set name (" << args.getSetName()
+ << ") differs from mine (" << _rsConfig.getReplSetName() << ")");
} else if (args.getLastDurableOpTime() < getMyLastAppliedOpTime()) {
response->setVoteGranted(false);
response
->setReason(str::stream()
<< "candidate's data is staler than mine. candidate's last applied OpTime: "
<< args.getLastDurableOpTime().toString()
- << ", my last applied OpTime: "
- << getMyLastAppliedOpTime().toString());
+ << ", my last applied OpTime: " << getMyLastAppliedOpTime().toString());
} else if (!args.isADryRun() && _lastVote.getTerm() == args.getTerm()) {
response->setVoteGranted(false);
response->setReason(str::stream()
<< "already voted for another candidate ("
<< _rsConfig.getMemberAt(_lastVote.getCandidateIndex()).getHostAndPort()
- << ") this term ("
- << _lastVote.getTerm()
- << ")");
+ << ") this term (" << _lastVote.getTerm() << ")");
} else {
int betterPrimary = _findHealthyPrimaryOfEqualOrGreaterPriority(args.getCandidateIndex());
if (_selfConfig().isArbiter() && betterPrimary >= 0) {
diff --git a/src/mongo/db/repl/topology_coordinator.h b/src/mongo/db/repl/topology_coordinator.h
index d73cbd469f9..d53a581e82b 100644
--- a/src/mongo/db/repl/topology_coordinator.h
+++ b/src/mongo/db/repl/topology_coordinator.h
@@ -1072,7 +1072,7 @@ public:
/**
* Gets the number of retries left for this heartbeat attempt. Invalid to call if the current
* state is 'UNINITIALIZED'.
- */
+ */
int retriesLeft() const {
return kMaxHeartbeatRetries - _numFailuresSinceLastStart;
}
diff --git a/src/mongo/db/repl/topology_coordinator_v1_test.cpp b/src/mongo/db/repl/topology_coordinator_v1_test.cpp
index 678b3d87148..6da911b3aca 100644
--- a/src/mongo/db/repl/topology_coordinator_v1_test.cpp
+++ b/src/mongo/db/repl/topology_coordinator_v1_test.cpp
@@ -53,9 +53,9 @@
#define ASSERT_NO_ACTION(EXPRESSION) \
ASSERT_EQUALS(mongo::repl::HeartbeatResponseAction::NoAction, (EXPRESSION))
-using std::unique_ptr;
-using mongo::rpc::ReplSetMetadata;
using mongo::rpc::OplogQueryMetadata;
+using mongo::rpc::ReplSetMetadata;
+using std::unique_ptr;
namespace mongo {
namespace repl {
@@ -326,9 +326,7 @@ 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"
@@ -399,44 +397,31 @@ TEST_F(TopoCoordTest, NodeReturnsSecondaryWithMostRecentDataAsSyncSource) {
}
TEST_F(TopoCoordTest, NodeReturnsClosestValidSyncSourceAsSyncSource) {
- updateConfig(BSON("_id"
- << "rs0"
- << "version"
- << 1
- << "members"
- << BSON_ARRAY(BSON("_id" << 1 << "host"
- << "hself")
- << BSON("_id" << 10 << "host"
- << "h1")
- << BSON("_id" << 20 << "host"
- << "h2"
- << "buildIndexes"
- << false
- << "priority"
- << 0)
- << BSON("_id" << 30 << "host"
- << "h3"
- << "hidden"
- << true
- << "priority"
- << 0
- << "votes"
- << 0)
- << BSON("_id" << 40 << "host"
- << "h4"
- << "arbiterOnly"
- << true)
- << BSON("_id" << 50 << "host"
- << "h5"
- << "slaveDelay"
- << 1
- << "priority"
- << 0)
- << BSON("_id" << 60 << "host"
- << "h6")
- << BSON("_id" << 70 << "host"
- << "hprimary"))),
- 0);
+ updateConfig(
+ BSON("_id"
+ << "rs0"
+ << "version" << 1 << "members"
+ << BSON_ARRAY(BSON("_id" << 1 << "host"
+ << "hself")
+ << BSON("_id" << 10 << "host"
+ << "h1")
+ << BSON("_id" << 20 << "host"
+ << "h2"
+ << "buildIndexes" << false << "priority" << 0)
+ << BSON("_id" << 30 << "host"
+ << "h3"
+ << "hidden" << true << "priority" << 0 << "votes" << 0)
+ << BSON("_id" << 40 << "host"
+ << "h4"
+ << "arbiterOnly" << true)
+ << BSON("_id" << 50 << "host"
+ << "h5"
+ << "slaveDelay" << 1 << "priority" << 0)
+ << BSON("_id" << 60 << "host"
+ << "h6")
+ << BSON("_id" << 70 << "host"
+ << "hprimary"))),
+ 0);
setSelfMemberState(MemberState::RS_SECONDARY);
OpTime lastOpTimeWeApplied = OpTime(Timestamp(100, 0), 0);
@@ -573,9 +558,7 @@ TEST_F(TopoCoordTest, NodeReturnsClosestValidSyncSourceAsSyncSource) {
TEST_F(TopoCoordTest, NodeWontChooseSyncSourceFromOlderTerm) {
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "members"
+ << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "hself")
<< BSON("_id" << 10 << "host"
@@ -625,10 +608,7 @@ TEST_F(TopoCoordTest, NodeWontChooseSyncSourceFromOlderTerm) {
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")
@@ -752,9 +732,7 @@ TEST_F(TopoCoordTest, ChooseOnlyVotersAsSyncSourceWhenNodeIsAVoter) {
TEST_F(TopoCoordTest, ChooseSameSyncSourceEvenWhenPrimary) {
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "members"
+ << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
@@ -809,9 +787,7 @@ TEST_F(TopoCoordTest, ChooseSameSyncSourceEvenWhenPrimary) {
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"
@@ -862,9 +838,7 @@ 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"
@@ -917,10 +891,7 @@ 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")
@@ -975,9 +946,7 @@ 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"
@@ -1050,9 +1019,7 @@ 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"
@@ -1086,13 +1053,10 @@ 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);
@@ -1108,21 +1072,15 @@ 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"
@@ -1150,21 +1108,15 @@ 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"
@@ -1187,21 +1139,15 @@ 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"
@@ -1225,21 +1171,15 @@ 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"
@@ -1264,21 +1204,15 @@ 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"
@@ -1303,21 +1237,15 @@ 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"
@@ -1346,21 +1274,15 @@ 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"
@@ -1395,21 +1317,15 @@ 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"
@@ -1445,21 +1361,15 @@ 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"
@@ -1494,21 +1404,15 @@ 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"
@@ -1562,21 +1466,15 @@ 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"
@@ -1837,12 +1735,10 @@ TEST_F(TopoCoordTest, ReplSetGetStatusWriteMajorityDifferentFromMajorityVoteCoun
<< "test1:1234")
<< BSON("_id" << 2 << "host"
<< "test2:1234"
- << "arbiterOnly"
- << true)
+ << "arbiterOnly" << true)
<< BSON("_id" << 3 << "host"
<< "test3:1234"
- << "arbiterOnly"
- << true))),
+ << "arbiterOnly" << true))),
3,
startupTime + Milliseconds(1));
@@ -1959,13 +1855,10 @@ TEST_F(TopoCoordTest, HeartbeatFrequencyShouldBeHalfElectionTimeoutWhenArbiter)
TEST_F(TopoCoordTest, PrepareStepDownAttemptFailsIfNotLeader) {
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 5
- << "members"
+ << "version" << 5 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host1:27017"))
- << "protocolVersion"
- << 1),
+ << "protocolVersion" << 1),
0);
getTopoCoord().changeMemberState_forTest(MemberState::RS_SECONDARY);
Status expectedStatus(ErrorCodes::NotMaster, "This node is not a primary. ");
@@ -1979,17 +1872,14 @@ 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"
- << BSON("protocolVersion" << 1)),
+ << "settings" << BSON("protocolVersion" << 1)),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
}
@@ -2013,8 +1903,8 @@ TEST_F(PrepareHeartbeatResponseV1Test,
prepareHeartbeatResponseV1(args, &response, &result);
stopCapturingLogMessages();
ASSERT_EQUALS(ErrorCodes::InconsistentReplicaSetNames, result);
- ASSERT(result.reason().find("repl set names do not match")) << "Actual string was \""
- << result.reason() << '"';
+ 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"));
@@ -2027,15 +1917,12 @@ TEST_F(PrepareHeartbeatResponseV1Test,
// reconfig self out of set
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 3
- << "members"
+ << "version" << 3 << "members"
<< BSON_ARRAY(BSON("_id" << 20 << "host"
<< "h2")
<< BSON("_id" << 30 << "host"
<< "h3"))
- << "settings"
- << BSON("protocolVersion" << 1)),
+ << "settings" << BSON("protocolVersion" << 1)),
-1);
ReplSetHeartbeatArgsV1 args;
args.setSetName("rs0");
@@ -2231,9 +2118,7 @@ TEST_F(TopoCoordTest, BecomeCandidateWhenBecomingSecondaryInSingleNodeSet) {
ASSERT_EQUALS(MemberState::RS_STARTUP, getTopoCoord().getMemberState().s);
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "members"
+ << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "hself"))),
0);
@@ -2251,9 +2136,7 @@ TEST_F(TopoCoordTest, DoNotBecomeCandidateWhenBecomingSecondaryInSingleNodeSetIf
ASSERT_EQUALS(MemberState::RS_STARTUP, getTopoCoord().getMemberState().s);
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "members"
+ << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "hself"))),
0);
@@ -2281,15 +2164,10 @@ TEST_F(TopoCoordTest, BecomeCandidateWhenReconfigToBeElectableInSingleNodeSet) {
ReplSetConfig cfg;
cfg.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "hself"
- << "priority"
- << 0))))
+ << "priority" << 0))))
.transitional_ignore();
getTopoCoord().updateConfig(cfg, 0, now()++);
ASSERT_EQUALS(MemberState::RS_STARTUP2, getTopoCoord().getMemberState().s);
@@ -2303,9 +2181,7 @@ TEST_F(TopoCoordTest, BecomeCandidateWhenReconfigToBeElectableInSingleNodeSet) {
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "members"
+ << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "hself"))),
0);
@@ -2319,15 +2195,10 @@ TEST_F(TopoCoordTest,
ReplSetConfig cfg;
ASSERT_OK(cfg.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "hself"
- << "priority"
- << 0)))));
+ << "priority" << 0)))));
getTopoCoord().updateConfig(cfg, 0, now()++);
ASSERT_EQUALS(MemberState::RS_STARTUP2, getTopoCoord().getMemberState().s);
@@ -2341,9 +2212,7 @@ TEST_F(TopoCoordTest,
getTopoCoord().adjustMaintenanceCountBy(1);
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "members"
+ << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "hself"))),
0);
@@ -2356,13 +2225,10 @@ TEST_F(TopoCoordTest, NodeDoesNotBecomeCandidateWhenBecomingSecondaryInSingleNod
ReplSetConfig cfg;
cfg.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "members"
+ << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "hself"
- << "priority"
- << 0))))
+ << "priority" << 0))))
.transitional_ignore();
getTopoCoord().updateConfig(cfg, 0, now()++);
@@ -2381,9 +2247,7 @@ 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"
@@ -2396,9 +2260,7 @@ TEST_F(TopoCoordTest, NodeTransitionsFromRemovedToStartup2WhenAddedToConfig) {
// reconfig to add to set
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host1:27017")
<< BSON("_id" << 1 << "host"
@@ -2416,9 +2278,7 @@ TEST_F(TopoCoordTest, NodeTransitionsToRemovedWhenRemovedFromConfig) {
ASSERT_EQUALS(MemberState::RS_STARTUP, getTopoCoord().getMemberState().s);
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "members"
+ << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host1:27017")
<< BSON("_id" << 1 << "host"
@@ -2432,9 +2292,7 @@ TEST_F(TopoCoordTest, NodeTransitionsToRemovedWhenRemovedFromConfig) {
// 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"
@@ -2450,9 +2308,7 @@ TEST_F(TopoCoordTest, NodeTransitionsToRemovedWhenRemovedFromConfigEvenWhenPrima
ASSERT_EQUALS(MemberState::RS_STARTUP, getTopoCoord().getMemberState().s);
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "members"
+ << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host1:27017"))),
0);
@@ -2469,9 +2325,7 @@ 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"
@@ -2487,11 +2341,7 @@ TEST_F(TopoCoordTest, NodeTransitionsToSecondaryWhenReconfiggingToBeUnelectable)
ASSERT_EQUALS(MemberState::RS_STARTUP, getTopoCoord().getMemberState().s);
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 1 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host1:27017"))),
0);
@@ -2508,13 +2358,10 @@ TEST_F(TopoCoordTest, NodeTransitionsToSecondaryWhenReconfiggingToBeUnelectable)
// now lose primary due to loss of electability
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host1:27017"
- << "priority"
- << 0)
+ << "priority" << 0)
<< BSON("_id" << 1 << "host"
<< "host2:27017")
<< BSON("_id" << 2 << "host"
@@ -2529,9 +2376,7 @@ TEST_F(TopoCoordTest, NodeMaintainsPrimaryStateAcrossReconfigIfNodeRemainsElecta
ASSERT_EQUALS(MemberState::RS_STARTUP, getTopoCoord().getMemberState().s);
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 1
- << "members"
+ << "version" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host1:27017"))),
0);
@@ -2550,9 +2395,7 @@ TEST_F(TopoCoordTest, NodeMaintainsPrimaryStateAcrossReconfigIfNodeRemainsElecta
// Add hosts
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host1:27017")
<< BSON("_id" << 1 << "host"
@@ -2567,18 +2410,13 @@ TEST_F(TopoCoordTest, NodeMaintainsPrimaryStateAcrossReconfigIfNodeRemainsElecta
// Change priorities and tags
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host1:27017"
- << "priority"
- << 10)
+ << "priority" << 10)
<< BSON("_id" << 1 << "host"
<< "host2:27017"
- << "priority"
- << 5
- << "tags"
+ << "priority" << 5 << "tags"
<< BSON("dc"
<< "NA"
<< "rack"
@@ -2592,9 +2430,7 @@ 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"
@@ -2608,9 +2444,7 @@ TEST_F(TopoCoordTest, NodeMaintainsSecondaryStateAcrossReconfig) {
// reconfig and stay secondary
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host1:27017")
<< BSON("_id" << 1 << "host"
@@ -2625,13 +2459,10 @@ TEST_F(TopoCoordTest, NodeMaintainsSecondaryStateAcrossReconfig) {
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"
@@ -2650,9 +2481,7 @@ 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"
@@ -2665,13 +2494,8 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantVotesToTwoDifferentNodesInTheSameTerm) {
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)))
.transitional_ignore();
ReplSetRequestVotesResponse response;
@@ -2684,13 +2508,8 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantVotesToTwoDifferentNodesInTheSameTerm) {
args2
.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)))
.transitional_ignore();
ReplSetRequestVotesResponse response2;
@@ -2705,9 +2524,7 @@ 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"
@@ -2721,14 +2538,8 @@ 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)))
.transitional_ignore();
@@ -2743,14 +2554,8 @@ TEST_F(TopoCoordTest, DryRunVoteRequestShouldNotPreventSubsequentDryRunsForThatT
args2
.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)))
.transitional_ignore();
@@ -2765,14 +2570,8 @@ TEST_F(TopoCoordTest, DryRunVoteRequestShouldNotPreventSubsequentDryRunsForThatT
args3
.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)))
.transitional_ignore();
@@ -2787,14 +2586,8 @@ TEST_F(TopoCoordTest, DryRunVoteRequestShouldNotPreventSubsequentDryRunsForThatT
args4
.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)))
.transitional_ignore();
@@ -2809,9 +2602,7 @@ 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"
@@ -2825,14 +2616,8 @@ 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)))
.transitional_ignore();
@@ -2847,14 +2632,8 @@ TEST_F(TopoCoordTest, VoteRequestShouldNotPreventDryRunsForThatTerm) {
args2
.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)))
.transitional_ignore();
@@ -2869,9 +2648,7 @@ 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"
@@ -2885,13 +2662,8 @@ 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)))
.transitional_ignore();
ReplSetRequestVotesResponse response;
@@ -2904,9 +2676,7 @@ 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"
@@ -2920,13 +2690,8 @@ 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)))
.transitional_ignore();
ReplSetRequestVotesResponse response;
@@ -2939,9 +2704,7 @@ 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"
@@ -2959,13 +2722,8 @@ 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)))
.transitional_ignore();
ReplSetRequestVotesResponse response;
@@ -2979,9 +2737,7 @@ 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"
@@ -2996,13 +2752,8 @@ 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)))
.transitional_ignore();
ReplSetRequestVotesResponse response;
@@ -3012,8 +2763,7 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantVoteWhenOpTimeIsStale) {
ASSERT_EQUALS(
str::stream() << "candidate's data is staler than mine. candidate's last applied OpTime: "
<< OpTime().toString()
- << ", my last applied OpTime: "
- << OpTime(Timestamp(20, 0), 0).toString(),
+ << ", my last applied OpTime: " << OpTime(Timestamp(20, 0), 0).toString(),
response.getReason());
ASSERT_FALSE(response.getVoteGranted());
}
@@ -3021,9 +2771,7 @@ 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"
@@ -3040,13 +2788,8 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantDryRunVoteWhenReplSetNameDoesNotMatch) {
argsForRealVote
.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)))
.transitional_ignore();
ReplSetRequestVotesResponse responseForRealVote;
@@ -3060,14 +2803,8 @@ 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)))
.transitional_ignore();
@@ -3082,9 +2819,7 @@ 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"
@@ -3101,13 +2836,8 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantDryRunVoteWhenConfigVersionDoesNotMatch) {
argsForRealVote
.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)))
.transitional_ignore();
ReplSetRequestVotesResponse responseForRealVote;
@@ -3121,14 +2851,8 @@ 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)))
.transitional_ignore();
@@ -3143,9 +2867,7 @@ 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"
@@ -3162,13 +2884,8 @@ TEST_F(TopoCoordTest, NodeDoesNotGrantDryRunVoteWhenTermIsStale) {
argsForRealVote
.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)))
.transitional_ignore();
ReplSetRequestVotesResponse responseForRealVote;
@@ -3181,14 +2898,8 @@ 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)))
.transitional_ignore();
@@ -3203,9 +2914,7 @@ 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"
@@ -3222,13 +2931,8 @@ TEST_F(TopoCoordTest, GrantDryRunVoteEvenWhenTermHasBeenSeen) {
argsForRealVote
.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)))
.transitional_ignore();
ReplSetRequestVotesResponse responseForRealVote;
@@ -3242,14 +2946,8 @@ 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)))
.transitional_ignore();
@@ -3264,9 +2962,7 @@ 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"
@@ -3283,13 +2979,8 @@ TEST_F(TopoCoordTest, DoNotGrantDryRunVoteWhenOpTimeIsStale) {
argsForRealVote
.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)))
.transitional_ignore();
ReplSetRequestVotesResponse responseForRealVote;
@@ -3303,14 +2994,8 @@ 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)))
.transitional_ignore();
@@ -3321,8 +3006,7 @@ TEST_F(TopoCoordTest, DoNotGrantDryRunVoteWhenOpTimeIsStale) {
ASSERT_EQUALS(
str::stream() << "candidate's data is staler than mine. candidate's last applied OpTime: "
<< OpTime().toString()
- << ", my last applied OpTime: "
- << OpTime(Timestamp(20, 0), 0).toString(),
+ << ", my last applied OpTime: " << OpTime(Timestamp(20, 0), 0).toString(),
response.getReason());
ASSERT_EQUALS(1, response.getTerm());
ASSERT_FALSE(response.getVoteGranted());
@@ -3338,12 +3022,7 @@ 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")
@@ -3365,12 +3044,7 @@ 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")
@@ -3391,18 +3065,14 @@ 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"
<< "host2:27017")
<< BSON("_id" << 2 << "host"
<< "host3:27017"))
- << "protocolVersion"
- << 1
- << "settings"
+ << "protocolVersion" << 1 << "settings"
<< BSON("heartbeatTimeoutSecs" << 5)),
0);
}
@@ -3420,23 +3090,15 @@ 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);
topoCoordSetMyLastAppliedOpTime(lastOpTimeApplied, Date_t(), false);
HeartbeatResponseAction nextAction = receiveUpHeartbeat(
@@ -3772,15 +3434,12 @@ TEST_F(HeartbeatResponseTestV1, ReconfigNodeRemovedBetweenHeartbeatRequestAndRep
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host1:27017")
<< BSON("_id" << 1 << "host"
<< "host2:27017"))
- << "protocolVersion"
- << 1),
+ << "protocolVersion" << 1),
0);
ReplSetHeartbeatResponse hb;
@@ -3822,28 +3481,19 @@ TEST_F(HeartbeatResponseTestV1, ReconfigBetweenHeartbeatRequestAndRepsonse) {
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host1:27017")
<< BSON("_id" << 2 << "host"
<< "host3:27017"))
- << "protocolVersion"
- << 1),
+ << "protocolVersion" << 1),
0);
ReplSetHeartbeatResponse hb;
hb.initialize(BSON("ok" << 1 << "durableOpTime" << OpTime(Timestamp(100, 0), 0).toBSON()
- << "durableWallTime"
- << Date_t() + Seconds(100)
- << "opTime"
- << OpTime(Timestamp(100, 0), 0).toBSON()
- << "wallTime"
- << Date_t() + Seconds(100)
- << "v"
- << 1
- << "state"
+ << "durableWallTime" << Date_t() + Seconds(100) << "opTime"
+ << OpTime(Timestamp(100, 0), 0).toBSON() << "wallTime"
+ << Date_t() + Seconds(100) << "v" << 1 << "state"
<< MemberState::RS_PRIMARY),
0,
/*requireWallTime*/ true)
@@ -3902,20 +3552,15 @@ 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"
+ << "protocolVersion" << 1 << "settings"
<< BSON("heartbeatTimeoutSecs" << 5)),
0);
@@ -3936,21 +3581,16 @@ TEST_F(HeartbeatResponseTestV1,
TEST_F(HeartbeatResponseTestV1, UpdateHeartbeatDataTermPreventsPriorityTakeover) {
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 5
- << "members"
+ << "version" << 5 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host0:27017"
- << "priority"
- << 2)
+ << "priority" << 2)
<< BSON("_id" << 1 << "host"
<< "host1:27017"
- << "priority"
- << 3)
+ << "priority" << 3)
<< BSON("_id" << 2 << "host"
<< "host2:27017"))
- << "settings"
- << BSON("heartbeatTimeoutSecs" << 5)),
+ << "settings" << BSON("heartbeatTimeoutSecs" << 5)),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -3991,18 +3631,14 @@ TEST_F(HeartbeatResponseTestV1, UpdateHeartbeatDataTermPreventsPriorityTakeover)
TEST_F(TopoCoordTest, FreshestNodeDoesCatchupTakeover) {
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 5
- << "members"
+ << "version" << 5 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "host1:27017")
<< BSON("_id" << 2 << "host"
<< "host2:27017")
<< BSON("_id" << 3 << "host"
<< "host3:27017"))
- << "protocolVersion"
- << 1
- << "settings"
+ << "protocolVersion" << 1 << "settings"
<< BSON("heartbeatTimeoutSecs" << 5)),
0);
@@ -4048,18 +3684,14 @@ TEST_F(TopoCoordTest, FreshestNodeDoesCatchupTakeover) {
TEST_F(TopoCoordTest, StaleNodeDoesntDoCatchupTakeover) {
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 5
- << "members"
+ << "version" << 5 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "host1:27017")
<< BSON("_id" << 2 << "host"
<< "host2:27017")
<< BSON("_id" << 3 << "host"
<< "host3:27017"))
- << "protocolVersion"
- << 1
- << "settings"
+ << "protocolVersion" << 1 << "settings"
<< BSON("heartbeatTimeoutSecs" << 5)),
0);
@@ -4107,18 +3739,14 @@ TEST_F(TopoCoordTest, StaleNodeDoesntDoCatchupTakeover) {
TEST_F(TopoCoordTest, NodeDoesntDoCatchupTakeoverHeartbeatSaysPrimaryCaughtUp) {
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 5
- << "members"
+ << "version" << 5 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "host1:27017")
<< BSON("_id" << 2 << "host"
<< "host2:27017")
<< BSON("_id" << 3 << "host"
<< "host3:27017"))
- << "protocolVersion"
- << 1
- << "settings"
+ << "protocolVersion" << 1 << "settings"
<< BSON("heartbeatTimeoutSecs" << 5)),
0);
@@ -4163,18 +3791,14 @@ TEST_F(TopoCoordTest, NodeDoesntDoCatchupTakeoverHeartbeatSaysPrimaryCaughtUp) {
TEST_F(TopoCoordTest, NodeDoesntDoCatchupTakeoverIfTermNumbersSayPrimaryCaughtUp) {
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 5
- << "members"
+ << "version" << 5 << "members"
<< BSON_ARRAY(BSON("_id" << 1 << "host"
<< "host1:27017")
<< BSON("_id" << 2 << "host"
<< "host2:27017")
<< BSON("_id" << 3 << "host"
<< "host3:27017"))
- << "protocolVersion"
- << 1
- << "settings"
+ << "protocolVersion" << 1 << "settings"
<< BSON("heartbeatTimeoutSecs" << 5)),
0);
@@ -4224,19 +3848,14 @@ TEST_F(TopoCoordTest, NodeDoesntDoCatchupTakeoverIfTermNumbersSayPrimaryCaughtUp
TEST_F(TopoCoordTest, StepDownAttemptFailsWhenNotPrimary) {
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"))
- << "protocolVersion"
- << 1
- << "settings"
- << BSON("heartbeatTimeoutSecs" << 5)),
+ << "protocolVersion" << 1 << "settings" << BSON("heartbeatTimeoutSecs" << 5)),
0);
const auto term = getTopoCoord().getTerm();
Date_t curTime = now();
@@ -4253,19 +3872,14 @@ TEST_F(TopoCoordTest, StepDownAttemptFailsWhenNotPrimary) {
TEST_F(TopoCoordTest, StepDownAttemptFailsWhenAlreadySteppingDown) {
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"))
- << "protocolVersion"
- << 1
- << "settings"
- << BSON("heartbeatTimeoutSecs" << 5)),
+ << "protocolVersion" << 1 << "settings" << BSON("heartbeatTimeoutSecs" << 5)),
0);
const auto term = getTopoCoord().getTerm();
Date_t curTime = now();
@@ -4283,19 +3897,14 @@ TEST_F(TopoCoordTest, StepDownAttemptFailsWhenAlreadySteppingDown) {
TEST_F(TopoCoordTest, StepDownAttemptFailsForDifferentTerm) {
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"))
- << "protocolVersion"
- << 1
- << "settings"
- << BSON("heartbeatTimeoutSecs" << 5)),
+ << "protocolVersion" << 1 << "settings" << BSON("heartbeatTimeoutSecs" << 5)),
0);
const auto term = getTopoCoord().getTerm();
Date_t curTime = now();
@@ -4313,19 +3922,14 @@ TEST_F(TopoCoordTest, StepDownAttemptFailsForDifferentTerm) {
TEST_F(TopoCoordTest, StepDownAttemptFailsIfPastStepDownUntil) {
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"))
- << "protocolVersion"
- << 1
- << "settings"
- << BSON("heartbeatTimeoutSecs" << 5)),
+ << "protocolVersion" << 1 << "settings" << BSON("heartbeatTimeoutSecs" << 5)),
0);
const auto term = getTopoCoord().getTerm();
Date_t curTime = now();
@@ -4345,19 +3949,14 @@ TEST_F(TopoCoordTest, StepDownAttemptFailsIfPastStepDownUntil) {
TEST_F(TopoCoordTest, StepDownAttemptFailsIfPastWaitUntil) {
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"))
- << "protocolVersion"
- << 1
- << "settings"
- << BSON("heartbeatTimeoutSecs" << 5)),
+ << "protocolVersion" << 1 << "settings" << BSON("heartbeatTimeoutSecs" << 5)),
0);
const auto term = getTopoCoord().getTerm();
Date_t curTime = now();
@@ -4380,19 +3979,14 @@ TEST_F(TopoCoordTest, StepDownAttemptFailsIfPastWaitUntil) {
TEST_F(TopoCoordTest, StepDownAttemptFailsIfNoSecondariesCaughtUp) {
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"))
- << "protocolVersion"
- << 1
- << "settings"
- << BSON("heartbeatTimeoutSecs" << 5)),
+ << "protocolVersion" << 1 << "settings" << BSON("heartbeatTimeoutSecs" << 5)),
0);
const auto term = getTopoCoord().getTerm();
Date_t curTime = now();
@@ -4413,19 +4007,14 @@ TEST_F(TopoCoordTest, StepDownAttemptFailsIfNoSecondariesCaughtUp) {
TEST_F(TopoCoordTest, StepDownAttemptFailsIfNoSecondariesCaughtUpForceIsTrueButNotPastWaitUntil) {
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"))
- << "protocolVersion"
- << 1
- << "settings"
- << BSON("heartbeatTimeoutSecs" << 5)),
+ << "protocolVersion" << 1 << "settings" << BSON("heartbeatTimeoutSecs" << 5)),
0);
const auto term = getTopoCoord().getTerm();
Date_t curTime = now();
@@ -4446,19 +4035,14 @@ TEST_F(TopoCoordTest, StepDownAttemptFailsIfNoSecondariesCaughtUpForceIsTrueButN
TEST_F(TopoCoordTest, StepDownAttemptSucceedsIfNoSecondariesCaughtUpForceIsTrueAndPastWaitUntil) {
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"))
- << "protocolVersion"
- << 1
- << "settings"
- << BSON("heartbeatTimeoutSecs" << 5)),
+ << "protocolVersion" << 1 << "settings" << BSON("heartbeatTimeoutSecs" << 5)),
0);
const auto term = getTopoCoord().getTerm();
Date_t curTime = now();
@@ -4479,19 +4063,14 @@ TEST_F(TopoCoordTest, StepDownAttemptSucceedsIfNoSecondariesCaughtUpForceIsTrueA
TEST_F(TopoCoordTest, StepDownAttemptSucceedsIfSecondariesCaughtUp) {
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"))
- << "protocolVersion"
- << 1
- << "settings"
- << BSON("heartbeatTimeoutSecs" << 5)),
+ << "protocolVersion" << 1 << "settings" << BSON("heartbeatTimeoutSecs" << 5)),
0);
const auto term = getTopoCoord().getTerm();
Date_t curTime = now();
@@ -4512,23 +4091,15 @@ TEST_F(TopoCoordTest, StepDownAttemptSucceedsIfSecondariesCaughtUp) {
TEST_F(TopoCoordTest, StepDownAttemptFailsIfSecondaryCaughtUpButNotElectable) {
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 5
- << "members"
+ << "version" << 5 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host1:27017")
<< BSON("_id" << 1 << "host"
<< "host2:27017"
- << "priority"
- << 0
- << "hidden"
- << true)
+ << "priority" << 0 << "hidden" << true)
<< BSON("_id" << 2 << "host"
<< "host3:27017"))
- << "protocolVersion"
- << 1
- << "settings"
- << BSON("heartbeatTimeoutSecs" << 5)),
+ << "protocolVersion" << 1 << "settings" << BSON("heartbeatTimeoutSecs" << 5)),
0);
const auto term = getTopoCoord().getTerm();
Date_t curTime = now();
@@ -4558,15 +4129,12 @@ TEST_F(TopoCoordTest,
ASSERT_EQUALS(MemberState::RS_STARTUP, getTopoCoord().getMemberState().s);
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 5
- << "members"
+ << "version" << 5 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host0:27017")
<< BSON("_id" << 1 << "host"
<< "host1:27017"))
- << "protocolVersion"
- << 1),
+ << "protocolVersion" << 1),
0);
{
BSONObjBuilder statusBuilder;
@@ -4615,15 +4183,12 @@ TEST_F(TopoCoordTest,
ASSERT_EQUALS(MemberState::RS_STARTUP, getTopoCoord().getMemberState().s);
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 5
- << "members"
+ << "version" << 5 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host0:27017")
<< BSON("_id" << 1 << "host"
<< "host1:27017"))
- << "protocolVersion"
- << 1),
+ << "protocolVersion" << 1),
0);
ASSERT(getTopoCoord().getSyncSourceAddress().empty());
@@ -4688,10 +4253,7 @@ TEST_F(TopoCoordTest, replSetGetStatusForThreeMemberedReplicaSet) {
ASSERT_EQUALS(MemberState::RS_STARTUP, getTopoCoord().getMemberState().s);
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 5
- << "settings"
- << BSON("chainingAllowed" << false)
+ << "version" << 5 << "settings" << BSON("chainingAllowed" << false)
<< "members"
<< BSON_ARRAY(BSON("_id" << 30 << "host"
<< "hself:27017")
@@ -4699,8 +4261,7 @@ TEST_F(TopoCoordTest, replSetGetStatusForThreeMemberedReplicaSet) {
<< "hprimary:27017")
<< BSON("_id" << 10 << "host"
<< "h1:27017"))
- << "protocolVersion"
- << 1),
+ << "protocolVersion" << 1),
0);
ASSERT(getTopoCoord().getSyncSourceAddress().empty());
@@ -4791,13 +4352,10 @@ TEST_F(TopoCoordTest, StatusResponseAlwaysIncludesStringStatusFieldsForNonMember
ASSERT_EQUALS(MemberState::RS_STARTUP, getTopoCoord().getMemberState().s);
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 5
- << "members"
+ << "version" << 5 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host0:27017"))
- << "protocolVersion"
- << 1),
+ << "protocolVersion" << 1),
-1); // This node is no longer part of this replica set.
BSONObjBuilder statusBuilder;
@@ -4827,9 +4385,7 @@ TEST_F(TopoCoordTest, StatusResponseAlwaysIncludesStringStatusFieldsForNonMember
TEST_F(TopoCoordTest, NoElectionHandoffCandidateInSingleNodeReplicaSet) {
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host0:27017"))),
0);
@@ -4844,9 +4400,7 @@ TEST_F(TopoCoordTest, NoElectionHandoffCandidateInSingleNodeReplicaSet) {
TEST_F(TopoCoordTest, NoElectionHandoffCandidateWithOneLaggedNode) {
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host0:27017")
<< BSON("_id" << 1 << "host"
@@ -4867,15 +4421,12 @@ TEST_F(TopoCoordTest, NoElectionHandoffCandidateWithOneLaggedNode) {
TEST_F(TopoCoordTest, NoElectionHandoffCandidateWithOneUnelectableNode) {
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host0:27017")
<< BSON("_id" << 1 << "host"
<< "host1:27017"
- << "priority"
- << 0))),
+ << "priority" << 0))),
0);
const auto term = getTopoCoord().getTerm();
@@ -4892,17 +4443,14 @@ TEST_F(TopoCoordTest, NoElectionHandoffCandidateWithOneUnelectableNode) {
TEST_F(TopoCoordTest, NoElectionHandoffCandidateWithOneLaggedAndOneUnelectableNode) {
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host0:27017")
<< BSON("_id" << 1 << "host"
<< "host1:27017")
<< BSON("_id" << 2 << "host"
<< "host2:27017"
- << "priority"
- << 0))),
+ << "priority" << 0))),
0);
const auto term = getTopoCoord().getTerm();
@@ -4922,9 +4470,7 @@ TEST_F(TopoCoordTest, NoElectionHandoffCandidateWithOneLaggedAndOneUnelectableNo
TEST_F(TopoCoordTest, ExactlyOneNodeEligibleForElectionHandoffOutOfOneSecondary) {
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host0:27017")
<< BSON("_id" << 1 << "host"
@@ -4945,15 +4491,12 @@ TEST_F(TopoCoordTest, ExactlyOneNodeEligibleForElectionHandoffOutOfOneSecondary)
TEST_F(TopoCoordTest, ExactlyOneNodeEligibleForElectionHandoffOutOfThreeSecondaries) {
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host0:27017")
<< BSON("_id" << 1 << "host"
<< "host1:27017"
- << "priority"
- << 0)
+ << "priority" << 0)
<< BSON("_id" << 2 << "host"
<< "host2:27017")
<< BSON("_id" << 3 << "host"
@@ -4982,17 +4525,14 @@ TEST_F(TopoCoordTest, ExactlyOneNodeEligibleForElectionHandoffOutOfThreeSecondar
TEST_F(TopoCoordTest, TwoNodesEligibleForElectionHandoffResolveByPriority) {
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host0:27017")
<< BSON("_id" << 1 << "host"
<< "host1:27017")
<< BSON("_id" << 2 << "host"
<< "host2:27017"
- << "priority"
- << 5))),
+ << "priority" << 5))),
0);
const auto term = getTopoCoord().getTerm();
@@ -5014,9 +4554,7 @@ TEST_F(TopoCoordTest, TwoNodesEligibleForElectionHandoffResolveByPriority) {
TEST_F(TopoCoordTest, TwoNodesEligibleForElectionHandoffEqualPriorityResolveByMemberId) {
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host0:27017")
<< BSON("_id" << 1 << "host"
@@ -5045,23 +4583,17 @@ TEST_F(TopoCoordTest, ArbiterNotIncludedInW3WriteInPSSAReplSet) {
// In a PSSA set, a w:3 write should only be acknowledged if both secondaries can satisfy it.
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host0:27017")
<< BSON("_id" << 1 << "host"
<< "host1:27017")
<< BSON("_id" << 2 << "host"
<< "host2:27017"
- << "priority"
- << 0
- << "votes"
- << 0)
+ << "priority" << 0 << "votes" << 0)
<< BSON("_id" << 3 << "host"
<< "host3:27017"
- << "arbiterOnly"
- << true))),
+ << "arbiterOnly" << true))),
0);
const auto term = getTopoCoord().getTerm();
@@ -5090,31 +4622,21 @@ TEST_F(TopoCoordTest, ArbitersNotIncludedInW2WriteInPSSAAReplSet) {
// can satisfy it.
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "members"
+ << "version" << 2 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host0:27017")
<< BSON("_id" << 1 << "host"
<< "host1:27017"
- << "priority"
- << 0
- << "votes"
- << 0)
+ << "priority" << 0 << "votes" << 0)
<< BSON("_id" << 2 << "host"
<< "host2:27017"
- << "priority"
- << 0
- << "votes"
- << 0)
+ << "priority" << 0 << "votes" << 0)
<< BSON("_id" << 3 << "host"
<< "host3:27017"
- << "arbiterOnly"
- << true)
+ << "arbiterOnly" << true)
<< BSON("_id" << 4 << "host"
<< "host4:27017"
- << "arbiterOnly"
- << true))),
+ << "arbiterOnly" << true))),
0);
const auto term = getTopoCoord().getTerm();
@@ -5139,59 +4661,52 @@ TEST_F(TopoCoordTest, ArbitersNotIncludedInW2WriteInPSSAAReplSet) {
TEST_F(TopoCoordTest, CheckIfCommitQuorumCanBeSatisfied) {
ReplSetConfig configA;
- ASSERT_OK(configA.initialize(BSON("_id"
- << "rs0"
- << "version"
- << 1
- << "protocolVersion"
- << 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 << "protocolVersion" << 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))))));
getTopoCoord().updateConfig(configA, -1, Date_t());
std::vector<MemberConfig> memberConfig;
@@ -5362,18 +4877,14 @@ TEST_F(HeartbeatResponseTestV1,
ScheduleACatchupTakeoverWhenElectableAndReceiveHeartbeatFromPrimaryInCatchup) {
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" << 6 << "host"
<< "host7:27017"))
- << "protocolVersion"
- << 1
- << "settings"
+ << "protocolVersion" << 1 << "settings"
<< BSON("heartbeatTimeoutSecs" << 5)),
0);
@@ -5396,22 +4907,16 @@ TEST_F(HeartbeatResponseTestV1,
ScheduleACatchupTakeoverWhenBothCatchupAndPriorityTakeoverPossible) {
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 5
- << "members"
+ << "version" << 5 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host0:27017"
- << "priority"
- << 2)
+ << "priority" << 2)
<< BSON("_id" << 1 << "host"
<< "host2:27017")
<< BSON("_id" << 6 << "host"
<< "host7:27017"
- << "priority"
- << 3))
- << "protocolVersion"
- << 1
- << "settings"
+ << "priority" << 3))
+ << "protocolVersion" << 1 << "settings"
<< BSON("heartbeatTimeoutSecs" << 5)),
0);
@@ -5434,43 +4939,26 @@ 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)),
+ << "protocolVersion" << 1 << "settings" << BSON("heartbeatTimeoutSecs" << 5)),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -5539,19 +5027,15 @@ 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),
+ << "protocolVersion" << 1),
0);
OpTime election = OpTime(Timestamp(400, 0), 0);
@@ -5652,19 +5136,15 @@ 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),
+ << "protocolVersion" << 1),
0);
OpTime election = OpTime(Timestamp(400, 0), 0);
@@ -5739,21 +5219,15 @@ TEST_F(HeartbeatResponseTestV1,
// multiprimary states in PV1.
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 6
- << "members"
+ << "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)),
+ << "priority" << 3))
+ << "protocolVersion" << 1 << "settings" << BSON("heartbeatTimeoutSecs" << 5)),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -5778,21 +5252,15 @@ TEST_F(HeartbeatResponseTestV1,
// multiprimary states in PV1.
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 6
- << "members"
+ << "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)),
+ << "priority" << 3))
+ << "protocolVersion" << 1 << "settings" << BSON("heartbeatTimeoutSecs" << 5)),
0);
OpTime election = OpTime(Timestamp(1000, 0), 0);
OpTime staleTime = OpTime();
@@ -5814,21 +5282,15 @@ TEST_F(HeartbeatResponseTestV1,
// multiprimary states in PV1.
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 6
- << "members"
+ << "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)),
+ << "priority" << 3))
+ << "protocolVersion" << 1 << "settings" << BSON("heartbeatTimeoutSecs" << 5)),
0);
OpTime election = OpTime(Timestamp(1000, 0), 0);
@@ -5851,21 +5313,15 @@ TEST_F(HeartbeatResponseTestV1,
// in all multiprimary states in PV1.
updateConfig(BSON("_id"
<< "rs0"
- << "version"
- << 6
- << "members"
+ << "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)),
+ << "priority" << 3))
+ << "protocolVersion" << 1 << "settings" << BSON("heartbeatTimeoutSecs" << 5)),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -6022,21 +5478,15 @@ 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);
topoCoordSetMyLastAppliedOpTime(lastOpTimeApplied, Date_t(), false);
HeartbeatResponseAction nextAction = receiveUpHeartbeat(
@@ -6350,18 +5800,14 @@ TEST_F(HeartbeatResponseHighVerbosityTestV1, UpdateHeartbeatDataSameConfig) {
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)))
.transitional_ignore();
diff --git a/src/mongo/db/repl/vote_requester_test.cpp b/src/mongo/db/repl/vote_requester_test.cpp
index 4fc8382bf4a..dd8dedb0ccb 100644
--- a/src/mongo/db/repl/vote_requester_test.cpp
+++ b/src/mongo/db/repl/vote_requester_test.cpp
@@ -59,31 +59,23 @@ class VoteRequesterTest : public mongo::unittest::Test {
public:
virtual void setUp() {
ReplSetConfig config;
- ASSERT_OK(config.initialize(BSON("_id"
- << "rs0"
- << "version"
- << 2
- << "protocolVersion"
- << 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" << 2 << "protocolVersion" << 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());
long long candidateId = 0;
long long term = 2;
@@ -216,31 +208,23 @@ class VoteRequesterDryRunTest : public VoteRequesterTest {
public:
virtual void setUp() {
ReplSetConfig config;
- ASSERT_OK(config.initialize(BSON("_id"
- << "rs0"
- << "version"
- << 2
- << "protocolVersion"
- << 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" << 2 << "protocolVersion" << 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());
long long candidateId = 0;
long long term = 2;
@@ -261,11 +245,7 @@ public:
ReplSetConfig config;
ASSERT_OK(config.initialize(BSON("_id"
<< "rs0"
- << "version"
- << 2
- << "protocolVersion"
- << 1
- << "members"
+ << "version" << 2 << "protocolVersion" << 1 << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "host0")
<< BSON("_id" << 1 << "host"