diff options
Diffstat (limited to 'jstests/replsets/drop_collections_two_phase_apply_ops_drop.js')
-rw-r--r-- | jstests/replsets/drop_collections_two_phase_apply_ops_drop.js | 95 |
1 files changed, 48 insertions, 47 deletions
diff --git a/jstests/replsets/drop_collections_two_phase_apply_ops_drop.js b/jstests/replsets/drop_collections_two_phase_apply_ops_drop.js index 8cfbca31166..0d83fc8602b 100644 --- a/jstests/replsets/drop_collections_two_phase_apply_ops_drop.js +++ b/jstests/replsets/drop_collections_two_phase_apply_ops_drop.js @@ -4,61 +4,62 @@ */ (function() { - "use strict"; +"use strict"; - load("jstests/replsets/libs/two_phase_drops.js"); // For TwoPhaseDropCollectionTest. +load("jstests/replsets/libs/two_phase_drops.js"); // For TwoPhaseDropCollectionTest. - // Set up a two phase drop test. - let testName = "drop_collection_two_phase_apply_ops_noop"; - let dbName = testName; - let collName = "collToDrop"; - let twoPhaseDropTest = new TwoPhaseDropCollectionTest(testName, dbName); +// Set up a two phase drop test. +let testName = "drop_collection_two_phase_apply_ops_noop"; +let dbName = testName; +let collName = "collToDrop"; +let twoPhaseDropTest = new TwoPhaseDropCollectionTest(testName, dbName); - // Initialize replica set. - let replTest = twoPhaseDropTest.initReplSet(); +// Initialize replica set. +let replTest = twoPhaseDropTest.initReplSet(); - // Check for 'system.drop' two phase drop support. - if (!twoPhaseDropTest.supportsDropPendingNamespaces()) { - jsTestLog('Drop pending namespaces not supported by storage engine. Skipping test.'); - twoPhaseDropTest.stop(); - return; - } +// Check for 'system.drop' two phase drop support. +if (!twoPhaseDropTest.supportsDropPendingNamespaces()) { + jsTestLog('Drop pending namespaces not supported by storage engine. Skipping test.'); + twoPhaseDropTest.stop(); + return; +} - // Create the collection that will be dropped. - twoPhaseDropTest.createCollection(collName); +// Create the collection that will be dropped. +twoPhaseDropTest.createCollection(collName); - // PREPARE collection drop. - twoPhaseDropTest.prepareDropCollection(collName); +// PREPARE collection drop. +twoPhaseDropTest.prepareDropCollection(collName); - // Drop drop-pending collection using applyOps with system.drop namespace. - const dropPendingColl = twoPhaseDropTest.collectionIsPendingDrop(collName); - const dropPendingCollName = dropPendingColl.name; - const primary = replTest.getPrimary(); - const cmdNs = dbName + '.$cmd'; - const applyOpsCmdWithName = {applyOps: [{op: 'c', ns: cmdNs, o: {drop: dropPendingCollName}}]}; - TwoPhaseDropCollectionTest._testLog( - 'Attempting to drop collection using applyOps with system.drop namespace: ' + - tojson(applyOpsCmdWithName)); - assert.commandWorked(primary.adminCommand(applyOpsCmdWithName)); - assert(twoPhaseDropTest.collectionIsPendingDrop(collName), - 'applyOps using collection name ' + dropPendingCollName + - ' removed drop-pending collection unexpectedly'); +// Drop drop-pending collection using applyOps with system.drop namespace. +const dropPendingColl = twoPhaseDropTest.collectionIsPendingDrop(collName); +const dropPendingCollName = dropPendingColl.name; +const primary = replTest.getPrimary(); +const cmdNs = dbName + '.$cmd'; +const applyOpsCmdWithName = { + applyOps: [{op: 'c', ns: cmdNs, o: {drop: dropPendingCollName}}] +}; +TwoPhaseDropCollectionTest._testLog( + 'Attempting to drop collection using applyOps with system.drop namespace: ' + + tojson(applyOpsCmdWithName)); +assert.commandWorked(primary.adminCommand(applyOpsCmdWithName)); +assert(twoPhaseDropTest.collectionIsPendingDrop(collName), + 'applyOps using collection name ' + dropPendingCollName + + ' removed drop-pending collection unexpectedly'); - // Drop drop-pending collection using applyOps with UUID. - const dropPendingCollUuid = dropPendingColl.info.uuid; - const applyOpsCmdWithUuid = { - applyOps: - [{op: 'c', ns: cmdNs, ui: dropPendingCollUuid, o: {drop: 'ignored_collection_name'}}] - }; - TwoPhaseDropCollectionTest._testLog('Attempting to drop collection using applyOps with UUID: ' + - tojson(applyOpsCmdWithUuid)); - assert.commandWorked(primary.adminCommand(applyOpsCmdWithUuid)); - assert(twoPhaseDropTest.collectionIsPendingDrop(collName), - 'applyOps using UUID ' + dropPendingCollUuid + - ' removed drop-pending collection unexpectedly'); +// Drop drop-pending collection using applyOps with UUID. +const dropPendingCollUuid = dropPendingColl.info.uuid; +const applyOpsCmdWithUuid = { + applyOps: [{op: 'c', ns: cmdNs, ui: dropPendingCollUuid, o: {drop: 'ignored_collection_name'}}] +}; +TwoPhaseDropCollectionTest._testLog('Attempting to drop collection using applyOps with UUID: ' + + tojson(applyOpsCmdWithUuid)); +assert.commandWorked(primary.adminCommand(applyOpsCmdWithUuid)); +assert( + twoPhaseDropTest.collectionIsPendingDrop(collName), + 'applyOps using UUID ' + dropPendingCollUuid + ' removed drop-pending collection unexpectedly'); - // COMMIT collection drop. - twoPhaseDropTest.commitDropCollection(collName); +// COMMIT collection drop. +twoPhaseDropTest.commitDropCollection(collName); - twoPhaseDropTest.stop(); +twoPhaseDropTest.stop(); }()); |