diff options
Diffstat (limited to 'jstests/replsets/initial_sync_uuid_not_found.js')
-rw-r--r-- | jstests/replsets/initial_sync_uuid_not_found.js | 103 |
1 files changed, 49 insertions, 54 deletions
diff --git a/jstests/replsets/initial_sync_uuid_not_found.js b/jstests/replsets/initial_sync_uuid_not_found.js index 267f468b0c4..0942ac1f54b 100644 --- a/jstests/replsets/initial_sync_uuid_not_found.js +++ b/jstests/replsets/initial_sync_uuid_not_found.js @@ -5,72 +5,67 @@ * results in an empty result or zero count. */ (function() { - 'use strict'; +'use strict'; - load('jstests/libs/check_log.js'); +load('jstests/libs/check_log.js'); - const basename = 'initial_sync_rename_collection'; +const basename = 'initial_sync_rename_collection'; - jsTestLog('Bring up set'); - const rst = new ReplSetTest( - {name: basename, nodes: [{}, {rsConfig: {priority: 0}}, {rsConfig: {priority: 0}}]}); - rst.startSet(); - rst.initiate(); +jsTestLog('Bring up set'); +const rst = new ReplSetTest( + {name: basename, nodes: [{}, {rsConfig: {priority: 0}}, {rsConfig: {priority: 0}}]}); +rst.startSet(); +rst.initiate(); - const primary = rst.getPrimary(); - const primaryDB = primary.getDB('d'); - const primaryColl = primaryDB.coll; +const primary = rst.getPrimary(); +const primaryDB = primary.getDB('d'); +const primaryColl = primaryDB.coll; - jsTestLog('Create a collection (with a UUID) and insert a document.'); - assert.writeOK(primaryColl.insert({_id: 0})); +jsTestLog('Create a collection (with a UUID) and insert a document.'); +assert.writeOK(primaryColl.insert({_id: 0})); - const collInfo = primaryDB.getCollectionInfos({name: primaryColl.getName()})[0]; - assert(collInfo.info.uuid, - 'newly created collection expected to have a UUID: ' + tojson(collInfo)); +const collInfo = primaryDB.getCollectionInfos({name: primaryColl.getName()})[0]; +assert(collInfo.info.uuid, 'newly created collection expected to have a UUID: ' + tojson(collInfo)); - jsTestLog('Make sure synced'); - rst.awaitReplication(); +jsTestLog('Make sure synced'); +rst.awaitReplication(); - jsTestLog('Resync the secondary enabling failpoint'); - function ResyncWithFailpoint(failpointName, failpointData) { - let setParameter = {numInitialSyncAttempts: 1}; - setParameter['failpoint.' + failpointName] = - tojson({mode: 'alwaysOn', data: failpointData}); - rst.restart(1, {startClean: true, setParameter}); - const secondary = rst.nodes[1]; - assert.eq(primary, rst.getPrimary(), 'Primary changed after reconfig'); +jsTestLog('Resync the secondary enabling failpoint'); +function ResyncWithFailpoint(failpointName, failpointData) { + let setParameter = {numInitialSyncAttempts: 1}; + setParameter['failpoint.' + failpointName] = tojson({mode: 'alwaysOn', data: failpointData}); + rst.restart(1, {startClean: true, setParameter}); + const secondary = rst.nodes[1]; + assert.eq(primary, rst.getPrimary(), 'Primary changed after reconfig'); - jsTestLog('Wait for new node to start cloning'); - secondary.setSlaveOk(); - const secondaryDB = secondary.getDB(primaryDB.getName()); - const secondaryColl = secondaryDB[primaryColl.getName()]; + jsTestLog('Wait for new node to start cloning'); + secondary.setSlaveOk(); + const secondaryDB = secondary.getDB(primaryDB.getName()); + const secondaryColl = secondaryDB[primaryColl.getName()]; - rst.reInitiate(); - checkLog.contains(secondary, 'initial sync - ' + failpointName + ' fail point enabled'); + rst.reInitiate(); + checkLog.contains(secondary, 'initial sync - ' + failpointName + ' fail point enabled'); - jsTestLog('Remove collection on the primary and insert a new document, recreating it.'); - assert(primaryColl.drop()); - assert.writeOK(primaryColl.insert({_id: 0}, {writeConcern: {w: 'majority'}})); - const newCollInfo = primaryDB.getCollectionInfos({name: primaryColl.getName()})[0]; - assert(collInfo.info.uuid, - 'recreated collection expected to have a UUID: ' + tojson(collInfo)); - assert.neq(collInfo.info.uuid, - newCollInfo.info.uuid, - 'recreated collection expected to have different UUID'); + jsTestLog('Remove collection on the primary and insert a new document, recreating it.'); + assert(primaryColl.drop()); + assert.writeOK(primaryColl.insert({_id: 0}, {writeConcern: {w: 'majority'}})); + const newCollInfo = primaryDB.getCollectionInfos({name: primaryColl.getName()})[0]; + assert(collInfo.info.uuid, 'recreated collection expected to have a UUID: ' + tojson(collInfo)); + assert.neq(collInfo.info.uuid, + newCollInfo.info.uuid, + 'recreated collection expected to have different UUID'); - jsTestLog('Disable failpoint and resume initial sync'); - assert.commandWorked( - secondary.adminCommand({configureFailPoint: failpointName, mode: 'off'})); + jsTestLog('Disable failpoint and resume initial sync'); + assert.commandWorked(secondary.adminCommand({configureFailPoint: failpointName, mode: 'off'})); - jsTestLog('Wait for both nodes to be up-to-date'); - rst.awaitSecondaryNodes(); - rst.awaitReplication(); + jsTestLog('Wait for both nodes to be up-to-date'); + rst.awaitSecondaryNodes(); + rst.awaitReplication(); - jsTestLog('Check consistency and shut down replica-set'); - rst.checkReplicatedDataHashes(); - } - ResyncWithFailpoint('initialSyncHangBeforeCollectionClone', - {namespace: primaryColl.getFullName()}); - ResyncWithFailpoint('initialSyncHangAfterListCollections', {database: primaryDB.getName()}); - rst.stopSet(); + jsTestLog('Check consistency and shut down replica-set'); + rst.checkReplicatedDataHashes(); +} +ResyncWithFailpoint('initialSyncHangBeforeCollectionClone', {namespace: primaryColl.getFullName()}); +ResyncWithFailpoint('initialSyncHangAfterListCollections', {database: primaryDB.getName()}); +rst.stopSet(); })(); |