diff options
| author | Spencer Jackson <spencer.jackson@mongodb.com> | 2016-12-13 17:53:24 -0500 |
|---|---|---|
| committer | Spencer Jackson <spencer.jackson@mongodb.com> | 2017-01-04 16:38:10 -0500 |
| commit | 116b0584eb4cf0e1f6cefd90cb58753f8dc0aa78 (patch) | |
| tree | a7b09fad5318ef0a184adf2ba1099aea050205bf /jstests/noPassthroughWithMongod | |
| parent | dc772bda588a2c40c5be8bbd8537a7ed0215ee8e (diff) | |
| download | mongo-116b0584eb4cf0e1f6cefd90cb58753f8dc0aa78.tar.gz | |
SERVER-26525: Factor out identical checkLog functions
(cherry picked from commit e55c4b224f1260e4d163be7a71db2737be298559)
Diffstat (limited to 'jstests/noPassthroughWithMongod')
| -rw-r--r-- | jstests/noPassthroughWithMongod/initial_sync_oplog_rollover.js | 17 | ||||
| -rw-r--r-- | jstests/noPassthroughWithMongod/initial_sync_replSetGetStatus.js | 20 |
2 files changed, 9 insertions, 28 deletions
diff --git a/jstests/noPassthroughWithMongod/initial_sync_oplog_rollover.js b/jstests/noPassthroughWithMongod/initial_sync_oplog_rollover.js index 9b6f6a7477d..3a47e14447c 100644 --- a/jstests/noPassthroughWithMongod/initial_sync_oplog_rollover.js +++ b/jstests/noPassthroughWithMongod/initial_sync_oplog_rollover.js @@ -9,6 +9,8 @@ (function() { "use strict"; + load("jstests/libs/check_log.js"); + // If the parameter is already set, don't run this test. var parameters = db.adminCommand({getCmdLineOpts: 1}).parsed.setParameter; if (parameters.use3dot2InitialSync || parameters.initialSyncOplogBuffer) { @@ -46,19 +48,8 @@ {configureFailPoint: 'initialSyncHangBeforeCopyingDatabases', mode: 'alwaysOn'})); replSet.reInitiate(); - // Wait for fail point message to be logged. - var checkLog = function(node, msg) { - assert.soon(function() { - var logMessages = assert.commandWorked(node.adminCommand({getLog: 'global'})).log; - for (var i = 0; i < logMessages.length; i++) { - if (logMessages[i].indexOf(msg) != -1) { - return true; - } - } - return false; - }, 'Did not see a log entry containing the following message: ' + msg); - }; - checkLog(secondary, 'initial sync - initialSyncHangBeforeCopyingDatabases fail point enabled'); + checkLog.contains(secondary, + 'initial sync - initialSyncHangBeforeCopyingDatabases fail point enabled'); // Keep inserting large documents until they roll over the oplog. const largeStr = new Array(4 * 1024 * oplogSizeOnPrimary).join('aaaaaaaa'); diff --git a/jstests/noPassthroughWithMongod/initial_sync_replSetGetStatus.js b/jstests/noPassthroughWithMongod/initial_sync_replSetGetStatus.js index 2ad77904ad4..0c9610e9ad6 100644 --- a/jstests/noPassthroughWithMongod/initial_sync_replSetGetStatus.js +++ b/jstests/noPassthroughWithMongod/initial_sync_replSetGetStatus.js @@ -5,6 +5,8 @@ (function() { "use strict"; + load("jstests/libs/check_log.js"); + // If the parameter is already set, don't run this test. var parameters = db.adminCommand({getCmdLineOpts: 1}).parsed.setParameter; if (parameters.use3dot2InitialSync || parameters.initialSyncOplogBuffer) { @@ -38,21 +40,9 @@ {configureFailPoint: 'initialSyncHangBeforeFinish', mode: 'alwaysOn'})); replSet.reInitiate(); - // Wait for fail point message to be logged. - var checkLog = function(node, msg) { - assert.soon(function() { - var logMessages = assert.commandWorked(node.adminCommand({getLog: 'global'})).log; - for (var i = 0; i < logMessages.length; i++) { - if (logMessages[i].indexOf(msg) != -1) { - return true; - } - } - return false; - }, 'Did not see a log entry containing the following message: ' + msg, 10000, 1000); - }; - // Wait for initial sync to pause before it copies the databases. - checkLog(secondary, 'initial sync - initialSyncHangBeforeCopyingDatabases fail point enabled'); + checkLog.contains(secondary, + 'initial sync - initialSyncHangBeforeCopyingDatabases fail point enabled'); // Test that replSetGetStatus returns the correct results while initial sync is in progress. var res = assert.commandWorked(secondary.adminCommand({replSetGetStatus: 1})); @@ -74,7 +64,7 @@ {configureFailPoint: 'initialSyncHangBeforeCopyingDatabases', mode: 'off'})); // Wait for initial sync to pause right before it finishes. - checkLog(secondary, 'initial sync - initialSyncHangBeforeFinish fail point enabled'); + checkLog.contains(secondary, 'initial sync - initialSyncHangBeforeFinish fail point enabled'); // Test that replSetGetStatus returns the correct results when initial sync is at the very end. res = assert.commandWorked(secondary.adminCommand({replSetGetStatus: 1, initialSync: 1})); |
