mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
cleaning up test framework and very simple sharding framework sanity test
This commit is contained in:
parent
d74b746c31
commit
1a4ad3f915
28
jstests/sharding/diffservers1.js
Normal file
28
jstests/sharding/diffservers1.js
Normal file
@ -0,0 +1,28 @@
|
||||
|
||||
|
||||
|
||||
a = startMongod( { port : 30000 , dbpath : "/data/db/diffservers1a" } )
|
||||
b = startMongod( { port : 30001 , dbpath : "/data/db/diffservers1b" } )
|
||||
|
||||
s = startMongos( { port : 30002 , configdb : "localhost:30000" } );
|
||||
|
||||
config = s.getDB( "config" );
|
||||
admin = s.getDB( "admin" );
|
||||
|
||||
admin.runCommand( { addserver : "localhost:30000" } )
|
||||
admin.runCommand( { addserver : "localhost:30001" } )
|
||||
|
||||
assert.eq( 2 , config.servers.count() , "server count wrong" );
|
||||
assert.eq( 2 , a.getDB( "config" ).servers.count() , "where are servers!" );
|
||||
assert.eq( 0 , b.getDB( "config" ).servers.count() , "shouldn't be here" );
|
||||
|
||||
test1 = s.getDB( "test1" ).foo;
|
||||
test1.save( { a : 1 } );
|
||||
test1.save( { a : 2 } );
|
||||
test1.save( { a : 3 } );
|
||||
assert( 3 , test1.count() );
|
||||
|
||||
stopMongoProgram( 30002 );
|
||||
stopMongod( 30000 );
|
||||
stopMongod( 30001 );
|
||||
|
@ -23,24 +23,46 @@ _parsePort = function() {
|
||||
return port;
|
||||
}
|
||||
|
||||
createMongoArgs = function( binaryName , args ){
|
||||
var fullArgs = [ binaryName ];
|
||||
|
||||
if ( args.length == 1 && isObject( args[0] ) ){
|
||||
var o = args[0];
|
||||
for ( var k in o ){
|
||||
fullArgs.push( "--" + k );
|
||||
fullArgs.push( "" + o[k] );
|
||||
}
|
||||
}
|
||||
else {
|
||||
for ( var i=0; i<args.length; i++ )
|
||||
fullArgs.push( args[i] )
|
||||
}
|
||||
|
||||
return fullArgs;
|
||||
}
|
||||
|
||||
// Start a mongod instance and return a 'Mongo' object connected to it.
|
||||
// This function's arguments are passed as command line arguments to mongod.
|
||||
// The specified 'dbpath' is cleared if it exists, created if not.
|
||||
startMongod = function() {
|
||||
var dbpath = _parsePath.apply( null, arguments );
|
||||
startMongod = function(){
|
||||
|
||||
var args = createMongoArgs( "mongod" , arguments );
|
||||
|
||||
var dbpath = _parsePath.apply( null, args );
|
||||
resetDbpath( dbpath );
|
||||
var fullArgs = Array();
|
||||
fullArgs[ 0 ] = "mongod";
|
||||
for( i = 0; i < arguments.length; ++i )
|
||||
fullArgs[ i + 1 ] = arguments[ i ];
|
||||
return startMongoProgram.apply( null, fullArgs );
|
||||
|
||||
return startMongoProgram.apply( null, args );
|
||||
}
|
||||
|
||||
startMongos = function(){
|
||||
return startMongoProgram.apply( null, createMongoArgs( "mongos" , arguments ) );
|
||||
}
|
||||
|
||||
// Start a mongo program instance (generally mongod or mongos) and return a
|
||||
// 'Mongo' object connected to it. This function's first argument is the
|
||||
// program name, and subsequent arguments to this function are passed as
|
||||
// command line arguments to the program.
|
||||
startMongoProgram = function() {
|
||||
startMongoProgram = function(){
|
||||
var port = _parsePort.apply( null, arguments );
|
||||
|
||||
_startMongoProgram.apply( null, arguments );
|
||||
|
Loading…
Reference in New Issue
Block a user