diff options
Diffstat (limited to 'jstests/disk')
-rw-r--r-- | jstests/disk/directoryperdb.js | 2 | ||||
-rw-r--r-- | jstests/disk/diskfull.js | 8 | ||||
-rw-r--r-- | jstests/disk/newcollection.js | 20 | ||||
-rw-r--r-- | jstests/disk/norepeat.js | 2 | ||||
-rw-r--r-- | jstests/disk/quota.js | 47 | ||||
-rw-r--r-- | jstests/disk/quota2.js | 38 | ||||
-rw-r--r-- | jstests/disk/repair3.js | 2 | ||||
-rw-r--r-- | jstests/disk/repair5.js | 43 |
8 files changed, 154 insertions, 8 deletions
diff --git a/jstests/disk/directoryperdb.js b/jstests/disk/directoryperdb.js index 3b65bd0..c29dea0 100644 --- a/jstests/disk/directoryperdb.js +++ b/jstests/disk/directoryperdb.js @@ -22,6 +22,8 @@ checkDir = function( dir ) { files = listFiles( dir + baseName ); for( f in files ) { + if ( files[f].isDirectory ) + continue; assert( new RegExp( baseName + "/" + baseName + "." ).test( files[ f ].name ) , "B dir:" + dir + " f: " + f ); } } diff --git a/jstests/disk/diskfull.js b/jstests/disk/diskfull.js index 26b707d..eddb300 100644 --- a/jstests/disk/diskfull.js +++ b/jstests/disk/diskfull.js @@ -20,10 +20,16 @@ if ( doIt ) { port = allocatePorts( 1 )[ 0 ]; m = startMongoProgram( "mongod", "--port", port, "--dbpath", dbpath, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); - c = m.getDB( "diskfulltest" ).getCollection( "diskfulltest" ) + d = m.getDB( "diskfulltest" ); + c = d.getCollection( "diskfulltest" ); c.save( { a: 6 } ); + assert.eq(d.getLastError(), "new file allocation failure"); // first fail assert.soon( function() { return rawMongoProgramOutput().match( /file allocation failure/ ); }, "didn't see 'file allocation failure'" ); assert.isnull( c.findOne() , "shouldn't exist" ); + c.save( { a: 6 } ); + assert.eq(d.getLastError(), "Can't take a write lock while out of disk space"); // every following fail + + sleep( 3000 ); m2 = new Mongo( m.host ); printjson( m2.getDBs() ); diff --git a/jstests/disk/newcollection.js b/jstests/disk/newcollection.js index 944ad1c..57ae179 100644 --- a/jstests/disk/newcollection.js +++ b/jstests/disk/newcollection.js @@ -3,11 +3,21 @@ port = allocatePorts( 1 )[ 0 ] var baseName = "jstests_disk_newcollection"; var m = startMongod( "--noprealloc", "--smallfiles", "--port", port, "--dbpath", "/data/db/" + baseName ); +//var m = db.getMongo(); db = m.getDB( "test" ); -db.createCollection( baseName, {size:15.9*1024*1024} ); -db.baseName.drop(); +var t = db[baseName]; -size = m.getDBs().totalSize; -db.baseName.save( {} ); -assert.eq( size, m.getDBs().totalSize ); +for (var pass = 0; pass <= 1; pass++) { + + db.createCollection(baseName, { size: 15.8 * 1024 * 1024 }); + if( pass == 0 ) + t.drop(); + + size = m.getDBs().totalSize; + t.save({}); + assert.eq(size, m.getDBs().totalSize); + assert(size <= 32 * 1024 * 1024); + + t.drop(); +} diff --git a/jstests/disk/norepeat.js b/jstests/disk/norepeat.js index d9f1cd3..985fc36 100644 --- a/jstests/disk/norepeat.js +++ b/jstests/disk/norepeat.js @@ -45,7 +45,7 @@ assert.throws( function() { c.next() }, [], "unexpected: object found" ); m.getDB( "local" ).getCollectionNames().forEach( function( x ) { assert( !x.match( /^temp/ ), "temp collection found" ); } ); t.drop(); -m.getDB( baseName ).createCollection( baseName, { capped:true, size:100000, autoIdIndex:false } ); +m.getDB( baseName ).createCollection( baseName, { capped:true, size:100000, autoIndexId:false } ); t = m.getDB( baseName ).getCollection( baseName ); t.insert( {_id:"a"} ); t.insert( {_id:"a"} ); diff --git a/jstests/disk/quota.js b/jstests/disk/quota.js new file mode 100644 index 0000000..d93e5ea --- /dev/null +++ b/jstests/disk/quota.js @@ -0,0 +1,47 @@ +// Check functioning of --quotaFiles parameter, including with respect to SERVER-3293 ('local' database). + +port = allocatePorts( 1 )[ 0 ]; + +baseName = "jstests_disk_quota"; +dbpath = "/data/db/" + baseName; + +m = startMongod( "--port", port, "--dbpath", "/data/db/" + baseName, "--quotaFiles", "1", "--smallfiles" ); +db = m.getDB( baseName ); + +big = new Array( 10000 ).toString(); + +// Insert documents until quota is exhausted. +while( !db.getLastError() ) { + db[ baseName ].save( {b:big} ); +} +printjson( db.getLastError() ); + +dotTwoDataFile = dbpath + "/" + baseName + ".2"; +files = listFiles( 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 ].name ); +} + +dotTwoDataFile = dbpath + "/" + "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 ) { + l.save( {b:big} ); + assert( !db.getLastError() ); + dotTwoFound = false; + if ( i % 100 != 0 ) { + continue; + } + files = listFiles( dbpath ); + for( f in files ) { + if ( files[ f ].name == dotTwoDataFile ) { + dotTwoFound = true; + } + } + if ( dotTwoFound ) { + break; + } +} + +assert( dotTwoFound ); diff --git a/jstests/disk/quota2.js b/jstests/disk/quota2.js new file mode 100644 index 0000000..c0d30df --- /dev/null +++ b/jstests/disk/quota2.js @@ -0,0 +1,38 @@ +// Test for quotaFiles off by one file limit issue - SERVER-3420. + +if ( 0 ) { // SERVER-3420 + +port = allocatePorts( 1 )[ 0 ]; + +baseName = "jstests_disk_quota2"; +dbpath = "/data/db/" + baseName; + +m = startMongod( "--port", port, "--dbpath", "/data/db/" + baseName, "--quotaFiles", "1", "--smallfiles" ); +db = m.getDB( baseName ); + +big = new Array( 10000 ).toString(); + +// Insert documents until quota is exhausted. +while( !db.getLastError() ) { + db[ baseName ].save( {b:big} ); +} + +db.resetError(); + +// Trigger allocation of an additional file for a 'special' namespace. +for( n = 0; !db.getLastError(); ++n ) { + db.createCollection( '' + n ); +} + +print( n ); + +// Check that new docs are saved in the .0 file. +for( i = 0; i < n; ++i ) { + c = db[ ''+i ]; + c.save( {b:big} ); + if( !db.getLastError() ) { + assert.eq( 0, c.find()._addSpecial( "$showDiskLoc", true )[ 0 ].$diskLoc.file ); + } +} + +}
\ No newline at end of file diff --git a/jstests/disk/repair3.js b/jstests/disk/repair3.js index c986dce..9e6767c 100644 --- a/jstests/disk/repair3.js +++ b/jstests/disk/repair3.js @@ -1,4 +1,4 @@ -// test --repairpath on aother partition +// test --repairpath on another partition var baseName = "jstests_disk_repair3"; var repairbase = "/data/db/repairpartitiontest" diff --git a/jstests/disk/repair5.js b/jstests/disk/repair5.js new file mode 100644 index 0000000..65da330 --- /dev/null +++ b/jstests/disk/repair5.js @@ -0,0 +1,43 @@ +// SERVER-2351 Test killop with repair command. + +var baseName = "jstests_disk_repair5"; + +port = allocatePorts( 1 )[ 0 ]; +dbpath = "/data/db/" + baseName + "/"; +repairpath = dbpath + "repairDir/" + +resetDbpath( dbpath ); +resetDbpath( repairpath ); + +m = startMongoProgram( "mongod", "--port", port, "--dbpath", dbpath, "--repairpath", repairpath, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); +db = m.getDB( baseName ); + +big = new Array( 5000 ).toString(); +for( i = 0; i < 20000; ++i ) { + db[ baseName ].save( {i:i,b:big} ); +} + +function killRepair() { + while( 1 ) { + p = db.currentOp().inprog; + for( var i in p ) { + var o = p[ i ]; + printjson( o ); + // Find the active 'repairDatabase' op and kill it. + if ( o.active && o.query.repairDatabase ) { + db.killOp( o.opid ); + return; + } + } + } +} + +s = startParallelShell( killRepair.toString() + "; killRepair();" ); + +// Repair should fail due to killOp. +assert.commandFailed( db.runCommand( {repairDatabase:1, backupOriginalFiles:true} ) ); + +s(); + +assert.eq( 20000, db[ baseName ].find().itcount() ); +assert( db[ baseName ].validate().valid ); |