diff options
author | Charlie Swanson <charlie.swanson@mongodb.com> | 2015-09-01 16:19:57 -0400 |
---|---|---|
committer | Charlie Swanson <charlie.swanson@mongodb.com> | 2015-09-09 13:14:48 -0400 |
commit | c15f4bb96d2ee86874582d45d1865e9358168e7e (patch) | |
tree | 92c788863ae91a8b9c5801e1d536d7ef1a02ec05 /jstests/disk | |
parent | f5e063d4785b0460ab41de8cc4b537e5e2151338 (diff) | |
download | mongo-c15f4bb96d2ee86874582d45d1865e9358168e7e.tar.gz |
SERVER-18272 Update jstests to use allocatePort() instead of hard coding ports
Diffstat (limited to 'jstests/disk')
-rw-r--r-- | jstests/disk/directoryperdb.js | 5 | ||||
-rw-r--r-- | jstests/disk/filesize.js | 12 | ||||
-rw-r--r-- | jstests/disk/killall.js | 8 | ||||
-rw-r--r-- | jstests/disk/norepeat.js | 61 | ||||
-rw-r--r-- | jstests/disk/repair.js | 41 | ||||
-rw-r--r-- | jstests/disk/repair2.js | 95 | ||||
-rw-r--r-- | jstests/disk/repair3.js | 33 | ||||
-rw-r--r-- | jstests/disk/repair4.js | 17 |
8 files changed, 148 insertions, 124 deletions
diff --git a/jstests/disk/directoryperdb.js b/jstests/disk/directoryperdb.js index 157efbd07b6..b6e2ab5f9e5 100644 --- a/jstests/disk/directoryperdb.js +++ b/jstests/disk/directoryperdb.js @@ -1,9 +1,6 @@ var baseDir = "jstests_disk_directoryper"; var baseName = "directoryperdb" -port = allocatePorts( 1 )[ 0 ]; -dbpath = MongoRunner.dataPath + baseDir + "/"; - - +var dbpath = MongoRunner.dataPath + baseDir + "/"; var storageEngine = db.serverStatus().storageEngine.name; // The pattern which matches the names of database files diff --git a/jstests/disk/filesize.js b/jstests/disk/filesize.js index 77295c7b4bd..bb1291c0777 100644 --- a/jstests/disk/filesize.js +++ b/jstests/disk/filesize.js @@ -1,9 +1,8 @@ -// test for SERVER-7430: Warning about smallfiles should include filename -var port = allocatePorts( 1 )[ 0 ]; +// Test for SERVER-7430: Warning about smallfiles should include filename var baseName = "filesize"; // Start mongod with --smallfiles -var m = MongoRunner.runMongod({bind_ip: "127.0.0.1", nojournal: "", smallfiles: ""}); +var m = MongoRunner.runMongod({nojournal: "", smallfiles: ""}); var db = m.getDB( baseName ); @@ -14,7 +13,12 @@ if (db.serverBuildInfo().bits == 32) { // Restart mongod without --smallFiles MongoRunner.stopMongod(m); m = MongoRunner.runMongod({ - restart: true, cleanData: false, dbpath: m.dbpath, bind_ip: "127.0.0.1", nojournal: ""}); + restart: true, + cleanData: false, + dbpath: m.dbpath, + port: m.port, + 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 ba294a53504..beb3e99e778 100644 --- a/jstests/disk/killall.js +++ b/jstests/disk/killall.js @@ -6,19 +6,17 @@ * would not result in a zero return code. */ -var port = allocatePorts( 1 )[ 0 ] - var baseName = "jstests_disk_killall"; var dbpath = MongoRunner.dataPath + baseName; -var mongod = MongoRunner.runMongod({port: port, dbpath: dbpath}); +var mongod = MongoRunner.runMongod({dbpath: dbpath}); var db = mongod.getDB( "test" ); var collection = db.getCollection( baseName ); assert.writeOK(collection.insert({})); var awaitShell = startParallelShell( "db." + baseName + ".count( { $where: function() { while( 1 ) { ; } } } )", - port); + mongod.port); sleep( 1000 ); /** @@ -36,7 +34,7 @@ exitCode = awaitShell({checkExitSuccess: false}); assert.neq(0, exitCode, "expected shell to exit abnormally due to mongod being terminated"); mongod = MongoRunner.runMongod({ - port: port, + port: mongod.port, restart: true, cleanData: false, dbpath: mongod.dbpath diff --git a/jstests/disk/norepeat.js b/jstests/disk/norepeat.js deleted file mode 100644 index 1379ff1af20..00000000000 --- a/jstests/disk/norepeat.js +++ /dev/null @@ -1,61 +0,0 @@ -/* -baseName = "jstests_disk_norepeat"; - -ports = allocatePorts( 1 ); -m = startMongod( "--port", ports[ 0 ], "--deDupMem", "200", "--dbpath", MongoRunner.dataPath + baseName, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); - -t = m.getDB( baseName ).getCollection( baseName ); - -t.drop(); -t.ensureIndex( { i: 1 } ); -for( i = 0; i < 3; ++i ) { - t.save( { i: i } ); -} - -c = t.find().hint( { i: 1 } ).limit( 2 ); -assert.eq( 0, c.next().i ); -t.update( { i: 0 }, { i: 3 } ); -assert.eq( 1, c.next().i ); -assert.eq( 2, c.next().i ); -assert.throws( function() { c.next() }, [], "unexpected: object found" ); - -// now force upgrade to disk storage - -t.drop(); -t.ensureIndex( { i: 1 } ); -for( i = 0; i < 10; ++i ) { - t.save( { i: i } ); -} -// apparently this means we also request 2 in subsequent getMore's -c = t.find().hint( {i:1} ).limit( 2 ); -assert.eq( 0, c.next().i ); -t.update( { i: 0 }, { i: 10 } ); -for( i = 1; i < 10; ++i ) { - if ( i == 7 ) { - t.update( { i: 6 }, { i: 11 } ); - t.update( { i: 9 }, { i: 12 } ); - } - if ( i == 9 ) { - i = 12; - } - assert.eq( i, c.next().i ); -} -assert.throws( function() { c.next() }, [], "unexpected: object found" ); - -m.getDB( "local" ).getCollectionNames().forEach( function( x ) { assert( !x.match( /^temp/ ), "temp collection found" ); } ); - -t.drop(); -m.getDB( baseName ).createCollection( baseName, { capped:true, size:100000, autoIndexId:false } ); -t = m.getDB( baseName ).getCollection( baseName ); -t.insert( {_id:"a"} ); -t.insert( {_id:"a"} ); -t.insert( {_id:"a"} ); - -c = t.find().limit( 2 ); -assert.eq( "a", c.next()._id ); -assert.eq( "a", c.next()._id ); -assert.eq( "a", c.next()._id ); -assert( !c.hasNext() ); - -assert( t.validate().valid ); -*/ diff --git a/jstests/disk/repair.js b/jstests/disk/repair.js index 0a92658252b..699dbabf0d8 100644 --- a/jstests/disk/repair.js +++ b/jstests/disk/repair.js @@ -1,15 +1,17 @@ // check --repairpath and --repair var baseName = "jstests_disk_repair"; - -port = allocatePorts( 1 )[ 0 ]; -dbpath = MongoRunner.dataPath + baseName + "/"; -repairpath = dbpath + "repairDir/" +var dbpath = MongoRunner.dataPath + baseName + "/"; +var repairpath = dbpath + "repairDir/" resetDbpath( dbpath ); resetDbpath( repairpath ); -m = startMongoProgram( "mongod", "--port", port, "--dbpath", dbpath, "--repairpath", repairpath, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); +var m = MongoRunner.runMongod({ + dbpath: dbpath, + repairpath: repairpath, + noCleanData: true, +}); db = m.getDB( baseName ); db[ baseName ].save( {} ); assert.commandWorked( db.runCommand( {repairDatabase:1, backupOriginalFiles:true} ) ); @@ -22,26 +24,39 @@ function check() { assert.eq.automsg( "1", "db[ baseName ].count()" ); } check(); -MongoRunner.stopMongod( port ); +MongoRunner.stopMongod( m.port ); resetDbpath( repairpath ); -m = startMongoProgram( "mongod", "--port", port, "--dbpath", dbpath, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); +m = MongoRunner.runMongod({ + port: m.port, + dbpath: dbpath, + noCleanData: true, +}); db = m.getDB( baseName ); assert.commandWorked( db.runCommand( {repairDatabase:1} ) ); check(); -MongoRunner.stopMongod( port ); +MongoRunner.stopMongod( m.port ); resetDbpath( repairpath ); -rc = runMongoProgram( "mongod", "--repair", "--port", port, "--dbpath", dbpath, "--repairpath", repairpath, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); +rc = runMongoProgram("mongod", "--repair", "--port", m.port, "--dbpath", dbpath, + "--repairpath", repairpath); assert.eq.automsg( "0", "rc" ); -m = startMongoProgram( "mongod", "--port", port, "--dbpath", dbpath, "--repairpath", repairpath, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); +m = MongoRunner.runMongod({ + port: m.port, + dbpath: dbpath, + noCleanData: true, +}); db = m.getDB( baseName ); check(); -MongoRunner.stopMongod( port ); +MongoRunner.stopMongod( m.port ); resetDbpath( repairpath ); -rc = runMongoProgram( "mongod", "--repair", "--port", port, "--dbpath", dbpath, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); +rc = runMongoProgram("mongod", "--repair", "--port", m.port, "--dbpath", dbpath); assert.eq.automsg( "0", "rc" ); -m = startMongoProgram( "mongod", "--port", port, "--dbpath", dbpath, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); +m = MongoRunner.runMongod({ + port: m.port, + dbpath: dbpath, + noCleanData: true, +}); db = m.getDB( baseName ); check(); diff --git a/jstests/disk/repair2.js b/jstests/disk/repair2.js index a582d06a0ec..9a8da991f2d 100644 --- a/jstests/disk/repair2.js +++ b/jstests/disk/repair2.js @@ -12,16 +12,20 @@ function check() { assert.eq.automsg( "1", "db[ baseName ].count()" ); } -port = allocatePorts( 1 )[ 0 ]; -dbpath = MongoRunner.dataPath + baseName + "/"; -repairpath = dbpath + "repairDir/"; -longDBName = Array(61).join('a'); -longRepairPath = dbpath + Array(61).join('b') + '/'; +var dbpath = MongoRunner.dataPath + baseName + "/"; +var repairpath = dbpath + "repairDir/"; +var longDBName = Array(61).join('a'); +var longRepairPath = dbpath + Array(61).join('b') + '/'; resetDbpath( dbpath ); resetDbpath( repairpath ); -m = startMongoProgram( "mongod", "--directoryperdb", "--port", port, "--dbpath", dbpath, "--repairpath", repairpath, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); +var m = MongoRunner.runMongod({ + directoryperdb: "", + dbpath: dbpath, + repairpath: repairpath, + noCleanData: true, +}); db = m.getDB( baseName ); db[ baseName ].save( {} ); assert.commandWorked( db.runCommand( {repairDatabase:1, backupOriginalFiles:true} ) ); @@ -41,48 +45,97 @@ for( f in files ) { assert( fileCount > 0, "Expected more than zero nondirectory files in the database directory" ); check(); -MongoRunner.stopMongod( port ); +MongoRunner.stopMongod( m.port ); resetDbpath( repairpath ); -m = startMongoProgram( "mongod", "--directoryperdb", "--port", port, "--dbpath", dbpath, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); +m = MongoRunner.runMongod({ + port: m.port, + directoryperdb: "", + dbpath: dbpath, + noCleanData: true, +}); db = m.getDB( baseName ); assert.commandWorked( db.runCommand( {repairDatabase:1} ) ); check(); -MongoRunner.stopMongod( port ); +MongoRunner.stopMongod( m.port ); //Test long database names resetDbpath( repairpath ); -m = startMongoProgram( "mongod", "--directoryperdb", "--port", port, "--dbpath", dbpath, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); +m = MongoRunner.runMongod({ + port: m.port, + directoryperdb: "", + dbpath: dbpath, + noCleanData: true, +}); db = m.getDB( longDBName ); assert.writeOK(db[ baseName ].save( {} )); assert.commandWorked( db.runCommand( {repairDatabase:1} ) ); -MongoRunner.stopMongod( port ); +MongoRunner.stopMongod( m.port ); //Test long repairPath resetDbpath( longRepairPath ) -m = startMongoProgram( "mongod", "--directoryperdb", "--port", port, "--dbpath", dbpath, "--repairpath", longRepairPath, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); +m = MongoRunner.runMongod({ + port: m.port, + directoryperdb: "", + dbpath: dbpath, + repairpath: longRepairPath, + noCleanData: true, +}); db = m.getDB( longDBName ); assert.commandWorked( db.runCommand( {repairDatabase:1, backupOriginalFiles: true} ) ); check(); -MongoRunner.stopMongod( port ); +MongoRunner.stopMongod( m.port ); //Test database name and repairPath with --repair resetDbpath( longRepairPath ) -m = startMongoProgram( "mongod", "--repair", "--directoryperdb", "--port", port, "--dbpath", dbpath, "--repairpath", longRepairPath, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); -m = startMongoProgram( "mongod", "--directoryperdb", "--port", port, "--dbpath", dbpath, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); +var returnCode = runMongoProgram("mongod", + "--port", m.port, + "--repair", + "--directoryperdb", + "--dbpath", dbpath, + "--repairpath", longRepairPath); +assert.eq(returnCode, 0); +m = MongoRunner.runMongod({ + port: m.port, + directoryperdb: "", + dbpath: dbpath, + noCleanData: true, +}); db = m.getDB( longDBName ); check(); -MongoRunner.stopMongod( port ); +MongoRunner.stopMongod( m.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" ); +returnCode = runMongoProgram("mongod", + "--port", m.port, + "--repair", + "--directoryperdb", + "--dbpath", dbpath, + "--repairpath", repairpath); +assert.eq(returnCode, 0); +m = MongoRunner.runMongod({ + port: m.port, + directoryperdb: "", + dbpath: dbpath, + repairpath: repairpath, + noCleanData: true, +}); db = m.getDB( baseName ); check(); -MongoRunner.stopMongod( port ); +MongoRunner.stopMongod( m.port ); resetDbpath( repairpath ); -runMongoProgram( "mongod", "--repair", "--directoryperdb", "--port", port, "--dbpath", dbpath, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); -m = startMongoProgram( "mongod", "--directoryperdb", "--port", port, "--dbpath", dbpath, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); +returnCode = runMongoProgram("mongod", + "--port", m.port, + "--repair", + "--directoryperdb", + "--dbpath", dbpath); +assert.eq(returnCode, 0); +m = MongoRunner.runMongod({ + port: m.port, + directoryperdb: "", + dbpath: dbpath, + noCleanData: true, +}); db = m.getDB( baseName ); check(); diff --git a/jstests/disk/repair3.js b/jstests/disk/repair3.js index 6b4997cc83c..12c5356a2d6 100644 --- a/jstests/disk/repair3.js +++ b/jstests/disk/repair3.js @@ -17,15 +17,19 @@ if ( !doIt ) { doIt = false; } -if ( doIt ) { - - port = allocatePorts( 1 )[ 0 ]; - dbpath = MongoRunner.dataPath + baseName + "/"; +if (doIt) { + var dbpath = MongoRunner.dataPath + baseName + "/"; resetDbpath( dbpath ); resetDbpath( repairpath ); - m = startMongoProgram( "mongod", "--nssize", "8", "--noprealloc", "--smallfiles", "--port", port, "--dbpath", dbpath, "--repairpath", repairpath, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); + var m = MongoRunner.runMongod({ + nssize: 8, + noprealloc: "", + smallfiles: "", + dbpath: dbpath, + repairpath: repairpath, + }); db = m.getDB( baseName ); db[ baseName ].save( {} ); assert.commandWorked( db.runCommand( {repairDatabase:1, backupOriginalFiles:false} ) ); @@ -39,14 +43,21 @@ if ( doIt ) { } check(); - MongoRunner.stopMongod( port ); + MongoRunner.stopMongod( m.port ); resetDbpath( repairpath ); - rc = runMongoProgram( "mongod", "--nssize", "8", "--noprealloc", "--smallfiles", "--repair", "--port", port, "--dbpath", dbpath, "--repairpath", repairpath, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); + var rc = runMongoProgram("mongod", "--nssize", "8", "--noprealloc", "--smallfiles", "--repair", + "--port", m.port, "--dbpath", dbpath, "--repairpath", repairpath); assert.eq.automsg( "0", "rc" ); - m = startMongoProgram( "mongod", "--nssize", "8", "--noprealloc", "--smallfiles", "--port", port, "--dbpath", dbpath, "--repairpath", repairpath, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); + m = MongoRunner.runMongod({ + nssize: 8, + noprealloc: "", + smallfiles: "", + port: m.port, + dbpath: dbpath, + repairpath: repairpath, + }); db = m.getDB( baseName ); check(); - MongoRunner.stopMongod( port ); - -}
\ No newline at end of file + MongoRunner.stopMongod( m.port ); +} diff --git a/jstests/disk/repair4.js b/jstests/disk/repair4.js index 944a4f6fd11..38049ee1f9b 100644 --- a/jstests/disk/repair4.js +++ b/jstests/disk/repair4.js @@ -18,14 +18,21 @@ if ( !doIt ) { } if ( doIt ) { + var repairpath = MongoRunner.dataPath + baseName + "/"; - port = allocatePorts( 1 )[ 0 ]; - repairpath = MongoRunner.dataPath + baseName + "/"; - resetDbpath( smallpath ); resetDbpath( repairpath ); - m = startMongoProgram( "mongod", "--nssize", "8", "--noprealloc", "--smallfiles", "--port", port, "--dbpath", smallpath, "--repairpath", repairpath, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); + var m = MongoRunner.runMongod({ + nssize: "8", + noprealloc: "", + smallfiles: "", + dbpath: smallpath, + repairpath: repairpath, + nohttpinterface: "", + bind_ip: "127.0.0.1", + }); + db = m.getDB( baseName ); db[ baseName ].save( {} ); assert.commandWorked( db.runCommand( {repairDatabase:1, backupOriginalFiles:true} ) ); @@ -41,4 +48,4 @@ if ( doIt ) { check(); MongoRunner.stopMongod( port ); -}
\ No newline at end of file +} |