ToolTest = function( name, extraOptions ){ this.name = name; this.options = extraOptions; this.port = allocatePorts(1)[0]; this.baseName = "jstests_tool_" + name; this.root = MongoRunner.dataPath + this.baseName; this.dbpath = this.root + "/"; this.ext = this.root + "_external/"; this.extFile = this.root + "_external/a"; resetDbpath( this.dbpath ); resetDbpath( this.ext ); } ToolTest.prototype.startDB = function( coll ){ assert( ! this.m , "db already running" ); var options = {port : this.port, dbpath : this.dbpath, nohttpinterface : "", noprealloc : "", smallfiles : "", bind_ip : "127.0.0.1"}; Object.extend(options, this.options); this.m = startMongoProgram.apply(null, MongoRunner.arrOptions("mongod", options)); this.db = this.m.getDB( this.baseName ); if ( coll ) return this.db.getCollection( coll ); return this.db; } ToolTest.prototype.stop = function(){ if ( ! this.m ) return; _stopMongoProgram( this.port ); this.m = null; this.db = null; print('*** ' + this.name + " completed successfully ***"); } ToolTest.prototype.runTool = function(){ var a = [ "mongo" + arguments[0] ]; var hasdbpath = false; for ( var i=1; i= 2) { var port = hostAndPort[1]; } } if (port) { args.push("--port", port); } // Convert function into call-string if (typeof(jsCode) == "function") { var id = Math.floor(Math.random() * 100000); jsCode = "var f" + id + " = " + jsCode.toString() + ";f" + id + "();"; } else if(typeof(jsCode) == "string") {} // do nothing else { throw Error("bad first argument to startParallelShell"); } if (noConnect) { args.push("--nodb"); } else if (typeof(db) == "object") { jsCode = "db = db.getSiblingDB('" + db.getName() + "');" + jsCode; } if (TestData) { jsCode = "TestData = " + tojson(TestData) + ";" + jsCode; } args.push("--eval", jsCode); x = startMongoProgramNoConnect.apply(null, args); return function(){ return waitProgram( x ); }; } var testingReplication = false;