summaryrefslogtreecommitdiff
path: root/jstests/disk
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/disk')
-rw-r--r--jstests/disk/diskfull.js2
-rw-r--r--jstests/disk/killall.js55
-rw-r--r--jstests/disk/newcollection1.js20
-rw-r--r--jstests/disk/preallocate.js3
-rw-r--r--jstests/disk/preallocate2.js3
-rw-r--r--jstests/disk/quota.js2
-rw-r--r--jstests/disk/quota2.js4
-rw-r--r--jstests/disk/quota3.js23
-rw-r--r--jstests/disk/repair5.js6
9 files changed, 90 insertions, 28 deletions
diff --git a/jstests/disk/diskfull.js b/jstests/disk/diskfull.js
index eddb300d86c..de37db8e1ec 100644
--- a/jstests/disk/diskfull.js
+++ b/jstests/disk/diskfull.js
@@ -19,7 +19,7 @@ if ( doIt ) {
files.forEach( function( x ) { removeFile( x.name ) } );
port = allocatePorts( 1 )[ 0 ];
- m = startMongoProgram( "mongod", "--port", port, "--dbpath", dbpath, "--nohttpinterface", "--bind_ip", "127.0.0.1" );
+ m = startMongoProgram( "mongod", "--port", port, "--dbpath", dbpath, "--nohttpinterface", "--bind_ip", "127.0.0.1", '--nojournal' );
d = m.getDB( "diskfulltest" );
c = d.getCollection( "diskfulltest" );
c.save( { a: 6 } );
diff --git a/jstests/disk/killall.js b/jstests/disk/killall.js
index a1487bba130..01d9e57e118 100644
--- a/jstests/disk/killall.js
+++ b/jstests/disk/killall.js
@@ -1,42 +1,57 @@
-// running ops should be killed
-// dropped collection should be ok after restart
-
-if ( typeof _threadInject == "undefined" ) { // don't run in v8 mode - SERVER-2076
+/*
+ * Verify that killing an instance of mongod while it is in a long running computation or infinite
+ * loop still leads to clean shutdown, and that said shutdown is prompt.
+ *
+ * For our purposes, "prompt" is defined as "before stopMongod() decides to send a SIGKILL" and also
+ * "before mongod starts executing the next pending operation after the currently executing one."
+ *
+ * This is also a regression test for SERVER-1818. By queuing up a collection drop behind an
+ * infinitely looping operation, we ensure that killall interrupts the drop command (drop is
+ * normally a short lived operation and is otherwise difficult to kill deterministically). The
+ * subsequent drop() on restart would historically assert if the data integrity issue caused by
+ * SERVER-1818 occured.
+ */
port = allocatePorts( 1 )[ 0 ]
var baseName = "jstests_disk_killall";
+var dbpath = "/data/db/" + baseName;
-var m = startMongod( "--port", port, "--dbpath", "/data/db/" + baseName, "--nohttpinterface" );
+var mongod = startMongod( "--port", port, "--dbpath", dbpath, "--nohttpinterface" );
+var db = mongod.getDB( "test" );
+var collection = db.getCollection( baseName );
-m.getDB( "test" ).getCollection( baseName ).save( {} );
-m.getDB( "test" ).getLastError();
+collection.save( {} );
+assert( ! db.getLastError() );
s1 = startParallelShell( "db." + baseName + ".count( { $where: function() { while( 1 ) { ; } } } )", port );
+// HACK(schwerin): startParallelShell's return value should allow you to block until the command has
+// started, for some definition of started.
sleep( 1000 );
s2 = startParallelShell( "db." + baseName + ".drop()", port );
-sleep( 1000 );
+sleep( 1000 ); // HACK(schwerin): See above.
/**
- * 12 == mongod's exit code on interrupt (eg standard kill)
- * stopMongod sends a standard kill signal to mongod, then waits for mongod to stop. If mongod doesn't stop
- * in a reasonable amount of time, stopMongod sends kill -9 and in that case will not return 12. We're checking
- * in this assert that mongod will stop quickly even while evaling an infinite loop in server side js.
+ * 0 == mongod's exit code on Windows, or when it receives TERM, HUP or INT signals. On UNIX
+ * variants, stopMongod sends a TERM signal to mongod, then waits for mongod to stop. If mongod
+ * doesn't stop in a reasonable amount of time, stopMongod sends a KILL signal, in which case mongod
+ * will not exit cleanly. We're checking in this assert that mongod will stop quickly even while
+ * evaling an infinite loop in server side js.
*
- * 14 is sometimes returned instead due to SERVER-2184
+ * NOTE: 14 is sometimes returned instead due to SERVER-2652.
*/
-exitCode = stopMongod( port );
-assert( exitCode == 12 || exitCode == 14, "got unexpected exitCode: " + exitCode );
+var exitCode = stopMongod( port );
+assert( exitCode in [0, 14], "got unexpected exitCode: " + exitCode );
s1();
s2();
-var m = startMongoProgram( "mongod", "--port", port, "--dbpath", "/data/db/" + baseName );
+mongod = startMongoProgram( "mongod", "--port", port, "--dbpath", dbpath );
+db = mongod.getDB( "test" );
+collection = db.getCollection( baseName );
-m.getDB( "test" ).getCollection( baseName ).stats();
-m.getDB( "test" ).getCollection( baseName ).drop();
+assert( collection.stats().ok );
+assert( collection.drop() );
stopMongod( port );
-
-} \ No newline at end of file
diff --git a/jstests/disk/newcollection1.js b/jstests/disk/newcollection1.js
new file mode 100644
index 00000000000..e11e4a93a8a
--- /dev/null
+++ b/jstests/disk/newcollection1.js
@@ -0,0 +1,20 @@
+// SERVER-4560 test
+
+port = allocatePorts( 1 )[ 0 ]
+var baseName = "jstests_disk_newcollection1";
+var m = startMongod( "--noprealloc", "--smallfiles", "--port", port, "--dbpath", "/data/db/" + baseName );
+
+db = m.getDB( "test" );
+
+db.dropDatabase();
+
+var colls = db.getCollectionNames();
+
+assert ( colls.length==0 );
+
+db.createCollection("broken", {capped: true, size: -1});
+
+var new_colls = db.getCollectionNames();
+
+print (new_colls);
+assert( new_colls.length==0 );
diff --git a/jstests/disk/preallocate.js b/jstests/disk/preallocate.js
index 4f358664a5a..0f6ec503ab0 100644
--- a/jstests/disk/preallocate.js
+++ b/jstests/disk/preallocate.js
@@ -10,7 +10,8 @@ assert.eq( 0, m.getDBs().totalSize );
m.getDB( baseName ).createCollection( baseName + "1" );
-expectedMB = 100;
+// Windows does not currently use preallocation
+expectedMB = ( _isWindows() ? 70 : 100 );
if ( m.getDB( baseName ).serverBits() < 64 )
expectedMB /= 4;
diff --git a/jstests/disk/preallocate2.js b/jstests/disk/preallocate2.js
index 9b2159fd058..5486fc0c6b6 100644
--- a/jstests/disk/preallocate2.js
+++ b/jstests/disk/preallocate2.js
@@ -8,7 +8,8 @@ var m = startMongod( "--port", port, "--dbpath", "/data/db/" + baseName );
m.getDB( baseName )[ baseName ].save( {i:1} );
-expectedMB = 100;
+// Windows does not currently use preallocation
+expectedMB = ( _isWindows() ? 70 : 100 );
if ( m.getDB( baseName ).serverBits() < 64 )
expectedMB /= 4;
diff --git a/jstests/disk/quota.js b/jstests/disk/quota.js
index d93e5eaafc0..f78a768369b 100644
--- a/jstests/disk/quota.js
+++ b/jstests/disk/quota.js
@@ -5,7 +5,7 @@ port = allocatePorts( 1 )[ 0 ];
baseName = "jstests_disk_quota";
dbpath = "/data/db/" + baseName;
-m = startMongod( "--port", port, "--dbpath", "/data/db/" + baseName, "--quotaFiles", "1", "--smallfiles" );
+m = startMongod( "--port", port, "--dbpath", "/data/db/" + baseName, "--quotaFiles", "2", "--smallfiles" );
db = m.getDB( baseName );
big = new Array( 10000 ).toString();
diff --git a/jstests/disk/quota2.js b/jstests/disk/quota2.js
index c0d30dfecbf..a485ae98d27 100644
--- a/jstests/disk/quota2.js
+++ b/jstests/disk/quota2.js
@@ -7,7 +7,7 @@ port = allocatePorts( 1 )[ 0 ];
baseName = "jstests_disk_quota2";
dbpath = "/data/db/" + baseName;
-m = startMongod( "--port", port, "--dbpath", "/data/db/" + baseName, "--quotaFiles", "1", "--smallfiles" );
+m = startMongod( "--port", port, "--dbpath", "/data/db/" + baseName, "--quotaFiles", "2", "--smallfiles" );
db = m.getDB( baseName );
big = new Array( 10000 ).toString();
@@ -24,8 +24,6 @@ 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 ];
diff --git a/jstests/disk/quota3.js b/jstests/disk/quota3.js
new file mode 100644
index 00000000000..16830efca74
--- /dev/null
+++ b/jstests/disk/quota3.js
@@ -0,0 +1,23 @@
+// Test for quotaFiles being ignored allocating a large collection - SERVER-3511.
+
+if ( 0 ) { // SERVER-3511
+
+port = allocatePorts( 1 )[ 0 ];
+
+baseName = "jstests_disk_quota3";
+dbpath = "/data/db/" + baseName;
+
+m = startMongod( "--port", port, "--dbpath", "/data/db/" + baseName, "--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 );
+}
+
+} \ No newline at end of file
diff --git a/jstests/disk/repair5.js b/jstests/disk/repair5.js
index 65da3305d91..314739e330a 100644
--- a/jstests/disk/repair5.js
+++ b/jstests/disk/repair5.js
@@ -21,7 +21,7 @@ function killRepair() {
while( 1 ) {
p = db.currentOp().inprog;
for( var i in p ) {
- var o = p[ i ];
+ var o = p[ i ];
printjson( o );
// Find the active 'repairDatabase' op and kill it.
if ( o.active && o.query.repairDatabase ) {
@@ -34,6 +34,8 @@ function killRepair() {
s = startParallelShell( killRepair.toString() + "; killRepair();" );
+sleep(100); // make sure shell is actually running, lame
+
// Repair should fail due to killOp.
assert.commandFailed( db.runCommand( {repairDatabase:1, backupOriginalFiles:true} ) );
@@ -41,3 +43,5 @@ s();
assert.eq( 20000, db[ baseName ].find().itcount() );
assert( db[ baseName ].validate().valid );
+
+stopMongod( port )