diff options
Diffstat (limited to 'jstests')
79 files changed, 359 insertions, 363 deletions
diff --git a/jstests/auth/access_control_with_unreachable_configs.js b/jstests/auth/access_control_with_unreachable_configs.js index e14583a3c70..da328f098dd 100644 --- a/jstests/auth/access_control_with_unreachable_configs.js +++ b/jstests/auth/access_control_with_unreachable_configs.js @@ -34,7 +34,7 @@ assert.commandWorked(db.adminCommand('serverStatus')); jsTest.log('repeat without config server') // shut down only config server -stopMongod(config.port, /*signal*/15); +MongoRunner.stopMongod(config.port, /*signal*/15); // open a new connection to mongos (unauthorized) var conn2 = new Mongo(mongos.host); diff --git a/jstests/auth/auth1.js b/jstests/auth/auth1.js index 70d9a6438b4..2ee65c68ca7 100644 --- a/jstests/auth/auth1.js +++ b/jstests/auth/auth1.js @@ -7,7 +7,7 @@ function setupTest() { port = allocatePorts( 1 )[ 0 ]; baseName = "jstests_auth_auth1"; - m = startMongod( "--auth", "--port", port, "--dbpath", MongoRunner.dataPath + baseName, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); + m = MongoRunner.runMongod({auth: "", port: port, nohttpinterface: "", bind_ip: "127.0.0.1"}); return m; } diff --git a/jstests/auth/auth2.js b/jstests/auth/auth2.js index 3cb9838682a..52d1fac084b 100644 --- a/jstests/auth/auth2.js +++ b/jstests/auth/auth2.js @@ -1,9 +1,6 @@ // test read/write permissions -port = allocatePorts( 1 )[ 0 ]; -baseName = "jstests_auth_auth2"; - -m = startMongod( "--auth", "--port", port, "--dbpath", MongoRunner.dataPath + baseName, "--nohttpinterface", "--bind_ip", "127.0.0.1", "--nojournal", "--smallfiles" ); +m = MongoRunner.runMongod({auth: "", bind_ip: "127.0.0.1", nojournal: "", smallfiles: ""}); db = m.getDB( "admin" ); // These statements throw because the localhost exception does not allow diff --git a/jstests/auth/mr_auth.js b/jstests/auth/mr_auth.js index 9e61cdcde4d..8fc556db101 100644 --- a/jstests/auth/mr_auth.js +++ b/jstests/auth/mr_auth.js @@ -8,12 +8,9 @@ map = function(){ emit( this.x, this.y );} red = function( k, vs ){ var s=0; for (var i=0; i<vs.length; i++) s+=vs[i]; return s;} red2 = function( k, vs ){ return 42;} -ports = allocatePorts( 2 ); - // make sure writing is allowed when started without --auth enabled -port = ports[ 0 ]; -dbms = startMongod( "--port", port, "--dbpath", MongoRunner.dataPath + baseName, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); +dbms = MongoRunner.runMongod({bind_ip: "127.0.0.1"}); var d = dbms.getDB( dbName ); var t = d[ baseName ]; @@ -35,13 +32,12 @@ t.mapReduce( map, red, {out: { merge: out }} ) d[ out ].drop(); -stopMongod( port ); +MongoRunner.stopMongod(dbms); // In --auth mode, read-only user should not be able to write to existing or temporary collection, thus only can execute inline mode -port = ports[ 1 ]; -dbms = startMongodNoReset( "--auth", "--port", port, "--dbpath", MongoRunner.dataPath + baseName, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); +dbms = MongoRunner.runMongod({restart: true, cleanData: false, dbpath: dbms.dbpath, auth: "", bind_ip: "127.0.0.1"}); d = dbms.getDB( dbName ); t = d[ baseName ]; @@ -78,6 +74,6 @@ t.mapReduce( map, red, {out: { merge: out }} ) // make sure it fails if output to a diff db assert.throws(function() { t.mapReduce( map, red, {out: { replace: out, db: "admin" }} ) }) -stopMongod( port ); +MongoRunner.stopMongod(dbms); print("\n\n\nmr_auth.js SUCCESS\n\n\n"); diff --git a/jstests/auth/profile.js b/jstests/auth/profile.js index 43e32b0dc58..f24a303229f 100644 --- a/jstests/auth/profile.js +++ b/jstests/auth/profile.js @@ -1,5 +1,5 @@ // Check that username information gets recorded properly in profiler. -var conn = startMongodTest(); +var conn = MongoRunner.runMongod(); var db1 = conn.getDB("profile-a"); var db2 = db1.getSisterDB("profile-b"); var username = "user"; diff --git a/jstests/auth/rename.js b/jstests/auth/rename.js index 1ed0e584811..1e6b0092a65 100644 --- a/jstests/auth/rename.js +++ b/jstests/auth/rename.js @@ -1,13 +1,10 @@ // test renameCollection with auth -port = allocatePorts( 1 )[ 0 ]; +var m = MongoRunner.runMongod({auth: ""}); -baseName = "jstests_rename_auth"; -m = startMongod( "--auth", "--port", port, "--dbpath", MongoRunner.dataPath + baseName, "--nohttpinterface" ); - -db1 = m.getDB( baseName ) -db2 = m.getDB( baseName + '_other' ) -admin = m.getDB( 'admin' ) +var db1 = m.getDB("foo"); +var db2 = m.getDB("bar"); +var admin = m.getDB( 'admin' ); // Setup initial data admin.createUser({user:'admin', pwd: 'password', roles: jsTest.adminUserRoles}); diff --git a/jstests/auth/server-4892.js b/jstests/auth/server-4892.js index 779462da4fd..161db17956a 100644 --- a/jstests/auth/server-4892.js +++ b/jstests/auth/server-4892.js @@ -24,7 +24,7 @@ function with_mongod( extra_mongod_args, operation ) { try { operation( mongod ); } finally { - stopMongod( port ); + MongoRunner.stopMongod( port ); } } diff --git a/jstests/auth/show_log_auth.js b/jstests/auth/show_log_auth.js index dfc5c736714..1620ab48d37 100644 --- a/jstests/auth/show_log_auth.js +++ b/jstests/auth/show_log_auth.js @@ -1,9 +1,8 @@ // test that "show log dbname" and "show logs" have good err messages when unauthorized -var port = allocatePorts( 1 )[ 0 ]; var baseName = "jstests_show_log_auth"; -var m = startMongod( "--auth", "--port", port, "--dbpath", MongoRunner.dataPath + baseName, "--nohttpinterface", "--bind_ip", "127.0.0.1" , "--nojournal" , "--smallfiles" ); +var m = MongoRunner.runMongod({auth: "", bind_ip: "127.0.0.1", nojournal: "", smallfiles: ""}); var db = m.getDB( "admin" ); db.createUser({user: "admin" , pwd: "pass", roles: jsTest.adminUserRoles}); diff --git a/jstests/auth/system_user_exception.js b/jstests/auth/system_user_exception.js index 6d0ec4c0cf7..f9c79828b86 100644 --- a/jstests/auth/system_user_exception.js +++ b/jstests/auth/system_user_exception.js @@ -18,4 +18,4 @@ assert.eq(1, m.getDB("local").auth({user: "__system", pwd: "foopdedoop", mechani m.getDB("test").createUser({user: "guest" , pwd: "guest", roles: jsTest.readOnlyUserRoles}); assert.eq(0, m.getDB("test").auth("guest", "guest")); -stopMongod(port); +MongoRunner.stopMongod(port); diff --git a/jstests/disk/dbNoCreate.js b/jstests/disk/dbNoCreate.js index 65cb0331401..f365e0730e9 100644 --- a/jstests/disk/dbNoCreate.js +++ b/jstests/disk/dbNoCreate.js @@ -1,6 +1,6 @@ var baseName = "jstests_dbNoCreate"; -var m = startMongod( "--port", "27018", "--dbpath", MongoRunner.dataPath + baseName ); +var m = MongoRunner.runMongod({}); var t = m.getDB( baseName ).t; @@ -9,9 +9,9 @@ t.remove({}); t.update( {}, { a:1 } ); t.drop(); -stopMongod( 27018 ); +MongoRunner.stopMongod(m); -var m = startMongoProgram( "mongod", "--port", "27018", "--dbpath", MongoRunner.dataPath + baseName ); +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/filesize.js b/jstests/disk/filesize.js index 1662c8807df..77295c7b4bd 100644 --- a/jstests/disk/filesize.js +++ b/jstests/disk/filesize.js @@ -3,9 +3,7 @@ var port = allocatePorts( 1 )[ 0 ]; var baseName = "filesize"; // Start mongod with --smallfiles -var m = startMongod( - "--port", port, "--dbpath", MongoRunner.dataPath + baseName, "--nohttpinterface", - "--bind_ip", "127.0.0.1" , "--nojournal" , "--smallfiles" ); +var m = MongoRunner.runMongod({bind_ip: "127.0.0.1", nojournal: "", smallfiles: ""}); var db = m.getDB( baseName ); @@ -14,10 +12,9 @@ if (db.serverBuildInfo().bits == 32) { print("Skip on 32-bit"); } else { // Restart mongod without --smallFiles - stopMongod( port ); - m = startMongodNoReset( - "--port", port, "--dbpath", MongoRunner.dataPath + baseName, - "--nohttpinterface", "--bind_ip", "127.0.0.1" , "--nojournal" ); + MongoRunner.stopMongod(m); + m = MongoRunner.runMongod({ + restart: true, cleanData: false, dbpath: m.dbpath, bind_ip: "127.0.0.1", nojournal: ""}); db = m.getDB( baseName ); var log = db.adminCommand( { getLog : "global" } ).log diff --git a/jstests/disk/killall.js b/jstests/disk/killall.js index 7ec6a54a9f3..c10fec18dc2 100644 --- a/jstests/disk/killall.js +++ b/jstests/disk/killall.js @@ -11,7 +11,7 @@ var port = allocatePorts( 1 )[ 0 ] var baseName = "jstests_disk_killall"; var dbpath = MongoRunner.dataPath + baseName; -var mongod = startMongod( "--port", port, "--dbpath", dbpath, "--nohttpinterface" ); +var mongod = MongoRunner.runMongod({}); var db = mongod.getDB( "test" ); var collection = db.getCollection( baseName ); assert.writeOK(collection.insert({})); @@ -28,17 +28,17 @@ sleep( 1000 ); * 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. */ -var exitCode = stopMongod( port ); +var exitCode = MongoRunner.stopMongod(mongod); assert.eq(0, exitCode, "got unexpected exitCode"); // Waits for shell to complete s1(); -mongod = startMongoProgram( "mongod", "--port", port, "--dbpath", dbpath ); +mongod = MongoRunner.runMongod({restart:true, cleanData: false, dbpath: mongod.dbpath}); db = mongod.getDB( "test" ); collection = db.getCollection( baseName ); assert( collection.stats().ok ); assert( collection.drop() ); -stopMongod( port ); +MongoRunner.stopMongod(mongod); diff --git a/jstests/disk/newcollection.js b/jstests/disk/newcollection.js index 2c39389a81b..1c016cab103 100644 --- a/jstests/disk/newcollection.js +++ b/jstests/disk/newcollection.js @@ -1,9 +1,7 @@ // SERVER-594 test -port = allocatePorts( 1 )[ 0 ] var baseName = "jstests_disk_newcollection"; -var m = startMongod( "--noprealloc", "--smallfiles", "--port", port, "--dbpath", MongoRunner.dataPath + baseName ); -//var m = db.getMongo(); +var m = MongoRunner.runMongod({noprealloc: "", smallfiles: ""}); db = m.getDB( "test" ); var t = db[baseName]; diff --git a/jstests/disk/preallocate.js b/jstests/disk/preallocate.js index e35dda45cfe..4dd792b8f6b 100644 --- a/jstests/disk/preallocate.js +++ b/jstests/disk/preallocate.js @@ -1,10 +1,8 @@ // check that there is preallocation, and there are 2 files -port = allocatePorts( 1 )[ 0 ]; - var baseName = "jstests_preallocate"; -var m = startMongod( "--port", port, "--dbpath", MongoRunner.dataPath + baseName ); +var m = MongoRunner.runMongod({}); var getTotalNonLocalSize = function() { var totalNonLocalDBSize = 0; @@ -33,9 +31,9 @@ assert.soon(function() { return getTotalNonLocalSize() >= expectedMB * 1024 * 10 "\n\n\nFAIL preallocate.js expected second file to bring total size over " + expectedMB + "MB" ); -stopMongod( port ); +MongoRunner.stopMongod(m); -var m = startMongoProgram( "mongod", "--port", port, "--dbpath", MongoRunner.dataPath + baseName ); +m = MongoRunner.runMongod({restart: true, cleanData: false, dbpath: m.dbpath}); size = getTotalNonLocalSize(); diff --git a/jstests/disk/preallocate2.js b/jstests/disk/preallocate2.js index b7c529078cc..cf191f4265a 100644 --- a/jstests/disk/preallocate2.js +++ b/jstests/disk/preallocate2.js @@ -1,10 +1,8 @@ // check that there is preallocation on insert -port = allocatePorts( 1 )[ 0 ]; - var baseName = "jstests_preallocate2"; -var m = startMongod( "--port", port, "--dbpath", MongoRunner.dataPath + baseName ); +var m = MongoRunner.runMongod({}); m.getDB( baseName )[ baseName ].save( {i:1} ); diff --git a/jstests/disk/preallocate_directoryperdb.js b/jstests/disk/preallocate_directoryperdb.js index 38f55866f60..da14d0db2d3 100644 --- a/jstests/disk/preallocate_directoryperdb.js +++ b/jstests/disk/preallocate_directoryperdb.js @@ -7,7 +7,6 @@ var baseDir = "jstests_disk_preallocate_directoryperdb"; var baseName = "preallocate_directoryperdb" var baseName2 = "preallocate_directoryperdb2" var baseName3 = "preallocate_directoryperdb3" -port = allocatePorts( 1 )[ 0 ]; dbpath = MongoRunner.dataPath + baseDir + "/"; function checkDb2DirAbsent() { @@ -19,7 +18,7 @@ function checkDb2DirAbsent() { } } -var m = startMongod( "--smallfiles", "--directoryperdb", "--port", port, "--dbpath", dbpath, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); +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(); diff --git a/jstests/disk/quota.js b/jstests/disk/quota.js index e8476072ff1..a959f344531 100644 --- a/jstests/disk/quota.js +++ b/jstests/disk/quota.js @@ -1,11 +1,8 @@ // Check functioning of --quotaFiles parameter, including with respect to SERVER-3293 ('local' database). -port = allocatePorts( 1 )[ 0 ]; - baseName = "jstests_disk_quota"; -dbpath = MongoRunner.dataPath + baseName; -m = startMongod( "--port", port, "--dbpath", MongoRunner.dataPath + baseName, "--quotaFiles", "2", "--smallfiles" ); +var m = MongoRunner.runMongod({quotaFiles: 2, smallfiles: ""}); db = m.getDB( baseName ); big = new Array( 10000 ).toString(); @@ -18,7 +15,7 @@ while( !res.hasWriteError() ) { } dotTwoDataFile = baseName + ".2"; -files = listFiles( dbpath ); +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 ); @@ -33,7 +30,7 @@ for( i = 0; i < 10000; ++i ) { if ( i % 100 != 0 ) { continue; } - files = listFiles( dbpath ); + files = listFiles( m.dbpath ); for( f in files ) { if ( files[ f ].baseName == dotTwoDataFile ) { dotTwoFound = true; diff --git a/jstests/disk/quota2.js b/jstests/disk/quota2.js index cdeda1a2a23..95639d7cc4c 100644 --- a/jstests/disk/quota2.js +++ b/jstests/disk/quota2.js @@ -2,12 +2,9 @@ if ( 0 ) { // SERVER-3420 -port = allocatePorts( 1 )[ 0 ]; - baseName = "jstests_disk_quota2"; -dbpath = MongoRunner.dataPath + baseName; -m = startMongod( "--port", port, "--dbpath", MongoRunner.dataPath + baseName, "--quotaFiles", "2", "--smallfiles" ); +var m = MongoRunner.runMongod({quotaFiles: 2, smallfiles: ""}); db = m.getDB( baseName ); big = new Array( 10000 ).toString(); diff --git a/jstests/disk/quota3.js b/jstests/disk/quota3.js index 484231ef610..43227d21bfc 100644 --- a/jstests/disk/quota3.js +++ b/jstests/disk/quota3.js @@ -2,12 +2,10 @@ if ( 0 ) { // SERVER-3511 -port = allocatePorts( 1 )[ 0 ]; - baseName = "jstests_disk_quota3"; dbpath = MongoRunner.dataPath + baseName; -m = startMongod( "--port", port, "--dbpath", MongoRunner.dataPath + baseName, "--quotaFiles", "3", "--smallfiles" ); +var m = MongoRunner.runMongod({dbpath: dbpath, quotaFiles: 3, smallfiles: ""}); db = m.getDB( baseName ); db.createCollection( baseName, {size:128*1024*1024} ); diff --git a/jstests/disk/repair.js b/jstests/disk/repair.js index f6ac67690e0..0a92658252b 100644 --- a/jstests/disk/repair.js +++ b/jstests/disk/repair.js @@ -22,14 +22,14 @@ function check() { assert.eq.automsg( "1", "db[ baseName ].count()" ); } check(); -stopMongod( port ); +MongoRunner.stopMongod( port ); resetDbpath( repairpath ); m = startMongoProgram( "mongod", "--port", port, "--dbpath", dbpath, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); db = m.getDB( baseName ); assert.commandWorked( db.runCommand( {repairDatabase:1} ) ); check(); -stopMongod( port ); +MongoRunner.stopMongod( port ); resetDbpath( repairpath ); rc = runMongoProgram( "mongod", "--repair", "--port", port, "--dbpath", dbpath, "--repairpath", repairpath, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); @@ -37,7 +37,7 @@ assert.eq.automsg( "0", "rc" ); m = startMongoProgram( "mongod", "--port", port, "--dbpath", dbpath, "--repairpath", repairpath, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); db = m.getDB( baseName ); check(); -stopMongod( port ); +MongoRunner.stopMongod( port ); resetDbpath( repairpath ); rc = runMongoProgram( "mongod", "--repair", "--port", port, "--dbpath", dbpath, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); diff --git a/jstests/disk/repair2.js b/jstests/disk/repair2.js index f794653d144..a582d06a0ec 100644 --- a/jstests/disk/repair2.js +++ b/jstests/disk/repair2.js @@ -41,14 +41,14 @@ for( f in files ) { assert( fileCount > 0, "Expected more than zero nondirectory files in the database directory" ); check(); -stopMongod( port ); +MongoRunner.stopMongod( port ); resetDbpath( repairpath ); m = startMongoProgram( "mongod", "--directoryperdb", "--port", port, "--dbpath", dbpath, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); db = m.getDB( baseName ); assert.commandWorked( db.runCommand( {repairDatabase:1} ) ); check(); -stopMongod( port ); +MongoRunner.stopMongod( port ); //Test long database names resetDbpath( repairpath ); @@ -56,7 +56,7 @@ m = startMongoProgram( "mongod", "--directoryperdb", "--port", port, "--dbpath", db = m.getDB( longDBName ); assert.writeOK(db[ baseName ].save( {} )); assert.commandWorked( db.runCommand( {repairDatabase:1} ) ); -stopMongod( port ); +MongoRunner.stopMongod( port ); //Test long repairPath resetDbpath( longRepairPath ) @@ -64,7 +64,7 @@ m = startMongoProgram( "mongod", "--directoryperdb", "--port", port, "--dbpath", db = m.getDB( longDBName ); assert.commandWorked( db.runCommand( {repairDatabase:1, backupOriginalFiles: true} ) ); check(); -stopMongod( port ); +MongoRunner.stopMongod( port ); //Test database name and repairPath with --repair resetDbpath( longRepairPath ) @@ -72,14 +72,14 @@ m = startMongoProgram( "mongod", "--repair", "--directoryperdb", "--port", port, m = startMongoProgram( "mongod", "--directoryperdb", "--port", port, "--dbpath", dbpath, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); db = m.getDB( longDBName ); check(); -stopMongod( port ); +MongoRunner.stopMongod( port ); resetDbpath( repairpath ); runMongoProgram( "mongod", "--repair", "--directoryperdb", "--port", port, "--dbpath", dbpath, "--repairpath", repairpath, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); m = startMongoProgram( "mongod", "--directoryperdb", "--port", port, "--dbpath", dbpath, "--repairpath", repairpath, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); db = m.getDB( baseName ); check(); -stopMongod( port ); +MongoRunner.stopMongod( port ); resetDbpath( repairpath ); runMongoProgram( "mongod", "--repair", "--directoryperdb", "--port", port, "--dbpath", dbpath, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); diff --git a/jstests/disk/repair3.js b/jstests/disk/repair3.js index 0c5748575b1..6b4997cc83c 100644 --- a/jstests/disk/repair3.js +++ b/jstests/disk/repair3.js @@ -39,7 +39,7 @@ if ( doIt ) { } check(); - stopMongod( port ); + MongoRunner.stopMongod( port ); resetDbpath( repairpath ); rc = runMongoProgram( "mongod", "--nssize", "8", "--noprealloc", "--smallfiles", "--repair", "--port", port, "--dbpath", dbpath, "--repairpath", repairpath, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); @@ -47,6 +47,6 @@ if ( doIt ) { m = startMongoProgram( "mongod", "--nssize", "8", "--noprealloc", "--smallfiles", "--port", port, "--dbpath", dbpath, "--repairpath", repairpath, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); db = m.getDB( baseName ); check(); - stopMongod( port ); + MongoRunner.stopMongod( port ); }
\ No newline at end of file diff --git a/jstests/disk/repair4.js b/jstests/disk/repair4.js index 09b1e2cdc87..944a4f6fd11 100644 --- a/jstests/disk/repair4.js +++ b/jstests/disk/repair4.js @@ -39,6 +39,6 @@ if ( doIt ) { } check(); - stopMongod( port ); + MongoRunner.stopMongod( port ); }
\ No newline at end of file diff --git a/jstests/disk/repair5.js b/jstests/disk/repair5.js index b8dedb3ccf4..cef20dba0f3 100644 --- a/jstests/disk/repair5.js +++ b/jstests/disk/repair5.js @@ -2,17 +2,17 @@ var baseName = "jstests_disk_repair5"; -port = allocatePorts( 1 )[ 0 ]; dbpath = MongoRunner.dataPath + baseName + "/"; repairpath = dbpath + "repairDir/" resetDbpath( dbpath ); resetDbpath( repairpath ); -m = startMongodTest(port, - baseName + "/", - true, - {repairpath : repairpath, nohttpinterface : "", bind_ip : "127.0.0.1"}); +m = MongoRunner.runMongod({dbpath: dbpath, + repairpath: repairpath, + restart:true, + cleanData: false, // Don't clean data so repair dir doesn't get removed + bind_ip: "127.0.0.1"}); db = m.getDB( baseName ); @@ -48,4 +48,4 @@ s(); assert.eq( 20000, db[ baseName ].find().itcount() ); assert( db[ baseName ].validate().valid ); -stopMongod( port ) +MongoRunner.stopMongod(m); diff --git a/jstests/dur/a_quick.js b/jstests/dur/a_quick.js index bbec8af6939..937b0b71bf4 100755 --- a/jstests/dur/a_quick.js +++ b/jstests/dur/a_quick.js @@ -59,16 +59,16 @@ var path2 = MongoRunner.dataDir + "/quickdur"; // non-durable version tst.log("start mongod without dur"); -var conn = startMongodEmpty("--port", 30000, "--dbpath", path1, "--nodur"); +var conn = MongoRunner.runMongod({dbpath: path1, nodur: ""}); tst.log("without dur work"); var d = conn.getDB("test"); assert.writeOK(d.foo.insert({ _id: 123 })); tst.log("stop without dur"); -stopMongod(30000); +MongoRunner.stopMongod(conn); // durable version tst.log("start mongod with dur"); -conn = startMongodEmpty("--port", 30001, "--dbpath", path2, "--dur", "--durOptions", 8); +conn = MongoRunner.runMongod({dbpath: path2, dur: "", durOptions: 8}); tst.log("with dur work"); d = conn.getDB("test"); assert.writeOK(d.foo.insert({ _id: 123 })); @@ -81,7 +81,7 @@ sleep(8000); // kill the process hard tst.log("kill -9 mongod"); -stopMongod(30001, /*signal*/9); +MongoRunner.stopMongod(conn.port, /*signal*/9); // journal file should be present, and non-empty as we killed hard @@ -104,7 +104,7 @@ if (files.some(function (f) { return f.name.indexOf("lsn") >= 0; })) { // restart and recover tst.log("restart and recover"); -conn = startMongodNoReset("--port", 30002, "--dbpath", path2, "--dur", "--durOptions", 9); +conn = MongoRunner.runMongod({restart: true, cleanData: false, dbpath: path2, dur: "", durOptions: 9}); tst.log("check data results");
d = conn.getDB("test");
@@ -115,7 +115,7 @@ if (!countOk) { } tst.log("stop"); -stopMongod(30002); +MongoRunner.stopMongod(conn); // at this point, after clean shutdown, there should be no journal files tst.log("check no journal files"); diff --git a/jstests/dur/checksum.js b/jstests/dur/checksum.js index 1270e337a87..ed4abf31147 100644 --- a/jstests/dur/checksum.js +++ b/jstests/dur/checksum.js @@ -6,7 +6,7 @@ var path = MongoRunner.dataPath + testname; if (0) { // This is used to create the prototype journal file. jsTest.log("Just creating prototype journal, not testing anything"); - var conn = startMongodEmpty("--port", 30001, "--dbpath", path, "--dur"); + var conn = MongoRunner.runMongod({dbpath: path, dur: ""}); var db = conn.getDB("test"); // each insert is in it's own commit. @@ -16,7 +16,7 @@ if (0) { db.foo.insert({a: 2}); db.runCommand({getlasterror:1, j:1}) - stopMongod(30001, /*signal*/9); + MongoRunner.stopMongod(conn.port, /*signal*/9); jsTest.log("Journal file left at " + path + "/journal/j._0"); quit(); @@ -25,11 +25,12 @@ if (0) { } function startMongodWithJournal() { - return startMongodNoReset("--port", 30001, - "--dbpath", path, - "--dur", - "--smallfiles", - "--durOptions", 1 /*DurDumpJournal*/); + return MongoRunner.runMongod({restart: true, + cleanData: false, + dbpath: path, + dur: "", + smallfiles: "", + durOptions: 1 /*DurDumpJournal*/}); } @@ -40,7 +41,7 @@ copyFile("jstests/libs/dur_checksum_good.journal", path + "/journal/j._0"); var conn = startMongodWithJournal(); var db = conn.getDB('test'); assert.eq(db.foo.count(), 2); -stopMongod(30001); +MongoRunner.stopMongod(conn.port); // dur_checksum_bad_last.journal is good.journal with the bad checksum on the last section. @@ -51,7 +52,7 @@ copyFile("jstests/libs/dur_checksum_bad_last.journal", path + "/journal/j._0"); conn = startMongodWithJournal(); var db = conn.getDB('test'); assert.eq(db.foo.count(), 1); // 2nd insert "never happened" -stopMongod(30001); +MongoRunner.stopMongod(conn.port); // dur_checksum_bad_first.journal is good.journal with the bad checksum on the prior section. @@ -64,7 +65,7 @@ copyFile("jstests/libs/dur_checksum_bad_first.journal", path + "/journal/j._0"); conn = startMongodWithJournal(); var db = conn.getDB('test'); assert.eq(db.foo.count(), 0); // Neither insert happened. -stopMongod(30001); +MongoRunner.stopMongod(conn.port); // If we detect an error in a non-final journal file, that is considered an error. jsTest.log("Starting with bad_last.journal followed by good.journal"); diff --git a/jstests/dur/closeall.js b/jstests/dur/closeall.js index 00b4fff1c3c..6dc301e9ae2 100644 --- a/jstests/dur/closeall.js +++ b/jstests/dur/closeall.js @@ -2,8 +2,6 @@ // this is also a test of saveState() as that will get exercised by the update function f(variant, quickCommits, paranoid) { - var path = MongoRunner.dataDir + "/closeall"; - var path2 = MongoRunner.dataDir + "/closeall_slave"; var ourdb = "closealltest"; print("closeall.js start mongod variant:" + variant + "." + quickCommits + "." + paranoid); @@ -14,8 +12,14 @@ function f(variant, quickCommits, paranoid) { N = 300; // use replication to exercise that code too with a close, and also to test local.sources with a close - var conn = startMongodEmpty("--port", 30001, "--dbpath", path, "--dur", "--durOptions", options, "--master", "--oplogSize", 64); - var connSlave = startMongodEmpty("--port", 30002, "--dbpath", path2, "--dur", "--durOptions", options, "--slave", "--source", "localhost:30001"); + var conn = MongoRunner.runMongod({dur: "", + durOptions: options + "", + master: "", + oplogSize: 64}); + var connSlave = MongoRunner.runMongod({dur: "", + durOptions: options + "", + slave: "", + source: "localhost:" + conn.port}); var slave = connSlave.getDB(ourdb); @@ -45,7 +49,7 @@ function f(variant, quickCommits, paranoid) { { a: 1, b: 2, c: 3, d: 4 }); \ if( i == 800 ) \ coll.ensureIndex({ x: 1 }); \ - }', 30001); + }', conn.port); for( var i = 0; i < N; i++ ) { var res = null; @@ -80,8 +84,8 @@ function f(variant, quickCommits, paranoid) { print(slave.foo.count()); print("closeall.js shutting down servers"); - stopMongod(30002); - stopMongod(30001); + MongoRunner.stopMongod(connSlave); + MongoRunner.stopMongod(conn); writeOps(); } diff --git a/jstests/dur/diskfull.js b/jstests/dur/diskfull.js index 6fb38a15d1b..5d3b0da8906 100644 --- a/jstests/dur/diskfull.js +++ b/jstests/dur/diskfull.js @@ -94,10 +94,10 @@ function runFirstMongodAndFillDisk() { log(); clear(); - conn = startMongodNoReset("--port", 30001, "--dbpath", startPath, "--dur", "--smallfiles", "--durOptions", 8+64, "--noprealloc"); + conn = MongoRunner.runMongod({restart: true, cleanData: false, dbpath: startPath, dur: "", smallfiles: "", durOptions: 8+64, noprealloc: ""}); assert.throws( work, null, "no exception thrown when exceeding disk capacity" ); - stopMongod( 30001 ); + MongoRunner.stopMongod(conn); sleep(5000); } @@ -105,11 +105,11 @@ function runFirstMongodAndFillDisk() { function runSecondMongdAndRecover() { // restart and recover log(); - conn = startMongodNoReset("--port", 30003, "--dbpath", startPath, "--dur", "--smallfiles", "--durOptions", 8+64, "--noprealloc"); + conn = MongoRunner.runMongod({restart: true, cleanData: false, dbpath: startPath, dur: "", smallfiles: "", durOptions: 8+64, noprealloc: ""}); verify(); log("stop"); - stopMongod(30003); + MongoRunner.stopMongod(conn); // stopMongod seems to be asynchronous (hmmm) so we sleep here. sleep(5000); diff --git a/jstests/dur/dropdb.js b/jstests/dur/dropdb.js index 54de6bdd7f2..4e0cc73f811 100644 --- a/jstests/dur/dropdb.js +++ b/jstests/dur/dropdb.js @@ -110,20 +110,20 @@ var path2 = MongoRunner.dataPath + testname + "dur"; // non-durable version log("mongod nodur"); -conn = startMongodEmpty("--port", 30000, "--dbpath", path1, "--nodur", "--smallfiles"); +conn = MongoRunner.runMongod({dbpath: path1, nodur: "", smallfiles: ""}); work(); verify(); -stopMongod(30000); +MongoRunner.stopMongod(conn); // durable version log("mongod dur"); -conn = startMongodEmpty("--port", 30001, "--dbpath", path2, "--dur", "--smallfiles", "--durOptions", 8); +conn = MongoRunner.runMongod({dbpath: path2, dur: "", smallfiles: "", durOptions: 8}); work(); verify(); // kill the process hard log("kill 9"); -stopMongod(30001, /*signal*/9); +MongoRunner.stopMongod(conn.port, /*signal*/9); // journal file should be present, and non-empty as we killed hard @@ -133,13 +133,13 @@ removeFile(path2 + "/test.0"); removeFile(path2 + "/lsn"); log("restart and recover"); -conn = startMongodNoReset("--port", 30002, "--dbpath", path2, "--dur", "--smallfiles", "--durOptions", 9); +conn = MongoRunner.runMongod({restart: true, cleanData: false, dbpath: path2, dur: "", smallfiles: "", durOptions: 9}); log("verify after recovery"); verify(); log("stop mongod 30002"); -stopMongod(30002); +MongoRunner.stopMongod(conn); sleep(5000); // at this point, after clean shutdown, there should be no journal files diff --git a/jstests/dur/dur1.js b/jstests/dur/dur1.js index 0aecaaac21c..4668b4921e2 100755 --- a/jstests/dur/dur1.js +++ b/jstests/dur/dur1.js @@ -94,13 +94,13 @@ var path2 = MongoRunner.dataPath + testname+"dur"; // non-durable version log("run mongod without journaling"); -conn = startMongodEmpty("--port", 30000, "--dbpath", path1, "--nodur", "--smallfiles"); +conn = MongoRunner.runMongod({dbpath: path1, nodur: "", smallfiles: ""}); work(); -stopMongod(30000); +MongoRunner.stopMongod(conn); // durable version log("run mongod with --journal"); -conn = startMongodEmpty("--port", 30001, "--dbpath", path2, "--journal", "--smallfiles", "--journalOptions", 8); +conn = MongoRunner.runMongod({dbpath: path2, journal: "", smallfiles: "", journalOptions: 8}); work(); // wait for group commit. @@ -108,17 +108,22 @@ printjson(conn.getDB('admin').runCommand({getlasterror:1, fsync:1})); // kill the process hard
log("kill 9"); -stopMongod(30001, /*signal*/9); +MongoRunner.stopMongod(conn.port, /*signal*/9); // journal file should be present, and non-empty as we killed hard // restart and recover log("restart mongod --journal and recover"); -conn = startMongodNoReset("--port", 30002, "--dbpath", path2, "--journal", "--smallfiles", "--journalOptions", 8); +conn = MongoRunner.runMongod({restart: true, + cleanData: false, + dbpath: path2, + journal: "", + smallfiles: "", + journalOptions: 8}); verify(); log("stop mongod"); -stopMongod(30002); +MongoRunner.stopMongod(conn); // stopMongod seems to be asynchronous (hmmm) so we sleep here. // sleep(5000); diff --git a/jstests/dur/dur1_tool.js b/jstests/dur/dur1_tool.js index f50c3d123c2..f86e643b6f7 100755 --- a/jstests/dur/dur1_tool.js +++ b/jstests/dur/dur1_tool.js @@ -93,13 +93,14 @@ var path2 = MongoRunner.dataPath + testname+"dur"; // non-durable version log("run mongod without journaling"); -conn = startMongodEmpty("--port", 30000, "--dbpath", path1, "--nodur", "--smallfiles"); + +conn = MongoRunner.runMongod({dbpath: path1, nodur: "", smallfiles: ""}); work(); -stopMongod(30000); +MongoRunner.stopMongod(conn); // durable version log("run mongod with --journal"); -conn = startMongodEmpty("--port", 30001, "--dbpath", path2, "--journal", "--smallfiles", "--journalOptions", 8); +conn = MongoRunner.runMongod({dbpath: path2, journal: "", smallfiles: "", journalOptions: 8}); work(); // wait for group commit. @@ -107,18 +108,22 @@ printjson(conn.getDB('admin').runCommand({getlasterror:1, fsync:1})); // kill the process hard
log("kill 9"); -stopMongod(30001, /*signal*/9); +MongoRunner.stopMongod(conn, /*signal*/9); // journal file should be present, and non-empty as we killed hard // mongod with --dbpath and --journal options should do a recovery pass // empty.bson is an empty file so it won't actually insert anything log("use mongod to recover"); -conn = startMongoProgram('mongod', '--port', 30001, '--dbpath', path2, - '--journal', '--smallfiles', - '--nohttpinterface', '--noprealloc', '--bind_ip', '127.0.0.1'); +conn = MongoRunner.runMongod({restart: true, + cleanData: false, + dbpath: path2, + journal: "", + smallfiles: "", + noprealloc: "", + bind_ip: "127.0.0.1"}); verify(); -stopMongod(30001); +MongoRunner.stopMongod(conn); // at this point, after clean shutdown, there should be no journal files log("check no journal files (after presumably clean shutdown)"); diff --git a/jstests/dur/dur2.js b/jstests/dur/dur2.js index 25cf8b1ccb2..2748f69505e 100644 --- a/jstests/dur/dur2.js +++ b/jstests/dur/dur2.js @@ -68,21 +68,33 @@ if( debugging ) { var path = MongoRunner.dataPath + testname+"dur"; log("run mongod with --dur"); -conn = startMongodEmpty("--port", 30001, "--dbpath", path, "--dur", "--smallfiles", "--durOptions", /*DurParanoid*/8, "--master", "--oplogSize", 64); +conn = MongoRunner.runMongod({dbpath: path, + dur: "", + smallfiles: "", + durOptions: 8 /*DurParanoid*/, + master: "", + oplogSize: 64}); work();
log("kill -9"); -stopMongod(30001, /*signal*/9);
+MongoRunner.stopMongod(conn, /*signal*/9);
// journal file should be present, and non-empty as we killed hard
assert(listFiles(path + "/journal/").length > 0, "journal directory is unexpectantly empty after kill"); // restart and recover log("restart mongod and recover"); -conn = startMongodNoReset("--port", 30002, "--dbpath", path, "--dur", "--smallfiles", "--durOptions", 8, "--master", "--oplogSize", 64); +conn = MongoRunner.runMongod({restart: true, + cleanData: false, + dbpath: path, + dur: "", + smallfiles: "", + durOptions: 8, + master: "", + oplogSize: 64}); verify(); -log("stopping mongod 30002"); -stopMongod(30002); +log("stopping mongod " + conn.port); +MongoRunner.stopMongod(conn); print(testname + " SUCCESS"); diff --git a/jstests/dur/dur_jscore_passthrough.js b/jstests/dur/dur_jscore_passthrough.js index 859be03d456..30ef17cd44b 100644 --- a/jstests/dur/dur_jscore_passthrough.js +++ b/jstests/dur/dur_jscore_passthrough.js @@ -5,8 +5,7 @@ //TODO(mathias) add --master or make another test //conn = startMongodEmpty("--port", 30200, "--dbpath", MongoRunner.dataDir + "/dur_passthrough", "--dur", "--smallfiles", "--durOptions", "24"); -conn = startMongodEmpty("--port", 30200, "--dbpath", MongoRunner.dataDir + "/dur_passthrough", "--dur", "--nopreallocj", "--smallfiles", -"--durOptions", "8"); +var conn = MongoRunner.runMongod({dur: "", nopreallocj: "", smallfiles: "", durOptions: 8}); db = conn.getDB("test"); conn.forceWriteMode("commands"); @@ -38,7 +37,7 @@ function doTest() { } ); - stopMongod(30200); + MongoRunner.stopMongod(conn); var runnerEnd = new Date() diff --git a/jstests/dur/indexbg.js b/jstests/dur/indexbg.js index 71df92a41f6..60904acd917 100644 --- a/jstests/dur/indexbg.js +++ b/jstests/dur/indexbg.js @@ -1,6 +1,6 @@ path = MongoRunner.dataDir + '/indexbg_dur'; -m = startMongodEmpty( '--port', 30001, '--dbpath', path, '--journal', '--smallfiles', '--journalOptions', 24 ); +var m = MongoRunner.runMongod({journal: "", smallfiles: "", journalOptions: 24}); t = m.getDB( 'test' ).test; t.save( {x:1} ); t.createIndex( {x:1}, {background:true} ); diff --git a/jstests/dur/indexbg2.js b/jstests/dur/indexbg2.js index d239d4eaa44..b3234af432f 100644 --- a/jstests/dur/indexbg2.js +++ b/jstests/dur/indexbg2.js @@ -1,6 +1,6 @@ path = MongoRunner.dataDir + '/indexbg2_dur'; -m = startMongodEmpty( '--port', 30001, '--dbpath', path, '--journal', '--smallfiles' ); +var m = MongoRunner.runMongod({journal: "", smallfiles: ""}); t = m.getDB( 'test' ).test; t.createIndex( {a:1} ); diff --git a/jstests/dur/lsn.js b/jstests/dur/lsn.js index 93adf72b42e..347db279666 100755 --- a/jstests/dur/lsn.js +++ b/jstests/dur/lsn.js @@ -76,14 +76,20 @@ var path2 = MongoRunner.dataPath + testname+"dur"; // run mongod with a short --syncdelay to make LSN writing sooner log("run mongod --dur and a short --syncdelay"); -conn = startMongodEmpty("--syncdelay", 2, "--port", 30001, "--dbpath", path2, "--dur", "--smallfiles", "--durOptions", /*DurParanoid*/8, "--master", "--oplogSize", 64); +conn = MongoRunner.runMongod({dbpath: path2, + syncdelay: 2, + dur: "", + smallfiles: "", + durOptions: 8 /*DurParanoid*/, + master: "", + oplogSize: 64}); work(); log("wait a while for a sync and an lsn write"); sleep(14); // wait for lsn write log("kill mongod -9"); -stopMongod(30001, /*signal*/9); +MongoRunner.stopMongod(conn, /*signal*/9); // journal file should be present, and non-empty as we killed hard @@ -103,7 +109,14 @@ stopMongod(30001, /*signal*/9); // restart and recover log("restart mongod, recover, verify"); -conn = startMongodNoReset("--port", 30002, "--dbpath", path2, "--dur", "--smallfiles", "--durOptions", 24, "--master", "--oplogSize", 64); +conn = MongoRunner.runMongod({restart:true, + cleanData: false, + dbpath: path2, + dur: "", + smallfiles: "", + durOptions: 24, + master: "", + oplogSize: 64}); verify(); // idea here is to verify (in a simplistic way) that we are in a good state to do further ops after recovery @@ -120,7 +133,7 @@ log("add data after recovery"); d.xyz.insert({ x: 1 }); } -log("stop mongod 30002"); -stopMongod(30002); +log("stop mongod " + conn.port); +MongoRunner.stopMongod(conn); print(testname + " SUCCESS"); diff --git a/jstests/dur/manyRestart.js b/jstests/dur/manyRestart.js index 5a68afdecbb..f30b068a79a 100755 --- a/jstests/dur/manyRestart.js +++ b/jstests/dur/manyRestart.js @@ -105,29 +105,29 @@ var path1 = MongoRunner.dataPath + testname+"nodur"; var path2 = MongoRunner.dataPath + testname+"dur"; // non-durable version -log("starting 30000"); -conn = startMongodEmpty("--port", 30000, "--dbpath", path1, "--nodur", "--smallfiles"); +log("starting first mongod"); +conn = MongoRunner.runMongod({dbpath: path1, nodur: "", smallfiles: ""}); work(); -stopMongod(30000); +MongoRunner.stopMongod(conn); // hail mary for windows // Sat Jun 11 14:07:57 Error: boost::filesystem::create_directory: Access is denied: "\data\db\manyRestartsdur" (anon):1 sleep(1000); -log("starting 30001"); -conn = startMongodEmpty("--port", 30001, "--dbpath", path2, "--dur", "--smallfiles", "--durOptions", 8); +log("starting second mongod"); +conn = MongoRunner.runMongod({dbpath: path2, dur: "", smallfiles: "", durOptions: 8}); work(); // wait for group commit. printjson(conn.getDB('admin').runCommand({getlasterror:1, fsync:1})); -stopMongod(30001); +MongoRunner.stopMongod(conn); sleep(5000); for (var i = 0; i < 3; ++i) { // durable version - log("restarting 30001"); - conn = startMongodNoReset("--port", 30001, "--dbpath", path2, "--dur", "--smallfiles", "--durOptions", 8); + log("restarting second mongod"); + conn = MongoRunner.runMongod({restart: true, cleanData: false, dbpath: path2, dur: "", smallfiles: "", durOptions: 8}); // wait for group commit. printjson(conn.getDB('admin').runCommand({getlasterror:1, fsync:1})); @@ -136,7 +136,7 @@ for (var i = 0; i < 3; ++i) { // kill the process hard log("hard kill"); - stopMongod(30001, /*signal*/9); + MongoRunner.stopMongod(conn, /*signal*/9); sleep(5000); } @@ -145,11 +145,11 @@ for (var i = 0; i < 3; ++i) { // restart and recover log("restart"); -conn = startMongodNoReset("--port", 30002, "--dbpath", path2, "--dur", "--smallfiles", "--durOptions", 8); +conn = MongoRunner.runMongod({restart: true, cleanData: false, dbpath: path2, dur: "", smallfiles: "", durOptions: 8}); log("verify"); verify(); log("stop"); -stopMongod(30002); +MongoRunner.stopMongod(conn); sleep(5000); // at this point, after clean shutdown, there should be no journal files @@ -170,8 +170,8 @@ var nrows = 0; for (var i = 0; i < 5; ++i) { // durable version - log("restarting 30001"); - conn = startMongodNoReset("--port", 30001, "--dbpath", path2, "--dur", "--smallfiles", "--durOptions", 8); + log("restarting second mongod"); + conn = MongoRunner.runMongod({restart: true, cleanData: false, dbpath: path2, dur: "", smallfiles: "", durOptions: 8}); nrows += addRows(); // wait for group commit. printjson(conn.getDB('admin').runCommand({getlasterror:1, fsync:1})); @@ -180,7 +180,7 @@ for (var i = 0; i < 5; ++i) { // kill the process hard log("hard kill"); - stopMongod(30001, /*signal*/9); + MongoRunner.stopMongod(conn, /*signal*/9); sleep(5000); } diff --git a/jstests/dur/oplog.js b/jstests/dur/oplog.js index 8ded3c980a9..d0829f66f8b 100755 --- a/jstests/dur/oplog.js +++ b/jstests/dur/oplog.js @@ -103,30 +103,42 @@ var path2 = MongoRunner.dataPath + testname+"dur"; // non-durable version log(); -conn = startMongodEmpty("--port", 30000, "--dbpath", path1, "--nodur", "--smallfiles", "--master", "--oplogSize", 64); +conn = MongoRunner.runMongod({dbpath: path1, nodur: "", smallfiles: "", master: "", oplogSize: 64}); work(); -stopMongod(30000); +MongoRunner.stopMongod(conn); // durable version log(); -conn = startMongodEmpty("--port", 30001, "--dbpath", path2, "--dur", "--smallfiles", "--durOptions", /*DurParanoid*/8, "--master", "--oplogSize", 64); +conn = MongoRunner.runMongod({dbpath: path2, + dur: "", + smallfiles: "", + durOptions: 8 /*DurParanoid*/, + master: "", + oplogSize: 64}); work(); // wait for group commit. printjson(conn.getDB('admin').runCommand({getlasterror:1, fsync:1})); // kill the process hard -stopMongod(30001, /*signal*/9); +MongoRunner.stopMongod(conn, /*signal*/9); // journal file should be present, and non-empty as we killed hard // restart and recover log(); -conn = startMongodNoReset("--port", 30002, "--dbpath", path2, "--dur", "--smallfiles", "--durOptions", 8, "--master", "--oplogSize", 64); +conn = MongoRunner.runMongod({restart: true, + cleanData: false, + dbpath: path2, + dur: "", + smallfiles: "", + durOptions: 8, + master: "", + oplogSize: 64}); verify(); log("stop"); -stopMongod(30002); +MongoRunner.stopMongod(conn); // stopMongod seems to be asynchronous (hmmm) so we sleep here. sleep(5000); diff --git a/jstests/gle/get_last_error.js b/jstests/gle/get_last_error.js index c97c6da0b56..2cd9836350e 100644 --- a/jstests/gle/get_last_error.js +++ b/jstests/gle/get_last_error.js @@ -89,7 +89,8 @@ replTest.stopSet(); // Need to start a single server manually to keep this test in the jstests/replsets test suite var port = allocatePorts(1)[0]; var baseName = "SERVER-9005"; -var mongod = startMongod("--port", port, "--dbpath", MongoRunner.dataPath + baseName); + +var mongod = MongoRunner.runMongod({port: port}); var sdb = new Mongo("localhost:"+port).getDB("test"); sdb.foo.drop(); @@ -112,4 +113,4 @@ printjson(gle); assert.eq(gle.ok, 0); assert(gle.badGLE); -stopMongod(port); +MongoRunner.stopMongod(mongod); diff --git a/jstests/libs/slow_weekly_util.js b/jstests/libs/slow_weekly_util.js index f5f89643f16..18fc0874daa 100644 --- a/jstests/libs/slow_weekly_util.js +++ b/jstests/libs/slow_weekly_util.js @@ -5,7 +5,7 @@ SlowWeeklyMongod = function( name ) { this.start = new Date(); - this.conn = startMongodEmpty("--port", this.port, "--dbpath", MongoRunner.dataPath + this.name , "--smallfiles", "--nojournal" ); + this.conn = MongoRunner.runMongod({port: this.port, smallfiles: "", nojournal: ""}); }; SlowWeeklyMongod.prototype.getDB = function( name ) { @@ -13,7 +13,7 @@ SlowWeeklyMongod.prototype.getDB = function( name ) { } SlowWeeklyMongod.prototype.stop = function(){ - stopMongod( this.port ); + MongoRunner.stopMongod( this.conn ); var end = new Date(); print( "slowWeekly test: " + this.name + " completed successfully in " + ( ( end.getTime() - this.start.getTime() ) / 1000 ) + " seconds" ); }; diff --git a/jstests/mmap_v1/dur_big_atomic_update.js b/jstests/mmap_v1/dur_big_atomic_update.js index 04531a75fd1..33cd88e22b2 100644 --- a/jstests/mmap_v1/dur_big_atomic_update.js +++ b/jstests/mmap_v1/dur_big_atomic_update.js @@ -2,9 +2,7 @@ // // this tests writing 1GB in an atomic update to make sure we commit periodically -var path = MongoRunner.dataDir + "/dur_big_atomic_update"; - -conn = startMongodEmpty("--port", 30001, "--dbpath", path, "--dur", "--durOptions", 8); +var conn = MongoRunner.runMongod({dur: "", durOptions: 8}); d = conn.getDB("test"); d.foo.drop(); @@ -49,6 +47,6 @@ assert(err.n == 1024); // free up space d.dropDatabase(); -stopMongod(30001); +MongoRunner.stopMongod(conn); print("dur big atomic update SUCCESS"); diff --git a/jstests/mmap_v1/dur_remove_old_journals.js b/jstests/mmap_v1/dur_remove_old_journals.js index 59f50f9c359..56178af2cb6 100644 --- a/jstests/mmap_v1/dur_remove_old_journals.js +++ b/jstests/mmap_v1/dur_remove_old_journals.js @@ -10,7 +10,7 @@ else { PATH = MongoRunner.dataDir + "/dur_remove_old_journals"; SYNC_DELAY = 5; // must be a number - conn = startMongodEmpty("--port", 30001, "--dbpath", PATH, "--dur", "--smallfiles", "--syncdelay", ''+SYNC_DELAY); + var conn = MongoRunner.runMongod({dbpath: PATH, dur: "", smallfiles: "", syncdelay: SYNC_DELAY}); db = conn.getDB("test"); longString = 'x'; @@ -51,7 +51,7 @@ else { assert.eq(2, nfiles); // latest journal file and lsn - stopMongod(30001); + MongoRunner.stopMongod(conn); } print("*** success ***"); diff --git a/jstests/multiVersion/transitioning_to_and_from_WT.js b/jstests/multiVersion/transitioning_to_and_from_WT.js index 76d0a4df522..91b34bbd59e 100644 --- a/jstests/multiVersion/transitioning_to_and_from_WT.js +++ b/jstests/multiVersion/transitioning_to_and_from_WT.js @@ -136,7 +136,7 @@ assert.eq(0, ret); // stop previous mongod - stopMongod(toolTest.port); + MongoRunner.stopMongod(toolTest.port); // clear old node configuration info toolTest.m = null; diff --git a/jstests/noPassthrough/command_line_parsing.js b/jstests/noPassthrough/command_line_parsing.js index c715b011961..81acf2f8359 100644 --- a/jstests/noPassthrough/command_line_parsing.js +++ b/jstests/noPassthrough/command_line_parsing.js @@ -1,24 +1,23 @@ // validate command line parameter parsing -port = allocatePorts( 1 )[ 0 ]; var baseName = "jstests_slowNightly_command_line_parsing"; // test notablescan -var m = startMongod( "--port", port, "--dbpath", MongoRunner.dataPath + baseName, "--notablescan" ); +var m = MongoRunner.runMongod({notablescan: ""}); m.getDB( baseName ).getCollection( baseName ).save( {a:1} ); assert.throws( function() { m.getDB( baseName ).getCollection( baseName ).find( {a:1} ).toArray() } ); // test config file -var m2 = startMongod( "--port", port+2, "--dbpath", MongoRunner.dataPath + baseName +"2", "--config", "jstests/libs/testconfig"); +var m2 = MongoRunner.runMongod({config: "jstests/libs/testconfig"}); var m2expected = { "parsed" : { "config" : "jstests/libs/testconfig", "storage" : { - "dbPath" : MongoRunner.dataDir + "/jstests_slowNightly_command_line_parsing2", + "dbPath" : m2.dbpath }, "net" : { - "port" : 31002 + "port" : m2.port }, "help" : false, "version" : false, @@ -28,23 +27,24 @@ var m2expected = { var m2result = m2.getDB("admin").runCommand( "getCmdLineOpts" ); // remove variables that depend on the way the test is started. -delete m2result.parsed.setParameter -delete m2result.parsed.storage.engine -delete m2result.parsed.storage.wiredTiger +delete m2result.parsed.nopreallocj; +delete m2result.parsed.setParameter; +delete m2result.parsed.storage.engine; +delete m2result.parsed.storage.wiredTiger; +delete m2result.parsed.storage.journal; assert.docEq( m2expected.parsed, m2result.parsed ); // test JSON config file -var m3 = startMongod("--port", port+4, "--dbpath", MongoRunner.dataPath + baseName +"4", - "--config", "jstests/libs/testconfig"); +var m3 = MongoRunner.runMongod({config: "jstests/libs/testconfig"}); var m3expected = { "parsed" : { "config" : "jstests/libs/testconfig", "storage" : { - "dbPath" : MongoRunner.dataDir + "/jstests_slowNightly_command_line_parsing4", + "dbPath" : m3.dbpath }, "net" : { - "port" : 31004 + "port" : m3.port }, "help" : false, "version" : false, @@ -54,7 +54,9 @@ var m3expected = { var m3result = m3.getDB("admin").runCommand( "getCmdLineOpts" ); // remove variables that depend on the way the test is started. -delete m3result.parsed.setParameter -delete m3result.parsed.storage.engine -delete m3result.parsed.storage.wiredTiger +delete m3result.parsed.nopreallocj; +delete m3result.parsed.setParameter; +delete m3result.parsed.storage.engine; +delete m3result.parsed.storage.wiredTiger; +delete m3result.parsed.storage.journal; assert.docEq( m3expected.parsed, m3result.parsed ); diff --git a/jstests/noPassthrough/devnull.js b/jstests/noPassthrough/devnull.js index cbd97319a53..19c353cfba9 100644 --- a/jstests/noPassthrough/devnull.js +++ b/jstests/noPassthrough/devnull.js @@ -1,13 +1,8 @@ -port = 30201; - -mongo = startMongodEmpty("--port", port, - "--dbpath", MongoRunner.dataPath + this.name, - "--smallfiles", - "--storageEngine", "devnull" ); +var mongo = MongoRunner.runMongod({smallfiles: "", storageEngine: "devnull"}); db = mongo.getDB( "test" ); res = db.foo.insert( { x : 1 } ); assert.eq( 1, res.nInserted, tojson( res ) ); -stopMongod( port ); +MongoRunner.stopMongod(mongo); diff --git a/jstests/noPassthrough/lock_file.js b/jstests/noPassthrough/lock_file.js index 68240017c1a..cb7e96c2563 100644 --- a/jstests/noPassthrough/lock_file.js +++ b/jstests/noPassthrough/lock_file.js @@ -15,15 +15,14 @@ } var baseName = "jstests_lock_file"; - var port = allocatePorts(1)[0] ; var dbpath = MongoRunner.dataPath + baseName + '/'; // Test framework will append --storageEngine command line option if provided to smoke.py. - startMongodEmpty('--port', port, '--dbpath', dbpath, '--smallfiles'); + var mongod = MongoRunner.runMongod({dbpath: dbpath, smallfiles: ""}); assert.neq(0, getMongodLockFileSize(dbpath), 'mongod.lock should not be empty while server is running'); - stopMongod(port); + MongoRunner.stopMongod(mongod); // mongod.lock must be empty after shutting server down. assert.eq(0, getMongodLockFileSize(dbpath), diff --git a/jstests/noPassthrough/server_status.js b/jstests/noPassthrough/server_status.js index e04f930fd27..7c265a4740e 100644 --- a/jstests/noPassthrough/server_status.js +++ b/jstests/noPassthrough/server_status.js @@ -3,12 +3,8 @@ (function() { 'use strict'; - var baseName = "jstests_server_status"; - var port = allocatePorts(1)[0] ; - var dbpath = MongoRunner.dataPath + baseName + '/'; - // 'backgroundFlushing' is mmapv1-specific. - var mongo = startMongodEmpty('--port', port, '--dbpath', dbpath, '--smallfiles'); + var mongo = MongoRunner.runMongod({smallfiles: ""}); var testDB = mongo.getDB('test'); var serverStatus = assert.commandWorked(testDB.serverStatus()); if (serverStatus.storageEngine.name == 'mmapv1') { @@ -21,10 +17,10 @@ 'Unexpected backgroundFlushing document in non-mmapv1 db.serverStatus() result: ' + tojson(serverStatus)); } - stopMongod(port); + MongoRunner.stopMongod(mongo); // 'dur' is mmapv1-specific and should only be generated when journaling is enabled. - mongo = startMongodEmpty('--port', port, '--dbpath', dbpath, '--smallfiles', '--journal'); + mongo = MongoRunner.runMongod({smallfiles: "", journal: ""}); testDB = mongo.getDB('test'); serverStatus = assert.commandWorked(testDB.serverStatus()); if (serverStatus.storageEngine.name == 'mmapv1') { @@ -37,12 +33,12 @@ 'Unexpected "dur" document in non-mmapv1 db.serverStatus() result: ' + tojson(serverStatus)); } - stopMongod(port); - mongo = startMongodEmpty('--port', port, '--dbpath', dbpath, '--smallfiles', '--nojournal'); + MongoRunner.stopMongod(mongo); + mongo = MongoRunner.runMongod({smallfiles: "", nojournal: ""}); testDB = mongo.getDB('test'); serverStatus = assert.commandWorked(testDB.serverStatus()); assert(!serverStatus.dur, 'Unexpected "dur" document in db.serverStatus() result when journaling is disabled: ' + tojson(serverStatus)); - stopMongod(port); + MongoRunner.stopMongod(mongo); }()); diff --git a/jstests/noPassthrough/wt_nojournal_fsync.js b/jstests/noPassthrough/wt_nojournal_fsync.js index f6f4ee1552a..5673e1208ee 100644 --- a/jstests/noPassthrough/wt_nojournal_fsync.js +++ b/jstests/noPassthrough/wt_nojournal_fsync.js @@ -19,11 +19,13 @@ function writeDataAndRestart(doFsync) { } jsTestLog("kill -9"); - stopMongod(port, /*signal*/ 9); + MongoRunner.stopMongod(conn, /*signal*/ 9); jsTestLog("restart node"); - conn = startMongodNoReset("--port", port, "--dbpath", MongoRunner.dataPath + name, - "--storageEngine", "wiredTiger", "--nojournal"); + conn = MongoRunner.runMongod({restart: true, + cleanData: false, + storageEngine: "wiredTiger", + nojournal: ""}); return conn; } @@ -35,23 +37,21 @@ if ( typeof(TestData) != "object" || jsTestLog("Skipping test because storageEngine is not wiredTiger"); } else { - var port = allocatePorts( 1 )[ 0 ]; var name = "wt_nojournal_fsync"; jsTestLog("run mongod without journaling"); - conn = startMongodEmpty("--port", port, "--dbpath", MongoRunner.dataPath + name, - "--storageEngine", "wiredTiger", "--nojournal"); + conn = MongoRunner.runMongod({storageEngine: "wiredTiger", nojournal: ""}); // restart node without fsync and --nojournal. Data should not be there after restart - writeDataAndRestart(false); + conn = writeDataAndRestart(false); jsTestLog("check data is not in collection foo"); assert.eq(conn.getDB(name).foo.count(), 0); // restart node with fsync and --nojournal. Data should be there after restart - writeDataAndRestart(true); + conn = writeDataAndRestart(true); jsTestLog("check data is in collection foo"); assert.eq(conn.getDB(name).foo.count(), 100); - stopMongod(port); + MongoRunner.stopMongod(conn); jsTestLog("Success!"); } diff --git a/jstests/noPassthrough/wt_nojournal_repl.js b/jstests/noPassthrough/wt_nojournal_repl.js index 223c768ae33..79ec8f797a2 100644 --- a/jstests/noPassthrough/wt_nojournal_repl.js +++ b/jstests/noPassthrough/wt_nojournal_repl.js @@ -56,7 +56,7 @@ else { assert.commandWorked(secondary1.getDB("admin").runCommand({fsync : 1})); jsTestLog("kill -9 secondary 1"); - stopMongod(secondary1.port, /*signal*/ 9); + MongoRunner.stopMongod(secondary1.port, /*signal*/ 9); jsTestLog("add some data to a new collection bar"); for (var i=0; i<100; i++) { diff --git a/jstests/noPassthroughWithMongod/clonecollection.js b/jstests/noPassthroughWithMongod/clonecollection.js index f06ae41bc4d..7b6ae57a020 100644 --- a/jstests/noPassthroughWithMongod/clonecollection.js +++ b/jstests/noPassthroughWithMongod/clonecollection.js @@ -1,22 +1,22 @@ // Test cloneCollection command var baseName = "jstests_clonecollection"; -ports = allocatePorts( 2 ); - -f = startMongod( "--port", ports[ 0 ], "--dbpath", MongoRunner.dataPath + baseName + "_from", "--nohttpinterface", "--bind_ip", "127.0.0.1" ).getDB( baseName ); -t = startMongod( "--port", ports[ 1 ], "--dbpath", MongoRunner.dataPath + baseName + "_to", "--nohttpinterface", "--bind_ip", "127.0.0.1" ).getDB( baseName ); +var fromMongod = MongoRunner.runMongod({bind_ip: "127.0.0.1"}); +var toMongod = MongoRunner.runMongod({bind_ip: "127.0.0.1"}); +var f = fromMongod.getDB(baseName); +var t = toMongod.getDB(baseName); for( i = 0; i < 1000; ++i ) { f.a.save( { i: i } ); } assert.eq( 1000, f.a.find().count() , "A1" ); -assert.commandWorked( t.cloneCollection( "localhost:" + ports[ 0 ], "a" ) ); +assert.commandWorked( t.cloneCollection( "localhost:" + fromMongod.port, "a" ) ); assert.eq( 1000, t.a.find().count() , "A2" ); t.a.drop(); -assert.commandWorked( t.cloneCollection( "localhost:" + ports[ 0 ], "a", { i: { $gte: 10, $lt: 20 } } ) ); +assert.commandWorked( t.cloneCollection( "localhost:" + fromMongod.port, "a", { i: { $gte: 10, $lt: 20 } } ) ); assert.eq( 10, t.a.find().count() , "A3" ); t.a.drop(); @@ -24,7 +24,7 @@ assert.eq( 0, t.a.getIndexes().length, "prep 2"); f.a.ensureIndex( { i: 1 } ); assert.eq( 2, f.a.getIndexes().length, "expected index missing" ); -assert.commandWorked( t.cloneCollection( "localhost:" + ports[ 0 ], "a" ) ); +assert.commandWorked( t.cloneCollection( "localhost:" + fromMongod.port, "a" ) ); if ( t.a.getIndexes().length != 2 ) { printjson( t.a.getIndexes()); } @@ -41,7 +41,7 @@ t.a.drop(); f.createCollection( "a", {capped:true,size:1000} ); assert( f.a.isCapped() ); -assert.commandWorked( t.cloneCollection( "localhost:" + ports[ 0 ], "a" ) ); +assert.commandWorked( t.cloneCollection( "localhost:" + fromMongod.port, "a" ) ); assert( t.a.isCapped(), "cloned collection not capped" ); diff --git a/jstests/noPassthroughWithMongod/ipv6_connection_string_validation.js b/jstests/noPassthroughWithMongod/ipv6_connection_string_validation.js index 7e7e32a71b0..c4896e56406 100644 --- a/jstests/noPassthroughWithMongod/ipv6_connection_string_validation.js +++ b/jstests/noPassthroughWithMongod/ipv6_connection_string_validation.js @@ -9,17 +9,12 @@ if ("undefined" == typeof inner_mode) { // Start a mongod with --ipv6 port = allocatePorts( 1 )[ 0 ]; - var baseName = "jstests_slowNightly_ipv6_connection_string_validation"; jsTest.log("Outer mode test starting mongod with --ipv6"); // NOTE: bind_ip arg is present to test if it can parse ipv6 addresses (::1 in this case). // Unfortunately, having bind_ip = ::1 won't work in the test framework (But does work when // tested manually), so 127.0.0.1 is also present so the test mongo shell can connect // with that address. - var mongod = startMongod("--port", port, - "--ipv6", - "--bind_ip", "::1,127.0.0.1", - "--dbpath", - MongoRunner.dataPath + baseName ); + var mongod = MongoRunner.runMongod({port: port, ipv6: "", bind_ip: "::1,127.0.0.1"}); var args = ["mongo", "--nodb", "--ipv6", @@ -32,7 +27,7 @@ if ("undefined" == typeof inner_mode) { // Stop the server we started jsTest.log("Outer mode test stopping server"); - stopMongod(port, 15); + MongoRunner.stopMongod(port, 15); // Pass the inner test's exit code back as the outer test's exit code quit(exitCode); diff --git a/jstests/noPassthroughWithMongod/logpath.js b/jstests/noPassthroughWithMongod/logpath.js index 78be510f0a2..5f2b809d6df 100644 --- a/jstests/noPassthroughWithMongod/logpath.js +++ b/jstests/noPassthroughWithMongod/logpath.js @@ -57,7 +57,7 @@ var m = MongoRunner.runMongod({ port: port[0], dbpath: dbdir, logpath: logdir + // log should now exist (and no rotations should exist) assert.eq(logCount(logs[0], true), 1); -stopMongod(port[0]); +MongoRunner.stopMongod(port[0]); print("------ Start mongod with logpath set to existing file"); m = MongoRunner.runMongod({ port: port[1], dbpath: dbdir, logpath: logdir + logs[0]}); @@ -69,7 +69,7 @@ assert.eq(logCount(logs[0]), 1); assert.eq(logCount(logs[0], true), 2); cleanupFiles(); -stopMongod(port[1]); +MongoRunner.stopMongod(port[1]); // Blocking on SERVER-5117: // MongoRunner currently hangs if mongod fails to start so these tests don't work @@ -84,7 +84,7 @@ if ( false ) { // log should now exist (and no rotations should exist) assert.eq(logCount(logs[1], true), 1); - stopMongod(port[2]); + MongoRunner.stopMongod(port[2]); print("------ Start mongod with logpath set to existing file, fork"); m = MongoRunner.runMongod({ port: port[3], dbpath: dbdir, logpath: logdir + logs[1], fork: true}); @@ -96,7 +96,7 @@ if ( false ) { assert.eq(logCount(logs[1], true), 2); cleanupFiles(); - stopMongod(port[3]); + MongoRunner.stopMongod(port[3]); } // the following tests depend on undefined behavior; assume that MongoRunner raises exception on error diff --git a/jstests/noPassthroughWithMongod/newcollection2.js b/jstests/noPassthroughWithMongod/newcollection2.js index 0a2b5148260..86d5e9f7a3a 100644 --- a/jstests/noPassthroughWithMongod/newcollection2.js +++ b/jstests/noPassthroughWithMongod/newcollection2.js @@ -1,8 +1,7 @@ // Alocate collection forcing just a small size remainder in 2nd extent -port = allocatePorts( 1 )[ 0 ] var baseName = "jstests_disk_newcollection2"; -var m = startMongod( "--noprealloc", "--smallfiles", "--port", port, "--dbpath", MongoRunner.dataPath + baseName ); +var m = MongoRunner.runMongod({noprealloc: "", smallfiles: ""}); db = m.getDB( "test" ); db.createCollection( baseName, {size:0x1FFC0000-0x10-8192} ); diff --git a/jstests/noPassthroughWithMongod/sharding_migrateBigObject.js b/jstests/noPassthroughWithMongod/sharding_migrateBigObject.js index 32278c089f3..3546e53f4c0 100644 --- a/jstests/noPassthroughWithMongod/sharding_migrateBigObject.js +++ b/jstests/noPassthroughWithMongod/sharding_migrateBigObject.js @@ -1,14 +1,12 @@ +var shardA = MongoRunner.runMongod({shardsvr: "", nopreallocj: ""}); +var shardB = MongoRunner.runMongod({shardsvr: "", nopreallocj: ""}); +var config = MongoRunner.runMongod({configsvr: "", nopreallocj: ""}); +var mongos = MongoRunner.runMongos({configdb : "localhost:" + config.port }); -var shardA = startMongodEmpty("--shardsvr", "--port", 30001, "--dbpath", MongoRunner.dataDir + "/migrateBigger0", "--nopreallocj"); -var shardB = startMongodEmpty("--shardsvr", "--port", 30002, "--dbpath", MongoRunner.dataDir + "/migrateBigger1", "--nopreallocj"); -var config = startMongodEmpty("--configsvr", "--port", 29999, "--dbpath", MongoRunner.dataDir + "/migrateBiggerC", "--nopreallocj"); +var admin = mongos.getDB("admin"); -var mongos = startMongos({ port : 30000, configdb : "localhost:29999" }) - -var admin = mongos.getDB("admin") - -admin.runCommand({ addshard : "localhost:30001" }) -admin.runCommand({ addshard : "localhost:30002" }) +admin.runCommand({ addshard : "localhost:" + shardA.port }); +admin.runCommand({ addshard : "localhost:" + shardB.port }); db = mongos.getDB("test"); var coll = db.getCollection("stuff") @@ -67,9 +65,9 @@ assert.soon( } , "never migrated" , 10 * 60 * 1000 , 1000 ); -stopMongod( 30000 ); -stopMongod( 29999 ); -stopMongod( 30001 ); -stopMongod( 30002 ); +MongoRunner.stopMongos(mongos); +MongoRunner.stopMongod(config); +MongoRunner.stopMongod(shardA); +MongoRunner.stopMongod(shardB); diff --git a/jstests/noPassthroughWithMongod/sharding_rs_arb1.js b/jstests/noPassthroughWithMongod/sharding_rs_arb1.js index 0e51180b44d..7096b31ad0f 100644 --- a/jstests/noPassthroughWithMongod/sharding_rs_arb1.js +++ b/jstests/noPassthroughWithMongod/sharding_rs_arb1.js @@ -17,9 +17,9 @@ master = replTest.getMaster(); db = master.getDB( "test" ); printjson( rs.status() ); -var config = startMongodEmpty("--configsvr", "--port", 29999, "--dbpath", MongoRunner.dataPath + name + "_config" ); +var config = MongoRunner.runMongod({configsvr: ""}); -var mongos = startMongos({ port : 30000, configdb : getHostName() + ":29999" }) +var mongos = MongoRunner.runMongos({configdb : getHostName() + ":" + config.port }); var admin = mongos.getDB("admin") var url = name + "/"; for ( i=0; i<port.length; i++ ) { @@ -33,8 +33,7 @@ printjson( res ) assert( res.ok , tojson(res) ) - -stopMongod( 30000 ) -stopMongod( 29999 ) +MongoRunner.stopMongos(mongos); +MongoRunner.stopMongod(config); replTest.stopSet(); diff --git a/jstests/noPassthroughWithMongod/sync6_slow.js b/jstests/noPassthroughWithMongod/sync6_slow.js index d253478e1da..98e52f468a0 100644 --- a/jstests/noPassthroughWithMongod/sync6_slow.js +++ b/jstests/noPassthroughWithMongod/sync6_slow.js @@ -11,7 +11,7 @@ var test = new SyncCCTest("sync6", {logpath: bitbucket, logappend: ""}); // Startup another process to handle our commands to the cluster, mostly so it's // easier to read. -var commandConn = startMongodTest( 30000 + 4, "syncCommander", false, {}); +var commandConn = MongoRunner.runMongod({}); // Up the log level for this test commandConn.getDB( "admin" ).runCommand( { setParameter : 1, logLevel : 0 } ); @@ -79,5 +79,5 @@ for ( var i = 4; i < 5; i++ ) { } } -stopMongoProgram( 30004 ); +MongoRunner.stopMongod(commandConn); test.stop(); diff --git a/jstests/noPassthroughWithMongod/temp_namespace.js b/jstests/noPassthroughWithMongod/temp_namespace.js index 123ad07270b..108c5871c7a 100644 --- a/jstests/noPassthroughWithMongod/temp_namespace.js +++ b/jstests/noPassthroughWithMongod/temp_namespace.js @@ -1,9 +1,8 @@ // this is to make sure that temp collections get cleaned up on restart testname = 'temp_namespace_sw' -path = MongoRunner.dataPath+testname -conn = startMongodEmpty("--port", 30000, "--dbpath", path, "--smallfiles", "--noprealloc", "--nopreallocj"); +var conn = MongoRunner.runMongod({smallfiles: "", noprealloc: "", nopreallocj: ""}); d = conn.getDB('test') d.runCommand({create: testname+'temp1', temp: true}); d[testname+'temp1'].ensureIndex({x:1}); @@ -21,10 +20,15 @@ function countCollectionNames( theDB, regex ) { assert.eq(countCollectionNames( d, /temp\d$/) , 2) assert.eq(countCollectionNames( d, /keep\d$/) , 4) -stopMongod(30000); +MongoRunner.stopMongod(conn); -conn = startMongodNoReset("--port", 30000, "--dbpath", path, "--smallfiles", "--noprealloc", "--nopreallocj"); +conn = MongoRunner.runMongod({restart:true, + cleanData: false, + dbpath: conn.dbpath, + smallfiles: "", + noprealloc: "", + nopreallocj: ""}); d = conn.getDB('test') assert.eq(countCollectionNames( d, /temp\d$/) , 0) assert.eq(countCollectionNames( d, /keep\d$/) , 4) -stopMongod(30000); +MongoRunner.stopMongod(conn); diff --git a/jstests/noPassthroughWithMongod/testing_only_commands.js b/jstests/noPassthroughWithMongod/testing_only_commands.js index 11f4cca503e..a23ac3a7c4c 100644 --- a/jstests/noPassthroughWithMongod/testing_only_commands.js +++ b/jstests/noPassthroughWithMongod/testing_only_commands.js @@ -32,7 +32,7 @@ var assertCmdFound = function(db, cmdName) { jsTest.setOption('enableTestCommands', false); -var conn = startMongodTest(); +var conn = MongoRunner.runMongod({}); for (i in testOnlyCommands) { assertCmdNotFound(conn.getDB('test'), testOnlyCommands[i]); } @@ -41,7 +41,7 @@ MongoRunner.stopMongod(conn.port); // Now enable the commands jsTest.setOption('enableTestCommands', true); -var conn = startMongodTest(); +var conn = MongoRunner.runMongod({}); for (i in testOnlyCommands) { assertCmdFound(conn.getDB('test'), testOnlyCommands[i]); } diff --git a/jstests/noPassthroughWithMongod/ttl_repl_maintenance.js b/jstests/noPassthroughWithMongod/ttl_repl_maintenance.js index 852007b4300..300b57f906d 100644 --- a/jstests/noPassthroughWithMongod/ttl_repl_maintenance.js +++ b/jstests/noPassthroughWithMongod/ttl_repl_maintenance.js @@ -9,9 +9,7 @@ var runner; var conn; var primeSystemReplset = function() { - var port = allocatePorts(1)[0]; - runner = new MongodRunner(port, MongoRunner.dataDir + "/jstests_slowNightly-ttl"); - conn = runner.start(); + conn = MongoRunner.runMongod(); var localDB = conn.getDB("local"); localDB.system.replset.insert({x:1}); @@ -21,8 +19,8 @@ var primeSystemReplset = function() { }; var restartWithConfig = function() { - stopMongod(runner.port(), 15); - conn = runner.start(true /* reuse data */); + MongoRunner.stopMongod(conn.port, 15); + conn = MongoRunner.runMongod({restart:true, cleanData: false, dbpath: conn.dbpath}); testDB = conn.getDB("test"); var n = 100; for (var i=0; i<n; i++) { @@ -39,15 +37,15 @@ var restartWithoutConfig = function() { var localDB = conn.getDB("local"); assert.writeOK(localDB.system.replset.remove({})); - stopMongod(runner.port(), 15); + MongoRunner.stopMongod(conn.port, 15); - conn = runner.start(true /* reuse data */); + conn = MongoRunner.runMongod({restart:true, cleanData: false, dbpath: conn.dbpath}); assert.soon(function() { return conn.getDB("test").foo.count() < 100; }, "never deleted", 65000); - stopMongod(runner.port(), 15); + MongoRunner.stopMongod(conn.port, 15); }; print("Create a TTL collection and put doc in local.system.replset"); diff --git a/jstests/noPassthroughWithMongod/unix_socket1.js b/jstests/noPassthroughWithMongod/unix_socket1.js index 8f254e88126..8e28715558c 100644 --- a/jstests/noPassthroughWithMongod/unix_socket1.js +++ b/jstests/noPassthroughWithMongod/unix_socket1.js @@ -28,8 +28,7 @@ if ( ! _isWindows() ) { mkdir(path); var dataPath = MongoRunner.dataDir + "/sockpath_data"; - var conn = new MongodRunner(ports[0], dataPath, null, null, ["--unixSocketPrefix", path]); - conn.start(); + var conn = MongoRunner.runMongod({port: ports[0], dbpath: dataPath, unixSocketPrefix: path}); var sock2 = new Mongo(path+"/mongodb-"+ports[0]+".sock"); sockdb2 = sock2.getDB(db.getName()) diff --git a/jstests/replsets/auth1.js b/jstests/replsets/auth1.js index 989c55b7ef1..c01593131d5 100644 --- a/jstests/replsets/auth1.js +++ b/jstests/replsets/auth1.js @@ -12,7 +12,7 @@ var m = MongoRunner.runMongod({auth : "", port : port[4], dbpath : MongoRunner.d assert.eq(m.getDB("local").auth("__system", ""), 0); -stopMongod(port[4]); +MongoRunner.stopMongod(m); print("reset permissions"); @@ -26,7 +26,7 @@ m = runMongoProgram( "mongod", "--keyFile", path+"key1", "--port", port[0], "--d print("should fail with wrong permissions"); assert.eq(m, _isWindows()? 100 : 1, "mongod should exit w/ 1 (EXIT_FAILURE): permissions too open"); -stopMongod(port[0]); +MongoRunner.stopMongod(port[0]); print("change permissions on #1 & #2"); @@ -35,11 +35,11 @@ run("chmod", "600", path+"key2"); print("add a user to server0: foo"); -m = startMongodTest( port[0], name+"-0", 0 ); +m = MongoRunner.runMongod({dbpath: MongoRunner.dataPath + name + "-0"}); m.getDB("admin").createUser({user: "foo", pwd: "bar", roles: jsTest.adminUserRoles}); m.getDB("test").createUser({user: "bar", pwd: "baz", roles: jsTest.basicUserRoles}); print("make sure user is written before shutting down"); -stopMongod(port[0]); +MongoRunner.stopMongod(m); print("start up rs"); var rs = new ReplSetTest({"name" : name, "nodes" : 3, "startPort" : port[0]}); @@ -126,8 +126,11 @@ for (var i=0; i<1000; i++) { bulk.execute({ w:3, wtimeout:60000 }); print("add member with wrong key"); -var conn = new MongodRunner(port[3], MongoRunner.dataPath+name+"-3", null, null, ["--replSet","rs_auth1","--rest","--oplogSize","2", "--keyFile", path+"key2"], {no_bind : true}); -conn.start(); +var conn = MongoRunner.runMongod({dbpath: MongoRunner.dataPath + name + "-3", + port: port[3], + replSet: "rs_auth1", + oplogSize: 2, + keyFile: path + "key2"}); master.getDB("admin").auth("foo", "bar"); @@ -155,12 +158,15 @@ for (var i = 0; i<10; i++) { print("stop member"); -stopMongod(port[3]); +MongoRunner.stopMongod(conn); print("start back up with correct key"); -conn = new MongodRunner(port[3], MongoRunner.dataPath+name+"-3", null, null, ["--replSet","rs_auth1","--rest","--oplogSize","2", "--keyFile", path+"key1"], {no_bind : true}); -conn.start(); +var conn = MongoRunner.runMongod({dbpath: MongoRunner.dataPath + name + "-3", + port: port[3], + replSet: "rs_auth1", + oplogSize: 2, + keyFile: path + "key1"}); wait(function() { try { diff --git a/jstests/replsets/initial_sync1.js b/jstests/replsets/initial_sync1.js index 7a05f3c28be..f55ae0b4910 100644 --- a/jstests/replsets/initial_sync1.js +++ b/jstests/replsets/initial_sync1.js @@ -52,21 +52,16 @@ admin_s1.runCommand({replSetFreeze:999999}); print("6. Bring up #3"); -var ports = allocatePorts( 3 ); -var basePath = MongoRunner.dataPath + basename; var hostname = getHostName(); -var slave2 = startMongodTest (ports[2], - basename, - false, - Object.merge({replSet : basename, oplogSize : 2}, x509_options2)); +var slave2 = MongoRunner.runMongod(Object.merge({replSet: basename, oplogSize: 2}, x509_options2)); var local_s2 = slave2.getDB("local"); var admin_s2 = slave2.getDB("admin"); var config = replTest.getReplSetConfig(); config.version = 2; -config.members.push({_id:2, host:hostname+":"+ports[2]}); +config.members.push({_id:2, host:hostname+":"+slave2.port}); try { admin.runCommand({replSetReconfig:config}); } @@ -130,5 +125,5 @@ assert.writeOK(bulk.execute()); print("11. Everyone happy eventually"); replTest.awaitReplication(300000); -stopMongod(ports[2]); +MongoRunner.stopMongod(slave2); replTest.stopSet(); diff --git a/jstests/replsets/initial_sync2.js b/jstests/replsets/initial_sync2.js index 7166ea3ea96..1e519048fae 100644 --- a/jstests/replsets/initial_sync2.js +++ b/jstests/replsets/initial_sync2.js @@ -50,11 +50,9 @@ admin_s1.runCommand({replSetFreeze:999999}); print("6. Bring up #3"); -var ports = allocatePorts( 3 ); -var basePath = MongoRunner.dataPath + basename; var hostname = getHostName(); -var slave2 = startMongodTest (ports[2], basename, false, {replSet : basename, oplogSize : 2} ) +var slave2 = MongoRunner.runMongod({replSet: basename, oplogSize: 2}); var local_s2 = slave2.getDB("local"); var admin_s2 = slave2.getDB("admin"); @@ -67,7 +65,7 @@ config.version = 2; db = admin; // If _id is not provided, rs.add() will generate _id for #3 based on existing members' _ids. -assert.commandWorked(rs.add({host:hostname+":"+ports[2]}), "failed to add #3 to replica set"); +assert.commandWorked(rs.add({host:hostname+":"+slave2.port}), "failed to add #3 to replica set"); reconnect(slave1); reconnect(slave2); diff --git a/jstests/replsets/initial_sync4.js b/jstests/replsets/initial_sync4.js index 9e0d869d62f..da49839ef0c 100644 --- a/jstests/replsets/initial_sync4.js +++ b/jstests/replsets/initial_sync4.js @@ -25,15 +25,13 @@ print("3. Make sure synced"); replTest.awaitReplication(); print("4. Bring up a new node"); -ports = allocatePorts( 3 ); -basePath = MongoRunner.dataPath + basename; hostname = getHostName(); -s = startMongodTest (ports[2], basename, false, {replSet : basename, oplogSize : 2} ); +s = MongoRunner.runMongod({replSet: basename, oplogSize: 2}); var config = replTest.getReplSetConfig(); config.version = 2; -config.members.push({_id:2, host:hostname+":"+ports[2]}); +config.members.push({_id:2, host:hostname+":"+s.port}); try { m.getDB("admin").runCommand({replSetReconfig:config}); } diff --git a/jstests/replsets/single_server_majority.js b/jstests/replsets/single_server_majority.js index 136b1213001..c343436be0c 100644 --- a/jstests/replsets/single_server_majority.js +++ b/jstests/replsets/single_server_majority.js @@ -1,10 +1,8 @@ // This test checks that w:"majority" works correctly on a lone mongod // set up a mongod and connect a mongo -port = allocatePorts(1)[0]; -var baseName = "single_server_majority"; -var mongod = startMongod("--port", port, "--dbpath", MongoRunner.dataPath + baseName, "-v"); -var mongo = startMongoProgram("mongo", "--port", port); +var mongod = MongoRunner.runMongod({}); +var mongo = startMongoProgram("mongo", "--port", mongod.port); // get db and collection, then preform a trivial insert db = mongo.getDB("test") diff --git a/jstests/sharding/addshard1.js b/jstests/sharding/addshard1.js index 42342351d8a..41383201057 100644 --- a/jstests/sharding/addshard1.js +++ b/jstests/sharding/addshard1.js @@ -4,7 +4,7 @@ assert.eq( 1, s.config.shards.count(), "initial server count wrong" ); // create a shard and add a database; if the database is not duplicated the mongod should accepted // it as shard -conn1 = startMongodTest( 29000 ); +conn1 = MongoRunner.runMongod({}); db1 = conn1.getDB( "testDB" ); numObjs = 0; @@ -14,10 +14,11 @@ for (i=0; i<3; i++){ } newShard = "myShard"; -assert( s.admin.runCommand( { addshard: "localhost:29000" , name: newShard } ).ok, "did not accepted non-duplicated shard" ); +assert( s.admin.runCommand( { addshard: "localhost:" + conn1.port , name: newShard } ).ok, + "did not accept non-duplicated shard" ); // a mongod with an existing database name should not be allowed to become a shard -conn2 = startMongodTest( 29001 ); +conn2 = MongoRunner.runMongod({}); db2 = conn2.getDB( "otherDB" ); assert.writeOK(db2.foo.save({ a: 1 })); db3 = conn2.getDB( "testDB" ); @@ -25,7 +26,8 @@ assert.writeOK(db3.foo.save({ a: 1 } )); s.config.databases.find().forEach( printjson ) rejectedShard = "rejectedShard"; -assert( ! s.admin.runCommand( { addshard: "localhost:29001" , name : rejectedShard } ).ok, "accepted mongod with duplicate db" ); +assert( ! s.admin.runCommand( { addshard: "localhost:" + conn2.port , name : rejectedShard } ).ok, + "accepted mongod with duplicate db" ); // check that all collection that were local to the mongod's are accessible through the mongos sdb1 = s.getDB( "testDB" ); @@ -48,6 +50,6 @@ s.adminCommand( { split : "testDB.foo", middle: { a : Math.floor(numObjs/2) } } assert.eq( 2 , s.config.chunks.count(), "wrong chunk number after splitting collection that existed before" ); assert.eq( numObjs , sdb1.foo.count() , "wrong count after splitting collection that existed before" ); -stopMongod( 29000 ); -stopMongod( 29001 ); +MongoRunner.stopMongod(conn1); +MongoRunner.stopMongod(conn2); s.stop(); diff --git a/jstests/sharding/addshard2.js b/jstests/sharding/addshard2.js index 811997f5485..d6487c6d366 100644 --- a/jstests/sharding/addshard2.js +++ b/jstests/sharding/addshard2.js @@ -2,8 +2,8 @@ // don't start any shards, yet s = new ShardingTest( "add_shard2", 1, 0, 1, {useHostname : true} ); -var conn1 = startMongodTest( 30001 , "add_shard21" , 0 , {useHostname : true} ); -var conn2 = startMongodTest( 30002 , "add_shard22" , 0 , {useHostname : true} ); +var conn1 = MongoRunner.runMongod({useHostname: true}); +var conn2 = MongoRunner.runMongod({useHostname: true}); var rs1 = new ReplSetTest( { "name" : "add_shard2_rs1", nodes : 3 , startPort : 31200 } ); rs1.startSet(); @@ -26,7 +26,8 @@ rs4.startSet(); rs4.initiate(); // step 1. name given -assert(s.admin.runCommand({"addshard" : getHostName()+":30001", "name" : "bar"}).ok, "failed to add shard in step 1"); +assert(s.admin.runCommand({"addshard" : getHostName()+":" + conn1.port, "name" : "bar"}).ok, + "failed to add shard in step 1"); var shard = s.getDB("config").shards.findOne({"_id" : {"$nin" : ["shard0000"]}}); assert(shard, "shard wasn't found"); assert.eq("bar", shard._id, "shard has incorrect name"); @@ -45,7 +46,8 @@ assert(shard, "shard wasn't found"); assert.eq("myshard", shard._id, "t3 name"); // step 4. no name given -assert(s.admin.runCommand({"addshard" : getHostName()+":30002"}).ok, "failed to add shard in step 4"); +assert(s.admin.runCommand({"addshard" : getHostName()+":" + conn2.port}).ok, + "failed to add shard in step 4"); shard = s.getDB("config").shards.findOne({"_id" : {"$nin" : ["shard0000", "bar", "add_shard2_rs1", "myshard"]}}); assert(shard, "shard wasn't found"); assert.eq("shard0001", shard._id, "t4 name"); diff --git a/jstests/sharding/auth.js b/jstests/sharding/auth.js index 330e24cd846..41783fcce1a 100644 --- a/jstests/sharding/auth.js +++ b/jstests/sharding/auth.js @@ -61,7 +61,7 @@ function runTest(s) { printjson(s.getDB("config").settings.find().toArray()); print("restart mongos"); - stopMongoProgram(31000); + MongoRunner.stopMongos(31000); var opts = { port : 31000, v : 2, configdb : s._configDB, keyFile : "jstests/libs/key1", chunkSize : 1 }; var conn = startMongos( opts ); s.s = s._mongos[0] = s["s0"] = conn; diff --git a/jstests/sharding/bad_config_load.js b/jstests/sharding/bad_config_load.js index 72e56d14784..cf7fef1c395 100644 --- a/jstests/sharding/bad_config_load.js +++ b/jstests/sharding/bad_config_load.js @@ -26,7 +26,7 @@ st.printShardingStatus() var port = parseInt( st._configDB.replace( /^.*:/, "" ) ) jsTestLog( "Stopping " + port + "..." ) -stopMongod( port ) +MongoRunner.stopMongod( port ) jsTestLog( "Config flushed and config server down!" ) diff --git a/jstests/sharding/config_oplog.js b/jstests/sharding/config_oplog.js index 7485da2eb49..e74deb7d69b 100644 --- a/jstests/sharding/config_oplog.js +++ b/jstests/sharding/config_oplog.js @@ -19,12 +19,12 @@ assert.eq( true, oplogEntry.o.partitioned ); test.stop(); -var conn = startMongodTest( 30001, "config_oplog", false, { configsvr : "", oplogSize : 2 } ); +var conn = MongoRunner.runMongod({configsvr: "", oplogSize: 2}) stats = conn.getDB( "local" ).getCollection( "oplog.$main" ).stats(); assert.eq( true, stats.capped ); assert.eq( 2 * 1024 * 1024, stats.maxSize ); -stopMongoProgram( 30001 ); +MongoRunner.stopMongod(conn); print("END config_oplog.js"); diff --git a/jstests/sharding/remove1.js b/jstests/sharding/remove1.js index 58da5ba919f..d8792c35084 100644 --- a/jstests/sharding/remove1.js +++ b/jstests/sharding/remove1.js @@ -22,9 +22,9 @@ assert( !s.admin.runCommand( { removeshard: "shard0001" } ).ok , "allowed removi assert.isnull( s.config.databases.findOne({_id: 'local'}), 'should have removed local db'); // should create a shard0002 shard -conn = startMongodTest( 29000 ); -assert( s.admin.runCommand( { addshard: "localhost:29000" } ).ok, "failed to add shard" ); +var conn = MongoRunner.runMongod({}); +assert( s.admin.runCommand( { addshard: conn.host } ).ok, "failed to add shard" ); assert.eq( 2, s.config.shards.count(), "new server does not appear in count" ); -stopMongod( 29000 ); +MongoRunner.stopMongod(conn); s.stop(); diff --git a/jstests/sharding/sync6.js b/jstests/sharding/sync6.js index 84d1df8d692..ccd418a5884 100644 --- a/jstests/sharding/sync6.js +++ b/jstests/sharding/sync6.js @@ -12,7 +12,7 @@ var test = new SyncCCTest( "sync6", { logpath : bitbucket , logappend : "" } ); // Startup another process to handle our commands to the cluster, mostly so it's // easier to read. -var commandConn = startMongodTest( 30000 + 4, "syncCommander", false, {}); +var commandConn = MongoRunner.runMongod({}); // Up the log level for this test commandConn.getDB( "admin" ).runCommand( { setParameter : 1, logLevel : 1 } ); @@ -80,5 +80,5 @@ for ( var i = 8; i < 9; i++ ) { } -stopMongoProgram( 30004 ); +MongoRunner.stopMongod(commandConn); test.stop(); diff --git a/jstests/sharding/user_flags_sharded.js b/jstests/sharding/user_flags_sharded.js index 0b88507ff6c..2d7a341e4f4 100644 --- a/jstests/sharding/user_flags_sharded.js +++ b/jstests/sharding/user_flags_sharded.js @@ -11,7 +11,7 @@ if ( typeof(TestData) != "object" || var ns = dbname + "." + coll; // First create fresh collection on a new standalone mongod - var newShardConn = startMongodTest( 29000 ); + var newShardConn = MongoRunner.runMongod({}); var db1 = newShardConn.getDB( dbname ); var t = db1.getCollection( coll ); print(t); @@ -42,7 +42,7 @@ if ( typeof(TestData) != "object" || // start up a new sharded cluster, and add previous mongod var s = new ShardingTest( "user_flags", 1 ); - assert( s.admin.runCommand( { addshard: "localhost:29000" , name: "myShard" } ).ok, + assert( s.admin.runCommand( { addshard: newShardConn.host , name: "myShard" } ).ok, "did not accept new shard" ); // enable sharding of the collection. Only 1 chunk initially, so move it to @@ -60,7 +60,7 @@ if ( typeof(TestData) != "object" || assert.eq( shard2stats.count , numdocs , "moveChunk didn't succeed" ); assert.eq( shard2stats.userFlags , 0 , "new shard should also have userFlags = 0 "); - stopMongod( 29000 ); + MongoRunner.stopMongod(newShardConn); s.stop(); } diff --git a/jstests/tool/dumpauth.js b/jstests/tool/dumpauth.js index 7ae165f5ce1..58bbfa82e9e 100644 --- a/jstests/tool/dumpauth.js +++ b/jstests/tool/dumpauth.js @@ -1,9 +1,8 @@ // dumpauth.js // test mongodump with authentication -port = allocatePorts( 1 )[ 0 ]; baseName = "tool_dumpauth"; -m = startMongod( "--auth", "--port", port, "--dbpath", MongoRunner.dataPath + baseName, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); +var m = MongoRunner.runMongod({auth: "", bind_ip: "127.0.0.1"}); db = m.getDB( "admin" ); db.createUser({user: "testuser" , pwd: "testuser", roles: jsTest.adminUserRoles}); @@ -21,7 +20,7 @@ x = runMongoProgram( "mongodump", "--authenticationDatabase=admin", "-u", "testuser", "-p", "testuser", - "-h", "127.0.0.1:"+port, + "-h", "127.0.0.1:"+m.port, "--collection", "testcol" ); assert.eq(x, 0, "mongodump should succeed with authentication"); @@ -31,7 +30,7 @@ x = runMongoProgram( "mongodump", "--authenticationDatabase=admin", "-u", "testuser", "-p", "testuser", - "-h", "127.0.0.1:"+port, + "-h", "127.0.0.1:"+m.port, "--collection", "testcol", "--out", "-" ); assert.eq(x, 0, "mongodump should succeed with authentication while using '--out'"); diff --git a/jstests/tool/dumprestore3.js b/jstests/tool/dumprestore3.js index 9fcd540a767..39f97d3992f 100644 --- a/jstests/tool/dumprestore3.js +++ b/jstests/tool/dumprestore3.js @@ -30,8 +30,7 @@ var master = replTest.getMaster(); { step("dump & restore a db into a slave"); - var port = 30020; - var conn = startMongodTest(port, name + "-other"); + var conn = MongoRunner.runMongod({}); var c = conn.getDB("foo").bar; c.save({ a: 22 }); assert.eq(1, c.count(), "setup2"); @@ -41,7 +40,7 @@ step("try mongorestore to slave"); var data = MongoRunner.dataDir + "/dumprestore3-other1/"; resetDbpath(data); -runMongoProgram( "mongodump", "--host", "127.0.0.1:"+port, "--out", data ); +runMongoProgram( "mongodump", "--host", "127.0.0.1:"+conn.port, "--out", data ); var x = runMongoProgram( "mongorestore", "--host", "127.0.0.1:"+replTest.ports[1], "--dir", data ); assert.neq(x, 0, "mongorestore should exit w/ 1 on slave"); @@ -49,7 +48,7 @@ assert.neq(x, 0, "mongorestore should exit w/ 1 on slave"); step("try mongoimport to slave"); dataFile = MongoRunner.dataDir + "/dumprestore3-other2.json"; -runMongoProgram( "mongoexport", "--host", "127.0.0.1:"+port, "--out", dataFile, "--db", "foo", "--collection", "bar" ); +runMongoProgram( "mongoexport", "--host", "127.0.0.1:"+conn.port, "--out", dataFile, "--db", "foo", "--collection", "bar" ); x = runMongoProgram( "mongoimport", "--host", "127.0.0.1:"+replTest.ports[1], "--file", dataFile ); assert.neq(x, 0, "mongoreimport should exit w/ 1 on slave"); diff --git a/jstests/tool/dumprestore7.js b/jstests/tool/dumprestore7.js index a9225dd7044..04414bf85a8 100644 --- a/jstests/tool/dumprestore7.js +++ b/jstests/tool/dumprestore7.js @@ -36,8 +36,7 @@ var master = replTest.getMaster(); } } { - var port = 30020; - var conn = startMongodTest(port, name + "-other"); + var conn = MongoRunner.runMongod({}); } step("try mongodump with $timestamp"); @@ -52,7 +51,7 @@ MongoRunner.runMongoTool( "mongodump", step("try mongorestore from $timestamp"); -runMongoProgram( "mongorestore", "--host", "127.0.0.1:"+port, "--dir", data, "--writeConcern", 1); +runMongoProgram( "mongorestore", "--host", "127.0.0.1:"+conn.port, "--dir", data, "--writeConcern", 1); var x = 9; x = conn.getDB("local").getCollection("oplog.rs").count(); diff --git a/jstests/tool/restorewithauth.js b/jstests/tool/restorewithauth.js index d17769cf396..aec3d6859bc 100644 --- a/jstests/tool/restorewithauth.js +++ b/jstests/tool/restorewithauth.js @@ -15,10 +15,8 @@ */ -var port = allocatePorts(1)[0]; baseName = "jstests_restorewithauth"; -var conn = startMongod( "--port", port, "--dbpath", MongoRunner.dataPath + baseName, "--nohttpinterface", - "--nojournal", "--bind_ip", "127.0.0.1" ); +var conn = MongoRunner.runMongod({nojournal: "", bind_ip: "127.0.0.1"}); // write to ns foo.bar var foo = conn.getDB( "foo" ); @@ -42,17 +40,16 @@ assert.eq(foo.baz.getIndexes().length, 1); // get data dump var dumpdir = MongoRunner.dataDir + "/restorewithauth-dump1/"; resetDbpath( dumpdir ); -x = runMongoProgram("mongodump", "--db", "foo", "-h", "127.0.0.1:"+port, "--out", dumpdir); +x = runMongoProgram("mongodump", "--db", "foo", "-h", "127.0.0.1:"+ conn.port, "--out", dumpdir); // now drop the db foo.dropDatabase(); // stop mongod -stopMongod( port ); +MongoRunner.stopMongod(conn); // start mongod with --auth -conn = startMongod( "--auth", "--port", port, "--dbpath", MongoRunner.dataPath + baseName, "--nohttpinterface", - "--nojournal", "--bind_ip", "127.0.0.1" ); +conn = MongoRunner.runMongod({auth: "", nojournal: "", bind_ip: "127.0.0.1"}); // admin user var admin = conn.getDB( "admin" ) @@ -67,7 +64,7 @@ assert.eq(-1, collNames.indexOf("bar"), "bar collection already exists"); assert.eq(-1, collNames.indexOf("baz"), "baz collection already exists"); // now try to restore dump -x = runMongoProgram( "mongorestore", "-h", "127.0.0.1:" + port, "--dir" , dumpdir, "-vvvvv" ); +x = runMongoProgram( "mongorestore", "-h", "127.0.0.1:" + conn.port, "--dir" , dumpdir, "-vvvvv" ); // make sure that the collection isn't restored collNames = foo.getCollectionNames(); @@ -76,7 +73,7 @@ assert.eq(-1, collNames.indexOf("baz"), "baz collection was restored"); // now try to restore dump with correct credentials x = runMongoProgram( "mongorestore", - "-h", "127.0.0.1:" + port, + "-h", "127.0.0.1:" + conn.port, "-d", "foo", "--authenticationDatabase=admin", "-u", "admin", @@ -99,7 +96,7 @@ foo.createUser({user: 'user', pwd: 'password', roles: jsTest.basicUserRoles}); // now try to restore dump with foo database credentials x = runMongoProgram("mongorestore", - "-h", "127.0.0.1:" + port, + "-h", "127.0.0.1:" + conn.port, "-d", "foo", "-u", "user", "-p", "password", @@ -114,4 +111,4 @@ assert.eq(foo.bar.count(), 4); assert.eq(foo.baz.count(), 4); assert.eq(foo.bar.getIndexes().length + foo.baz.getIndexes().length, 3); // _id on foo, _id on bar, x on foo -stopMongod( port ); +MongoRunner.stopMongod(conn); diff --git a/jstests/tool/stat1.js b/jstests/tool/stat1.js index 71ec776c170..0b5bf7f02b0 100644 --- a/jstests/tool/stat1.js +++ b/jstests/tool/stat1.js @@ -1,16 +1,15 @@ // stat1.js // test mongostat with authentication SERVER-3875 -port = allocatePorts( 1 )[ 0 ]; baseName = "tool_stat1"; -m = startMongod( "--auth", "--port", port, "--dbpath", MongoRunner.dataPath + baseName, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); +var m = MongoRunner.runMongod({auth: "", bind_ip: "127.0.0.1"}); db = m.getDB( "admin" ); db.createUser({user: "eliot" , pwd: "eliot", roles: jsTest.adminUserRoles}); assert( db.auth( "eliot" , "eliot" ) , "auth failed" ); -x = runMongoProgram( "mongostat", "--host", "127.0.0.1:"+port, "--username", "eliot", "--password", "eliot", "--rowcount", "1", "--authenticationDatabase", "admin" ); +x = runMongoProgram( "mongostat", "--host", "127.0.0.1:"+m.port, "--username", "eliot", "--password", "eliot", "--rowcount", "1", "--authenticationDatabase", "admin" ); assert.eq(x, 0, "mongostat should exit successfully with eliot:eliot"); -x = runMongoProgram( "mongostat", "--host", "127.0.0.1:"+port, "--username", "eliot", "--password", "wrong", "--rowcount", "1", "--authenticationDatabase", "admin" ); +x = runMongoProgram( "mongostat", "--host", "127.0.0.1:"+m.port, "--username", "eliot", "--password", "wrong", "--rowcount", "1", "--authenticationDatabase", "admin" ); assert.neq(x, 0, "mongostat should exit with -1 with eliot:wrong"); diff --git a/jstests/tool/tool1.js b/jstests/tool/tool1.js index 5bd191faa49..6fb0a1f0f02 100644 --- a/jstests/tool/tool1.js +++ b/jstests/tool/tool1.js @@ -16,17 +16,16 @@ function fileSize(){ } -port = allocatePorts( 1 )[ 0 ]; resetDbpath( externalPath ); -m = startMongod( "--port", port, "--dbpath", dbPath, "--nohttpinterface", "--noprealloc" , "--bind_ip", "127.0.0.1" ); +var m = MongoRunner.runMongod({dbpath: dbPath, noprealloc: "", bind_ip: "127.0.0.1"}); c = m.getDB( baseName ).getCollection( baseName ); c.save( { a: 1 } ); assert( c.findOne() ); -runMongoProgram( "mongodump", "--host", "127.0.0.1:" + port, "--out", externalPath ); +runMongoProgram( "mongodump", "--host", "127.0.0.1:" + m.port, "--out", externalPath ); c.drop(); -runMongoProgram( "mongorestore", "--host", "127.0.0.1:" + port, "--dir", externalPath ); +runMongoProgram( "mongorestore", "--host", "127.0.0.1:" + m.port, "--dir", externalPath ); assert.soon( "c.findOne()" , "mongodump then restore has no data w/sleep" ); assert( c.findOne() , "mongodump then restore has no data" ); assert.eq( 1 , c.findOne().a , "mongodump then restore has no broken data" ); @@ -34,10 +33,10 @@ assert.eq( 1 , c.findOne().a , "mongodump then restore has no broken data" ); resetDbpath( externalPath ); assert.eq( -1 , fileSize() , "mongoexport prep invalid" ); -runMongoProgram( "mongoexport", "--host", "127.0.0.1:" + port, "-d", baseName, "-c", baseName, "--out", externalFile ); +runMongoProgram( "mongoexport", "--host", "127.0.0.1:" + m.port, "-d", baseName, "-c", baseName, "--out", externalFile ); assert.lt( 10 , fileSize() , "file size changed" ); c.drop(); -runMongoProgram( "mongoimport", "--host", "127.0.0.1:" + port, "-d", baseName, "-c", baseName, "--file", externalFile ); +runMongoProgram( "mongoimport", "--host", "127.0.0.1:" + m.port, "-d", baseName, "-c", baseName, "--file", externalFile ); assert.soon( "c.findOne()" , "mongo import json A" ); assert( c.findOne() && 1 == c.findOne().a , "mongo import json B" ); |