summaryrefslogtreecommitdiff
path: root/jstests/slow1
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2016-07-28 14:17:36 -0400
committerBenety Goh <benety@mongodb.com>2016-07-29 11:54:20 -0400
commitf92821ed3785918a6e8e39f79af972263a7d47a3 (patch)
treec4c20cd23c8301a3609ab8624c0c1b2f16716f54 /jstests/slow1
parentb9d0cb49822188d383ae293ef217d3825e44a36e (diff)
downloadmongo-f92821ed3785918a6e8e39f79af972263a7d47a3.tar.gz
SERVER-25084 added test for initial sync with many databases
Diffstat (limited to 'jstests/slow1')
-rw-r--r--jstests/slow1/initial_sync_many_dbs.js52
1 files changed, 52 insertions, 0 deletions
diff --git a/jstests/slow1/initial_sync_many_dbs.js b/jstests/slow1/initial_sync_many_dbs.js
new file mode 100644
index 00000000000..61bdce80bc8
--- /dev/null
+++ b/jstests/slow1/initial_sync_many_dbs.js
@@ -0,0 +1,52 @@
+/**
+ * Runs initial sync on a node with many databases.
+ */
+
+(function() {
+ var name = 'initial_sync_many_dbs';
+ var num_dbs = 64;
+ var num_colls = 16;
+ var num_docs = 4;
+ var replSet = new ReplSetTest({
+ name: name,
+ nodes: 1,
+ });
+ replSet.startSet();
+ replSet.initiate();
+
+ var primary = replSet.getPrimary();
+ jsTestLog('Seeding primary with ' + num_dbs + ' databases with ' + num_colls +
+ ' collections each. Each collection will contain ' + num_docs + ' documents');
+ for (var i = 0; i < num_dbs; i++) {
+ var dbname = name + '_db' + i;
+ for (var j = 0; j < num_colls; j++) {
+ var collname = name + '_coll' + j;
+ var coll = primary.getDB(dbname)[collname];
+ for (var k = 0; k < num_docs; k++) {
+ assert.writeOK(coll.insert({_id: k}));
+ }
+ }
+ }
+
+ // Add a secondary that will initial sync from the primary.
+ jsTestLog('Adding node to replica set to trigger initial sync process');
+ replSet.add();
+ replSet.reInitiate();
+
+ replSet.awaitSecondaryNodes(10 * 60 * 1000);
+ var secondary = replSet.getSecondary();
+ jsTestLog('New node has transitioned to secondary. Checking collection sizes');
+ for (var i = 0; i < num_dbs; i++) {
+ var dbname = name + '_db' + i;
+ for (var j = 0; j < num_colls; j++) {
+ var collname = name + '_coll' + j;
+ var coll = secondary.getDB(dbname)[collname];
+ assert.eq(num_docs,
+ coll.find().itcount(),
+ 'collection size inconsistent with primary after initial sync: ' +
+ coll.getFullName());
+ }
+ }
+
+ replSet.stopSet();
+})();