summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/collection_cloner_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/repl/collection_cloner_test.cpp')
-rw-r--r--src/mongo/db/repl/collection_cloner_test.cpp68
1 files changed, 33 insertions, 35 deletions
diff --git a/src/mongo/db/repl/collection_cloner_test.cpp b/src/mongo/db/repl/collection_cloner_test.cpp
index 20c4eb00ae3..09e61df9080 100644
--- a/src/mongo/db/repl/collection_cloner_test.cpp
+++ b/src/mongo/db/repl/collection_cloner_test.cpp
@@ -261,15 +261,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());
@@ -283,12 +283,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() {
@@ -443,8 +441,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());
@@ -566,15 +563,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);
@@ -633,13 +630,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.
{
@@ -688,9 +686,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));
};
@@ -698,8 +696,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();
};
@@ -1402,8 +1401,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);