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_oplog_fetcher_test.cpp9
-rw-r--r--src/mongo/db/repl/abstract_oplog_fetcher_test_fixture.cpp3
-rw-r--r--src/mongo/db/repl/base_cloner_test_fixture.cpp2
-rw-r--r--src/mongo/db/repl/check_quorum_for_config_change.cpp2
-rw-r--r--src/mongo/db/repl/check_quorum_for_config_change_test.cpp25
-rw-r--r--src/mongo/db/repl/databases_cloner_test.cpp11
-rw-r--r--src/mongo/db/repl/initial_syncer_test.cpp8
-rw-r--r--src/mongo/db/repl/oplog_fetcher_test.cpp175
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp2
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_heartbeat_v1_test.cpp5
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_test.cpp21
-rw-r--r--src/mongo/db/repl/replication_coordinator_test_fixture.cpp11
-rw-r--r--src/mongo/db/repl/replication_coordinator_test_fixture.h7
-rw-r--r--src/mongo/db/repl/reporter_test.cpp2
-rw-r--r--src/mongo/db/repl/scatter_gather_test.cpp56
-rw-r--r--src/mongo/db/repl/vote_requester_test.cpp14
16 files changed, 168 insertions, 185 deletions
diff --git a/src/mongo/db/repl/abstract_oplog_fetcher_test.cpp b/src/mongo/db/repl/abstract_oplog_fetcher_test.cpp
index 388e1492461..13446ed9ff5 100644
--- a/src/mongo/db/repl/abstract_oplog_fetcher_test.cpp
+++ b/src/mongo/db/repl/abstract_oplog_fetcher_test.cpp
@@ -451,8 +451,7 @@ TEST_F(AbstractOplogFetcherTest, OplogFetcherTimesOutCorrectlyOnInitialFindReque
net->enterNetwork();
auto when = net->now() + initialFindMaxTime + kNetworkTimeoutBufferMS + Milliseconds(10);
auto noi = getNet()->getNextReadyRequest();
- RemoteCommandResponse response = {
- {makeCursorResponse(1, {ops[0], ops[1]})}, rpc::makeEmptyMetadata(), Milliseconds(0)};
+ RemoteCommandResponse response = {{makeCursorResponse(1, {ops[0], ops[1]})}, Milliseconds(0)};
auto request = net->scheduleSuccessfulResponse(noi, when, response);
net->runUntil(when);
net->runReadyNetworkOperations();
@@ -492,8 +491,7 @@ TEST_F(AbstractOplogFetcherTest, OplogFetcherTimesOutCorrectlyOnRetriedFindReque
net->enterNetwork();
auto when = net->now() + initialFindMaxTime + kNetworkTimeoutBufferMS + Milliseconds(10);
auto noi = getNet()->getNextReadyRequest();
- RemoteCommandResponse response = {
- {makeCursorResponse(1, {ops[0], ops[1]})}, rpc::makeEmptyMetadata(), Milliseconds(0)};
+ RemoteCommandResponse response = {{makeCursorResponse(1, {ops[0], ops[1]})}, Milliseconds(0)};
auto request = net->scheduleSuccessfulResponse(noi, when, response);
net->runUntil(when);
net->runReadyNetworkOperations();
@@ -503,8 +501,7 @@ TEST_F(AbstractOplogFetcherTest, OplogFetcherTimesOutCorrectlyOnRetriedFindReque
net->enterNetwork();
when = net->now() + retriedFindMaxTime + kNetworkTimeoutBufferMS + Milliseconds(10);
noi = getNet()->getNextReadyRequest();
- response = {
- {makeCursorResponse(1, {ops[0], ops[1]})}, rpc::makeEmptyMetadata(), Milliseconds(0)};
+ response = {{makeCursorResponse(1, {ops[0], ops[1]})}, Milliseconds(0)};
request = net->scheduleSuccessfulResponse(noi, when, response);
net->runUntil(when);
net->runReadyNetworkOperations();
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 2b0696c8531..ed0e0f9105a 100644
--- a/src/mongo/db/repl/abstract_oplog_fetcher_test_fixture.cpp
+++ b/src/mongo/db/repl/abstract_oplog_fetcher_test_fixture.cpp
@@ -139,8 +139,7 @@ executor::RemoteCommandRequest AbstractOplogFetcherTest::processNetworkResponse(
executor::RemoteCommandRequest AbstractOplogFetcherTest::processNetworkResponse(
BSONObj obj, bool expectReadyRequestsAfterProcessing) {
- return processNetworkResponse({obj, rpc::makeEmptyMetadata(), Milliseconds(0)},
- expectReadyRequestsAfterProcessing);
+ return processNetworkResponse({obj, Milliseconds(0)}, expectReadyRequestsAfterProcessing);
}
} // namespace repl
diff --git a/src/mongo/db/repl/base_cloner_test_fixture.cpp b/src/mongo/db/repl/base_cloner_test_fixture.cpp
index 8fb69472329..88d0a84d996 100644
--- a/src/mongo/db/repl/base_cloner_test_fixture.cpp
+++ b/src/mongo/db/repl/base_cloner_test_fixture.cpp
@@ -162,7 +162,7 @@ const Status& BaseClonerTest::getStatus() const {
void BaseClonerTest::scheduleNetworkResponse(NetworkOperationIterator noi, const BSONObj& obj) {
auto net = getNet();
Milliseconds millis(0);
- RemoteCommandResponse response(obj, BSONObj(), millis);
+ RemoteCommandResponse response(obj, millis);
log() << "Scheduling response to request:" << noi->getDiagnosticString() << " -- resp:" << obj;
net->scheduleResponse(noi, net->now(), response);
}
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 67204eed65c..f5c967163d0 100644
--- a/src/mongo/db/repl/check_quorum_for_config_change.cpp
+++ b/src/mongo/db/repl/check_quorum_for_config_change.cpp
@@ -226,7 +226,7 @@ void QuorumChecker::_tabulateHeartbeatResponse(const RemoteCommandRequest& reque
if (_rsConfig->hasReplicaSetId()) {
StatusWith<rpc::ReplSetMetadata> replMetadata =
- rpc::ReplSetMetadata::readFromMetadata(response.metadata);
+ rpc::ReplSetMetadata::readFromMetadata(response.data);
if (replMetadata.isOK() && replMetadata.getValue().getReplicaSetId().isSet() &&
_rsConfig->getReplicaSetId() != replMetadata.getValue().getReplicaSetId()) {
std::string message = str::stream()
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 2d4c0416b3e..7829fd72ec5 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
@@ -233,7 +233,7 @@ const BSONObj makeHeartbeatRequest(const ReplSetConfig& rsConfig, int myConfigIn
executor::RemoteCommandResponse makeHeartbeatResponse(const ReplSetConfig& rsConfig,
const stdx::chrono::milliseconds millis,
const long long configVersion = 0,
- const BSONObj& metadata = {}) {
+ const BSONObj& extraFields = {}) {
ReplSetHeartbeatResponse hbResp;
hbResp.setSetName(rsConfig.getReplSetName());
hbResp.setConfigVersion(configVersion);
@@ -241,7 +241,9 @@ executor::RemoteCommandResponse makeHeartbeatResponse(const ReplSetConfig& rsCon
OpTime opTime(Timestamp(), 0);
hbResp.setAppliedOpTime(opTime);
hbResp.setDurableOpTime(opTime);
- return RemoteCommandResponse(hbResp.toBSON(), metadata, duration_cast<Milliseconds>(millis));
+ auto bob = BSONObjBuilder(hbResp.toBSON());
+ bob.appendElements(extraFields);
+ return RemoteCommandResponse(bob.obj(), duration_cast<Milliseconds>(millis));
}
TEST_F(CheckQuorumForInitiate, QuorumCheckSuccessForFiveNodes) {
@@ -399,13 +401,10 @@ TEST_F(CheckQuorumForInitiate, QuorumCheckFailedDueToSetNameMismatch) {
(RemoteCommandResponse(
BSON("ok" << 0 << "code" << ErrorCodes::InconsistentReplicaSetNames << "errmsg"
<< "replica set name doesn't match."),
- BSONObj(),
Milliseconds(8))));
} else {
getNet()->scheduleResponse(
- noi,
- startDate + 10ms,
- (RemoteCommandResponse(BSON("ok" << 1), BSONObj(), Milliseconds(8))));
+ noi, startDate + 10ms, RemoteCommandResponse(BSON("ok" << 1), Milliseconds(8)));
}
}
getNet()->runUntil(startDate + 10ms);
@@ -473,14 +472,14 @@ TEST_F(CheckQuorumForInitiate, QuorumCheckFailedDueToSetIdMismatch) {
unexpectedId,
rpc::ReplSetMetadata::kNoPrimary,
-1);
- BSONObjBuilder metadataBuilder;
- metadata.writeToMetadata(&metadataBuilder).transitional_ignore();
+ BSONObjBuilder bob;
+ uassertStatusOK(metadata.writeToMetadata(&bob));
long long configVersion = 0;
getNet()->scheduleResponse(
noi,
startDate + 10ms,
- makeHeartbeatResponse(rsConfig, 8ms, configVersion, metadataBuilder.obj()));
+ makeHeartbeatResponse(rsConfig, 8ms, configVersion, bob.obj()));
} else {
getNet()->scheduleResponse(noi, startDate + 10ms, makeHeartbeatResponse(rsConfig, 8ms));
}
@@ -713,7 +712,6 @@ TEST_F(CheckQuorumForReconfig, QuorumCheckVetoedDueToIncompatibleSetName) {
(RemoteCommandResponse(
BSON("ok" << 0 << "code" << ErrorCodes::InconsistentReplicaSetNames << "errmsg"
<< "replica set name doesn't match."),
- BSONObj(),
Milliseconds(8))));
} else {
getNet()->scheduleResponse(
@@ -949,10 +947,9 @@ TEST_F(CheckQuorumForReconfig, QuorumCheckProcessesCallbackCanceledResponse) {
startDate + 10ms,
(RemoteCommandResponse(ErrorCodes::CallbackCanceled, "Testing canceled callback")));
} else {
- getNet()->scheduleResponse(
- noi,
- startDate + 10ms,
- (RemoteCommandResponse(BSON("ok" << 0), BSONObj(), Milliseconds(8))));
+ getNet()->scheduleResponse(noi,
+ startDate + Milliseconds(10),
+ RemoteCommandResponse(BSON("ok" << 0), Milliseconds(8)));
}
}
getNet()->runUntil(startDate + 10ms);
diff --git a/src/mongo/db/repl/databases_cloner_test.cpp b/src/mongo/db/repl/databases_cloner_test.cpp
index f32c83c756a..66f2138ceaa 100644
--- a/src/mongo/db/repl/databases_cloner_test.cpp
+++ b/src/mongo/db/repl/databases_cloner_test.cpp
@@ -104,7 +104,7 @@ public:
const BSONObj& obj) {
NetworkInterfaceMock* net = getNet();
Milliseconds millis(0);
- RemoteCommandResponse response(obj, BSONObj(), millis);
+ RemoteCommandResponse response(obj, millis);
net->scheduleResponse(noi, net->now(), response);
}
@@ -242,11 +242,10 @@ protected:
log() << "Sending response for network request:";
log() << " req: " << noi->getRequest().dbname << "." << noi->getRequest().cmdObj;
log() << " resp:" << responses[processedRequests].second;
- net->scheduleResponse(noi,
- net->now(),
- RemoteCommandResponse(responses[processedRequests].second,
- BSONObj(),
- Milliseconds(10)));
+ net->scheduleResponse(
+ noi,
+ net->now(),
+ RemoteCommandResponse(responses[processedRequests].second, Milliseconds(10)));
if ((Date_t::now() - lastLog) > Seconds(1)) {
lastLog = Date_t();
diff --git a/src/mongo/db/repl/initial_syncer_test.cpp b/src/mongo/db/repl/initial_syncer_test.cpp
index 2948a08ff01..fe3483cb792 100644
--- a/src/mongo/db/repl/initial_syncer_test.cpp
+++ b/src/mongo/db/repl/initial_syncer_test.cpp
@@ -162,7 +162,7 @@ public:
const BSONObj& obj) {
NetworkInterfaceMock* net = getNet();
Milliseconds millis(0);
- RemoteCommandResponse response(obj, BSONObj(), millis);
+ RemoteCommandResponse response(obj, millis);
log() << "Sending response for network request:";
log() << " req: " << noi->getRequest().dbname << "." << noi->getRequest().cmdObj;
log() << " resp:" << response;
@@ -501,9 +501,6 @@ RemoteCommandResponse makeCursorResponse(CursorId cursorId,
int rbid = 1) {
OpTime futureOpTime(Timestamp(1000, 1000), 1000);
rpc::OplogQueryMetadata oqMetadata(futureOpTime, futureOpTime, rbid, 0, 0);
- BSONObjBuilder metadataBob;
- ASSERT_OK(oqMetadata.writeToMetadata(&metadataBob));
- auto metadataObj = metadataBob.obj();
BSONObjBuilder bob;
{
@@ -518,8 +515,9 @@ RemoteCommandResponse makeCursorResponse(CursorId cursorId,
}
}
}
+ ASSERT_OK(oqMetadata.writeToMetadata(&bob));
bob.append("ok", 1);
- return {bob.obj(), metadataObj, Milliseconds(0)};
+ return {bob.obj(), Milliseconds()};
}
/**
diff --git a/src/mongo/db/repl/oplog_fetcher_test.cpp b/src/mongo/db/repl/oplog_fetcher_test.cpp
index 5209ea0c4e3..8f03c6c50cb 100644
--- a/src/mongo/db/repl/oplog_fetcher_test.cpp
+++ b/src/mongo/db/repl/oplog_fetcher_test.cpp
@@ -192,8 +192,7 @@ std::unique_ptr<ShutdownState> OplogFetcherTest::processSingleBatch(RemoteComman
std::unique_ptr<ShutdownState> OplogFetcherTest::processSingleBatch(BSONObj obj,
bool requireFresherSyncSource) {
- return processSingleBatch({obj, rpc::makeEmptyMetadata(), Milliseconds(0)},
- requireFresherSyncSource);
+ return processSingleBatch({obj, Milliseconds(0)}, requireFresherSyncSource);
}
void _checkDefaultCommandObjectFields(BSONObj cmdObj) {
@@ -219,6 +218,12 @@ std::unique_ptr<OplogFetcher> OplogFetcherTest::makeOplogFetcher(ReplSetConfig c
defaultBatchSize);
}
+BSONObj concatenate(BSONObj a, const BSONObj& b) {
+ auto bob = BSONObjBuilder(std::move(a));
+ bob.appendElements(b);
+ return bob.obj();
+}
+
TEST_F(
OplogFetcherTest,
FindQueryContainsTermAndStartTimestampIfGetCurrentTermAndLastCommittedOpTimeReturnsValidTerm) {
@@ -255,19 +260,21 @@ TEST_F(OplogFetcherTest, AwaitDataTimeoutShouldEqualHalfElectionTimeoutUnderProt
}
TEST_F(OplogFetcherTest, InvalidReplSetMetadataInResponseStopsTheOplogFetcher) {
- auto shutdownState = processSingleBatch(
- {makeCursorResponse(0, {makeNoopOplogEntry(lastFetched)}),
- BSON(rpc::kReplSetMetadataFieldName << BSON("invalid_repl_metadata_field" << 1)),
- Milliseconds(0)});
+ auto shutdownState =
+ processSingleBatch({concatenate(makeCursorResponse(0, {makeNoopOplogEntry(lastFetched)}),
+ BSON(rpc::kReplSetMetadataFieldName
+ << BSON("invalid_repl_metadata_field" << 1))),
+ Milliseconds(0)});
ASSERT_EQUALS(ErrorCodes::NoSuchKey, shutdownState->getStatus());
}
TEST_F(OplogFetcherTest, InvalidOplogQueryMetadataInResponseStopsTheOplogFetcher) {
- auto shutdownState = processSingleBatch(
- {makeCursorResponse(0, {makeNoopOplogEntry(lastFetched)}),
- BSON(rpc::kOplogQueryMetadataFieldName << BSON("invalid_oq_metadata_field" << 1)),
- Milliseconds(0)});
+ auto shutdownState =
+ processSingleBatch({concatenate(makeCursorResponse(0, {makeNoopOplogEntry(lastFetched)}),
+ BSON(rpc::kOplogQueryMetadataFieldName
+ << BSON("invalid_oq_metadata_field" << 1))),
+ Milliseconds(0)});
ASSERT_EQUALS(ErrorCodes::NoSuchKey, shutdownState->getStatus());
}
@@ -279,10 +286,11 @@ TEST_F(OplogFetcherTest,
ASSERT_OK(metadata.writeToMetadata(&bob));
auto metadataObj = bob.obj();
- ASSERT_OK(processSingleBatch({makeCursorResponse(0, {makeNoopOplogEntry(lastFetched)}),
- metadataObj,
- Milliseconds(0)})
- ->getStatus());
+ ASSERT_OK(
+ processSingleBatch(
+ {concatenate(makeCursorResponse(0, {makeNoopOplogEntry(lastFetched)}), metadataObj),
+ Milliseconds(0)})
+ ->getStatus());
ASSERT_TRUE(dataReplicatorExternalState->metadataWasProcessed);
ASSERT_EQUALS(metadata.getPrimaryIndex(),
dataReplicatorExternalState->replMetadataProcessed.getPrimaryIndex());
@@ -296,10 +304,11 @@ TEST_F(OplogFetcherTest, ValidMetadataWithInResponseShouldBeForwardedToProcessMe
ASSERT_OK(replMetadata.writeToMetadata(&bob));
ASSERT_OK(oqMetadata.writeToMetadata(&bob));
auto metadataObj = bob.obj();
- ASSERT_OK(processSingleBatch({makeCursorResponse(0, {makeNoopOplogEntry(lastFetched)}),
- metadataObj,
- Milliseconds(0)})
- ->getStatus());
+ ASSERT_OK(
+ processSingleBatch(
+ {concatenate(makeCursorResponse(0, {makeNoopOplogEntry(lastFetched)}), metadataObj),
+ Milliseconds(0)})
+ ->getStatus());
ASSERT_TRUE(dataReplicatorExternalState->metadataWasProcessed);
ASSERT_EQUALS(replMetadata.getPrimaryIndex(),
dataReplicatorExternalState->replMetadataProcessed.getPrimaryIndex());
@@ -315,11 +324,12 @@ TEST_F(OplogFetcherTest, MetadataAndBatchAreNotProcessedWhenSyncSourceRollsBack)
ASSERT_OK(oqMetadata.writeToMetadata(&bob));
auto metadataObj = bob.obj();
- ASSERT_EQUALS(ErrorCodes::InvalidSyncSource,
- processSingleBatch({makeCursorResponse(0, {makeNoopOplogEntry(lastFetched)}),
- metadataObj,
- Milliseconds(0)})
- ->getStatus());
+ ASSERT_EQUALS(
+ ErrorCodes::InvalidSyncSource,
+ processSingleBatch(
+ {concatenate(makeCursorResponse(0, {makeNoopOplogEntry(lastFetched)}), metadataObj),
+ Milliseconds(0)})
+ ->getStatus());
ASSERT_FALSE(dataReplicatorExternalState->metadataWasProcessed);
ASSERT(lastEnqueuedDocuments.empty());
}
@@ -332,11 +342,12 @@ TEST_F(OplogFetcherTest, MetadataAndBatchAreNotProcessedWhenSyncSourceIsBehind)
ASSERT_OK(oqMetadata.writeToMetadata(&bob));
auto metadataObj = bob.obj();
- ASSERT_EQUALS(ErrorCodes::InvalidSyncSource,
- processSingleBatch({makeCursorResponse(0, {makeNoopOplogEntry(lastFetched)}),
- metadataObj,
- Milliseconds(0)})
- ->getStatus());
+ ASSERT_EQUALS(
+ ErrorCodes::InvalidSyncSource,
+ processSingleBatch(
+ {concatenate(makeCursorResponse(0, {makeNoopOplogEntry(lastFetched)}), metadataObj),
+ Milliseconds(0)})
+ ->getStatus());
ASSERT_FALSE(dataReplicatorExternalState->metadataWasProcessed);
ASSERT(lastEnqueuedDocuments.empty());
}
@@ -349,11 +360,12 @@ TEST_F(OplogFetcherTest, MetadataAndBatchAreNotProcessedWhenSyncSourceIsNotAhead
ASSERT_OK(oqMetadata.writeToMetadata(&bob));
auto metadataObj = bob.obj();
- ASSERT_EQUALS(ErrorCodes::InvalidSyncSource,
- processSingleBatch({makeCursorResponse(0, {makeNoopOplogEntry(lastFetched)}),
- metadataObj,
- Milliseconds(0)})
- ->getStatus());
+ ASSERT_EQUALS(
+ ErrorCodes::InvalidSyncSource,
+ processSingleBatch(
+ {concatenate(makeCursorResponse(0, {makeNoopOplogEntry(lastFetched)}), metadataObj),
+ Milliseconds(0)})
+ ->getStatus());
ASSERT_FALSE(dataReplicatorExternalState->metadataWasProcessed);
ASSERT(lastEnqueuedDocuments.empty());
}
@@ -370,7 +382,8 @@ TEST_F(OplogFetcherTest,
auto entry = makeNoopOplogEntry({123LL, staleOpTime});
ASSERT_EQUALS(
ErrorCodes::InvalidSyncSource,
- processSingleBatch({makeCursorResponse(0, {entry}), metadataObj, Milliseconds(0)}, false)
+ processSingleBatch(
+ {concatenate(makeCursorResponse(0, {entry}), metadataObj), Milliseconds(0)}, false)
->getStatus());
ASSERT_FALSE(dataReplicatorExternalState->metadataWasProcessed);
ASSERT(lastEnqueuedDocuments.empty());
@@ -388,8 +401,8 @@ TEST_F(OplogFetcherTest, MetadataAndBatchAreProcessedWhenSyncSourceIsCurrentButM
auto metadataObj = bob.obj();
auto entry = makeNoopOplogEntry(lastFetched);
- auto shutdownState =
- processSingleBatch({makeCursorResponse(0, {entry}), metadataObj, Milliseconds(0)}, false);
+ auto shutdownState = processSingleBatch(
+ {concatenate(makeCursorResponse(0, {entry}), metadataObj), Milliseconds(0)}, false);
ASSERT_OK(shutdownState->getStatus());
ASSERT(dataReplicatorExternalState->metadataWasProcessed);
}
@@ -404,8 +417,8 @@ TEST_F(OplogFetcherTest,
auto metadataObj = bob.obj();
auto entry = makeNoopOplogEntry(lastFetched);
- auto shutdownState =
- processSingleBatch({makeCursorResponse(0, {entry}), metadataObj, Milliseconds(0)}, false);
+ auto shutdownState = processSingleBatch(
+ {concatenate(makeCursorResponse(0, {entry}), metadataObj), Milliseconds(0)}, false);
ASSERT_OK(shutdownState->getStatus());
ASSERT(dataReplicatorExternalState->metadataWasProcessed);
}
@@ -418,8 +431,9 @@ TEST_F(OplogFetcherTest,
auto metadataObj = bob.obj();
ASSERT_EQUALS(ErrorCodes::OplogStartMissing,
processSingleBatch(
- {makeCursorResponse(0, {makeNoopOplogEntry(Seconds(456), lastFetched.value)}),
- metadataObj,
+ {concatenate(makeCursorResponse(
+ 0, {makeNoopOplogEntry(Seconds(456), lastFetched.value)}),
+ metadataObj),
Milliseconds(0)})
->getStatus());
ASSERT_FALSE(dataReplicatorExternalState->metadataWasProcessed);
@@ -434,17 +448,17 @@ TEST_F(OplogFetcherTest, MetadataIsNotProcessedOnBatchThatTriggersRollback) {
auto metadataObj = bob.obj();
ASSERT_EQUALS(ErrorCodes::OplogStartMissing,
processSingleBatch(
- {makeCursorResponse(0, {makeNoopOplogEntry(Seconds(456), lastFetched.value)}),
- metadataObj,
+ {concatenate(makeCursorResponse(
+ 0, {makeNoopOplogEntry(Seconds(456), lastFetched.value)}),
+ metadataObj),
Milliseconds(0)})
->getStatus());
ASSERT_FALSE(dataReplicatorExternalState->metadataWasProcessed);
}
TEST_F(OplogFetcherTest, EmptyMetadataIsNotProcessed) {
- ASSERT_OK(processSingleBatch({makeCursorResponse(0, {makeNoopOplogEntry(lastFetched)}),
- rpc::makeEmptyMetadata(),
- Milliseconds(0)})
+ ASSERT_OK(processSingleBatch(
+ {makeCursorResponse(0, {makeNoopOplogEntry(lastFetched)}), Milliseconds(0)})
->getStatus());
ASSERT_FALSE(dataReplicatorExternalState->metadataWasProcessed);
}
@@ -456,10 +470,10 @@ TEST_F(OplogFetcherTest, EmptyFirstBatchStopsOplogFetcherWithOplogStartMissingEr
TEST_F(OplogFetcherTest, MissingOpTimeInFirstDocumentCausesOplogFetcherToStopWithInvalidBSONError) {
auto metadataObj = makeOplogQueryMetadataObject(remoteNewerOpTime, rbid, 2, 2);
- ASSERT_EQUALS(
- ErrorCodes::InvalidBSON,
- processSingleBatch({makeCursorResponse(0, {BSONObj()}), metadataObj, Milliseconds(0)})
- ->getStatus());
+ ASSERT_EQUALS(ErrorCodes::InvalidBSON,
+ processSingleBatch({concatenate(makeCursorResponse(0, {BSONObj()}), metadataObj),
+ Milliseconds(0)})
+ ->getStatus());
}
TEST_F(
@@ -468,8 +482,9 @@ TEST_F(
auto metadataObj = makeOplogQueryMetadataObject(remoteNewerOpTime, rbid, 2, 2);
ASSERT_EQUALS(ErrorCodes::OplogStartMissing,
processSingleBatch(
- {makeCursorResponse(0, {makeNoopOplogEntry(Seconds(456), lastFetched.value)}),
- metadataObj,
+ {concatenate(makeCursorResponse(
+ 0, {makeNoopOplogEntry(Seconds(456), lastFetched.value)}),
+ metadataObj),
Milliseconds(0)})
->getStatus());
}
@@ -480,8 +495,9 @@ TEST_F(OplogFetcherTest,
ASSERT_EQUALS(
ErrorCodes::OplogStartMissing,
processSingleBatch(
- {makeCursorResponse(0, {makeNoopOplogEntry(remoteNewerOpTime, lastFetched.value + 1)}),
- metadataObj,
+ {concatenate(makeCursorResponse(
+ 0, {makeNoopOplogEntry(remoteNewerOpTime, lastFetched.value + 1)}),
+ metadataObj),
Milliseconds(0)})
->getStatus());
}
@@ -489,28 +505,30 @@ TEST_F(OplogFetcherTest,
TEST_F(OplogFetcherTest,
MissingOpTimeInSecondDocumentOfFirstBatchCausesOplogFetcherToStopWithNoSuchKey) {
auto metadataObj = makeOplogQueryMetadataObject(remoteNewerOpTime, rbid, 2, 2);
- ASSERT_EQUALS(ErrorCodes::NoSuchKey,
- processSingleBatch(
- {makeCursorResponse(0,
- {makeNoopOplogEntry(lastFetched),
- BSON("o" << BSON("msg"
- << "oplog entry without optime"))}),
- metadataObj,
- Milliseconds(0)})
- ->getStatus());
+ ASSERT_EQUALS(
+ ErrorCodes::NoSuchKey,
+ processSingleBatch(
+ {concatenate(makeCursorResponse(0,
+ {makeNoopOplogEntry(lastFetched),
+ BSON("o" << BSON("msg"
+ << "oplog entry without optime"))}),
+ metadataObj),
+ Milliseconds(0)})
+ ->getStatus());
}
TEST_F(OplogFetcherTest, TimestampsNotAdvancingInBatchCausesOplogFetcherStopWithOplogOutOfOrder) {
auto metadataObj = makeOplogQueryMetadataObject(remoteNewerOpTime, rbid, 2, 2);
- ASSERT_EQUALS(ErrorCodes::OplogOutOfOrder,
- processSingleBatch({makeCursorResponse(0,
- {makeNoopOplogEntry(lastFetched),
- makeNoopOplogEntry(Seconds(1000), 1),
- makeNoopOplogEntry(Seconds(2000), 1),
- makeNoopOplogEntry(Seconds(1500), 1)}),
- metadataObj,
- Milliseconds(0)})
- ->getStatus());
+ ASSERT_EQUALS(
+ ErrorCodes::OplogOutOfOrder,
+ processSingleBatch({concatenate(makeCursorResponse(0,
+ {makeNoopOplogEntry(lastFetched),
+ makeNoopOplogEntry(Seconds(1000), 1),
+ makeNoopOplogEntry(Seconds(2000), 1),
+ makeNoopOplogEntry(Seconds(1500), 1)}),
+ metadataObj),
+ Milliseconds(0)})
+ ->getStatus());
}
TEST_F(OplogFetcherTest, OplogFetcherShouldExcludeFirstDocumentInFirstBatchWhenEnqueuingDocuments) {
@@ -521,8 +539,8 @@ TEST_F(OplogFetcherTest, OplogFetcherShouldExcludeFirstDocumentInFirstBatchWhenE
auto thirdEntry = makeNoopOplogEntry({{Seconds(789), 0}, lastFetched.opTime.getTerm()}, 300);
Fetcher::Documents documents{firstEntry, secondEntry, thirdEntry};
- auto shutdownState =
- processSingleBatch({makeCursorResponse(0, documents), metadataObj, Milliseconds(0)});
+ auto shutdownState = processSingleBatch(
+ {concatenate(makeCursorResponse(0, documents), metadataObj), Milliseconds(0)});
ASSERT_EQUALS(2U, lastEnqueuedDocuments.size());
ASSERT_BSONOBJ_EQ(secondEntry, lastEnqueuedDocuments[0]);
@@ -559,8 +577,8 @@ TEST_F(OplogFetcherTest, OplogFetcherShouldReportErrorsThrownFromCallback) {
return Status(ErrorCodes::InternalError, "my custom error");
};
- auto shutdownState =
- processSingleBatch({makeCursorResponse(0, documents), metadataObj, Milliseconds(0)});
+ auto shutdownState = processSingleBatch(
+ {concatenate(makeCursorResponse(0, documents), metadataObj), Milliseconds(0)});
ASSERT_EQ(shutdownState->getStatus(), Status(ErrorCodes::InternalError, "my custom error"));
}
@@ -582,8 +600,8 @@ void OplogFetcherTest::testSyncSourceChecking(rpc::ReplSetMetadata* replMetadata
dataReplicatorExternalState->shouldStopFetchingResult = true;
- auto shutdownState =
- processSingleBatch({makeCursorResponse(0, documents), metadataObj, Milliseconds(0)});
+ auto shutdownState = processSingleBatch(
+ {concatenate(makeCursorResponse(0, documents), metadataObj), Milliseconds(0)});
// Sync source checking happens after we have successfully pushed the operations into
// the buffer for the next replication phase (eg. applier).
@@ -697,7 +715,8 @@ RemoteCommandRequest OplogFetcherTest::testTwoBatchHandling() {
auto metadataObj = makeOplogQueryMetadataObject(remoteNewerOpTime, rbid, 2, 2);
processNetworkResponse(
- {makeCursorResponse(cursorId, {firstEntry, secondEntry}), metadataObj, Milliseconds(0)},
+ {concatenate(makeCursorResponse(cursorId, {firstEntry, secondEntry}), metadataObj),
+ Milliseconds(0)},
true);
ASSERT_EQUALS(1U, lastEnqueuedDocuments.size());
diff --git a/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp b/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp
index 479881621eb..2b06d004d0a 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp
@@ -149,7 +149,7 @@ void ReplicationCoordinatorImpl::_handleHeartbeatResponse(
resp = cbData.response.data;
responseStatus = hbResponse.initialize(resp, _topCoord->getTerm());
StatusWith<rpc::ReplSetMetadata> replMetadata =
- rpc::ReplSetMetadata::readFromMetadata(cbData.response.metadata);
+ rpc::ReplSetMetadata::readFromMetadata(cbData.response.data);
LOG_FOR_HEARTBEATS(2) << "Received response to heartbeat (requestId: " << cbData.request.id
<< ") from " << target << ", " << resp;
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 61a63ca9225..5bb5c2a2ee2 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
@@ -394,10 +394,9 @@ TEST_F(ReplCoordHBV1Test, IgnoreTheContentsOfMetadataWhenItsReplicaSetIdDoesNotM
rpc::ReplSetMetadata metadata(
opTime.getTerm(), opTime, opTime, rsConfig.getConfigVersion(), unexpectedId, 1, -1);
- BSONObjBuilder metadataBuilder;
- metadata.writeToMetadata(&metadataBuilder).transitional_ignore();
+ uassertStatusOK(metadata.writeToMetadata(&responseBuilder));
- heartbeatResponse = makeResponseStatus(responseBuilder.obj(), metadataBuilder.obj());
+ heartbeatResponse = makeResponseStatus(responseBuilder.obj());
}
// process heartbeat
diff --git a/src/mongo/db/repl/replication_coordinator_impl_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_test.cpp
index 9d64861a4ab..f703624e158 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_test.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_test.cpp
@@ -384,9 +384,8 @@ TEST_F(ReplCoordTest, InitiateSucceedsWhenQuorumCheckPasses) {
hbResp.setConfigVersion(0);
hbResp.setAppliedOpTime(OpTime(Timestamp(100, 1), 0));
hbResp.setDurableOpTime(OpTime(Timestamp(100, 1), 0));
- getNet()->scheduleResponse(noi,
- startDate + Milliseconds(10),
- RemoteCommandResponse(hbResp.toBSON(), BSONObj(), Milliseconds(8)));
+ getNet()->scheduleResponse(
+ noi, startDate + Milliseconds(10), RemoteCommandResponse(hbResp.toBSON(), Milliseconds(8)));
getNet()->runUntil(startDate + Milliseconds(10));
getNet()->exitNetwork();
ASSERT_EQUALS(startDate + Milliseconds(10), getNet()->now());
@@ -4521,9 +4520,8 @@ TEST_F(ReplCoordTest,
<< 3
<< "syncSourceIndex"
<< 1)));
- BSONObjBuilder metadataBuilder;
- ASSERT_OK(metadata.getValue().writeToMetadata(&metadataBuilder));
- auto metadataObj = metadataBuilder.obj();
+ BSONObjBuilder responseBuilder;
+ ASSERT_OK(metadata.getValue().writeToMetadata(&responseBuilder));
auto net = getNet();
net->enterNetwork();
@@ -4538,7 +4536,8 @@ TEST_F(ReplCoordTest,
hbResp.setConfigVersion(config.getConfigVersion());
hbResp.setSetName(config.getReplSetName());
hbResp.setState(MemberState::RS_SECONDARY);
- net->scheduleResponse(noi, net->now(), makeResponseStatus(hbResp.toBSON(), metadataObj));
+ responseBuilder.appendElements(hbResp.toBSON());
+ net->scheduleResponse(noi, net->now(), makeResponseStatus(responseBuilder.obj()));
net->runReadyNetworkOperations();
net->exitNetwork();
@@ -4647,9 +4646,8 @@ TEST_F(ReplCoordTest, TermAndLastCommittedOpTimeUpdatedFromHeartbeatWhenArbiter)
<< 3
<< "syncSourceIndex"
<< 1)));
- BSONObjBuilder metadataBuilder;
- ASSERT_OK(metadata.getValue().writeToMetadata(&metadataBuilder));
- auto metadataObj = metadataBuilder.obj();
+ BSONObjBuilder responseBuilder;
+ ASSERT_OK(metadata.getValue().writeToMetadata(&responseBuilder));
auto net = getNet();
net->enterNetwork();
@@ -4664,7 +4662,8 @@ TEST_F(ReplCoordTest, TermAndLastCommittedOpTimeUpdatedFromHeartbeatWhenArbiter)
hbResp.setConfigVersion(config.getConfigVersion());
hbResp.setSetName(config.getReplSetName());
hbResp.setState(MemberState::RS_SECONDARY);
- net->scheduleResponse(noi, net->now(), makeResponseStatus(hbResp.toBSON(), metadataObj));
+ responseBuilder.appendElements(hbResp.toBSON());
+ net->scheduleResponse(noi, net->now(), makeResponseStatus(responseBuilder.obj()));
net->runReadyNetworkOperations();
net->exitNetwork();
diff --git a/src/mongo/db/repl/replication_coordinator_test_fixture.cpp b/src/mongo/db/repl/replication_coordinator_test_fixture.cpp
index 456c9443276..10f1babe0f2 100644
--- a/src/mongo/db/repl/replication_coordinator_test_fixture.cpp
+++ b/src/mongo/db/repl/replication_coordinator_test_fixture.cpp
@@ -212,15 +212,8 @@ void ReplCoordTest::assertStartSuccess(const BSONObj& configDoc, const HostAndPo
executor::RemoteCommandResponse ReplCoordTest::makeResponseStatus(const BSONObj& doc,
Milliseconds millis) {
- return makeResponseStatus(doc, BSONObj(), millis);
-}
-
-executor::RemoteCommandResponse ReplCoordTest::makeResponseStatus(const BSONObj& doc,
- const BSONObj& metadata,
- Milliseconds millis) {
- log() << "Responding with " << doc << " (metadata: " << metadata << "; elapsed: " << millis
- << ")";
- return RemoteCommandResponse(doc, metadata, millis);
+ log() << "Responding with " << doc << " (elapsed: " << millis << ")";
+ return RemoteCommandResponse(doc, millis);
}
void ReplCoordTest::simulateEnoughHeartbeatsForAllNodesUp() {
diff --git a/src/mongo/db/repl/replication_coordinator_test_fixture.h b/src/mongo/db/repl/replication_coordinator_test_fixture.h
index b5718a65a70..2e3732a4caa 100644
--- a/src/mongo/db/repl/replication_coordinator_test_fixture.h
+++ b/src/mongo/db/repl/replication_coordinator_test_fixture.h
@@ -65,13 +65,6 @@ public:
const BSONObj& doc, Milliseconds millis = Milliseconds(0));
/**
- * Makes a command response with the given "doc" response, metadata and optional elapsed time
- * "millis".
- */
- static executor::RemoteCommandResponse makeResponseStatus(
- const BSONObj& doc, const BSONObj& metadata, Milliseconds millis = Milliseconds(0));
-
- /**
* Constructs a ReplSetConfig from the given BSON, or raises a test failure exception.
*/
static ReplSetConfig assertMakeRSConfig(const BSONObj& configBSON);
diff --git a/src/mongo/db/repl/reporter_test.cpp b/src/mongo/db/repl/reporter_test.cpp
index 5fb620d5252..8c6ac958c16 100644
--- a/src/mongo/db/repl/reporter_test.cpp
+++ b/src/mongo/db/repl/reporter_test.cpp
@@ -331,7 +331,7 @@ TEST_F(ReporterTestNoTriggerAtSetUp, IsNotActiveAfterUpdatePositionTimeoutExpire
// Schedule a response to the updatePosition command at a time that exceeds the timeout. Then
// make sure the reporter shut down due to a remote command timeout.
auto updatePosRequest = net->getNextReadyRequest();
- RemoteCommandResponse response(BSON("ok" << 1), BSONObj(), Milliseconds(0));
+ RemoteCommandResponse response(BSON("ok" << 1), Milliseconds(0));
executor::TaskExecutor::ResponseStatus responseStatus(response);
net->scheduleResponse(
updatePosRequest, net->now() + updatePositionTimeout + Milliseconds(1), responseStatus);
diff --git a/src/mongo/db/repl/scatter_gather_test.cpp b/src/mongo/db/repl/scatter_gather_test.cpp
index 1d5a32b4895..8d1c8f480fb 100644
--- a/src/mongo/db/repl/scatter_gather_test.cpp
+++ b/src/mongo/db/repl/scatter_gather_test.cpp
@@ -165,21 +165,18 @@ TEST_F(ScatterGatherTest, DeleteAlgorithmAfterItHasCompleted) {
NetworkInterfaceMock* net = getNet();
net->enterNetwork();
NetworkInterfaceMock::NetworkOperationIterator noi = net->getNextReadyRequest();
- net->scheduleResponse(noi,
- net->now() + Seconds(2),
- (RemoteCommandResponse(BSON("ok" << 1), BSONObj(), Milliseconds(10))));
+ net->scheduleResponse(
+ noi, net->now() + Seconds(2), (RemoteCommandResponse(BSON("ok" << 1), Milliseconds(10))));
ASSERT_FALSE(ranCompletion);
noi = net->getNextReadyRequest();
- net->scheduleResponse(noi,
- net->now() + Seconds(2),
- (RemoteCommandResponse(BSON("ok" << 1), BSONObj(), Milliseconds(10))));
+ net->scheduleResponse(
+ noi, net->now() + Seconds(2), (RemoteCommandResponse(BSON("ok" << 1), Milliseconds(10))));
ASSERT_FALSE(ranCompletion);
noi = net->getNextReadyRequest();
- net->scheduleResponse(noi,
- net->now() + Seconds(5),
- (RemoteCommandResponse(BSON("ok" << 1), BSONObj(), Milliseconds(10))));
+ net->scheduleResponse(
+ noi, net->now() + Seconds(5), (RemoteCommandResponse(BSON("ok" << 1), Milliseconds(10))));
ASSERT_FALSE(ranCompletion);
net->runUntil(net->now() + Seconds(2));
@@ -208,21 +205,19 @@ TEST_F(ScatterGatherTest, DeleteAlgorithmBeforeItCompletes) {
net->enterNetwork();
NetworkInterfaceMock::NetworkOperationIterator noi = net->getNextReadyRequest();
net->scheduleResponse(
- noi, net->now(), (RemoteCommandResponse(BSON("ok" << 1), BSONObj(), Milliseconds(10))));
+ noi, net->now(), (RemoteCommandResponse(BSON("ok" << 1), Milliseconds(10))));
ASSERT_FALSE(ranCompletion);
// Get and process the response from the first node immediately.
net->runReadyNetworkOperations();
noi = net->getNextReadyRequest();
- net->scheduleResponse(noi,
- net->now() + Seconds(2),
- (RemoteCommandResponse(BSON("ok" << 1), BSONObj(), Milliseconds(10))));
+ net->scheduleResponse(
+ noi, net->now() + Seconds(2), (RemoteCommandResponse(BSON("ok" << 1), Milliseconds(10))));
ASSERT_FALSE(ranCompletion);
noi = net->getNextReadyRequest();
- net->scheduleResponse(noi,
- net->now() + Seconds(5),
- (RemoteCommandResponse(BSON("ok" << 1), BSONObj(), Milliseconds(10))));
+ net->scheduleResponse(
+ noi, net->now() + Seconds(5), (RemoteCommandResponse(BSON("ok" << 1), Milliseconds(10))));
ASSERT_FALSE(ranCompletion);
sga.reset();
@@ -248,9 +243,8 @@ TEST_F(ScatterGatherTest, DeleteAlgorithmAfterCancel) {
NetworkInterfaceMock* net = getNet();
net->enterNetwork();
NetworkInterfaceMock::NetworkOperationIterator noi = net->getNextReadyRequest();
- net->scheduleResponse(noi,
- net->now() + Seconds(2),
- (RemoteCommandResponse(BSON("ok" << 1), BSONObj(), Milliseconds(10))));
+ net->scheduleResponse(
+ noi, net->now() + Seconds(2), (RemoteCommandResponse(BSON("ok" << 1), Milliseconds(10))));
ASSERT_FALSE(ranCompletion);
// Cancel the runner so following responses won't change the result. All pending requests
@@ -347,21 +341,18 @@ TEST_F(ScatterGatherTest, DoNotProcessMoreThanSufficientResponses) {
NetworkInterfaceMock* net = getNet();
net->enterNetwork();
NetworkInterfaceMock::NetworkOperationIterator noi = net->getNextReadyRequest();
- net->scheduleResponse(noi,
- net->now() + Seconds(2),
- (RemoteCommandResponse(BSON("ok" << 1), BSONObj(), Milliseconds(10))));
+ net->scheduleResponse(
+ noi, net->now() + Seconds(2), (RemoteCommandResponse(BSON("ok" << 1), Milliseconds(10))));
ASSERT_FALSE(ranCompletion);
noi = net->getNextReadyRequest();
- net->scheduleResponse(noi,
- net->now() + Seconds(2),
- (RemoteCommandResponse(BSON("ok" << 1), BSONObj(), Milliseconds(10))));
+ net->scheduleResponse(
+ noi, net->now() + Seconds(2), (RemoteCommandResponse(BSON("ok" << 1), Milliseconds(10))));
ASSERT_FALSE(ranCompletion);
noi = net->getNextReadyRequest();
- net->scheduleResponse(noi,
- net->now() + Seconds(5),
- (RemoteCommandResponse(BSON("ok" << 1), BSONObj(), Milliseconds(10))));
+ net->scheduleResponse(
+ noi, net->now() + Seconds(5), (RemoteCommandResponse(BSON("ok" << 1), Milliseconds(10))));
ASSERT_FALSE(ranCompletion);
net->runUntil(net->now() + Seconds(2));
@@ -390,9 +381,8 @@ TEST_F(ScatterGatherTest, AlgorithmProcessesCallbackCanceledResponse) {
NetworkInterfaceMock* net = getNet();
net->enterNetwork();
NetworkInterfaceMock::NetworkOperationIterator noi = net->getNextReadyRequest();
- net->scheduleResponse(noi,
- net->now() + Seconds(2),
- (RemoteCommandResponse(BSON("ok" << 1), BSONObj(), Milliseconds(10))));
+ net->scheduleResponse(
+ noi, net->now() + Seconds(2), (RemoteCommandResponse(BSON("ok" << 1), Milliseconds(10))));
ASSERT_FALSE(ranCompletion);
noi = net->getNextReadyRequest();
@@ -493,7 +483,7 @@ TEST_F(ScatterGatherTest, SuccessfulScatterGatherViaRun) {
net->enterNetwork();
NetworkInterfaceMock::NetworkOperationIterator noi = net->getNextReadyRequest();
net->scheduleResponse(
- noi, net->now(), (RemoteCommandResponse(BSON("ok" << 1), BSONObj(), Milliseconds(10))));
+ noi, net->now(), (RemoteCommandResponse(BSON("ok" << 1), Milliseconds(10))));
net->runReadyNetworkOperations();
noi = net->getNextReadyRequest();
@@ -502,7 +492,7 @@ TEST_F(ScatterGatherTest, SuccessfulScatterGatherViaRun) {
noi = net->getNextReadyRequest();
net->scheduleResponse(
- noi, net->now(), (RemoteCommandResponse(BSON("ok" << 1), BSONObj(), Milliseconds(10))));
+ noi, net->now(), (RemoteCommandResponse(BSON("ok" << 1), Milliseconds(10))));
net->runReadyNetworkOperations();
net->exitNetwork();
diff --git a/src/mongo/db/repl/vote_requester_test.cpp b/src/mongo/db/repl/vote_requester_test.cpp
index 74374d3ad36..9a11270e577 100644
--- a/src/mongo/db/repl/vote_requester_test.cpp
+++ b/src/mongo/db/repl/vote_requester_test.cpp
@@ -153,7 +153,7 @@ protected:
ReplSetRequestVotesResponse response;
response.setVoteGranted(true);
response.setTerm(1);
- return RemoteCommandResponse(response.toBSON(), BSONObj(), Milliseconds(10));
+ return RemoteCommandResponse(response.toBSON(), Milliseconds(10));
}
RemoteCommandResponse votedYesStatusNotOkBecauseFailedToStoreLastVote() {
@@ -164,7 +164,7 @@ protected:
response.addToBSON(&result);
auto status = Status(ErrorCodes::InterruptedDueToStepDown, "operation was interrupted");
CommandHelpers::appendCommandStatusNoThrow(result, status);
- return RemoteCommandResponse(result.obj(), BSONObj(), Milliseconds(10));
+ return RemoteCommandResponse(result.obj(), Milliseconds(10));
}
RemoteCommandResponse votedNoBecauseConfigVersionDoesNotMatch() {
@@ -172,7 +172,7 @@ protected:
response.setVoteGranted(false);
response.setTerm(1);
response.setReason("candidate's config version differs from mine");
- return RemoteCommandResponse(response.toBSON(), BSONObj(), Milliseconds(10));
+ return RemoteCommandResponse(response.toBSON(), Milliseconds(10));
}
RemoteCommandResponse votedNoBecauseSetNameDiffers() {
@@ -180,7 +180,7 @@ protected:
response.setVoteGranted(false);
response.setTerm(1);
response.setReason("candidate's set name differs from mine");
- return RemoteCommandResponse(response.toBSON(), BSONObj(), Milliseconds(10));
+ return RemoteCommandResponse(response.toBSON(), Milliseconds(10));
}
RemoteCommandResponse votedNoBecauseLastOpTimeIsGreater() {
@@ -188,7 +188,7 @@ protected:
response.setVoteGranted(false);
response.setTerm(1);
response.setReason("candidate's data is staler than mine");
- return RemoteCommandResponse(response.toBSON(), BSONObj(), Milliseconds(10));
+ return RemoteCommandResponse(response.toBSON(), Milliseconds(10));
}
RemoteCommandResponse votedNoBecauseTermIsGreater() {
@@ -196,7 +196,7 @@ protected:
response.setVoteGranted(false);
response.setTerm(3);
response.setReason("candidate's term is lower than mine");
- return RemoteCommandResponse(response.toBSON(), BSONObj(), Milliseconds(10));
+ return RemoteCommandResponse(response.toBSON(), Milliseconds(10));
}
RemoteCommandResponse votedNoBecauseAlreadyVoted() {
@@ -204,7 +204,7 @@ protected:
response.setVoteGranted(false);
response.setTerm(2);
response.setReason("already voted for another candidate this term");
- return RemoteCommandResponse(response.toBSON(), BSONObj(), Milliseconds(10));
+ return RemoteCommandResponse(response.toBSON(), Milliseconds(10));
}
std::unique_ptr<VoteRequester::Algorithm> _requester;