diff options
author | Vesselina Ratcheva <vesselina.ratcheva@10gen.com> | 2020-05-21 16:44:10 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-05-27 16:27:41 +0000 |
commit | f644958702c699d5f463c9b4028956e1a75e23fb (patch) | |
tree | 75ad759350d35649b3905e0467d1b0eaa43035b7 /jstests/replsets | |
parent | 17d9094752fec7dd29c9eedac9bd7cccb8cf8f6e (diff) | |
download | mongo-f644958702c699d5f463c9b4028956e1a75e23fb.tar.gz |
SERVER-48379 Make ReplSetTest wait for secondaries before checking db hashes
Diffstat (limited to 'jstests/replsets')
-rw-r--r-- | jstests/replsets/replsettest_checks_wait_for_secondaries.js | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/jstests/replsets/replsettest_checks_wait_for_secondaries.js b/jstests/replsets/replsettest_checks_wait_for_secondaries.js new file mode 100644 index 00000000000..861f038b8f1 --- /dev/null +++ b/jstests/replsets/replsettest_checks_wait_for_secondaries.js @@ -0,0 +1,51 @@ +/** + * Tests that ReplSetTest consistency checks, namely checkDBHashesForReplSet and + * checkCollectionCounts, wait for secondaries to have fully transitioned to SECONDARY state before + * attempting data reads. + */ +(function() { +"use strict"; +load("jstests/libs/fail_point_util.js"); + +const testName = jsTestName(); +const dbName = "testdb"; +const collName = "testcoll"; + +const rst = new ReplSetTest({name: testName, nodes: 1}); +rst.startSet(); +rst.initiateWithHighElectionTimeout(); + +const primary = rst.getPrimary(); +const primaryDb = primary.getDB(dbName); +const primaryColl = primaryDb.getCollection(collName); + +assert.commandWorked(primaryColl.insert({"starting": "doc"})); + +jsTestLog("Adding a new node to the replica set"); +const secondaryParams = { + 'failpoint.initialSyncHangBeforeCopyingDatabases': tojson({mode: 'alwaysOn'}), + 'numInitialSyncAttempts': 1, +}; +const secondary = rst.add({rsConfig: {priority: 0}, setParameter: secondaryParams}); +rst.reInitiate(); + +jsTestLog("Waiting for node to reach initial sync"); +assert.commandWorked(secondary.adminCommand({ + waitForFailPoint: "initialSyncHangBeforeCopyingDatabases", + timesEntered: 1, + maxTimeMS: kDefaultWaitForFailPointTimeout +})); + +// Turn off the failpoint and immediately proceeed with collection counts checks. +jsTestLog("Trying checkCollectionCounts"); +assert.commandWorked(secondary.adminCommand( + {configureFailPoint: "initialSyncHangBeforeCopyingDatabases", mode: "off"})); +rst.checkCollectionCounts(); + +// Restart the node so we can try checkReplicatedDBHashes. +rst.stop(1); +rst.start(1, {startClean: true}); + +// stopSet() will call checkReplicatedDBHashes +rst.stopSet(); +})();
\ No newline at end of file |