diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2016-12-14 16:41:22 -0500 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2016-12-15 18:44:38 -0500 |
commit | 0a3bee733d104a17fad51e5bf87917b6fd8655e9 (patch) | |
tree | 0c3c67f780eb6007eaaf9f3c49cda64fd6a1ecf2 /src | |
parent | 20bc3f49fafb2c8a8d9e8224e8723cd767549d2c (diff) | |
download | mongo-0a3bee733d104a17fad51e5bf87917b6fd8655e9.tar.gz |
SERVER-27428 Wait for the onCommand thread in MigrationChunkClonerSourceLegacy's unit-tests
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/s/migration_chunk_cloner_source_legacy_test.cpp | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/src/mongo/db/s/migration_chunk_cloner_source_legacy_test.cpp b/src/mongo/db/s/migration_chunk_cloner_source_legacy_test.cpp index 403a951c20e..f0d4a42ecc9 100644 --- a/src/mongo/db/s/migration_chunk_cloner_source_legacy_test.cpp +++ b/src/mongo/db/s/migration_chunk_cloner_source_legacy_test.cpp @@ -200,11 +200,14 @@ TEST_F(MigrationChunkClonerSourceLegacyTest, CorrectDocumentsFetched) { kDonorConnStr, kRecipientConnStr.getServers()[0]); - auto futureStart = launchAsync([&]() { - onCommand([&](const RemoteCommandRequest& request) { return BSON("ok" << true); }); - }); + { + auto futureStartClone = launchAsync([&]() { + onCommand([&](const RemoteCommandRequest& request) { return BSON("ok" << true); }); + }); - ASSERT_OK(cloner.startClone(operationContext())); + ASSERT_OK(cloner.startClone(operationContext())); + futureStartClone.timed_get(kFutureTimeout); + } // Ensure the initial clone documents are available { @@ -290,6 +293,7 @@ TEST_F(MigrationChunkClonerSourceLegacyTest, CorrectDocumentsFetched) { }); ASSERT_OK(cloner.commitClone(operationContext())); + futureCommit.timed_get(kFutureTimeout); } TEST_F(MigrationChunkClonerSourceLegacyTest, CollectionNotFound) { @@ -330,14 +334,18 @@ TEST_F(MigrationChunkClonerSourceLegacyTest, FailedToEngageRecipientShard) { kDonorConnStr, kRecipientConnStr.getServers()[0]); - auto future = launchAsync([&]() { - onCommand([&](const RemoteCommandRequest& request) { - return Status(ErrorCodes::NetworkTimeout, "Did not receive confirmation from donor"); + { + auto futureStartClone = launchAsync([&]() { + onCommand([&](const RemoteCommandRequest& request) { + return Status(ErrorCodes::NetworkTimeout, + "Did not receive confirmation from donor"); + }); }); - }); - auto startCloneStatus = cloner.startClone(operationContext()); - ASSERT_EQ(ErrorCodes::NetworkTimeout, startCloneStatus.code()); + auto startCloneStatus = cloner.startClone(operationContext()); + ASSERT_EQ(ErrorCodes::NetworkTimeout, startCloneStatus.code()); + futureStartClone.timed_get(kFutureTimeout); + } // Ensure that if the recipient tries to fetch some documents, the cloner won't crash { |