
OPERATIONAL DEFECT DATABASE
...

...
The runMongoProgram() shell helper is a generic construct to allow an arbitrary executable to be run. It does not configure the options of the mongod based on the global TestData object.
max.hirschhorn@10gen.com commented on Wed, 27 May 2015 00:58:51 +0000: To resolve the test failures in SERVER-17861, I made a more minimal change to enable runMongoProgram("mongod", ...) to use the storage engine that's configured on the global TestData object. If we are still interested in standardizing how mongod's are started in tests (with the --repair option or not), then here's the initial approach I took to rewriting repair.js: diff --git a/jstests/disk/repair.js b/jstests/disk/repair.js index 0a92658..74ad631 100644 --- a/jstests/disk/repair.js +++ b/jstests/disk/repair.js @@ -2,46 +2,66 @@ var baseName = "jstests_disk_repair"; -port = allocatePorts( 1 )[ 0 ]; -dbpath = MongoRunner.dataPath + baseName + "/"; -repairpath = dbpath + "repairDir/" +var port = allocatePorts(1)[0]; +var dbpath = MongoRunner.dataPath + baseName + "/"; +var repairpath = dbpath + "repairDir/"; +var mongodOptions = { + port: port, + dbpath: dbpath, + nohttpinterface: "", + bind_ip: "127.0.0.1", + noCleanData: true, +}; + +function getRepairCmdLineArgs(options) { + // Add --repair to the command line invocation. + options = Object.merge(options, {repair: ""}); + + // Convert 'options' to an array. + var args = MongoRunner.arrOptions("mongod", options); + + // Apply storage engine options to the command line invocation. + return MongoRunner.appendSetParameterArgs(args); +} + +function check(conn) { + var pattern = new RegExp("^" + dbpath + "backup_"); + listFiles(dbpath).forEach(function(file) { + assert(!pattern.test(file.name), + "backup directory " + file.name + " was found in the dbpath"); + }); + assert.eq(1, conn.getDB(baseName)[baseName].count()); +} resetDbpath( dbpath ); resetDbpath( repairpath ); -m = startMongoProgram( "mongod", "--port", port, "--dbpath", dbpath, "--repairpath", repairpath, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); -db = m.getDB( baseName ); -db[ baseName ].save( {} ); -assert.commandWorked( db.runCommand( {repairDatabase:1, backupOriginalFiles:true} ) ); -function check() { - files = listFiles( dbpath ); - for( f in files ) { - assert( ! new RegExp( "^" + dbpath + "backup_" ).test( files[ f ].name ), "backup dir in dbpath" ); - } - - assert.eq.automsg( "1", "db[ baseName ].count()" ); -} -check(); -MongoRunner.stopMongod( port ); +var conn = MongoRunner.runMongod(Object.merge(mongodOptions, {repairpath: repairpath})); +assert.writeOK(conn.getDB(baseName)[baseName].insert({})); +assert.commandWorked(conn.getDB(baseName).runCommand({ + repairDatabase: 1, + backupOriginalFiles: true, +})); +check(conn); +MongoRunner.stopMongod(conn); 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(); -MongoRunner.stopMongod( port ); +conn = MongoRunner.runMongod(mongodOptions); +assert.commandWorked(conn.getDB(baseName).runCommand({repairDatabase: 1})); +check(conn); +MongoRunner.stopMongod(conn); resetDbpath( repairpath ); -rc = runMongoProgram( "mongod", "--repair", "--port", port, "--dbpath", dbpath, "--repairpath", repairpath, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); -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(); -MongoRunner.stopMongod( port ); +var options = Object.merge(mongodOptions, {repairpath: repairpath}); +var exitCode = runMongoProgram.apply(null, getRepairCmdLineArgs(options)); +assert.eq(0, exitCode, "--repair did not execute successfully"); +conn = MongoRunner.runMongod(options); +check(conn); +MongoRunner.stopMongod(conn); resetDbpath( repairpath ); -rc = runMongoProgram( "mongod", "--repair", "--port", port, "--dbpath", dbpath, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); -assert.eq.automsg( "0", "rc" ); -m = startMongoProgram( "mongod", "--port", port, "--dbpath", dbpath, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); -db = m.getDB( baseName ); -check(); +exitCode = runMongoProgram.apply(null, getRepairCmdLineArgs(mongodOptions)); +assert.eq(0, exitCode, "--repair did not execute successfully"); +conn = MongoRunner.runMongod(mongodOptions); +check(conn); +MongoRunner.stopMongod(conn); diff --git a/src/mongo/shell/servers.js b/src/mongo/shell/servers.js index 1da9db3..5ce4a73 100755 --- a/src/mongo/shell/servers.js +++ b/src/mongo/shell/servers.js @@ -807,6 +807,8 @@ function appendSetParameterArgs(argArray) { return argArray; }; +MongoRunner.appendSetParameterArgs = appendSetParameterArgs; + /** * Start a mongo process with a particular argument array. If we aren't waiting for connect, * return null.
mongo --nodb --eval 'TestData = new Object(); TestData.storageEngine="wiredTiger"; MongoRunner.runMongod({})' starts up a mongod with the wiredTiger storage engine. mongo --nodb --eval 'TestData = new Object(); TestData.storageEngine="wiredTiger"; runMongoProgram("mongod", "--port", 27017)' starts up a mongod with the default storage engine.
Click on a version to see all relevant bugs
MongoDB Integration
Learn more about where this data comes from
Bug Scrub Advisor
Streamline upgrades with automated vendor bug scrubs
BugZero Enterprise
Wish you caught this bug sooner? Get proactive today.