diff options
author | clang-format-7.0.1 <adam.martin@10gen.com> | 2019-07-26 18:20:35 -0400 |
---|---|---|
committer | ADAM David Alan Martin <adam.martin@10gen.com> | 2019-07-27 11:02:23 -0400 |
commit | 134a4083953270e8a11430395357fb70a29047ad (patch) | |
tree | dd428e1230e31d92b20b393dfdc17ffe7fa79cb6 /jstests/replsets/rollback_drop_database.js | |
parent | 1e46b5049003f427047e723ea5fab15b5a9253ca (diff) | |
download | mongo-134a4083953270e8a11430395357fb70a29047ad.tar.gz |
SERVER-41772 Apply clang-format 7.0.1 to the codebase
Diffstat (limited to 'jstests/replsets/rollback_drop_database.js')
-rw-r--r-- | jstests/replsets/rollback_drop_database.js | 109 |
1 files changed, 54 insertions, 55 deletions
diff --git a/jstests/replsets/rollback_drop_database.js b/jstests/replsets/rollback_drop_database.js index 70fb8561140..aa783cc9dd3 100644 --- a/jstests/replsets/rollback_drop_database.js +++ b/jstests/replsets/rollback_drop_database.js @@ -1,73 +1,72 @@ /* -* Test that the server is able to roll back a 'dropDatabase' entry correctly. This test creates -* a collection, then executes a 'dropDatabase' command, partitioning the primary such that the -* final 'dropDatabase' oplog entry is not replicated. The test then forces rollback of that entry. -* -* The 'dropDatabase' command drops each collection, ensures that the last drop is committed, -* and only then logs a 'dropDatabase' oplog entry. This is therefore the only entry that could -* get rolled back. -*/ + * Test that the server is able to roll back a 'dropDatabase' entry correctly. This test creates + * a collection, then executes a 'dropDatabase' command, partitioning the primary such that the + * final 'dropDatabase' oplog entry is not replicated. The test then forces rollback of that entry. + * + * The 'dropDatabase' command drops each collection, ensures that the last drop is committed, + * and only then logs a 'dropDatabase' oplog entry. This is therefore the only entry that could + * get rolled back. + */ (function() { - load("jstests/replsets/libs/rollback_test.js"); - load("jstests/libs/check_log.js"); +load("jstests/replsets/libs/rollback_test.js"); +load("jstests/libs/check_log.js"); - const testName = "rollback_drop_database"; - const oldDbName = "oldDatabase"; - const newDbName = "newDatabase"; +const testName = "rollback_drop_database"; +const oldDbName = "oldDatabase"; +const newDbName = "newDatabase"; - let rollbackTest = new RollbackTest(testName); - let rollbackNode = rollbackTest.getPrimary(); - let syncSourceNode = rollbackTest.getSecondary(); +let rollbackTest = new RollbackTest(testName); +let rollbackNode = rollbackTest.getPrimary(); +let syncSourceNode = rollbackTest.getSecondary(); - // Perform initial insert (common operation). - assert.writeOK(rollbackNode.getDB(oldDbName)["beforeRollback"].insert({"num": 1})); +// Perform initial insert (common operation). +assert.writeOK(rollbackNode.getDB(oldDbName)["beforeRollback"].insert({"num": 1})); - // Set a failpoint on the original primary, so that it blocks after it commits the last - // 'dropCollection' entry but before the 'dropDatabase' entry is logged. - assert.commandWorked(rollbackNode.adminCommand( - {configureFailPoint: "dropDatabaseHangBeforeLog", mode: "alwaysOn"})); +// Set a failpoint on the original primary, so that it blocks after it commits the last +// 'dropCollection' entry but before the 'dropDatabase' entry is logged. +assert.commandWorked( + rollbackNode.adminCommand({configureFailPoint: "dropDatabaseHangBeforeLog", mode: "alwaysOn"})); - // Issue a 'dropDatabase' command. - let dropDatabaseFn = function() { - const rollbackDb = "oldDatabase"; - var primary = db.getMongo(); - jsTestLog("Dropping database " + rollbackDb + " on primary node " + primary.host); - var dbToDrop = db.getSiblingDB(rollbackDb); - assert.commandWorked(dbToDrop.dropDatabase({w: 1})); - }; - let waitForDropDatabaseToFinish = startParallelShell(dropDatabaseFn, rollbackNode.port); +// Issue a 'dropDatabase' command. +let dropDatabaseFn = function() { + const rollbackDb = "oldDatabase"; + var primary = db.getMongo(); + jsTestLog("Dropping database " + rollbackDb + " on primary node " + primary.host); + var dbToDrop = db.getSiblingDB(rollbackDb); + assert.commandWorked(dbToDrop.dropDatabase({w: 1})); +}; +let waitForDropDatabaseToFinish = startParallelShell(dropDatabaseFn, rollbackNode.port); - // Ensure that we've hit the failpoint before moving on. - checkLog.contains(rollbackNode, "dropDatabase - fail point dropDatabaseHangBeforeLog enabled"); +// Ensure that we've hit the failpoint before moving on. +checkLog.contains(rollbackNode, "dropDatabase - fail point dropDatabaseHangBeforeLog enabled"); - // Wait for the secondary to finish dropping the collection (the last replicated entry). - // We use the default 10-minute timeout for this. - assert.soon(function() { - let res = syncSourceNode.getDB(oldDbName).getCollectionNames().includes("beforeRollback"); - return !res; - }, "Sync source did not finish dropping collection beforeRollback", 10 * 60 * 1000); +// Wait for the secondary to finish dropping the collection (the last replicated entry). +// We use the default 10-minute timeout for this. +assert.soon(function() { + let res = syncSourceNode.getDB(oldDbName).getCollectionNames().includes("beforeRollback"); + return !res; +}, "Sync source did not finish dropping collection beforeRollback", 10 * 60 * 1000); - rollbackTest.transitionToRollbackOperations(); +rollbackTest.transitionToRollbackOperations(); - // Allow the final 'dropDatabase' entry to be logged on the now isolated primary. - // This is the rollback node's divergent oplog entry. - assert.commandWorked( - rollbackNode.adminCommand({configureFailPoint: "dropDatabaseHangBeforeLog", mode: "off"})); - waitForDropDatabaseToFinish(); - assert.eq(false, rollbackNode.getDB(oldDbName).getCollectionNames().includes("beforeRollback")); - jsTestLog("Database " + oldDbName + " successfully dropped on primary node " + - rollbackNode.host); +// Allow the final 'dropDatabase' entry to be logged on the now isolated primary. +// This is the rollback node's divergent oplog entry. +assert.commandWorked( + rollbackNode.adminCommand({configureFailPoint: "dropDatabaseHangBeforeLog", mode: "off"})); +waitForDropDatabaseToFinish(); +assert.eq(false, rollbackNode.getDB(oldDbName).getCollectionNames().includes("beforeRollback")); +jsTestLog("Database " + oldDbName + " successfully dropped on primary node " + rollbackNode.host); - rollbackTest.transitionToSyncSourceOperationsBeforeRollback(); +rollbackTest.transitionToSyncSourceOperationsBeforeRollback(); - // Perform an insert on another database while interfacing with the new primary. - // This is the sync source's divergent oplog entry. - assert.writeOK(syncSourceNode.getDB(newDbName)["afterRollback"].insert({"num": 2})); +// Perform an insert on another database while interfacing with the new primary. +// This is the sync source's divergent oplog entry. +assert.writeOK(syncSourceNode.getDB(newDbName)["afterRollback"].insert({"num": 2})); - rollbackTest.transitionToSyncSourceOperationsDuringRollback(); - rollbackTest.transitionToSteadyStateOperations(); +rollbackTest.transitionToSyncSourceOperationsDuringRollback(); +rollbackTest.transitionToSteadyStateOperations(); - rollbackTest.stop(); +rollbackTest.stop(); })(); |