diff options
| author | Judah Schvimer <judah@mongodb.com> | 2016-09-22 09:40:38 -0400 |
|---|---|---|
| committer | Judah Schvimer <judah@mongodb.com> | 2016-09-22 09:40:38 -0400 |
| commit | 77062664e98ff492855b51619d41185f746a42b6 (patch) | |
| tree | da6e15d8c45ab089f6f62f15b0ac2820801f63a3 /jstests/noPassthroughWithMongod | |
| parent | 160344c5862ce31097253ebe55307d44c074e674 (diff) | |
| download | mongo-77062664e98ff492855b51619d41185f746a42b6.tar.gz | |
SERVER-26223 Slow down inserts in initial_sync_oplog_rollover.js
Diffstat (limited to 'jstests/noPassthroughWithMongod')
| -rw-r--r-- | jstests/noPassthroughWithMongod/initial_sync_oplog_rollover.js | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/jstests/noPassthroughWithMongod/initial_sync_oplog_rollover.js b/jstests/noPassthroughWithMongod/initial_sync_oplog_rollover.js index 6808370b6d5..55cc54418a9 100644 --- a/jstests/noPassthroughWithMongod/initial_sync_oplog_rollover.js +++ b/jstests/noPassthroughWithMongod/initial_sync_oplog_rollover.js @@ -1,8 +1,8 @@ /** * This test tests that initial sync succeeds when the sync source's oplog rolls over before the * destination node reaches the oplog apply phase. It adds a new secondary to a replicaset and then - * pauses the initial sync before it copies the databases but after the oplog buffer has begun - * buffering oplog entries. The primary then fills up its oplog until it rolls over. At that point + * pauses the initial sync before it copies the databases but after it starts to fetch and buffer + * oplog entries. The primary then fills up its oplog until it rolls over. At that point * initial sync is resumed and we assert that it succeeds and that all of the inserted documents * are there. */ @@ -12,7 +12,7 @@ // If the parameter is already set, don't run this test. var parameters = db.adminCommand({getCmdLineOpts: 1}).parsed.setParameter; if (parameters.use3dot2InitialSync || parameters.initialSyncOplogBuffer) { - jsTest.log("Skipping initial_sync_parameters.js because use3dot2InitialSync or " + + jsTest.log("Skipping initial_sync_oplog_rollover.js because use3dot2InitialSync or " + "initialSyncOplogBuffer was already provided."); return; } @@ -30,7 +30,12 @@ var coll = primary.getDB('test').foo; assert.writeOK(coll.insert({a: 1})); - var firstOplogEntry = primary.getDB('local').oplog.rs.find().sort({ts: 1}).limit(1)[0]; + + function getFirstOplogEntry(conn) { + return conn.getDB('local').oplog.rs.find().sort({ts: 1}).limit(1)[0]; + } + + var firstOplogEntry = getFirstOplogEntry(primary); // Add a secondary node but make it hang before copying databases. var secondary = replSet.add( @@ -55,21 +60,20 @@ }; checkLog(secondary, 'initial sync - initialSyncHangBeforeCopyingDatabases fail point enabled'); - // Make documents around 100KB so that they overflow the oplog. - const largeStr = new Array(16 * 1024 * oplogSizeOnPrimary).join('aaaaaaaa'); - for (var i = 0; i < 40; i++) { - assert.writeOK(coll.insert({a: 2, x: i, long_str: largeStr})); + // Keep inserting large documents until they roll over the oplog. + const largeStr = new Array(4 * 1024 * oplogSizeOnPrimary).join('aaaaaaaa'); + var i = 0; + while (bsonWoCompare(getFirstOplogEntry(primary), firstOplogEntry) === 0) { + assert.writeOK(coll.insert({a: 2, x: i++, long_str: largeStr})); + sleep(100); } - // Assert that the oplog has rolled over on the primary. - assert.neq(primary.getDB('local').oplog.rs.find().sort({ts: 1}).limit(1)[0], firstOplogEntry); - assert.commandWorked(secondary.getDB('admin').runCommand( {configureFailPoint: 'initialSyncHangBeforeCopyingDatabases', mode: 'off'})); replSet.awaitSecondaryNodes(200 * 1000); - assert.eq(40, + assert.eq(i, secondary.getDB('test').foo.count({a: 2}), 'collection successfully synced to secondary'); })(); |
