diff options
author | Eliot Horowitz <eliot@10gen.com> | 2014-06-18 18:15:03 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2014-06-19 01:49:58 -0400 |
commit | b4cafb46595d6e889f8effdca16e98c3f505078e (patch) | |
tree | b3304b672e2d540a72c7ba7424469e9b78bcce74 /src/mongo/dbtests/directclienttests.cpp | |
parent | 7ce2ffdbbaac003fb608e81ae03090adef960237 (diff) | |
download | mongo-b4cafb46595d6e889f8effdca16e98c3f505078e.tar.gz |
SERVER-13635 SERVER-1153: can choose heap1 at startup, but doesn't remotely work yet
Diffstat (limited to 'src/mongo/dbtests/directclienttests.cpp')
-rw-r--r-- | src/mongo/dbtests/directclienttests.cpp | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/src/mongo/dbtests/directclienttests.cpp b/src/mongo/dbtests/directclienttests.cpp index 772d7b4d668..0bea6ea2399 100644 --- a/src/mongo/dbtests/directclienttests.cpp +++ b/src/mongo/dbtests/directclienttests.cpp @@ -45,37 +45,30 @@ namespace DirectClientTests { // NOTE: Not bothering to backup the old error record. ClientBase() { mongo::lastError.reset( new LastError() ); } virtual ~ClientBase() { } - protected: - static bool error() { - return !_client.getPrevError().getField( "err" ).isNull(); - } - DBDirectClient &client() const { return _client; } - private: - static DBDirectClient _client; }; - DBDirectClient ClientBase::_client; const char *ns = "a.b"; class Capped : public ClientBase { public: virtual void run() { + DBDirectClient client; for( int pass=0; pass < 3; pass++ ) { - client().createCollection(ns, 1024 * 1024, true, 999); + client.createCollection(ns, 1024 * 1024, true, 999); for( int j =0; j < pass*3; j++ ) - client().insert(ns, BSON("x" << j)); + client.insert(ns, BSON("x" << j)); // test truncation of a capped collection if( pass ) { BSONObj info; BSONObj cmd = BSON( "captrunc" << "b" << "n" << 1 << "inc" << true ); //cout << cmd.toString() << endl; - bool ok = client().runCommand("a", cmd, info); + bool ok = client.runCommand("a", cmd, info); //cout << info.toString() << endl; verify(ok); } - verify( client().dropCollection(ns) ); + verify( client.dropCollection(ns) ); } } }; @@ -83,21 +76,22 @@ namespace DirectClientTests { class InsertMany : ClientBase { public: virtual void run(){ + DBDirectClient client; vector<BSONObj> objs; objs.push_back(BSON("_id" << 1)); objs.push_back(BSON("_id" << 1)); objs.push_back(BSON("_id" << 2)); - client().dropCollection(ns); - client().insert(ns, objs); - ASSERT_EQUALS(client().getLastErrorDetailed()["code"].numberInt(), 11000); - ASSERT_EQUALS((int)client().count(ns), 1); + client.dropCollection(ns); + client.insert(ns, objs); + ASSERT_EQUALS(client.getLastErrorDetailed()["code"].numberInt(), 11000); + ASSERT_EQUALS((int)client.count(ns), 1); - client().dropCollection(ns); - client().insert(ns, objs, InsertOption_ContinueOnError); - ASSERT_EQUALS(client().getLastErrorDetailed()["code"].numberInt(), 11000); - ASSERT_EQUALS((int)client().count(ns), 2); + client.dropCollection(ns); + client.insert(ns, objs, InsertOption_ContinueOnError); + ASSERT_EQUALS(client.getLastErrorDetailed()["code"].numberInt(), 11000); + ASSERT_EQUALS((int)client.count(ns), 2); } }; @@ -105,16 +99,18 @@ namespace DirectClientTests { class BadNSCmd : ClientBase { public: virtual void run(){ + DBDirectClient client; BSONObj result; BSONObj cmdObj = BSON( "count" << "" ); - ASSERT_THROWS( client().runCommand( "", cmdObj, result ), UserException ); + ASSERT_THROWS( client.runCommand( "", cmdObj, result ), UserException ); } }; class BadNSQuery : ClientBase { public: virtual void run(){ - auto_ptr<DBClientCursor> cursor = client().query( "", Query(), 1 ); + DBDirectClient client; + auto_ptr<DBClientCursor> cursor = client.query( "", Query(), 1 ); ASSERT(cursor->more()); BSONObj result = cursor->next().getOwned(); ASSERT( result.hasField( "$err" )); @@ -125,7 +121,8 @@ namespace DirectClientTests { class BadNSGetMore : ClientBase { public: virtual void run(){ - auto_ptr<DBClientCursor> cursor = client().getMore("", 1, 1); + DBDirectClient client; + auto_ptr<DBClientCursor> cursor = client.getMore("", 1, 1); ASSERT(cursor->more()); BSONObj result = cursor->next().getOwned(); ASSERT(result.hasField("$err")); @@ -136,24 +133,27 @@ namespace DirectClientTests { class BadNSInsert : ClientBase { public: virtual void run(){ - client().insert( "", BSONObj(), 0 ); - ASSERT( !client().getLastError().empty() ); + DBDirectClient client; + client.insert( "", BSONObj(), 0 ); + ASSERT( !client.getLastError().empty() ); } }; class BadNSUpdate : ClientBase { public: virtual void run(){ - client().update( "", Query(), BSON( "$set" << BSON( "x" << 1 )) ); - ASSERT( !client().getLastError().empty() ); + DBDirectClient client; + client.update( "", Query(), BSON( "$set" << BSON( "x" << 1 )) ); + ASSERT( !client.getLastError().empty() ); } }; class BadNSRemove : ClientBase { public: virtual void run(){ - client().remove( "", Query() ); - ASSERT( !client().getLastError().empty() ); + DBDirectClient client; + client.remove( "", Query() ); + ASSERT( !client.getLastError().empty() ); } }; |