summaryrefslogtreecommitdiff
path: root/jstests/disk
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2015-04-24 14:10:35 -0400
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2015-04-24 14:54:52 -0400
commit4370f71f9f79799a273682bf61548c8f2694f964 (patch)
treec026d588cc2cb5db3917ac10d0d742f9161cd93b /jstests/disk
parent7d8ba7602b1fffa7ef2c3a0873a62172ca6d1dfa (diff)
downloadmongo-4370f71f9f79799a273682bf61548c8f2694f964.tar.gz
SERVER-18201 Explicitly pass the port to the test shell
While at it, I also put the test into a function so it doesn't change global variables.
Diffstat (limited to 'jstests/disk')
-rw-r--r--jstests/disk/repair5.js76
1 files changed, 40 insertions, 36 deletions
diff --git a/jstests/disk/repair5.js b/jstests/disk/repair5.js
index dc33289eba5..5655e72d0e5 100644
--- a/jstests/disk/repair5.js
+++ b/jstests/disk/repair5.js
@@ -1,50 +1,54 @@
// SERVER-2351 Test killop with repair command.
+(function() {
+ 'use strict';
+ var baseName = "jstests_disk_repair5";
-var baseName = "jstests_disk_repair5";
+ var dbpath = MongoRunner.dataPath + baseName + "/";
+ var repairpath = dbpath + "repairDir/"
-dbpath = MongoRunner.dataPath + baseName + "/";
-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
-m = MongoRunner.runMongod({dbpath: dbpath,
- repairpath: repairpath,
- restart:true,
- cleanData: false}); // Don't clean data so repair dir doesn't get removed
+ var dbTest = m.getDB( baseName );
-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 && o.query.repairDatabase ) {
- db.killOp( o.opid );
- return;
+ // Insert a lot of data so repair runs a long time
+ var bulk = dbTest[baseName].initializeUnorderedBulkOp();
+ var big = new Array( 5000 ).toString();
+ for( i = 0; i < 20000; ++i ) {
+ bulk.insert( {i:i,b:big} );
+ }
+ assert.writeOK(bulk.execute());
+
+ 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 && o.query.repairDatabase ) {
+ db.killOp( o.opid );
+ return;
+ }
}
}
}
-}
-
-s = startParallelShell( killRepair.toString() + "; killRepair();" );
-sleep(100); // make sure shell is actually running, lame
+ var s = startParallelShell(killRepair.toString() + "; killRepair();", m.port);
+ sleep(100); // make sure shell is actually running, lame
-// Repair should fail due to killOp.
-assert.commandFailed( db.runCommand( {repairDatabase:1, backupOriginalFiles:true} ) );
+ // Repair should fail due to killOp.
+ assert.commandFailed( dbTest.runCommand( {repairDatabase:1, backupOriginalFiles:true} ) );
-s();
+ s();
-assert.eq( 20000, db[ baseName ].find().itcount() );
-assert( db[ baseName ].validate().valid );
+ assert.eq( 20000, dbTest[ baseName ].find().itcount() );
+ assert( dbTest[ baseName ].validate().valid );
-MongoRunner.stopMongod(m);
+ MongoRunner.stopMongod(m);
+})();