diff --git a/SConstruct b/SConstruct index 2149a0956fb..6c6313b7905 100644 --- a/SConstruct +++ b/SConstruct @@ -772,14 +772,31 @@ def addSmoketest( name, deps, actions ): # Prevent smoke tests from running in parallel testEnv.SideEffect( "dummySmokeSideEffect", name ) +def ensureDir( name ): + d = os.path.dirname( name ) + if not os.path.exists( d ): + print( "Creating dir: " + name ); + os.makedirs( d ) + if not os.path.exists( d ): + print( "Failed to create dir: " + name ); + Exit( 1 ) + def testSetup( env , target , source ): - Execute( Mkdir( "/tmp/unittest/" ) ) + ensureDir( "/tmp/unittest/" ) addSmoketest( "smoke", [ "test" ] , [ testSetup , test[ 0 ].abspath ] ) addSmoketest( "smokePerf", [ "perftest" ] , [ perftest[ 0 ].abspath ] ) -clientExec = [ x[0].abspath for x in clientTests ]; -addSmoketest( "smokeClient" , clientExec , clientExec ) +clientExec = [ x[0].abspath for x in clientTests ] +def runClientTests( env, target, source ): + global clientExec + global mongodForTestsPort + import subprocess + for i in clientExec: + if( subprocess.call( [ i, "--port", mongodForTestsPort ] ) != 0 ): + return True + return False +addSmoketest( "smokeClient" , clientExec, runClientTests ) addSmoketest( "mongosTest" , [ mongos[0].abspath ] , [ mongos[0].abspath + " --test" ] ) def jsSpec( suffix ): @@ -802,14 +819,20 @@ if not onlyServer and not noshell: addSmoketest( "smokeQuota", [ "mongo" ], [ mongo[0].abspath + " " + jsSpec( [ "quota", "*.js" ] ) ] ) mongodForTests = None +mongodForTestsPort = "27017" def startMongodForTests( env, target, source ): global mongodForTests + global mongodForTestsPort global mongod if mongodForTests: return + mongodForTestsPort = "40000" + import os + dirName = "/data/db/sconsTests/" + ensureDir( dirName ) from subprocess import Popen - mongodForTests = Popen( [ mongod[0].abspath, "run" ] ) + mongodForTests = Popen( [ mongod[0].abspath, "--port", mongodForTestsPort, "--dbpath", dirName ] ) # Wait for mongod to start from time import sleep sleep( 2 ) diff --git a/client/examples/authTest.cpp b/client/examples/authTest.cpp index b027e957d9f..d4c82a2aeb6 100644 --- a/client/examples/authTest.cpp +++ b/client/examples/authTest.cpp @@ -6,11 +6,18 @@ using namespace mongo; -int main() { +int main( int argc, const char **argv ) { + + const char *port = "27017"; + if ( argc != 1 ) { + if ( argc != 3 ) + throw -12; + port = argv[ 2 ]; + } DBClientConnection conn; string errmsg; - if ( ! conn.connect( "127.0.0.1" , errmsg ) ) { + if ( ! conn.connect( string( "127.0.0.1:" ) + port , errmsg ) ) { cout << "couldn't connect : " << errmsg << endl; throw -11; } diff --git a/client/examples/clientTest.cpp b/client/examples/clientTest.cpp index 9921cb74073..ce7fc5f0a72 100644 --- a/client/examples/clientTest.cpp +++ b/client/examples/clientTest.cpp @@ -11,11 +11,18 @@ using namespace std; using namespace mongo; -int main() { +int main( int argc, const char **argv ) { + + const char *port = "27017"; + if ( argc != 1 ) { + if ( argc != 3 ) + throw -12; + port = argv[ 2 ]; + } DBClientConnection conn; string errmsg; - if ( ! conn.connect(/* "192.168.58.1"*/"127.0.0.1" , errmsg ) ) { + if ( ! conn.connect( string( "127.0.0.1:" ) + port , errmsg ) ) { cout << "couldn't connect : " << errmsg << endl; throw -11; } diff --git a/client/examples/first.cpp b/client/examples/first.cpp index 0fdb1fa8151..7600c27f170 100644 --- a/client/examples/first.cpp +++ b/client/examples/first.cpp @@ -15,11 +15,18 @@ void insert( mongo::DBClientConnection & conn , const char * name , int num ) { conn.insert( "test.people" , obj.obj() ); } -int main() { +int main( int argc, const char **argv ) { + const char *port = "27017"; + if ( argc != 1 ) { + if ( argc != 3 ) + throw -12; + port = argv[ 2 ]; + } + mongo::DBClientConnection conn; string errmsg; - if ( ! conn.connect( "127.0.0.1" , errmsg ) ) { + if ( ! conn.connect( string( "127.0.0.1:" ) + port , errmsg ) ) { cout << "couldn't connect : " << errmsg << endl; throw -11; } diff --git a/client/examples/second.cpp b/client/examples/second.cpp index 86aba0bcbe7..7f6d1212a3d 100644 --- a/client/examples/second.cpp +++ b/client/examples/second.cpp @@ -7,11 +7,18 @@ using namespace std; using namespace mongo; -int main() { +int main( int argc, const char **argv ) { + + const char *port = "27017"; + if ( argc != 1 ) { + if ( argc != 3 ) + throw -12; + port = argv[ 2 ]; + } DBClientConnection conn; string errmsg; - if ( ! conn.connect( "127.0.0.1" , errmsg ) ) { + if ( ! conn.connect( string( "127.0.0.1:" ) + port , errmsg ) ) { cout << "couldn't connect : " << errmsg << endl; throw -11; } diff --git a/client/examples/whereExample.cpp b/client/examples/whereExample.cpp index 2f83af6ea1f..cc3ab4ae39b 100644 --- a/client/examples/whereExample.cpp +++ b/client/examples/whereExample.cpp @@ -7,11 +7,18 @@ using namespace std; using namespace mongo; -int main() { +int main( int argc, const char **argv ) { + + const char *port = "27017"; + if ( argc != 1 ) { + if ( argc != 3 ) + throw -12; + port = argv[ 2 ]; + } DBClientConnection conn; string errmsg; - if ( ! conn.connect( "127.0.0.1" , errmsg ) ) { + if ( ! conn.connect( string( "127.0.0.1:" ) + port , errmsg ) ) { cout << "couldn't connect : " << errmsg << endl; throw -11; }