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/disk/wt_repair_corrupt_files.js | |
parent | 1e46b5049003f427047e723ea5fab15b5a9253ca (diff) | |
download | mongo-134a4083953270e8a11430395357fb70a29047ad.tar.gz |
SERVER-41772 Apply clang-format 7.0.1 to the codebase
Diffstat (limited to 'jstests/disk/wt_repair_corrupt_files.js')
-rw-r--r-- | jstests/disk/wt_repair_corrupt_files.js | 152 |
1 files changed, 76 insertions, 76 deletions
diff --git a/jstests/disk/wt_repair_corrupt_files.js b/jstests/disk/wt_repair_corrupt_files.js index c19a6d672d1..839dda32ab7 100644 --- a/jstests/disk/wt_repair_corrupt_files.js +++ b/jstests/disk/wt_repair_corrupt_files.js @@ -7,109 +7,109 @@ (function() { - load('jstests/disk/libs/wt_file_helper.js'); +load('jstests/disk/libs/wt_file_helper.js'); - const baseName = "wt_repair_corrupt_files"; - const collName = "test"; - const dbpath = MongoRunner.dataPath + baseName + "/"; +const baseName = "wt_repair_corrupt_files"; +const collName = "test"; +const dbpath = MongoRunner.dataPath + baseName + "/"; + +/** + * Run the test by supplying additional paramters to MongoRunner.runMongod with 'mongodOptions'. + */ +let runTest = function(mongodOptions) { + resetDbpath(dbpath); + jsTestLog("Running test with args: " + tojson(mongodOptions)); /** - * Run the test by supplying additional paramters to MongoRunner.runMongod with 'mongodOptions'. + * Test 1. Create a collection, corrupt its .wt file in an unrecoverable way, run repair. + * Verify that repair succeeds at rebuilding it. An empty collection should be visible on + * normal startup. */ - let runTest = function(mongodOptions) { - resetDbpath(dbpath); - jsTestLog("Running test with args: " + tojson(mongodOptions)); - - /** - * Test 1. Create a collection, corrupt its .wt file in an unrecoverable way, run repair. - * Verify that repair succeeds at rebuilding it. An empty collection should be visible on - * normal startup. - */ - let mongod = startMongodOnExistingPath(dbpath, mongodOptions); - let testColl = mongod.getDB(baseName)[collName]; + let mongod = startMongodOnExistingPath(dbpath, mongodOptions); + let testColl = mongod.getDB(baseName)[collName]; - const doc = {a: 1}; - assert.commandWorked(testColl.insert(doc)); + const doc = {a: 1}; + assert.commandWorked(testColl.insert(doc)); - let testCollUri = getUriForColl(testColl); - let testCollFile = dbpath + testCollUri + ".wt"; + let testCollUri = getUriForColl(testColl); + let testCollFile = dbpath + testCollUri + ".wt"; - MongoRunner.stopMongod(mongod); + MongoRunner.stopMongod(mongod); - jsTestLog("corrupting collection file: " + testCollFile); - corruptFile(testCollFile); + jsTestLog("corrupting collection file: " + testCollFile); + corruptFile(testCollFile); - assertRepairSucceeds(dbpath, mongod.port, mongodOptions); + assertRepairSucceeds(dbpath, mongod.port, mongodOptions); - mongod = startMongodOnExistingPath(dbpath, mongodOptions); - testColl = mongod.getDB(baseName)[collName]; + mongod = startMongodOnExistingPath(dbpath, mongodOptions); + testColl = mongod.getDB(baseName)[collName]; - assert.eq(testCollUri, getUriForColl(testColl)); - assert.eq(testColl.find({}).itcount(), 0); - assert.eq(testColl.count(), 0); + assert.eq(testCollUri, getUriForColl(testColl)); + assert.eq(testColl.find({}).itcount(), 0); + assert.eq(testColl.count(), 0); - /** - * Test 2. Corrupt an index file in an unrecoverable way. Verify that repair rebuilds and - * allows MongoDB to start up normally. - */ + /** + * Test 2. Corrupt an index file in an unrecoverable way. Verify that repair rebuilds and + * allows MongoDB to start up normally. + */ - assert.commandWorked(testColl.insert(doc)); + assert.commandWorked(testColl.insert(doc)); - const indexName = "a_1"; - assert.commandWorked(testColl.createIndex({a: 1}, {name: indexName})); - assertQueryUsesIndex(testColl, doc, indexName); + const indexName = "a_1"; + assert.commandWorked(testColl.createIndex({a: 1}, {name: indexName})); + assertQueryUsesIndex(testColl, doc, indexName); - let indexUri = getUriForIndex(testColl, indexName); + let indexUri = getUriForIndex(testColl, indexName); - MongoRunner.stopMongod(mongod); + MongoRunner.stopMongod(mongod); - let indexFile = dbpath + indexUri + ".wt"; - jsTestLog("corrupting index file: " + indexFile); - corruptFile(indexFile); + let indexFile = dbpath + indexUri + ".wt"; + jsTestLog("corrupting index file: " + indexFile); + corruptFile(indexFile); - assertRepairSucceeds(dbpath, mongod.port, mongodOptions); - mongod = startMongodOnExistingPath(dbpath, mongodOptions); - testColl = mongod.getDB(baseName)[collName]; + assertRepairSucceeds(dbpath, mongod.port, mongodOptions); + mongod = startMongodOnExistingPath(dbpath, mongodOptions); + testColl = mongod.getDB(baseName)[collName]; - // Repair creates new idents. - assert.neq(indexUri, getUriForIndex(testColl, indexName)); + // Repair creates new idents. + assert.neq(indexUri, getUriForIndex(testColl, indexName)); - assertQueryUsesIndex(testColl, doc, indexName); - assert.eq(testColl.find(doc).itcount(), 1); - assert.eq(testColl.count(), 1); + assertQueryUsesIndex(testColl, doc, indexName); + assert.eq(testColl.find(doc).itcount(), 1); + assert.eq(testColl.count(), 1); - MongoRunner.stopMongod(mongod); + MongoRunner.stopMongod(mongod); - /** - * Test 3. Corrupt the _mdb_catalog in an unrecoverable way. Verify that repair suceeds - * in creating an empty catalog and recovers the orphaned testColl, which will still be - * accessible in the 'local.orphan-' namespace. - */ + /** + * Test 3. Corrupt the _mdb_catalog in an unrecoverable way. Verify that repair suceeds + * in creating an empty catalog and recovers the orphaned testColl, which will still be + * accessible in the 'local.orphan-' namespace. + */ - let mdbCatalogFile = dbpath + "_mdb_catalog.wt"; - jsTestLog("corrupting catalog file: " + mdbCatalogFile); - corruptFile(mdbCatalogFile); + let mdbCatalogFile = dbpath + "_mdb_catalog.wt"; + jsTestLog("corrupting catalog file: " + mdbCatalogFile); + corruptFile(mdbCatalogFile); - assertRepairSucceeds(dbpath, mongod.port, mongodOptions); + assertRepairSucceeds(dbpath, mongod.port, mongodOptions); - mongod = startMongodOnExistingPath(dbpath, mongodOptions); - testColl = mongod.getDB(baseName)[collName]; - assert.isnull(testColl.exists()); - assert.eq(testColl.find(doc).itcount(), 0); - assert.eq(testColl.count(), 0); + mongod = startMongodOnExistingPath(dbpath, mongodOptions); + testColl = mongod.getDB(baseName)[collName]; + assert.isnull(testColl.exists()); + assert.eq(testColl.find(doc).itcount(), 0); + assert.eq(testColl.count(), 0); - // Ensure the collection orphan was created with the existing document. - const orphanCollName = "orphan." + testCollUri.replace(/-/g, "_"); - let orphanColl = mongod.getDB('local').getCollection(orphanCollName); - assert(orphanColl.exists()); - assert.eq(orphanColl.find(doc).itcount(), 1); - assert.eq(orphanColl.count(), 1); + // Ensure the collection orphan was created with the existing document. + const orphanCollName = "orphan." + testCollUri.replace(/-/g, "_"); + let orphanColl = mongod.getDB('local').getCollection(orphanCollName); + assert(orphanColl.exists()); + assert.eq(orphanColl.find(doc).itcount(), 1); + assert.eq(orphanColl.count(), 1); - MongoRunner.stopMongod(mongod); - }; + MongoRunner.stopMongod(mongod); +}; - runTest({}); - runTest({directoryperdb: ""}); - runTest({wiredTigerDirectoryForIndexes: ""}); +runTest({}); +runTest({directoryperdb: ""}); +runTest({wiredTigerDirectoryForIndexes: ""}); })(); |