summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorMedha Potluri <medha.potluri@mongodb.com>2019-05-30 11:22:10 -0400
committerMedha Potluri <medha.potluri@mongodb.com>2019-06-13 17:04:31 -0400
commitfffb564422ebf4d0569052ebe61bd96e6494e25f (patch)
tree90aa55c4fa12958e83ed9a32a159ad0964c443cd /jstests
parentf90df932ab3f8c5f279b6f14343fe0efa80c1b9a (diff)
downloadmongo-fffb564422ebf4d0569052ebe61bd96e6494e25f.tar.gz
SERVER-7019 Return initial sync status information by default in replSetGetStatus and remove it after successful initial sync attempt
Diffstat (limited to 'jstests')
-rw-r--r--jstests/disk/libs/wt_file_helper.js10
-rw-r--r--jstests/replsets/initial_sync_drop_collection.js6
-rw-r--r--jstests/replsets/initial_sync_during_stepdown.js6
-rw-r--r--jstests/replsets/initial_sync_fcv.js4
-rw-r--r--jstests/replsets/initial_sync_replSetGetStatus.js18
-rw-r--r--jstests/replsets/initial_sync_update_missing_doc1.js8
-rw-r--r--jstests/replsets/initial_sync_update_missing_doc2.js8
-rw-r--r--jstests/replsets/initial_sync_update_missing_doc3.js2
-rw-r--r--jstests/replsets/libs/initial_sync_test.js7
9 files changed, 47 insertions, 22 deletions
diff --git a/jstests/disk/libs/wt_file_helper.js b/jstests/disk/libs/wt_file_helper.js
index 54e7781608d..75bd3688301 100644
--- a/jstests/disk/libs/wt_file_helper.js
+++ b/jstests/disk/libs/wt_file_helper.js
@@ -128,10 +128,15 @@ let assertStartInReplSet = function(replSet, originalNode, cleanData, expectResy
let node = replSet.start(
originalNode, {dbpath: originalNode.dbpath, port: originalNode.port, restart: !cleanData});
+ // Skip clearing initial sync progress after a successful initial sync attempt so that we
+ // can check initialSyncStatus fields after initial sync is complete.
+ assert.commandWorked(
+ node.adminCommand({configureFailPoint: 'skipClearInitialSyncState', mode: 'alwaysOn'}));
+
replSet.awaitSecondaryNodes();
// Ensure that an initial sync attempt was made and succeeded if the data directory was cleaned.
- let res = assert.commandWorked(node.adminCommand({replSetGetStatus: 1, initialSync: 1}));
+ let res = assert.commandWorked(node.adminCommand({replSetGetStatus: 1}));
if (expectResync) {
assert.eq(1, res.initialSyncStatus.initialSyncAttempts.length);
assert.eq(0, res.initialSyncStatus.failedInitialSyncAttempts);
@@ -139,6 +144,9 @@ let assertStartInReplSet = function(replSet, originalNode, cleanData, expectResy
assert.eq(undefined, res.initialSyncStatus);
}
+ assert.commandWorked(
+ node.adminCommand({configureFailPoint: 'skipClearInitialSyncState', mode: 'off'}));
+
testFunc(node);
return node;
};
diff --git a/jstests/replsets/initial_sync_drop_collection.js b/jstests/replsets/initial_sync_drop_collection.js
index 54cc039540f..babb30dac56 100644
--- a/jstests/replsets/initial_sync_drop_collection.js
+++ b/jstests/replsets/initial_sync_drop_collection.js
@@ -44,6 +44,9 @@
secondaryStartupParams = secondaryStartupParams || {};
secondaryStartupParams['failpoint.' + failPoint] =
tojson({mode: 'alwaysOn', data: {nss: nss}});
+ // Skip clearing initial sync progress after a successful initial sync attempt so that we
+ // can check initialSyncStatus fields after initial sync is complete.
+ secondaryStartupParams['failpoint.skipClearInitialSyncState'] = tojson({mode: 'alwaysOn'});
secondaryStartupParams['numInitialSyncAttempts'] = 1;
replTest.restart(secondary, {startClean: true, setParameter: secondaryStartupParams});
@@ -84,8 +87,7 @@
jsTestLog("Waiting for initial sync to complete.");
replTest.waitForState(secondary, ReplSetTest.State.SECONDARY);
- let res =
- assert.commandWorked(secondary.adminCommand({replSetGetStatus: 1, initialSync: 1}));
+ let res = assert.commandWorked(secondary.adminCommand({replSetGetStatus: 1}));
assert.eq(0, res.initialSyncStatus.failedInitialSyncAttempts);
if (createNew) {
diff --git a/jstests/replsets/initial_sync_during_stepdown.js b/jstests/replsets/initial_sync_during_stepdown.js
index 10e553a6c7e..d142b911b3c 100644
--- a/jstests/replsets/initial_sync_during_stepdown.js
+++ b/jstests/replsets/initial_sync_during_stepdown.js
@@ -50,6 +50,9 @@
jsTestLog("Starting secondary.");
secondaryStartupParams['numInitialSyncAttempts'] = 1;
+ // Skip clearing initial sync progress after a successful initial sync attempt so that we
+ // can check initialSyncStatus fields after initial sync is complete.
+ secondaryStartupParams['failpoint.skipClearInitialSyncState'] = tojson({mode: 'alwaysOn'});
rst.start(secondary, {startClean: true, setParameter: secondaryStartupParams});
// Wait until secondary reaches RS_STARTUP2 state.
@@ -81,8 +84,7 @@
rst.waitForState(primary, ReplSetTest.State.SECONDARY);
jsTestLog("Validating initial sync data.");
- let res =
- assert.commandWorked(secondary.adminCommand({replSetGetStatus: 1, initialSync: 1}));
+ let res = assert.commandWorked(secondary.adminCommand({replSetGetStatus: 1}));
assert.eq(0, res.initialSyncStatus.failedInitialSyncAttempts);
assert.eq(2 + DocsCopiedByOplogFetcher, secondaryColl.find().itcount());
diff --git a/jstests/replsets/initial_sync_fcv.js b/jstests/replsets/initial_sync_fcv.js
index 01d2e8d9536..a0fd4420548 100644
--- a/jstests/replsets/initial_sync_fcv.js
+++ b/jstests/replsets/initial_sync_fcv.js
@@ -36,6 +36,7 @@
startClean: true,
setParameter: {
'failpoint.initialSyncHangBeforeListCollections': failPointOptions,
+ 'failpoint.skipClearInitialSyncState': tojson({mode: 'alwaysOn'}),
numInitialSyncAttempts: 2
}
});
@@ -62,8 +63,7 @@
rst.awaitSecondaryNodes();
rst.awaitReplication();
- let res =
- assert.commandWorked(secondary.adminCommand({replSetGetStatus: 1, initialSync: 1}));
+ let res = assert.commandWorked(secondary.adminCommand({replSetGetStatus: 1}));
assert.eq(res.initialSyncStatus.failedInitialSyncAttempts, 1);
// We check oplogs and data hashes before we restart the second node.
diff --git a/jstests/replsets/initial_sync_replSetGetStatus.js b/jstests/replsets/initial_sync_replSetGetStatus.js
index 26914eddf06..2d6bf11829b 100644
--- a/jstests/replsets/initial_sync_replSetGetStatus.js
+++ b/jstests/replsets/initial_sync_replSetGetStatus.js
@@ -37,12 +37,12 @@
// Test that replSetGetStatus returns the correct results while initial sync is in progress.
var res = assert.commandWorked(secondary.adminCommand({replSetGetStatus: 1}));
- assert(!res.initialSyncStatus,
- "Response should not have an 'initialSyncStatus' field: " + tojson(res));
-
- res = assert.commandWorked(secondary.adminCommand({replSetGetStatus: 1, initialSync: 1}));
assert(res.initialSyncStatus,
- "Response should have an 'initialSyncStatus' field: " + tojson(res));
+ () => "Response should have an 'initialSyncStatus' field: " + tojson(res));
+
+ res = assert.commandWorked(secondary.adminCommand({replSetGetStatus: 1, initialSync: 0}));
+ assert(!res.initialSyncStatus,
+ () => "Response should not have an 'initialSyncStatus' field: " + tojson(res));
assert.commandFailedWithCode(secondary.adminCommand({replSetGetStatus: 1, initialSync: "t"}),
ErrorCodes.TypeMismatch);
@@ -58,8 +58,9 @@
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}));
- assert(res.initialSyncStatus, "Response should have an 'initialSyncStatus' field.");
+ res = assert.commandWorked(secondary.adminCommand({replSetGetStatus: 1}));
+ assert(res.initialSyncStatus,
+ () => "Response should have an 'initialSyncStatus' field: " + tojson(res));
assert.eq(res.initialSyncStatus.fetchedMissingDocs, 0);
assert.eq(res.initialSyncStatus.appliedOps, 3);
assert.eq(res.initialSyncStatus.failedInitialSyncAttempts, 0);
@@ -80,12 +81,13 @@
// Test that replSetGetStatus returns the correct results after initial sync is finished.
res = assert.commandWorked(secondary.adminCommand({replSetGetStatus: 1}));
assert(!res.initialSyncStatus,
- "Response should not have an 'initialSyncStatus' field: " + tojson(res));
+ () => "Response should not have an 'initialSyncStatus' field: " + tojson(res));
assert.commandFailedWithCode(secondary.adminCommand({replSetGetStatus: 1, initialSync: "m"}),
ErrorCodes.TypeMismatch);
assert.eq(0,
secondary.getDB('local')['temp_oplog_buffer'].find().itcount(),
"Oplog buffer was not dropped after initial sync");
+
replSet.stopSet();
})();
diff --git a/jstests/replsets/initial_sync_update_missing_doc1.js b/jstests/replsets/initial_sync_update_missing_doc1.js
index ea9adc7419a..6d4fe624892 100644
--- a/jstests/replsets/initial_sync_update_missing_doc1.js
+++ b/jstests/replsets/initial_sync_update_missing_doc1.js
@@ -35,6 +35,10 @@
{configureFailPoint: 'initialSyncHangBeforeCopyingDatabases', mode: 'alwaysOn'}));
assert.commandWorked(secondary.getDB('admin').runCommand(
{configureFailPoint: 'initialSyncHangBeforeGettingMissingDocument', mode: 'alwaysOn'}));
+ // Skip clearing initial sync progress after a successful initial sync attempt so that we
+ // can check initialSyncStatus fields after initial sync is complete.
+ assert.commandWorked(secondary.getDB('admin').runCommand(
+ {configureFailPoint: 'skipClearInitialSyncState', mode: 'alwaysOn'}));
replSet.reInitiate();
// Wait for fail point message to be logged.
@@ -51,7 +55,7 @@
checkLog.contains(secondary, 'Fetching missing document');
checkLog.contains(
secondary, 'initial sync - initialSyncHangBeforeGettingMissingDocument fail point enabled');
- var res = assert.commandWorked(secondary.adminCommand({replSetGetStatus: 1, initialSync: 1}));
+ var res = assert.commandWorked(secondary.adminCommand({replSetGetStatus: 1}));
assert.eq(res.initialSyncStatus.fetchedMissingDocs, 0);
var firstOplogEnd = res.initialSyncStatus.initialSyncOplogEnd;
@@ -71,7 +75,7 @@
secondary.getDB('test').getCollection(name).find().itcount(),
'collection successfully synced to secondary');
- res = assert.commandWorked(secondary.adminCommand({replSetGetStatus: 1, initialSync: 1}));
+ res = assert.commandWorked(secondary.adminCommand({replSetGetStatus: 1}));
// Fetch count stays at zero because we are unable to get the document from the sync source.
assert.eq(res.initialSyncStatus.fetchedMissingDocs, 0);
diff --git a/jstests/replsets/initial_sync_update_missing_doc2.js b/jstests/replsets/initial_sync_update_missing_doc2.js
index fbd5f3d5411..e47f9b7e385 100644
--- a/jstests/replsets/initial_sync_update_missing_doc2.js
+++ b/jstests/replsets/initial_sync_update_missing_doc2.js
@@ -35,6 +35,10 @@
{configureFailPoint: 'initialSyncHangBeforeCopyingDatabases', mode: 'alwaysOn'}));
assert.commandWorked(secondary.getDB('admin').runCommand(
{configureFailPoint: 'initialSyncHangBeforeGettingMissingDocument', mode: 'alwaysOn'}));
+ // Skip clearing initial sync progress after a successful initial sync attempt so that we
+ // can check initialSyncStatus fields after initial sync is complete.
+ assert.commandWorked(secondary.getDB('admin').runCommand(
+ {configureFailPoint: 'skipClearInitialSyncState', mode: 'alwaysOn'}));
replSet.reInitiate();
// Wait for fail point message to be logged.
@@ -56,7 +60,7 @@
// Re-insert deleted document.
assert.writeOK(coll.insert(doc, {writeConcern: {w: 1}}));
- var res = assert.commandWorked(secondary.adminCommand({replSetGetStatus: 1, initialSync: 1}));
+ var res = assert.commandWorked(secondary.adminCommand({replSetGetStatus: 1}));
assert.eq(res.initialSyncStatus.fetchedMissingDocs, 0);
var firstOplogEnd = res.initialSyncStatus.initialSyncOplogEnd;
@@ -76,7 +80,7 @@
assert.eq(1, coll.find().itcount(), 'collection successfully synced to secondary');
assert.eq(doc, coll.findOne(), 'document on secondary matches primary');
- res = assert.commandWorked(secondary.adminCommand({replSetGetStatus: 1, initialSync: 1}));
+ res = assert.commandWorked(secondary.adminCommand({replSetGetStatus: 1}));
assert.eq(res.initialSyncStatus.fetchedMissingDocs, 1);
var finalOplogEnd = res.initialSyncStatus.initialSyncOplogEnd;
assert(!friendlyEqual(firstOplogEnd, finalOplogEnd),
diff --git a/jstests/replsets/initial_sync_update_missing_doc3.js b/jstests/replsets/initial_sync_update_missing_doc3.js
index 4018d437cd5..0aaf5d3b8b4 100644
--- a/jstests/replsets/initial_sync_update_missing_doc3.js
+++ b/jstests/replsets/initial_sync_update_missing_doc3.js
@@ -69,7 +69,7 @@
// Mark the collection as drop pending so it gets renamed, but retains the UUID.
assert.commandWorked(primary.getDB('test').runCommand({"drop": name}));
- var res = assert.commandWorked(secondary.adminCommand({replSetGetStatus: 1, initialSync: 1}));
+ var res = assert.commandWorked(secondary.adminCommand({replSetGetStatus: 1}));
assert.eq(res.initialSyncStatus.fetchedMissingDocs, 0);
var firstOplogEnd = res.initialSyncStatus.initialSyncOplogEnd;
diff --git a/jstests/replsets/libs/initial_sync_test.js b/jstests/replsets/libs/initial_sync_test.js
index c457d82ab2a..0c19bfef057 100644
--- a/jstests/replsets/libs/initial_sync_test.js
+++ b/jstests/replsets/libs/initial_sync_test.js
@@ -99,10 +99,13 @@ function InitialSyncTest(name = "InitialSyncTest", replSet, timeout) {
* Calls replSetGetStatus and checks if the node is in the provided state.
*/
function isNodeInState(node, state) {
+ // We suppress the initialSync field here, because initial sync is paused while holding the
+ // mutex needed to report initial sync progress.
return state ===
assert
- .commandWorkedOrFailedWithCode(node.adminCommand({replSetGetStatus: 1}),
- ErrorCodes.NotYetInitialized)
+ .commandWorkedOrFailedWithCode(
+ node.adminCommand({replSetGetStatus: 1, initialSync: 0}),
+ ErrorCodes.NotYetInitialized)
.myState;
}