diff options
author | Jonathan Abrahams <jonathan@mongodb.com> | 2016-03-09 12:27:20 -0500 |
---|---|---|
committer | Jonathan Abrahams <jonathan@mongodb.com> | 2016-03-09 12:27:56 -0500 |
commit | 8c5ff5834ab1f61e68b7839cd99c3de1f87c2121 (patch) | |
tree | ef4d91cc230300a6a48eeeac696ca15df6db1212 /jstests/disk | |
parent | 0875be78b405016736ff42e3a50166be7561c2f8 (diff) | |
download | mongo-8c5ff5834ab1f61e68b7839cd99c3de1f87c2121.tar.gz |
SERVER-22468 Format JS code with approved style in jstests/
Diffstat (limited to 'jstests/disk')
-rw-r--r-- | jstests/disk/datafile_options.js | 38 | ||||
-rw-r--r-- | jstests/disk/dbNoCreate.js | 14 | ||||
-rw-r--r-- | jstests/disk/directoryperdb.js | 126 | ||||
-rw-r--r-- | jstests/disk/diskfull.js | 4 | ||||
-rw-r--r-- | jstests/disk/filesize.js | 13 | ||||
-rw-r--r-- | jstests/disk/index_options.js | 36 | ||||
-rw-r--r-- | jstests/disk/killall.js | 27 | ||||
-rw-r--r-- | jstests/disk/newcollection.js | 15 | ||||
-rw-r--r-- | jstests/disk/preallocate.js | 26 | ||||
-rw-r--r-- | jstests/disk/preallocate2.js | 10 | ||||
-rw-r--r-- | jstests/disk/preallocate_directoryperdb.js | 39 | ||||
-rw-r--r-- | jstests/disk/quota.js | 46 | ||||
-rw-r--r-- | jstests/disk/quota2.js | 47 | ||||
-rw-r--r-- | jstests/disk/quota3.js | 27 | ||||
-rw-r--r-- | jstests/disk/repair.js | 46 | ||||
-rw-r--r-- | jstests/disk/repair2.js | 113 | ||||
-rw-r--r-- | jstests/disk/repair3.js | 55 | ||||
-rw-r--r-- | jstests/disk/repair4.js | 40 | ||||
-rw-r--r-- | jstests/disk/repair5.js | 42 | ||||
-rw-r--r-- | jstests/disk/too_many_fds.js | 13 |
20 files changed, 381 insertions, 396 deletions
diff --git a/jstests/disk/datafile_options.js b/jstests/disk/datafile_options.js index 62d4b137311..a7639c43d7d 100644 --- a/jstests/disk/datafile_options.js +++ b/jstests/disk/datafile_options.js @@ -4,51 +4,35 @@ load('jstests/libs/command_line/test_parsed_options.js'); jsTest.log("Testing \"noprealloc\" command line option"); var expectedResult = { - "parsed" : { - "storage" : { - "mmapv1" : { - "preallocDataFiles" : false - } - } - } + "parsed": {"storage": {"mmapv1": {"preallocDataFiles": false}}} }; -testGetCmdLineOptsMongod({ noprealloc : "" }, expectedResult); +testGetCmdLineOptsMongod({noprealloc: ""}, expectedResult); jsTest.log("Testing \"storage.mmapv1.preallocDataFiles\" config file option"); expectedResult = { - "parsed" : { - "config" : "jstests/libs/config_files/enable_prealloc.json", - "storage" : { - "mmapv1" : { - "preallocDataFiles" : true - } - } + "parsed": { + "config": "jstests/libs/config_files/enable_prealloc.json", + "storage": {"mmapv1": {"preallocDataFiles": true}} } }; -testGetCmdLineOptsMongod({ config : "jstests/libs/config_files/enable_prealloc.json" }, +testGetCmdLineOptsMongod({config: "jstests/libs/config_files/enable_prealloc.json"}, expectedResult); jsTest.log("Testing with no explicit data file option setting"); expectedResult = { - "parsed" : { - "storage" : { } - } + "parsed": {"storage": {}} }; testGetCmdLineOptsMongod({}, expectedResult); // Test that we preserve switches explicitly set to false in config files. See SERVER-13439. jsTest.log("Testing explicitly disabled \"noprealloc\" config file option"); expectedResult = { - "parsed" : { - "config" : "jstests/libs/config_files/disable_noprealloc.ini", - "storage" : { - "mmapv1" : { - "preallocDataFiles" : true - } - } + "parsed": { + "config": "jstests/libs/config_files/disable_noprealloc.ini", + "storage": {"mmapv1": {"preallocDataFiles": true}} } }; -testGetCmdLineOptsMongod({ config : "jstests/libs/config_files/disable_noprealloc.ini" }, +testGetCmdLineOptsMongod({config: "jstests/libs/config_files/disable_noprealloc.ini"}, expectedResult); print(baseName + " succeeded."); diff --git a/jstests/disk/dbNoCreate.js b/jstests/disk/dbNoCreate.js index f365e0730e9..f3498fcedb4 100644 --- a/jstests/disk/dbNoCreate.js +++ b/jstests/disk/dbNoCreate.js @@ -2,16 +2,16 @@ var baseName = "jstests_dbNoCreate"; var m = MongoRunner.runMongod({}); -var t = m.getDB( baseName ).t; +var t = m.getDB(baseName).t; -assert.eq( 0, t.find().toArray().length ); +assert.eq(0, t.find().toArray().length); t.remove({}); -t.update( {}, { a:1 } ); +t.update({}, {a: 1}); t.drop(); MongoRunner.stopMongod(m); -m = MongoRunner.runMongod({restart:true, cleanData:false, dbpath: m.dbpath}); -assert.eq( -1, - m.getDBNames().indexOf( baseName ), - "found " + baseName + " in " + tojson(m.getDBNames())); +m = MongoRunner.runMongod({restart: true, cleanData: false, dbpath: m.dbpath}); +assert.eq(-1, + m.getDBNames().indexOf(baseName), + "found " + baseName + " in " + tojson(m.getDBNames())); diff --git a/jstests/disk/directoryperdb.js b/jstests/disk/directoryperdb.js index 9587908355f..3c889cb5b1f 100644 --- a/jstests/disk/directoryperdb.js +++ b/jstests/disk/directoryperdb.js @@ -5,86 +5,83 @@ var storageEngine = db.serverStatus().storageEngine.name; // The pattern which matches the names of database files var dbFileMatcher; -if ( storageEngine == "mmapv1" ) { +if (storageEngine == "mmapv1") { // Matches mmapv1 *.ns and *.0, *.1, etc files. dbFileMatcher = /\.(ns|\d+)$/; -} else if ( storageEngine == "wiredTiger" ) { +} else if (storageEngine == "wiredTiger") { // Matches wiredTiger collection-*.wt and index-*.wt files dbFileMatcher = /(collection|index)-.+\.wt$/; } else { - assert( false, "This test must be run against mmapv1 or wiredTiger" ); + assert(false, "This test must be run against mmapv1 or wiredTiger"); } // Set up helper functions. assertDocumentCount = function(db, count) { - assert.eq( count, db[ baseName ].count() , - "Expected " + count + " documents in " + db._name + "." + baseName + ". " + - "Found: " + tojson( db[ baseName ].find().toArray() ) ); + assert.eq(count, + db[baseName].count(), + "Expected " + count + " documents in " + db._name + "." + baseName + ". " + + "Found: " + tojson(db[baseName].find().toArray())); }; - -checkDBFilesInDBDirectory = function( db ) { - db.adminCommand( { fsync : 1 } ); +checkDBFilesInDBDirectory = function(db) { + db.adminCommand({fsync: 1}); var dir = dbpath + db._name; - files = listFiles( dir ); + files = listFiles(dir); var fileCount = 0; - for( f in files ) { - if ( files[ f ].isDirectory ) + for (f in files) { + if (files[f].isDirectory) continue; fileCount += 1; - assert( dbFileMatcher.test( files[ f ].name ), - "In directory:" + dir + " found unexpected file: " + files[ f ].name ); + assert(dbFileMatcher.test(files[f].name), + "In directory:" + dir + " found unexpected file: " + files[f].name); } - assert( fileCount > 0, "Expected more than zero nondirectory files in database directory" ); + assert(fileCount > 0, "Expected more than zero nondirectory files in database directory"); }; -checkDBDirectoryNonexistent = function( db ) { - db.adminCommand( { fsync : 1 } ); +checkDBDirectoryNonexistent = function(db) { + db.adminCommand({fsync: 1}); - var files = listFiles( dbpath ); + var files = listFiles(dbpath); // Check that there are no files in the toplevel dbpath. - for ( f in files ) { - if ( !files[ f ].isDirectory ) { - assert( !dbFileMatcher.test( files[ f ].name ), - "Database file" + files[ f ].name + - " exists in dbpath after deleting all non-directoryperdb databases"); + for (f in files) { + if (!files[f].isDirectory) { + assert(!dbFileMatcher.test(files[f].name), + "Database file" + files[f].name + + " exists in dbpath after deleting all non-directoryperdb databases"); } } // Check db directories to ensure db files in them have been destroyed. // mmapv1 removes the database directory, pending SERVER-1379. - if ( storageEngine == "mmapv1" ) { - var files = listFiles( dbpath ); + if (storageEngine == "mmapv1") { + var files = listFiles(dbpath); var fileNotFound = true; - for ( f in files ) { - assert( files[ f ].name != db._name, - "Directory " + db._name + " still exists" ); + for (f in files) { + assert(files[f].name != db._name, "Directory " + db._name + " still exists"); } - } else if ( storageEngine == "wiredTiger" ) { - var files = listFiles( dbpath + db._name ); - assert.eq( files.length, 0, - "Files left behind in database directory" ); + } else if (storageEngine == "wiredTiger") { + var files = listFiles(dbpath + db._name); + assert.eq(files.length, 0, "Files left behind in database directory"); } }; // Start the directoryperdb instance of mongod. -var m = MongoRunner.runMongod( { storageEngine : storageEngine, dbpath : dbpath, - directoryperdb : "" } ); +var m = MongoRunner.runMongod({storageEngine: storageEngine, dbpath: dbpath, directoryperdb: ""}); // Check that the 'local' db has allocated data. -var localDb = m.getDB( "local" ); -checkDBFilesInDBDirectory( localDb ); +var localDb = m.getDB("local"); +checkDBFilesInDBDirectory(localDb); // Create database with directoryperdb. -var dbBase = m.getDB( baseName ); -dbBase[ baseName ].insert( {} ); -assertDocumentCount( dbBase, 1 ); -checkDBFilesInDBDirectory( dbBase ); +var dbBase = m.getDB(baseName); +dbBase[baseName].insert({}); +assertDocumentCount(dbBase, 1); +checkDBFilesInDBDirectory(dbBase); // Drop a database created with directoryperdb. -assert.commandWorked( dbBase.runCommand( { dropDatabase : 1 } ) ); -assertDocumentCount( dbBase, 0 ); -checkDBDirectoryNonexistent( dbBase ); +assert.commandWorked(dbBase.runCommand({dropDatabase: 1})); +assertDocumentCount(dbBase, 0); +checkDBDirectoryNonexistent(dbBase); // It should be impossible to create a database named "journal" with directoryperdb, as that // directory exists. This test has been disabled until SERVER-2460 is resolved. @@ -95,42 +92,41 @@ assert.writeError(db[ "journal" ].insert( {} )); // Using WiredTiger, it should be impossible to create a database named "WiredTiger" with // directoryperdb, as that file is created by the WiredTiger storageEngine. -if ( storageEngine == "wiredTiger" ) { - var dbW = m.getDB( "WiredTiger" ); - assert.writeError( dbW[ baseName ].insert( {} ) ); +if (storageEngine == "wiredTiger") { + var dbW = m.getDB("WiredTiger"); + assert.writeError(dbW[baseName].insert({})); } // Create a database named 'a' repeated 63 times. -var dbNameAA = Array( 64 ).join( 'a' ); -var dbAA = m.getDB( dbNameAA ); -assert.writeOK( dbAA[ baseName ].insert( {} ) ); -assertDocumentCount( dbAA, 1 ); -checkDBFilesInDBDirectory( dbAA ); +var dbNameAA = Array(64).join('a'); +var dbAA = m.getDB(dbNameAA); +assert.writeOK(dbAA[baseName].insert({})); +assertDocumentCount(dbAA, 1); +checkDBFilesInDBDirectory(dbAA); // Create a database named '&'. -var dbAnd = m.getDB( '&' ); -assert.writeOK( dbAnd[ baseName ].insert( {} ) ); -assertDocumentCount( dbAnd, 1 ); -checkDBFilesInDBDirectory( dbAnd ); - +var dbAnd = m.getDB('&'); +assert.writeOK(dbAnd[baseName].insert({})); +assertDocumentCount(dbAnd, 1); +checkDBFilesInDBDirectory(dbAnd); // Unicode directoryperdb databases do not work on Windows. // Disabled until https://jira.mongodb.org/browse/SERVER-16725 // is resolved. -if ( !_isWindows() ) { +if (!_isWindows()) { // Create a database named '処'. var dbNameU = '処'; - var dbU = m.getDB( dbNameU ); - assert.writeOK( dbU[ baseName ].insert( {} ) ); - assertDocumentCount( dbU, 1 ); - checkDBFilesInDBDirectory( dbU ); + var dbU = m.getDB(dbNameU); + assert.writeOK(dbU[baseName].insert({})); + assertDocumentCount(dbU, 1); + checkDBFilesInDBDirectory(dbU); // Create a database named '処' repeated 21 times. var dbNameUU = Array(22).join('処'); - var dbUU = m.getDB( dbNameUU ); - assert.writeOK( dbUU[ baseName ].insert( {} ) ); - assertDocumentCount( dbUU, 1 ); - checkDBFilesInDBDirectory( dbUU ); + var dbUU = m.getDB(dbNameUU); + assert.writeOK(dbUU[baseName].insert({})); + assertDocumentCount(dbUU, 1); + checkDBFilesInDBDirectory(dbUU); } print("SUCCESS directoryperdb.js"); diff --git a/jstests/disk/diskfull.js b/jstests/disk/diskfull.js index 6bd086080eb..cf24d4468d3 100644 --- a/jstests/disk/diskfull.js +++ b/jstests/disk/diskfull.js @@ -4,9 +4,9 @@ assert.commandWorked(db.adminCommand({configureFailPoint: "allocateDiskFull", mo var d = db.getSisterDB("DiskFullTestDB"); var c = d.getCollection("DiskFullTestCollection"); -var writeError1 = c.insert({ a : 6 }).getWriteError(); +var writeError1 = c.insert({a: 6}).getWriteError(); assert.eq(12520, writeError1.code); // All subsequent requests should fail -var writeError2 = c.insert({ a : 6 }).getWriteError(); +var writeError2 = c.insert({a: 6}).getWriteError(); assert.eq(12520, writeError2.code); diff --git a/jstests/disk/filesize.js b/jstests/disk/filesize.js index 1f2da5db80e..954139c25fc 100644 --- a/jstests/disk/filesize.js +++ b/jstests/disk/filesize.js @@ -4,7 +4,7 @@ var baseName = "filesize"; // Start mongod with --smallfiles var m = MongoRunner.runMongod({nojournal: "", smallfiles: ""}); -var db = m.getDB( baseName ); +var db = m.getDB(baseName); // Skip on 32 bits, since 32-bit servers don't warn about small files if (db.serverBuildInfo().bits == 32) { @@ -20,21 +20,20 @@ if (db.serverBuildInfo().bits == 32) { nojournal: "", }); - db = m.getDB( baseName ); - var log = db.adminCommand( { getLog : "global" } ).log; + db = m.getDB(baseName); + var log = db.adminCommand({getLog: "global"}).log; // Find log message like: // "openExisting file size 16777216 but // mmapv1GlobalOptions.smallfiles=false: /data/db/filesize/local.0" var found = false, logline = ''; - for ( i=log.length - 1; i>= 0; i-- ) { + for (i = log.length - 1; i >= 0; i--) { logline = log[i]; - if ( logline.indexOf( "openExisting file" ) >= 0 - && logline.indexOf( "local.0" ) >= 0 ) { + if (logline.indexOf("openExisting file") >= 0 && logline.indexOf("local.0") >= 0) { found = true; break; } } - assert( found ); + assert(found); } diff --git a/jstests/disk/index_options.js b/jstests/disk/index_options.js index d8a3b267333..68710de75a1 100644 --- a/jstests/disk/index_options.js +++ b/jstests/disk/index_options.js @@ -4,44 +4,34 @@ load('jstests/libs/command_line/test_parsed_options.js'); jsTest.log("Testing \"noIndexBuildRetry\" command line option"); var expectedResult = { - "parsed" : { - "storage" : { - "indexBuildRetry" : false - } - } + "parsed": {"storage": {"indexBuildRetry": false}} }; -testGetCmdLineOptsMongod({ noIndexBuildRetry : "" }, expectedResult); +testGetCmdLineOptsMongod({noIndexBuildRetry: ""}, expectedResult); jsTest.log("Testing \"storage.indexBuildRetry\" config file option"); expectedResult = { - "parsed" : { - "config" : "jstests/libs/config_files/enable_indexbuildretry.json", - "storage" : { - "indexBuildRetry" : true - } + "parsed": { + "config": "jstests/libs/config_files/enable_indexbuildretry.json", + "storage": {"indexBuildRetry": true} } }; -testGetCmdLineOptsMongod({ config : "jstests/libs/config_files/enable_indexbuildretry.json" }, - expectedResult); +testGetCmdLineOptsMongod({config: "jstests/libs/config_files/enable_indexbuildretry.json"}, + expectedResult); jsTest.log("Testing with no explicit index option setting"); expectedResult = { - "parsed" : { - "storage" : { } - } + "parsed": {"storage": {}} }; testGetCmdLineOptsMongod({}, expectedResult); jsTest.log("Testing explicitly disabled \"noIndexBuildRetry\" config file option"); expectedResult = { - "parsed" : { - "config" : "jstests/libs/config_files/disable_noindexbuildretry.ini", - "storage" : { - "indexBuildRetry" : true - } + "parsed": { + "config": "jstests/libs/config_files/disable_noindexbuildretry.ini", + "storage": {"indexBuildRetry": true} } }; -testGetCmdLineOptsMongod({ config : "jstests/libs/config_files/disable_noindexbuildretry.ini" }, - expectedResult); +testGetCmdLineOptsMongod({config: "jstests/libs/config_files/disable_noindexbuildretry.ini"}, + expectedResult); print(baseName + " succeeded."); diff --git a/jstests/disk/killall.js b/jstests/disk/killall.js index beb3e99e778..675c2a42c5f 100644 --- a/jstests/disk/killall.js +++ b/jstests/disk/killall.js @@ -10,14 +10,13 @@ var baseName = "jstests_disk_killall"; var dbpath = MongoRunner.dataPath + baseName; var mongod = MongoRunner.runMongod({dbpath: dbpath}); -var db = mongod.getDB( "test" ); -var collection = db.getCollection( baseName ); +var db = mongod.getDB("test"); +var collection = db.getCollection(baseName); assert.writeOK(collection.insert({})); var awaitShell = startParallelShell( - "db." + baseName + ".count( { $where: function() { while( 1 ) { ; } } } )", - mongod.port); -sleep( 1000 ); + "db." + baseName + ".count( { $where: function() { while( 1 ) { ; } } } )", mongod.port); +sleep(1000); /** * 0 == mongod's exit code on Windows, or when it receives TERM, HUP or INT signals. On UNIX @@ -33,16 +32,12 @@ assert.eq(0, exitCode, "got unexpected exitCode"); exitCode = awaitShell({checkExitSuccess: false}); assert.neq(0, exitCode, "expected shell to exit abnormally due to mongod being terminated"); -mongod = MongoRunner.runMongod({ - port: mongod.port, - restart: true, - cleanData: false, - dbpath: mongod.dbpath -}); -db = mongod.getDB( "test" ); -collection = db.getCollection( baseName ); - -assert( collection.stats().ok ); -assert( collection.drop() ); +mongod = MongoRunner.runMongod( + {port: mongod.port, restart: true, cleanData: false, dbpath: mongod.dbpath}); +db = mongod.getDB("test"); +collection = db.getCollection(baseName); + +assert(collection.stats().ok); +assert(collection.drop()); MongoRunner.stopMongod(mongod); diff --git a/jstests/disk/newcollection.js b/jstests/disk/newcollection.js index e6a79948c9a..aab959b44df 100644 --- a/jstests/disk/newcollection.js +++ b/jstests/disk/newcollection.js @@ -2,27 +2,28 @@ var baseName = "jstests_disk_newcollection"; var m = MongoRunner.runMongod({noprealloc: "", smallfiles: ""}); -db = m.getDB( "test" ); +db = m.getDB("test"); var t = db[baseName]; var getTotalNonLocalSize = function() { var totalNonLocalDBSize = 0; - m.getDBs().databases.forEach( function(dbStats) { + m.getDBs().databases.forEach(function(dbStats) { // We accept the local database's space overhead. - if (dbStats.name == "local") return; + if (dbStats.name == "local") + return; // Databases with "sizeOnDisk=1" and "empty=true" dont' actually take up space o disk. // See SERVER-11051. - if (dbStats.sizeOnDisk == 1 && dbStats.empty) return; + if (dbStats.sizeOnDisk == 1 && dbStats.empty) + return; totalNonLocalDBSize += dbStats.sizeOnDisk; }); return totalNonLocalDBSize; }; for (var pass = 0; pass <= 1; pass++) { - - db.createCollection(baseName, { size: 15.8 * 1024 * 1024 }); - if( pass == 0 ) + db.createCollection(baseName, {size: 15.8 * 1024 * 1024}); + if (pass == 0) t.drop(); size = getTotalNonLocalSize(); diff --git a/jstests/disk/preallocate.js b/jstests/disk/preallocate.js index 68010dba173..2a01dd89820 100644 --- a/jstests/disk/preallocate.js +++ b/jstests/disk/preallocate.js @@ -6,30 +6,32 @@ var m = MongoRunner.runMongod({}); var getTotalNonLocalSize = function() { var totalNonLocalDBSize = 0; - m.getDBs().databases.forEach( function(dbStats) { + m.getDBs().databases.forEach(function(dbStats) { // We accept the local database's space overhead. - if (dbStats.name == "local") return; + if (dbStats.name == "local") + return; // Databases with "sizeOnDisk=1" and "empty=true" dont' actually take up space o disk. // See SERVER-11051. - if (dbStats.sizeOnDisk == 1 && dbStats.empty) return; + if (dbStats.sizeOnDisk == 1 && dbStats.empty) + return; totalNonLocalDBSize += dbStats.sizeOnDisk; }); return totalNonLocalDBSize; }; -assert.eq( 0, getTotalNonLocalSize() ); +assert.eq(0, getTotalNonLocalSize()); -m.getDB( baseName ).createCollection( baseName + "1" ); +m.getDB(baseName).createCollection(baseName + "1"); // Windows does not currently use preallocation expectedMB = 64 + 16; -if ( m.getDB( baseName ).serverBits() < 64 ) +if (m.getDB(baseName).serverBits() < 64) expectedMB /= 4; -assert.soon(function() { return getTotalNonLocalSize() >= expectedMB * 1024 * 1024; }, - "\n\n\nFAIL preallocate.js expected second file to bring total size over " + - expectedMB + "MB" ); +assert.soon(function() { + return getTotalNonLocalSize() >= expectedMB * 1024 * 1024; +}, "\n\n\nFAIL preallocate.js expected second file to bring total size over " + expectedMB + "MB"); MongoRunner.stopMongod(m); @@ -37,8 +39,8 @@ m = MongoRunner.runMongod({restart: true, cleanData: false, dbpath: m.dbpath}); size = getTotalNonLocalSize(); -m.getDB( baseName ).createCollection( baseName + "2" ); +m.getDB(baseName).createCollection(baseName + "2"); -sleep( 2000 ); // give prealloc a chance +sleep(2000); // give prealloc a chance -assert.eq( size, getTotalNonLocalSize() ); +assert.eq(size, getTotalNonLocalSize()); diff --git a/jstests/disk/preallocate2.js b/jstests/disk/preallocate2.js index cf191f4265a..f4d9eb2f253 100644 --- a/jstests/disk/preallocate2.js +++ b/jstests/disk/preallocate2.js @@ -4,11 +4,13 @@ var baseName = "jstests_preallocate2"; var m = MongoRunner.runMongod({}); -m.getDB( baseName )[ baseName ].save( {i:1} ); +m.getDB(baseName)[baseName].save({i: 1}); // Windows does not currently use preallocation -expectedMB = ( _isWindows() ? 70 : 100 ); -if ( m.getDB( baseName ).serverBits() < 64 ) +expectedMB = (_isWindows() ? 70 : 100); +if (m.getDB(baseName).serverBits() < 64) expectedMB /= 4; -assert.soon( function() { return m.getDBs().totalSize > expectedMB * 1000000; }, "\n\n\nFAIL preallocate.js expected second file to bring total size over " + expectedMB + "MB" ); +assert.soon(function() { + return m.getDBs().totalSize > expectedMB * 1000000; +}, "\n\n\nFAIL preallocate.js expected second file to bring total size over " + expectedMB + "MB"); diff --git a/jstests/disk/preallocate_directoryperdb.js b/jstests/disk/preallocate_directoryperdb.js index c21710e579c..cc17677c680 100644 --- a/jstests/disk/preallocate_directoryperdb.js +++ b/jstests/disk/preallocate_directoryperdb.js @@ -10,23 +10,24 @@ var baseName3 = "preallocate_directoryperdb3"; dbpath = MongoRunner.dataPath + baseDir + "/"; function checkDb2DirAbsent() { - files = listFiles( dbpath ); -// printjson( files ); - for( var f in files ) { - var name = files[ f ].name; - assert.eq( -1, name.indexOf( dbpath + baseName2 ), "baseName2 dir still present" ); - } + files = listFiles(dbpath); + // printjson( files ); + for (var f in files) { + var name = files[f].name; + assert.eq(-1, name.indexOf(dbpath + baseName2), "baseName2 dir still present"); + } } -var m = MongoRunner.runMongod({smallfiles: "", directoryperdb: "", dbpath: dbpath, bind_ip: "127.0.0.1"}); -db = m.getDB( baseName ); -db2 = m.getDB( baseName2 ); -var bulk = db[ baseName ].initializeUnorderedBulkOp(); -var bulk2 = db2[ baseName2 ].initializeUnorderedBulkOp(); -var big = new Array( 5000 ).toString(); -for( var i = 0; i < 3000; ++i ) { - bulk.insert({ b:big }); - bulk2.insert({ b:big }); +var m = MongoRunner.runMongod( + {smallfiles: "", directoryperdb: "", dbpath: dbpath, bind_ip: "127.0.0.1"}); +db = m.getDB(baseName); +db2 = m.getDB(baseName2); +var bulk = db[baseName].initializeUnorderedBulkOp(); +var bulk2 = db2[baseName2].initializeUnorderedBulkOp(); +var big = new Array(5000).toString(); +for (var i = 0; i < 3000; ++i) { + bulk.insert({b: big}); + bulk2.insert({b: big}); } assert.writeOK(bulk.execute()); assert.writeOK(bulk2.execute()); @@ -41,9 +42,9 @@ checkDb2DirAbsent(); db.dropDatabase(); // Try writing a new database, to ensure file allocator is still working. -db3 = m.getDB( baseName3 ); -c3 = db[ baseName3 ]; -assert.writeOK(c3.insert( {} )); -assert.eq( 1, c3.count() ); +db3 = m.getDB(baseName3); +c3 = db[baseName3]; +assert.writeOK(c3.insert({})); +assert.eq(1, c3.count()); checkDb2DirAbsent(); diff --git a/jstests/disk/quota.js b/jstests/disk/quota.js index a959f344531..c1815f1c1f7 100644 --- a/jstests/disk/quota.js +++ b/jstests/disk/quota.js @@ -1,44 +1,46 @@ -// Check functioning of --quotaFiles parameter, including with respect to SERVER-3293 ('local' database). +// Check functioning of --quotaFiles parameter, including with respect to SERVER-3293 ('local' +// database). baseName = "jstests_disk_quota"; var m = MongoRunner.runMongod({quotaFiles: 2, smallfiles: ""}); -db = m.getDB( baseName ); +db = m.getDB(baseName); -big = new Array( 10000 ).toString(); +big = new Array(10000).toString(); // Insert documents until quota is exhausted. -var coll = db[ baseName ]; -var res = coll.insert({ b: big }); -while( !res.hasWriteError() ) { - res = coll.insert({ b: big }); +var coll = db[baseName]; +var res = coll.insert({b: big}); +while (!res.hasWriteError()) { + res = coll.insert({b: big}); } dotTwoDataFile = baseName + ".2"; -files = listFiles( m.dbpath ); -for( i in files ) { - // Since only one data file is allowed, a .0 file is expected and a .1 file may be preallocated (SERVER-3410) but no .2 file is expected. - assert.neq( dotTwoDataFile, files[ i ].baseName ); +files = listFiles(m.dbpath); +for (i in files) { + // Since only one data file is allowed, a .0 file is expected and a .1 file may be preallocated + // (SERVER-3410) but no .2 file is expected. + assert.neq(dotTwoDataFile, files[i].baseName); } dotTwoDataFile = "local" + ".2"; // Check that quota does not apply to local db, and a .2 file can be created. -l = m.getDB( "local" )[ baseName ]; -for( i = 0; i < 10000; ++i ) { - assert.writeOK(l.insert({ b: big })); +l = m.getDB("local")[baseName]; +for (i = 0; i < 10000; ++i) { + assert.writeOK(l.insert({b: big})); dotTwoFound = false; - if ( i % 100 != 0 ) { + if (i % 100 != 0) { continue; } - files = listFiles( m.dbpath ); - for( f in files ) { - if ( files[ f ].baseName == dotTwoDataFile ) { - dotTwoFound = true; + files = listFiles(m.dbpath); + for (f in files) { + if (files[f].baseName == dotTwoDataFile) { + dotTwoFound = true; } } - if ( dotTwoFound ) { - break; + if (dotTwoFound) { + break; } } -assert( dotTwoFound ); +assert(dotTwoFound); diff --git a/jstests/disk/quota2.js b/jstests/disk/quota2.js index a53e6dec6b8..797034a65af 100644 --- a/jstests/disk/quota2.js +++ b/jstests/disk/quota2.js @@ -1,34 +1,33 @@ // Test for quotaFiles off by one file limit issue - SERVER-3420. -if ( 0 ) { // SERVER-3420 +if (0) { // SERVER-3420 -baseName = "jstests_disk_quota2"; + baseName = "jstests_disk_quota2"; -var m = MongoRunner.runMongod({quotaFiles: 2, smallfiles: ""}); -db = m.getDB( baseName ); + var m = MongoRunner.runMongod({quotaFiles: 2, smallfiles: ""}); + db = m.getDB(baseName); -big = new Array( 10000 ).toString(); + big = new Array(10000).toString(); -// Insert documents until quota is exhausted. -var coll = db[ baseName ]; -var res = coll.insert({ b: big }); -while( !res.hasWriteError() ) { - res = coll.insert({ b: big }); -} - -// Trigger allocation of an additional file for a 'special' namespace. -for( n = 0; !db.getLastError(); ++n ) { - db.createCollection( '' + n ); -} + // Insert documents until quota is exhausted. + var coll = db[baseName]; + var res = coll.insert({b: big}); + while (!res.hasWriteError()) { + res = coll.insert({b: big}); + } -// Check that new docs are saved in the .0 file. -for( i = 0; i < n; ++i ) { - c = db[ ''+i ]; - res = c.insert({ b: big }); - if( !res.hasWriteError() ) { - var recordId = c.find().showRecord()[0].$recordId; - assert.eq(0, recordId >> 32); + // Trigger allocation of an additional file for a 'special' namespace. + for (n = 0; !db.getLastError(); ++n) { + db.createCollection('' + n); } -} + // Check that new docs are saved in the .0 file. + for (i = 0; i < n; ++i) { + c = db['' + i]; + res = c.insert({b: big}); + if (!res.hasWriteError()) { + var recordId = c.find().showRecord()[0].$recordId; + assert.eq(0, recordId >> 32); + } + } } diff --git a/jstests/disk/quota3.js b/jstests/disk/quota3.js index 43227d21bfc..0332667e53e 100644 --- a/jstests/disk/quota3.js +++ b/jstests/disk/quota3.js @@ -1,21 +1,20 @@ // Test for quotaFiles being ignored allocating a large collection - SERVER-3511. -if ( 0 ) { // SERVER-3511 +if (0) { // SERVER-3511 -baseName = "jstests_disk_quota3"; -dbpath = MongoRunner.dataPath + baseName; + baseName = "jstests_disk_quota3"; + dbpath = MongoRunner.dataPath + baseName; -var m = MongoRunner.runMongod({dbpath: dbpath, quotaFiles: 3, smallfiles: ""}); -db = m.getDB( baseName ); + var m = MongoRunner.runMongod({dbpath: dbpath, quotaFiles: 3, smallfiles: ""}); + db = m.getDB(baseName); -db.createCollection( baseName, {size:128*1024*1024} ); -assert( db.getLastError() ); - -dotFourDataFile = dbpath + "/" + baseName + ".4"; -files = listFiles( dbpath ); -for( i in files ) { - // .3 file may be preallocated but not .4 - assert.neq( dotFourDataFile, files[ i ].name ); -} + db.createCollection(baseName, {size: 128 * 1024 * 1024}); + assert(db.getLastError()); + dotFourDataFile = dbpath + "/" + baseName + ".4"; + files = listFiles(dbpath); + for (i in files) { + // .3 file may be preallocated but not .4 + assert.neq(dotFourDataFile, files[i].name); + } }
\ No newline at end of file diff --git a/jstests/disk/repair.js b/jstests/disk/repair.js index 072afa3cf08..a38870ce24e 100644 --- a/jstests/disk/repair.js +++ b/jstests/disk/repair.js @@ -4,59 +4,59 @@ var baseName = "jstests_disk_repair"; var dbpath = MongoRunner.dataPath + baseName + "/"; var repairpath = dbpath + "repairDir/"; -resetDbpath( dbpath ); -resetDbpath( repairpath ); +resetDbpath(dbpath); +resetDbpath(repairpath); var m = MongoRunner.runMongod({ dbpath: dbpath, repairpath: repairpath, noCleanData: true, }); -db = m.getDB( baseName ); -db[ baseName ].save( {} ); -assert.commandWorked( db.runCommand( {repairDatabase:1, backupOriginalFiles:true} ) ); +db = m.getDB(baseName); +db[baseName].save({}); +assert.commandWorked(db.runCommand({repairDatabase: 1, backupOriginalFiles: true})); function check() { - files = listFiles( dbpath ); - for( f in files ) { - assert( ! new RegExp( "^" + dbpath + "backup_" ).test( files[ f ].name ), "backup dir in dbpath" ); + files = listFiles(dbpath); + for (f in files) { + assert(!new RegExp("^" + dbpath + "backup_").test(files[f].name), "backup dir in dbpath"); } - assert.eq.automsg( "1", "db[ baseName ].count()" ); + assert.eq.automsg("1", "db[ baseName ].count()"); } check(); -MongoRunner.stopMongod( m.port ); +MongoRunner.stopMongod(m.port); -resetDbpath( repairpath ); +resetDbpath(repairpath); m = MongoRunner.runMongod({ port: m.port, dbpath: dbpath, noCleanData: true, }); -db = m.getDB( baseName ); -assert.commandWorked( db.runCommand( {repairDatabase:1} ) ); +db = m.getDB(baseName); +assert.commandWorked(db.runCommand({repairDatabase: 1})); check(); -MongoRunner.stopMongod( m.port ); +MongoRunner.stopMongod(m.port); -resetDbpath( repairpath ); -rc = runMongoProgram("mongod", "--repair", "--port", m.port, "--dbpath", dbpath, - "--repairpath", repairpath); -assert.eq.automsg( "0", "rc" ); +resetDbpath(repairpath); +rc = runMongoProgram( + "mongod", "--repair", "--port", m.port, "--dbpath", dbpath, "--repairpath", repairpath); +assert.eq.automsg("0", "rc"); m = MongoRunner.runMongod({ port: m.port, dbpath: dbpath, noCleanData: true, }); -db = m.getDB( baseName ); +db = m.getDB(baseName); check(); -MongoRunner.stopMongod( m.port ); +MongoRunner.stopMongod(m.port); -resetDbpath( repairpath ); +resetDbpath(repairpath); rc = runMongoProgram("mongod", "--repair", "--port", m.port, "--dbpath", dbpath); -assert.eq.automsg( "0", "rc" ); +assert.eq.automsg("0", "rc"); m = MongoRunner.runMongod({ port: m.port, dbpath: dbpath, noCleanData: true, }); -db = m.getDB( baseName ); +db = m.getDB(baseName); check(); diff --git a/jstests/disk/repair2.js b/jstests/disk/repair2.js index 1ee79dff3d0..67dd0f4cdf7 100644 --- a/jstests/disk/repair2.js +++ b/jstests/disk/repair2.js @@ -3,13 +3,13 @@ var baseName = "jstests_disk_repair2"; function check() { - files = listFiles( dbpath ); - for( f in files ) { - assert( ! new RegExp( "^" + dbpath + "backup_" ).test( files[ f ].name ), - "backup dir " + files[ f ].name + " in dbpath" ); + files = listFiles(dbpath); + for (f in files) { + assert(!new RegExp("^" + dbpath + "backup_").test(files[f].name), + "backup dir " + files[f].name + " in dbpath"); } - assert.eq.automsg( "1", "db[ baseName ].count()" ); + assert.eq.automsg("1", "db[ baseName ].count()"); } var dbpath = MongoRunner.dataPath + baseName + "/"; @@ -17,8 +17,8 @@ var repairpath = dbpath + "repairDir/"; var longDBName = Array(61).join('a'); var longRepairPath = dbpath + Array(61).join('b') + '/'; -resetDbpath( dbpath ); -resetDbpath( repairpath ); +resetDbpath(dbpath); +resetDbpath(repairpath); var m = MongoRunner.runMongod({ directoryperdb: "", @@ -26,54 +26,54 @@ var m = MongoRunner.runMongod({ repairpath: repairpath, noCleanData: true, }); -db = m.getDB( baseName ); -db[ baseName ].save( {} ); -assert.commandWorked( db.runCommand( {repairDatabase:1, backupOriginalFiles:true} ) ); +db = m.getDB(baseName); +db[baseName].save({}); +assert.commandWorked(db.runCommand({repairDatabase: 1, backupOriginalFiles: true})); -//Check that repair files exist in the repair directory, and nothing else -db.adminCommand( { fsync : 1 } ); -files = listFiles( repairpath + "/backup_repairDatabase_0/" + baseName ); +// Check that repair files exist in the repair directory, and nothing else +db.adminCommand({fsync: 1}); +files = listFiles(repairpath + "/backup_repairDatabase_0/" + baseName); var fileCount = 0; -for( f in files ) { - print( files[ f ].name ); - if ( files[ f ].isDirectory ) +for (f in files) { + print(files[f].name); + if (files[f].isDirectory) continue; fileCount += 1; - assert( /\.bak$/.test( files[ f ].name ), - "In database repair directory, found unexpected file: " + files[ f ].name ); + assert(/\.bak$/.test(files[f].name), + "In database repair directory, found unexpected file: " + files[f].name); } -assert( fileCount > 0, "Expected more than zero nondirectory files in the database directory" ); +assert(fileCount > 0, "Expected more than zero nondirectory files in the database directory"); check(); -MongoRunner.stopMongod( m.port ); +MongoRunner.stopMongod(m.port); -resetDbpath( repairpath ); +resetDbpath(repairpath); m = MongoRunner.runMongod({ port: m.port, directoryperdb: "", dbpath: dbpath, noCleanData: true, }); -db = m.getDB( baseName ); -assert.commandWorked( db.runCommand( {repairDatabase:1} ) ); +db = m.getDB(baseName); +assert.commandWorked(db.runCommand({repairDatabase: 1})); check(); -MongoRunner.stopMongod( m.port ); +MongoRunner.stopMongod(m.port); -//Test long database names -resetDbpath( repairpath ); +// Test long database names +resetDbpath(repairpath); m = MongoRunner.runMongod({ port: m.port, directoryperdb: "", dbpath: dbpath, noCleanData: true, }); -db = m.getDB( longDBName ); -assert.writeOK(db[ baseName ].save( {} )); -assert.commandWorked( db.runCommand( {repairDatabase:1} ) ); -MongoRunner.stopMongod( m.port ); +db = m.getDB(longDBName); +assert.writeOK(db[baseName].save({})); +assert.commandWorked(db.runCommand({repairDatabase: 1})); +MongoRunner.stopMongod(m.port); -//Test long repairPath -resetDbpath( longRepairPath ); +// Test long repairPath +resetDbpath(longRepairPath); m = MongoRunner.runMongod({ port: m.port, directoryperdb: "", @@ -81,19 +81,22 @@ m = MongoRunner.runMongod({ repairpath: longRepairPath, noCleanData: true, }); -db = m.getDB( longDBName ); -assert.commandWorked( db.runCommand( {repairDatabase:1, backupOriginalFiles: true} ) ); +db = m.getDB(longDBName); +assert.commandWorked(db.runCommand({repairDatabase: 1, backupOriginalFiles: true})); check(); -MongoRunner.stopMongod( m.port ); +MongoRunner.stopMongod(m.port); -//Test database name and repairPath with --repair -resetDbpath( longRepairPath ); +// Test database name and repairPath with --repair +resetDbpath(longRepairPath); var returnCode = runMongoProgram("mongod", - "--port", m.port, + "--port", + m.port, "--repair", "--directoryperdb", - "--dbpath", dbpath, - "--repairpath", longRepairPath); + "--dbpath", + dbpath, + "--repairpath", + longRepairPath); assert.eq(returnCode, 0); m = MongoRunner.runMongod({ port: m.port, @@ -101,17 +104,20 @@ m = MongoRunner.runMongod({ dbpath: dbpath, noCleanData: true, }); -db = m.getDB( longDBName ); +db = m.getDB(longDBName); check(); -MongoRunner.stopMongod( m.port ); +MongoRunner.stopMongod(m.port); -resetDbpath( repairpath ); +resetDbpath(repairpath); returnCode = runMongoProgram("mongod", - "--port", m.port, + "--port", + m.port, "--repair", "--directoryperdb", - "--dbpath", dbpath, - "--repairpath", repairpath); + "--dbpath", + dbpath, + "--repairpath", + repairpath); assert.eq(returnCode, 0); m = MongoRunner.runMongod({ port: m.port, @@ -120,16 +126,13 @@ m = MongoRunner.runMongod({ repairpath: repairpath, noCleanData: true, }); -db = m.getDB( baseName ); +db = m.getDB(baseName); check(); -MongoRunner.stopMongod( m.port ); +MongoRunner.stopMongod(m.port); -resetDbpath( repairpath ); -returnCode = runMongoProgram("mongod", - "--port", m.port, - "--repair", - "--directoryperdb", - "--dbpath", dbpath); +resetDbpath(repairpath); +returnCode = + runMongoProgram("mongod", "--port", m.port, "--repair", "--directoryperdb", "--dbpath", dbpath); assert.eq(returnCode, 0); m = MongoRunner.runMongod({ port: m.port, @@ -137,5 +140,5 @@ m = MongoRunner.runMongod({ dbpath: dbpath, noCleanData: true, }); -db = m.getDB( baseName ); +db = m.getDB(baseName); check(); diff --git a/jstests/disk/repair3.js b/jstests/disk/repair3.js index 57e73477aed..83fbbf7b9f3 100644 --- a/jstests/disk/repair3.js +++ b/jstests/disk/repair3.js @@ -5,23 +5,23 @@ var repairbase = MongoRunner.dataDir + "/repairpartitiontest"; var repairpath = repairbase + "/dir"; doIt = false; -files = listFiles( MongoRunner.dataDir ); -for ( i in files ) { - if ( files[ i ].name == repairbase ) { +files = listFiles(MongoRunner.dataDir); +for (i in files) { + if (files[i].name == repairbase) { doIt = true; } } -if ( !doIt ) { - print( "path " + repairpath + " missing, skipping repair3 test" ); +if (!doIt) { + print("path " + repairpath + " missing, skipping repair3 test"); doIt = false; } if (doIt) { var dbpath = MongoRunner.dataPath + baseName + "/"; - resetDbpath( dbpath ); - resetDbpath( repairpath ); + resetDbpath(dbpath); + resetDbpath(repairpath); var m = MongoRunner.runMongod({ nssize: 8, @@ -30,25 +30,36 @@ if (doIt) { dbpath: dbpath, repairpath: repairpath, }); - db = m.getDB( baseName ); - db[ baseName ].save( {} ); - assert.commandWorked( db.runCommand( {repairDatabase:1, backupOriginalFiles:false} ) ); + db = m.getDB(baseName); + db[baseName].save({}); + assert.commandWorked(db.runCommand({repairDatabase: 1, backupOriginalFiles: false})); function check() { - files = listFiles( dbpath ); - for( f in files ) { - assert( ! new RegExp( "^" + dbpath + "backup_" ).test( files[ f ].name ), "backup dir in dbpath" ); + files = listFiles(dbpath); + for (f in files) { + assert(!new RegExp("^" + dbpath + "backup_").test(files[f].name), + "backup dir in dbpath"); } - - assert.eq.automsg( "1", "db[ baseName ].count()" ); + + assert.eq.automsg("1", "db[ baseName ].count()"); } check(); - MongoRunner.stopMongod( m.port ); + MongoRunner.stopMongod(m.port); - resetDbpath( repairpath ); - var rc = runMongoProgram("mongod", "--nssize", "8", "--noprealloc", "--smallfiles", "--repair", - "--port", m.port, "--dbpath", dbpath, "--repairpath", repairpath); - assert.eq.automsg( "0", "rc" ); + resetDbpath(repairpath); + var rc = runMongoProgram("mongod", + "--nssize", + "8", + "--noprealloc", + "--smallfiles", + "--repair", + "--port", + m.port, + "--dbpath", + dbpath, + "--repairpath", + repairpath); + assert.eq.automsg("0", "rc"); m = MongoRunner.runMongod({ nssize: 8, noprealloc: "", @@ -57,7 +68,7 @@ if (doIt) { dbpath: dbpath, repairpath: repairpath, }); - db = m.getDB( baseName ); + db = m.getDB(baseName); check(); - MongoRunner.stopMongod( m.port ); + MongoRunner.stopMongod(m.port); } diff --git a/jstests/disk/repair4.js b/jstests/disk/repair4.js index ff99389a380..f38f9036e47 100644 --- a/jstests/disk/repair4.js +++ b/jstests/disk/repair4.js @@ -5,24 +5,24 @@ var smallbase = MongoRunner.dataDir + "/repairpartitiontest"; var smallpath = smallbase + "/dir"; doIt = false; -files = listFiles( MongoRunner.dataDir ); -for ( i in files ) { - if ( files[ i ].name == smallbase ) { +files = listFiles(MongoRunner.dataDir); +for (i in files) { + if (files[i].name == smallbase) { doIt = true; } } -if ( !doIt ) { - print( "path " + smallpath + " missing, skipping repair4 test" ); +if (!doIt) { + print("path " + smallpath + " missing, skipping repair4 test"); doIt = false; } -if ( doIt ) { +if (doIt) { var repairpath = MongoRunner.dataPath + baseName + "/"; - resetDbpath( smallpath ); - resetDbpath( repairpath ); - + resetDbpath(smallpath); + resetDbpath(repairpath); + var m = MongoRunner.runMongod({ nssize: "8", noprealloc: "", @@ -33,19 +33,19 @@ if ( doIt ) { bind_ip: "127.0.0.1", }); - db = m.getDB( baseName ); - db[ baseName ].save( {} ); - assert.commandWorked( db.runCommand( {repairDatabase:1, backupOriginalFiles:true} ) ); + db = m.getDB(baseName); + db[baseName].save({}); + assert.commandWorked(db.runCommand({repairDatabase: 1, backupOriginalFiles: true})); function check() { - files = listFiles( smallpath ); - for( f in files ) { - assert( ! new RegExp( "^" + smallpath + "backup_" ).test( files[ f ].name ), "backup dir in dbpath" ); + files = listFiles(smallpath); + for (f in files) { + assert(!new RegExp("^" + smallpath + "backup_").test(files[f].name), + "backup dir in dbpath"); } - - assert.eq.automsg( "1", "db[ baseName ].count()" ); + + assert.eq.automsg("1", "db[ baseName ].count()"); } - - check(); - MongoRunner.stopMongod( port ); + check(); + MongoRunner.stopMongod(port); } diff --git a/jstests/disk/repair5.js b/jstests/disk/repair5.js index 2dc9d7798e9..b8663c55e7c 100644 --- a/jstests/disk/repair5.js +++ b/jstests/disk/repair5.js @@ -6,34 +6,36 @@ var dbpath = MongoRunner.dataPath + baseName + "/"; var repairpath = dbpath + "repairDir/"; - resetDbpath( dbpath ); - resetDbpath( repairpath ); + resetDbpath(dbpath); + resetDbpath(repairpath); - var m = MongoRunner.runMongod({dbpath: dbpath, - repairpath: repairpath, - restart:true, - cleanData: false}); // So that the repair dir won't get removed + var m = MongoRunner.runMongod({ + dbpath: dbpath, + repairpath: repairpath, + restart: true, + cleanData: false + }); // So that the repair dir won't get removed - var dbTest = m.getDB( baseName ); + var dbTest = m.getDB(baseName); // Insert a lot of data so repair runs a long time var bulk = dbTest[baseName].initializeUnorderedBulkOp(); - var big = new Array( 5000 ).toString(); - for(var i = 0; i < 20000; ++i) { - bulk.insert( {i:i,b:big} ); + var big = new Array(5000).toString(); + for (var i = 0; i < 20000; ++i) { + bulk.insert({i: i, b: big}); } assert.writeOK(bulk.execute()); function killRepair() { - while( 1 ) { + while (1) { var p = db.currentOp().inprog; - for( var i in p ) { - var o = p[ i ]; - printjson( o ); + for (var i in p) { + var o = p[i]; + printjson(o); // Find the active 'repairDatabase' op and kill it. - if ( o.active && o.query && o.query.repairDatabase ) { - db.killOp( o.opid ); + if (o.active && o.query && o.query.repairDatabase) { + db.killOp(o.opid); return; } } @@ -41,15 +43,15 @@ } var s = startParallelShell(killRepair.toString() + "; killRepair();", m.port); - sleep(100); // make sure shell is actually running, lame + sleep(100); // make sure shell is actually running, lame // Repair should fail due to killOp. - assert.commandFailed( dbTest.runCommand( {repairDatabase:1, backupOriginalFiles:true} ) ); + assert.commandFailed(dbTest.runCommand({repairDatabase: 1, backupOriginalFiles: true})); s(); - assert.eq( 20000, dbTest[ baseName ].find().itcount() ); - assert( dbTest[ baseName ].validate().valid ); + assert.eq(20000, dbTest[baseName].find().itcount()); + assert(dbTest[baseName].validate().valid); MongoRunner.stopMongod(m); })(); diff --git a/jstests/disk/too_many_fds.js b/jstests/disk/too_many_fds.js index edb232c2f70..0397a29e08b 100644 --- a/jstests/disk/too_many_fds.js +++ b/jstests/disk/too_many_fds.js @@ -4,26 +4,25 @@ function doTest() { var baseName = "jstests_disk_too_many_fds"; - var m = MongoRunner.runMongod( { smallfiles: "" , nssize: 1 } ); + var m = MongoRunner.runMongod({smallfiles: "", nssize: 1}); // Make 1026 collections, each in a separate database. On some storage engines, this may cause // 1026 files to be created. for (var i = 1; i < 1026; ++i) { var db = m.getDB("db" + i); var coll = db.getCollection("coll" + i); - assert.writeOK(coll.insert( {} )); + assert.writeOK(coll.insert({})); } - MongoRunner.stopMongod( m ); + MongoRunner.stopMongod(m); // Ensure we can still start up with that many files. - var m2 = MongoRunner.runMongod( { dbpath: m.dbpath, smallfiles: "" , nssize: 1, - restart: true, cleanData: false } ); + var m2 = MongoRunner.runMongod( + {dbpath: m.dbpath, smallfiles: "", nssize: 1, restart: true, cleanData: false}); assert.eq(1, m2.getDB("db1025").getCollection("coll1025").count()); } if (db.serverBuildInfo().bits == 64) { doTest(); -} -else { +} else { print("Skipping. Only run this test on 64bit builds"); } |