diff options
Diffstat (limited to 'src/mongo/db/repl/collection_cloner_test.cpp')
-rw-r--r-- | src/mongo/db/repl/collection_cloner_test.cpp | 68 |
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 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); |