diff --git a/README b/README index a47c0708c4624..325f199c197ab 100644 --- a/README +++ b/README @@ -16,19 +16,6 @@ BUILDING http://www.mongodb.org/display/DOCS/Building - -- Pre-requisite for 'test' binary, the MongoDB unit test suite: - This is not required for building or running the database - - To compile the unit tests, you need to install the unit test framework from: - http://unittest.red-bean.com/ - - $ cd .. - $ svn co http://svn.red-bean.com/unittest/trunk/ unittest - $ cd unittest - $ ./configure - $ make - $ sudo make install - Then use scons to build. @@ -41,7 +28,7 @@ BUILDING $ scons To install - + $ scons --prefix=/opt/mongo install RUNNING diff --git a/bin/buildDeps b/bin/buildDeps deleted file mode 100644 index c348b7de825e9..0000000000000 --- a/bin/buildDeps +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/tcsh - -cd .. -test ! -d v8 && svn checkout http://v8.googlecode.com/svn/trunk/ v8 -cd v8 -scons libv8.a - -cd .. -test ! -d unittest && svn co http://svn.red-bean.com/unittest/trunk/ unittest -cd unittest -./configure --prefix=/usr/local -make -make install - - - diff --git a/bin/run.tcsh b/bin/run.tcsh deleted file mode 100644 index 44689aecca8ac..0000000000000 --- a/bin/run.tcsh +++ /dev/null @@ -1,17 +0,0 @@ - -limit coredumpsize 200m - -while ( 1 == 1 ) - - if ( -f log/run.log.6 ) mv log/run.log.6 log/run.log.7 - if ( -f log/run.log.5 ) mv log/run.log.5 log/run.log.6 - if ( -f log/run.log.4 ) mv log/run.log.4 log/run.log.5 - if ( -f log/run.log.3 ) mv log/run.log.3 log/run.log.4 - if ( -f log/run.log.2 ) mv log/run.log.2 log/run.log.3 - if ( -f log/run.log.1 ) mv log/run.log.1 log/run.log.2 - if ( -f log/run.log ) mv log/run.log log/run.log.1 - - ./mongod --master >& log/run.log - sleep 2 -end - diff --git a/bin/start.tcsh b/bin/start.tcsh deleted file mode 100644 index 476063b880f1b..0000000000000 --- a/bin/start.tcsh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/tcsh - -tcsh bin/run.tcsh >& /dev/null & diff --git a/db/dbcommands.cpp b/db/dbcommands.cpp index 75b6dcc79f43f..4477a80049706 100644 --- a/db/dbcommands.cpp +++ b/db/dbcommands.cpp @@ -1250,6 +1250,8 @@ namespace mongo { if ( n == 0 ){ n = map.size(); s->setObject( "$key" , key , true ); + + uassert( "group() can't handle more than 10000 unique keys" , n < 10000 ); } s->setObject( "obj" , obj , true ); @@ -1258,7 +1260,7 @@ namespace mongo { throw UserException( (string)"reduce invoke failed: " + s->getError() ); } } - + if (!finalize.empty()){ s->exec( "$finalize = " + finalize , "finalize define" , false , true , true , 100 ); ScriptingFunction g = s->createFunction( diff --git a/dbtests/basictests.cpp b/dbtests/basictests.cpp index 827a678a6970c..5bdf7d3e82a06 100644 --- a/dbtests/basictests.cpp +++ b/dbtests/basictests.cpp @@ -49,13 +49,13 @@ namespace BasicTests { class All : public Suite { public: - All() { + All() : Suite( "basic" ){ + } + + void setupTests(){ add< Rarely >(); } - }; + } myall; } // namespace BasicTests -UnitTest::TestPtr basicTests() { - return UnitTest::createSuite< BasicTests::All >(); -} diff --git a/dbtests/btreetests.cpp b/dbtests/btreetests.cpp index 663d865a965b4..a2425b2ffd42d 100644 --- a/dbtests/btreetests.cpp +++ b/dbtests/btreetests.cpp @@ -213,9 +213,12 @@ namespace BtreeTests { } }; - class All : public UnitTest::Suite { + class All : public Suite { public: - All() { + All() : Suite( "btree" ){ + } + + void setupTests(){ add< Create >(); add< SimpleInsertDelete >(); add< SplitRightHeavyBucket >(); @@ -223,9 +226,6 @@ namespace BtreeTests { add< MissingLocate >(); add< MissingLocateMultiBucket >(); } - }; + } myall; } -UnitTest::TestPtr btreeTests() { - return UnitTest::createSuite< BtreeTests::All >(); -} diff --git a/dbtests/cursortests.cpp b/dbtests/cursortests.cpp index 8246a82f7f158..c3b6259157787 100644 --- a/dbtests/cursortests.cpp +++ b/dbtests/cursortests.cpp @@ -194,18 +194,16 @@ namespace CursorTests { } // namespace MultiBtreeCursorTests - class All : public ::Suite { + class All : public Suite { public: - All() { + All() : Suite( "cursor" ){} + + void setupTests(){ add< IdSetTests::BasicSize >(); add< IdSetTests::Upgrade >(); add< BtreeCursorTests::MultiRange >(); add< BtreeCursorTests::MultiRangeGap >(); add< BtreeCursorTests::MultiRangeReverse >(); } - }; + } myall; } // namespace CursorTests - -UnitTest::TestPtr cursorTests() { - return UnitTest::createSuite< CursorTests::All >(); -} diff --git a/dbtests/dbtests.cpp b/dbtests/dbtests.cpp index 5ef7113a4b2f0..29260dde5ce10 100644 --- a/dbtests/dbtests.cpp +++ b/dbtests/dbtests.cpp @@ -22,8 +22,6 @@ #include "../db/instance.h" #include "../util/file_allocator.h" -#include - #if !defined(_WIN32) #include #endif @@ -34,14 +32,10 @@ using namespace std; namespace mongo { extern string dbpath; -} // namespace mongo -string dbpathSpec = "/tmp/unittest/"; - -Suite::~Suite() { - DBDirectClient c; - c.dropDatabase( "unittests" ); } +string dbpathSpec = "/tmp/unittest/"; + void usage() { string instructions = "dbtests usage:\n" @@ -97,29 +91,10 @@ int main( int argc, char** argv ) { out() << "random seed: " << seed << endl; theFileAllocator().start(); + - UnitTest::Registry tests; - - // NOTE Starting JNI changes global state (for example, locale and FPU precision); - // make sure all tests run with this setup, by running javajs tests first. - tests.add( jsTests(), "js" ); - - tests.add( basicTests(), "basic" ); - tests.add( btreeTests(), "btree" ); - tests.add( cursorTests(), "cursor" ); - tests.add( jsobjTests(), "jsobj" ); - tests.add( jsonTests(), "json" ); - tests.add( matcherTests(), "matcher" ); - tests.add( namespaceTests(), "namespace" ); - tests.add( pairingTests(), "pairing" ); - tests.add( pdfileTests(), "pdfile" ); - tests.add( queryTests(), "query" ); - tests.add( queryOptimizerTests(), "queryoptimizer" ); - tests.add( replTests(), "repl" ); - tests.add( sockTests(), "sock" ); - tests.add( updateTests(), "update" ); - - int ret = tests.run( argc, argv ); + + int ret = mongo::regression::Suite::run( argc, argv ); #if !defined(_WIN32) && !defined(__sunos__) flock( lockFile, LOCK_UN ); diff --git a/dbtests/dbtests.h b/dbtests/dbtests.h index 113fb2c907740..3184a050f4b69 100644 --- a/dbtests/dbtests.h +++ b/dbtests/dbtests.h @@ -17,28 +17,8 @@ * along with this program. If not, see . */ -#include +#include "framework.h" using namespace mongo; +using namespace mongo::regression; -// Utility class to handle per suite cleanup -class Suite : public UnitTest::Suite { -public: - ~Suite(); -}; - -UnitTest::TestPtr basicTests(); -UnitTest::TestPtr btreeTests(); -UnitTest::TestPtr cursorTests(); -UnitTest::TestPtr jsTests(); -UnitTest::TestPtr jsobjTests(); -UnitTest::TestPtr jsonTests(); -UnitTest::TestPtr matcherTests(); -UnitTest::TestPtr namespaceTests(); -UnitTest::TestPtr pairingTests(); -UnitTest::TestPtr pdfileTests(); -UnitTest::TestPtr queryTests(); -UnitTest::TestPtr queryOptimizerTests(); -UnitTest::TestPtr replTests(); -UnitTest::TestPtr sockTests(); -UnitTest::TestPtr updateTests(); diff --git a/dbtests/framework.cpp b/dbtests/framework.cpp new file mode 100644 index 0000000000000..5a481b15e5498 --- /dev/null +++ b/dbtests/framework.cpp @@ -0,0 +1,222 @@ +// framework.cpp + +/** +* Copyright (C) 2008 10gen Inc. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU Affero General Public License, version 3, +* as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Affero General Public License for more details. +* +* You should have received a copy of the GNU Affero General Public License +* along with this program. If not, see . +*/ + +#include "../stdafx.h" +#include "framework.h" + +#ifndef _WIN32 +#include +#endif + +namespace mongo { + + namespace regression { + + map * mongo::regression::Suite::_suites = 0; + + class Result { + public: + Result( string name ) : _name( name ) , _rc(0) , _tests(0) , _fails(0) , _asserts(0) { + } + + string toString(){ + stringstream ss; + ss << _name << " tests:" << _tests << " fails:" << _fails << " assert calls:" << _asserts << "\n"; + for ( list::iterator i=_messages.begin(); i!=_messages.end(); i++ ){ + ss << "\t" << *i << "\n"; + } + return ss.str(); + } + + int rc(){ + return _rc; + } + + string _name; + + int _rc; + int _tests; + int _fails; + int _asserts; + list _messages; + + static Result * cur; + }; + + Result * Result::cur = 0; + + Result * Suite::run(){ + setupTests(); + + Result * r = new Result( _name ); + Result::cur = r; + + for ( list::iterator i=_tests.begin(); i!=_tests.end(); i++ ){ + TestCase * tc = *i; + + r->_tests++; + + bool passes = false; + + log(1) << "\t" << tc->getName() << endl; + + try { + tc->run(); + passes = true; + } + catch ( ... ){ + log() << "unknown exception in test: " << tc->getName() << endl; + } + + if ( ! passes ) + r->_fails++; + } + + return r; + } + + int Suite::run( int argc , char ** argv ){ + list torun; + + for ( int i=1; i::iterator i=_suites->begin() ; i!=_suites->end(); i++ ) + cout << i->first << endl; + return 0; + } + + if ( s == "-debug" ){ + logLevel = 1; + continue; + } + + torun.push_back( s ); + if ( _suites->find( s ) == _suites->end() ){ + cout << "invalid test [" << s << "] use -list to see valid names" << endl; + return -1; + } + } + + if ( torun.size() == 0 ) + for ( map::iterator i=_suites->begin() ; i!=_suites->end(); i++ ) + torun.push_back( i->first ); + + list results; + + for ( list::iterator i=torun.begin(); i!=torun.end(); i++ ){ + string name = *i; + Suite * s = (*_suites)[name]; + assert( s ); + + log() << "going to run suite: " << name << endl; + results.push_back( s->run() ); + } + + cout << "**************************************************" << endl; + cout << "**************************************************" << endl; + cout << "**************************************************" << endl; + + int rc = 0; + + int tests = 0; + int fails = 0; + int asserts = 0; + + for ( list::iterator i=results.begin(); i!=results.end(); i++ ){ + Result * r = *i; + cout << r->toString(); + if ( abs( r->rc() ) > abs( rc ) ) + rc = r->rc(); + + tests += r->_tests; + fails += r->_fails; + asserts += r->_asserts; + } + + cout << "TOTALS tests:" << tests << " fails: " << fails << " asserts calls: " << asserts << endl; + + return rc; + } + + void Suite::registerSuite( string name , Suite * s ){ + if ( ! _suites ) + _suites = new map(); + Suite*& m = (*_suites)[name]; + uassert( "already have suite with that name" , ! m ); + m = s; + } + + void assert_pass(){ + Result::cur->_asserts++; + } + + void assert_fail( const char * exp , const char * file , unsigned line ){ + Result::cur->_asserts++; + Result::cur->_fails++; + + stringstream ss; + ss << "ASSERT FAILED! " << file << ":" << line << endl; + log() << ss.str() << endl; + Result::cur->_messages.push_back( ss.str() ); + } + + void fail( const char * exp , const char * file , unsigned line ){ + assert(0); + } + + string demangleName( const type_info& typeinfo ){ + int status; + + char * niceName = abi::__cxa_demangle(typeinfo.name(), 0, 0, &status); + if ( ! niceName ) + return typeinfo.name(); + + string s = niceName; + free(niceName); + return s; + } + + void MyAsserts::printLocation(){ + log() << _file << ":" << _line << " " << _aexp << " != " << _bexp << " "; + } + + void MyAsserts::ae( double a , double b ){ + Result::cur->_asserts++; + if ( a == b ) + return; + + printLocation(); + log() << a << " != " << b << endl; + throw -1; + } + + void MyAsserts::ae( string a , string b ){ + Result::cur->_asserts++; + if ( a == b ) + return; + + printLocation(); + log() << a << " != " << b << endl; + throw -1; + } + + } +} diff --git a/dbtests/framework.h b/dbtests/framework.h new file mode 100644 index 0000000000000..9c378418078f8 --- /dev/null +++ b/dbtests/framework.h @@ -0,0 +1,157 @@ +// framework.h + +/** +* Copyright (C) 2008 10gen Inc. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU Affero General Public License, version 3, +* as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Affero General Public License for more details. +* +* You should have received a copy of the GNU Affero General Public License +* along with this program. If not, see . +*/ + +/* + + simple portable regression system + */ + +#include "../stdafx.h" + +#define ASSERT_EXCEPTION(a,b) \ + try { \ + a; \ + mongo::regression::assert_fail( #a , __FILE__ , __LINE__ ); \ + } catch ( b& x ){ \ + mongo::regression::assert_pass(); \ + } + + + +#define ASSERT_EQUALS(a,b) (mongo::regression::MyAsserts( #a , #b , __FILE__ , __LINE__ ) ).ae( (a) , (b) ) +#define ASSERT(x) (void)( (!(!(x))) ? mongo::regression::assert_pass() : mongo::regression::assert_fail( #x , __FILE__ , __LINE__ ) ) +#define FAIL(x) mongo::regression::fail( #x , __FILE__ , __LINE__ ) + +#include "../db/instance.h" + +namespace mongo { + + namespace regression { + + class Result; + + string demangleName( const type_info& typeinfo ); + + class TestCase { + public: + virtual ~TestCase(){} + virtual void run() = 0; + virtual string getName() = 0; + }; + + template< class T > + class TestHolderBase : public TestCase { + public: + TestHolderBase(){} + virtual ~TestHolderBase(){} + virtual void run(){ + auto_ptr t; + t.reset( create() ); + t->run(); + } + virtual T * create() = 0; + virtual string getName(){ + return demangleName( typeid(T) ); + } + }; + + template< class T > + class TestHolder0 : public TestHolderBase { + public: + virtual T * create(){ + return new T(); + } + }; + + template< class T , typename A > + class TestHolder1 : public TestHolderBase { + public: + TestHolder1( const A& a ) : _a(a){} + virtual T * create(){ + return new T( _a ); + } + const A& _a; + }; + + class Suite { + public: + Suite( string name ) : _name( name ){ + registerSuite( name , this ); + _ran = 0; + } + + virtual ~Suite() { + if ( _ran ){ + DBDirectClient c; + c.dropDatabase( "unittests" ); + } + } + + template + void add(){ + _tests.push_back( new TestHolder0() ); + } + + template + void add( const A& a ){ + _tests.push_back( new TestHolder1(a) ); + } + + Result * run(); + + static int run( int argc , char ** argv ); + + + protected: + virtual void setupTests() = 0; + + private: + string _name; + list _tests; + bool _ran; + + static map * _suites; + + void registerSuite( string name , Suite * s ); + }; + + void assert_pass(); + void assert_fail( const char * exp , const char * file , unsigned line ); + void fail( const char * exp , const char * file , unsigned line ); + + class MyAsserts { + public: + MyAsserts( const char * aexp , const char * bexp , const char * file , unsigned line ) + : _aexp( aexp ) , _bexp( bexp ) , _file( file ) , _line( line ){ + + } + + void ae( double a , double b ); + void ae( string a , string b ); + + void printLocation(); + + private: + string _aexp; + string _bexp; + string _file; + unsigned _line; + }; + + } +} diff --git a/dbtests/jsobjtests.cpp b/dbtests/jsobjtests.cpp index a3e76503bf34f..6c0e03bc30f53 100644 --- a/dbtests/jsobjtests.cpp +++ b/dbtests/jsobjtests.cpp @@ -902,7 +902,10 @@ namespace JsobjTests { class All : public Suite { public: - All() { + All() : Suite( "jsobj" ){ + } + + void setupTests(){ add< BufBuilderBasic >(); add< BSONElementBasic >(); add< BSONObjTests::Create >(); @@ -970,10 +973,7 @@ namespace JsobjTests { add< external_sort::Basic3 >(); add< external_sort::Big1 >(); } - }; + } myall; } // namespace JsobjTests -UnitTest::TestPtr jsobjTests() { - return UnitTest::createSuite< JsobjTests::All >(); -} diff --git a/dbtests/jsontests.cpp b/dbtests/jsontests.cpp index 971683af8c352..80f964a22cbb7 100644 --- a/dbtests/jsontests.cpp +++ b/dbtests/jsontests.cpp @@ -901,7 +901,10 @@ namespace JsonTests { class All : public Suite { public: - All() { + All() : Suite( "json" ){ + } + + void setupTests(){ add< JsonStringTests::Empty >(); add< JsonStringTests::SingleStringMember >(); add< JsonStringTests::EscapedCharacters >(); @@ -973,10 +976,7 @@ namespace JsonTests { add< FromJsonTests::ObjectId >(); add< FromJsonTests::ObjectId2 >(); } - }; + } myall; } // namespace JsonTests -UnitTest::TestPtr jsonTests() { - return UnitTest::createSuite< JsonTests::All >(); -} diff --git a/dbtests/jstests.cpp b/dbtests/jstests.cpp index 68a769f5d4d5a..ea48ee6975fd1 100644 --- a/dbtests/jstests.cpp +++ b/dbtests/jstests.cpp @@ -609,7 +609,10 @@ namespace JSTests { class All : public Suite { public: - All() { + All() : Suite( "js" ) { + } + + void setupTests(){ add< Fundamental >(); add< BasicScope >(); add< FalseTests >(); @@ -632,10 +635,7 @@ namespace JSTests { add< VarTests >(); } - }; + } myall; } // namespace JavaJSTests -UnitTest::TestPtr jsTests() { - return UnitTest::createSuite< JSTests::All >(); -} diff --git a/dbtests/matchertests.cpp b/dbtests/matchertests.cpp index 78e387f6f1573..7b6dcc244ed74 100644 --- a/dbtests/matchertests.cpp +++ b/dbtests/matchertests.cpp @@ -110,7 +110,10 @@ namespace MatcherTests { class All : public Suite { public: - All() { + All() : Suite( "matcher" ){ + } + + void setupTests(){ add< Basic >(); add< DoubleEqual >(); add< MixedNumericEqual >(); @@ -118,10 +121,7 @@ namespace MatcherTests { add< MixedNumericIN >(); add< Size >(); } - }; + } dball; } // namespace MatcherTests -UnitTest::TestPtr matcherTests() { - return UnitTest::createSuite< MatcherTests::All >(); -} diff --git a/dbtests/namespacetests.cpp b/dbtests/namespacetests.cpp index 8efbad6e6e262..5c35be8bea851 100644 --- a/dbtests/namespacetests.cpp +++ b/dbtests/namespacetests.cpp @@ -699,7 +699,10 @@ namespace NamespaceTests { class All : public Suite { public: - All() { + All() : Suite( "namespace" ){ + } + + void setupTests(){ add< IndexDetailsTests::Create >(); add< IndexDetailsTests::GetKeysFromObjectSimple >(); add< IndexDetailsTests::GetKeysFromObjectDotted >(); @@ -727,9 +730,6 @@ namespace NamespaceTests { // add< NamespaceDetailsTests::BigCollection >(); add< NamespaceDetailsTests::Size >(); } - }; + } myall; } // namespace NamespaceTests -UnitTest::TestPtr namespaceTests() { - return UnitTest::createSuite< NamespaceTests::All >(); -} diff --git a/dbtests/pairingtests.cpp b/dbtests/pairingtests.cpp index 3446d9f491a5d..b3e772ba55164 100644 --- a/dbtests/pairingtests.cpp +++ b/dbtests/pairingtests.cpp @@ -326,7 +326,10 @@ namespace PairingTests { class All : public Suite { public: - All() { + All() : Suite( "pairing" ){ + } + + void setupTests(){ add< ReplPairTests::Create >(); add< ReplPairTests::Dominant >(); add< ReplPairTests::SetMaster >(); @@ -336,9 +339,6 @@ namespace PairingTests { add< NegotiateWithCatchup >(); add< NobodyCaughtUp >(); } - }; + } myall; } // namespace PairingTests -UnitTest::TestPtr pairingTests() { - return UnitTest::createSuite< PairingTests::All >(); -} diff --git a/dbtests/pdfiletests.cpp b/dbtests/pdfiletests.cpp index ca611f9b56a21..e53b7f576f777 100644 --- a/dbtests/pdfiletests.cpp +++ b/dbtests/pdfiletests.cpp @@ -303,7 +303,9 @@ namespace PdfileTests { class All : public Suite { public: - All() { + All() : Suite( "pdfile" ){} + + void setupTests(){ add< ScanCapped::Empty >(); add< ScanCapped::EmptyLooped >(); add< ScanCapped::EmptyMultiExtentLooped >(); @@ -319,10 +321,7 @@ namespace PdfileTests { add< ScanCapped::LastInExtent >(); add< Insert::UpdateDate >(); } - }; + } myall; } // namespace PdfileTests -UnitTest::TestPtr pdfileTests() { - return UnitTest::createSuite< PdfileTests::All >(); -} diff --git a/dbtests/queryoptimizertests.cpp b/dbtests/queryoptimizertests.cpp index ab79b2273d429..df7e73a7e09e2 100644 --- a/dbtests/queryoptimizertests.cpp +++ b/dbtests/queryoptimizertests.cpp @@ -1097,7 +1097,9 @@ namespace QueryOptimizerTests { class All : public Suite { public: - All() { + All() : Suite( "queryoptimizer" ){} + + void setupTests(){ add< FieldRangeTests::Empty >(); add< FieldRangeTests::Eq >(); add< FieldRangeTests::DupEq >(); @@ -1158,10 +1160,7 @@ namespace QueryOptimizerTests { add< QueryPlanSetTests::EqualityThenIn >(); add< QueryPlanSetTests::NotEqualityThenIn >(); } - }; + } myall; } // namespace QueryOptimizerTests -UnitTest::TestPtr queryOptimizerTests() { - return UnitTest::createSuite< QueryOptimizerTests::All >(); -} diff --git a/dbtests/querytests.cpp b/dbtests/querytests.cpp index d0de419de6065..4dd775e9422de 100644 --- a/dbtests/querytests.cpp +++ b/dbtests/querytests.cpp @@ -692,7 +692,10 @@ namespace QueryTests { class All : public Suite { public: - All() { + All() : Suite( "query" ) { + } + + void setupTests(){ add< CountBasic >(); add< CountQuery >(); add< CountFields >(); @@ -727,10 +730,7 @@ namespace QueryTests { add< DifferentNumbers >(); add< SymbolStringSame >(); } - }; + } myall; } // namespace QueryTests -UnitTest::TestPtr queryTests() { - return UnitTest::createSuite< QueryTests::All >(); -} diff --git a/dbtests/repltests.cpp b/dbtests/repltests.cpp index 740bc339f0b32..48681bb8914e7 100644 --- a/dbtests/repltests.cpp +++ b/dbtests/repltests.cpp @@ -935,7 +935,10 @@ namespace ReplTests { class All : public Suite { public: - All() { + All() : Suite( "repl" ){ + } + + void setupTests(){ add< LogBasic >(); add< Idempotence::InsertTimestamp >(); add< Idempotence::InsertAutoId >(); @@ -978,10 +981,7 @@ namespace ReplTests { add< MemIdsTest >(); add< IdTrackerTest >(); } - }; + } myall; } // namespace ReplTests -UnitTest::TestPtr replTests() { - return UnitTest::createSuite< ReplTests::All >(); -} diff --git a/dbtests/socktests.cpp b/dbtests/socktests.cpp index 5ea9132bbba60..16631c9f89c62 100644 --- a/dbtests/socktests.cpp +++ b/dbtests/socktests.cpp @@ -33,13 +33,11 @@ namespace SockTests { class All : public Suite { public: - All() { + All() : Suite( "sock" ){} + void setupTests(){ add< HostByName >(); } - }; + } myall; } // namespace SockTests -UnitTest::TestPtr sockTests() { - return UnitTest::createSuite< SockTests::All >(); -} diff --git a/dbtests/updatetests.cpp b/dbtests/updatetests.cpp index 325a031a4542e..0214a923398e3 100644 --- a/dbtests/updatetests.cpp +++ b/dbtests/updatetests.cpp @@ -481,7 +481,9 @@ namespace UpdateTests { class All : public Suite { public: - All() { + All() : Suite( "update" ) { + } + void setupTests(){ add< ModId >(); add< ModNonmodMix >(); add< InvalidMod >(); @@ -530,10 +532,7 @@ namespace UpdateTests { add< CheckNoMods >(); add< UpdateMissingToNull >(); } - }; + } myall; } // namespace UpdateTests -UnitTest::TestPtr updateTests() { - return UnitTest::createSuite< UpdateTests::All >(); -} diff --git a/s/commands_admin.cpp b/s/commands_admin.cpp index 726c806406f7b..891c6ba19bc50 100644 --- a/s/commands_admin.cpp +++ b/s/commands_admin.cpp @@ -472,7 +472,14 @@ namespace mongo { bool run(const char *ns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool){ ScopedDbConnection conn( configServer.getPrimary() ); - BSONObj shard = BSON( "host" << cmdObj["addshard"].valuestrsafe() ); + BSONObj shard; + { + BSONObjBuilder b; + b.append( "host" , cmdObj["addshard"].valuestrsafe() ); + if ( cmdObj["maxSize"].isNumber() ) + b.append( cmdObj["maxSize"] ); + shard = b.obj(); + } BSONObj old = conn->findOne( "config.shards" , shard ); if ( ! old.isEmpty() ){ diff --git a/s/config.cpp b/s/config.cpp index 51334d79b477c..6f6b3f2fbb8c2 100644 --- a/s/config.cpp +++ b/s/config.cpp @@ -149,6 +149,7 @@ namespace mongo { while ( c->more() ){ BSONObj s = c->next(); all.push_back( s["host"].valuestrsafe() ); + // look at s["maxSize"] if exists } conn.done();