diff options
Diffstat (limited to 'src/mongo/db/s/resharding/resharding_oplog_fetcher_test.cpp')
| -rw-r--r-- | src/mongo/db/s/resharding/resharding_oplog_fetcher_test.cpp | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/src/mongo/db/s/resharding/resharding_oplog_fetcher_test.cpp b/src/mongo/db/s/resharding/resharding_oplog_fetcher_test.cpp index e7c512e2669..b3b85758e83 100644 --- a/src/mongo/db/s/resharding/resharding_oplog_fetcher_test.cpp +++ b/src/mongo/db/s/resharding/resharding_oplog_fetcher_test.cpp @@ -36,7 +36,7 @@ #include "mongo/bson/bsonobj.h" #include "mongo/db/client.h" -#include "mongo/db/concurrency/write_conflict_exception.h" +#include "mongo/db/concurrency/exception_util.h" #include "mongo/db/db_raii.h" #include "mongo/db/dbdirectclient.h" #include "mongo/db/dbhelpers.h" @@ -666,6 +666,44 @@ TEST_F(ReshardingOplogFetcherTest, RetriesOnRemoteInterruptionError) { ASSERT_TRUE(moreToCome); } +TEST_F(ReshardingOplogFetcherTest, RetriesOnNetworkTimeoutError) { + const NamespaceString outputCollectionNss("dbtests.outputCollection"); + const NamespaceString dataCollectionNss("dbtests.runFetchIteration"); + + create(outputCollectionNss); + create(dataCollectionNss); + _fetchTimestamp = repl::StorageInterface::get(_svcCtx)->getLatestOplogTimestamp(_opCtx); + + const auto& collectionUUID = [&] { + AutoGetCollection dataColl(_opCtx, dataCollectionNss, LockMode::MODE_IX); + return dataColl->uuid(); + }(); + + auto fetcherJob = launchAsync([&, this] { + ThreadClient tc("RunnerForFetcher", _svcCtx, nullptr); + + ReshardingDonorOplogId startAt{_fetchTimestamp, _fetchTimestamp}; + ReshardingOplogFetcher fetcher(makeFetcherEnv(), + _reshardingUUID, + collectionUUID, + startAt, + _donorShard, + _destinationShard, + outputCollectionNss); + + auto factory = makeCancelableOpCtx(); + return fetcher.iterate(&cc(), factory); + }); + + onCommand([&](const executor::RemoteCommandRequest& request) -> StatusWith<BSONObj> { + // Inject network timeout error. + return {ErrorCodes::NetworkInterfaceExceededTimeLimit, "exceeded network time limit"}; + }); + + auto moreToCome = fetcherJob.timed_get(Seconds(5)); + ASSERT_TRUE(moreToCome); +} + TEST_F(ReshardingOplogFetcherTest, ImmediatelyDoneWhenFinalOpHasAlreadyBeenFetched) { const NamespaceString outputCollectionNss("dbtests.outputCollection"); const NamespaceString dataCollectionNss("dbtests.runFetchIteration"); |
