summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/collection_cloner_test.cpp
diff options
context:
space:
mode:
authorVesselina Ratcheva <vesselina.ratcheva@10gen.com>2020-08-25 22:19:24 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-08-27 05:03:49 +0000
commited3073ed0ae632bdb0e40fcdbd1d41dd84ec40aa (patch)
tree5ed061fc77a30cc03879172c9e842e88331b2aa0 /src/mongo/db/repl/collection_cloner_test.cpp
parentcefce38b2c914aa2167943e92fb4fe23a1cb9c3b (diff)
downloadmongo-ed3073ed0ae632bdb0e40fcdbd1d41dd84ec40aa.tar.gz
SERVER-50303 Initialize tenant cloner batch size in contructor
Diffstat (limited to 'src/mongo/db/repl/collection_cloner_test.cpp')
-rw-r--r--src/mongo/db/repl/collection_cloner_test.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/mongo/db/repl/collection_cloner_test.cpp b/src/mongo/db/repl/collection_cloner_test.cpp
index 3f34709840a..62c9dfe2274 100644
--- a/src/mongo/db/repl/collection_cloner_test.cpp
+++ b/src/mongo/db/repl/collection_cloner_test.cpp
@@ -35,6 +35,7 @@
#include "mongo/bson/bsonmisc.h"
#include "mongo/db/repl/cloner_test_fixture.h"
#include "mongo/db/repl/collection_cloner.h"
+#include "mongo/db/repl/repl_server_parameters_gen.h"
#include "mongo/db/repl/storage_interface.h"
#include "mongo/db/repl/storage_interface_mock.h"
#include "mongo/db/service_context_test_fixture.h"
@@ -337,6 +338,36 @@ TEST_F(CollectionClonerTestResumable, InsertDocumentsSingleBatch) {
ASSERT_EQUALS(1u, stats.receivedBatches);
}
+TEST_F(CollectionClonerTestResumable, BatchSizeStoredInConstructor) {
+ auto batchSizeDefault = collectionClonerBatchSize;
+ collectionClonerBatchSize = 3;
+ ON_BLOCK_EXIT([&]() { collectionClonerBatchSize = batchSizeDefault; });
+
+ // Set up data for preliminary stages.
+ _mockServer->setCommandReply("count", createCountResponse(2));
+ _mockServer->setCommandReply("listIndexes",
+ createCursorResponse(_nss.ns(), BSON_ARRAY(_idIndexSpec)));
+
+ // Set up documents to be returned from upstream node. It should take 3 batches to clone the
+ // documents.
+ _mockServer->insert(_nss.ns(), BSON("_id" << 1));
+ _mockServer->insert(_nss.ns(), BSON("_id" << 2));
+ _mockServer->insert(_nss.ns(), BSON("_id" << 3));
+ _mockServer->insert(_nss.ns(), BSON("_id" << 4));
+ _mockServer->insert(_nss.ns(), BSON("_id" << 5));
+ _mockServer->insert(_nss.ns(), BSON("_id" << 6));
+ _mockServer->insert(_nss.ns(), BSON("_id" << 7));
+
+ auto cloner = makeCollectionCloner();
+ ASSERT_OK(cloner->run());
+
+ ASSERT_EQUALS(7, _collectionStats->insertCount);
+ ASSERT_TRUE(_collectionStats->commitCalled);
+
+ auto stats = cloner->getStats();
+ ASSERT_EQUALS(3u, stats.receivedBatches);
+}
+
TEST_F(CollectionClonerTestResumable, InsertDocumentsMultipleBatches) {
// Set up data for preliminary stages
_mockServer->setCommandReply("count", createCountResponse(2));