summaryrefslogtreecommitdiff
path: root/jstests/replsets/drop_databases_two_phase.js
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2018-12-23 12:16:32 -0500
committerBenety Goh <benety@mongodb.com>2018-12-23 12:16:49 -0500
commitf7089e3b12fc79adb583a031da87fed14cc6fc35 (patch)
tree4d6dfbd77d1283b46bc576f217e06cd07a821ba2 /jstests/replsets/drop_databases_two_phase.js
parentbf2b72c0f436f26b9bcc481243c73a39486c34de (diff)
downloadmongo-f7089e3b12fc79adb583a031da87fed14cc6fc35.tar.gz
SERVER-38604 two phase drop tests that use system.drop namespaces check serverStatus() for support before proceeding
Diffstat (limited to 'jstests/replsets/drop_databases_two_phase.js')
-rw-r--r--jstests/replsets/drop_databases_two_phase.js42
1 files changed, 31 insertions, 11 deletions
diff --git a/jstests/replsets/drop_databases_two_phase.js b/jstests/replsets/drop_databases_two_phase.js
index e4f4dac378c..8320e523adf 100644
--- a/jstests/replsets/drop_databases_two_phase.js
+++ b/jstests/replsets/drop_databases_two_phase.js
@@ -17,6 +17,8 @@
(function() {
"use strict";
+ load('jstests/replsets/libs/two_phase_drops.js'); // For TwoPhaseDropCollectionTest.
+
// Returns a list of all collections in a given database. Use 'args' as the
// 'listCollections' command arguments.
function listCollections(database, args) {
@@ -103,13 +105,21 @@
},
'Primary ' + primary.host + ' failed to prepare two phase drop of collection ' +
collToDrop.getFullName());
- var dropPendingCollections = listDropPendingCollections(dbToDrop);
- assert.eq(1,
- dropPendingCollections.length,
- "Collection was not found in the 'system.drop' namespace. " +
- "Full drop-pending collection list: " + tojson(dropPendingCollections));
- jsTestLog('Primary ' + primary.host + ' successfully started two phase drop of collection ' +
- collToDrop.getFullName());
+
+ // 'collToDrop' is no longer visible with its original name. If 'system.drop' two phase drops
+ // are supported by the storage engine, check for the drop-pending namespace using
+ // listCollections.
+ const supportsDropPendingNamespaces =
+ TwoPhaseDropCollectionTest.supportsDropPendingNamespaces(replTest);
+ if (supportsDropPendingNamespaces) {
+ var dropPendingCollections = listDropPendingCollections(dbToDrop);
+ assert.eq(1,
+ dropPendingCollections.length,
+ "Collection was not found in the 'system.drop' namespace. " +
+ "Full drop-pending collection list: " + tojson(dropPendingCollections));
+ jsTestLog('Primary ' + primary.host +
+ ' successfully started two phase drop of collection ' + collToDrop.getFullName());
+ }
// Commands that manipulate the database being dropped or perform destructive catalog operations
// should fail with the DatabaseDropPending error code while the database is in a drop-pending
@@ -118,10 +128,20 @@
dbToDrop.createCollection('collectionToCreateWhileDroppingDatabase'),
ErrorCodes.DatabaseDropPending,
'collection creation should fail while we are in the process of dropping the database');
- assert.commandFailedWithCode(
- dbToDrop.adminCommand('restartCatalog'),
- ErrorCodes.DatabaseDropPending,
- 'restartCatalog should fail if any databases are marked drop-pending');
+
+ // restartCatalog can only detect that a database is in a drop-pending state when 'system.drop'
+ // namespaces are supported. Since 4.2, dropped collections are managed internally by the
+ // storage engine. See serverStatus().
+ if (supportsDropPendingNamespaces) {
+ assert.commandFailedWithCode(
+ dbToDrop.adminCommand('restartCatalog'),
+ ErrorCodes.DatabaseDropPending,
+ 'restartCatalog should fail if any databases are marked drop-pending');
+ } else {
+ // Drop-pending idents are known only to the storage engine and will be ignored by
+ // restartCatalog.
+ assert.commandWorked(dbToDrop.adminCommand('restartCatalog'));
+ }
/**
* DROP DATABASE 'Database' PHASE