diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2014-07-01 03:56:39 -0400 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2014-07-01 09:04:58 -0400 |
commit | f64357e485c8d46bd6fd393f7416df6117672de1 (patch) | |
tree | a90f2bb933dd4a1c2e774ac4e280e8ce7dbcbaeb /src/mongo/dbtests/jstests.cpp | |
parent | e7e24a657b64fa59c30b063c72ff4cbee9674b7e (diff) | |
download | mongo-f64357e485c8d46bd6fd393f7416df6117672de1.tar.gz |
SERVER-13961 Add OperationContext argument to Client::Context
Time tracking and database access in Client::Context require access to the
OperationContext. Adding it as argument.
This is in preparation for removing LockState from Client.
Diffstat (limited to 'src/mongo/dbtests/jstests.cpp')
-rw-r--r-- | src/mongo/dbtests/jstests.cpp | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/src/mongo/dbtests/jstests.cpp b/src/mongo/dbtests/jstests.cpp index 400aceffd40..a5f8ff997b6 100644 --- a/src/mongo/dbtests/jstests.cpp +++ b/src/mongo/dbtests/jstests.cpp @@ -29,18 +29,20 @@ * then also delete it in the license file. */ -#include "mongo/pch.h" +#include "mongo/platform/basic.h" #include <limits> #include "mongo/base/parse_number.h" #include "mongo/db/instance.h" #include "mongo/db/json.h" +#include "mongo/db/operation_context_impl.h" #include "mongo/db/storage_options.h" #include "mongo/dbtests/dbtests.h" #include "mongo/scripting/engine.h" #include "mongo/util/timer.h" + namespace mongo { bool dbEval(const string& dbName , BSONObj& cmd, BSONObjBuilder& result, string& errmsg); } // namespace mongo @@ -916,6 +918,10 @@ namespace JSTests { } string utf8ObjSpec = "{'_id':'\\u0001\\u007f\\u07ff\\uffff'}"; BSONObj utf8Obj = fromjson( utf8ObjSpec ); + + OperationContextImpl txn; + DBDirectClient client(&txn); + client.insert( ns(), utf8Obj ); client.eval( "unittest", "v = db.jstests.utf8check.findOne(); db.jstests.utf8check.remove( {} ); db.jstests.utf8check.insert( v );" ); check( utf8Obj, client.findOne( ns(), BSONObj() ) ); @@ -927,12 +933,15 @@ namespace JSTests { FAIL( fail.c_str() ); } } + void reset() { + OperationContextImpl txn; + DBDirectClient client(&txn); + client.dropCollection( ns() ); } - static const char *ns() { return "unittest.jstests.utf8check"; } - DBDirectClient client; + static const char *ns() { return "unittest.jstests.utf8check"; } }; class LongUtf8String { @@ -942,15 +951,21 @@ namespace JSTests { void run() { if( !globalScriptEngine->utf8Ok() ) return; + + OperationContextImpl txn; + DBDirectClient client(&txn); + client.eval( "unittest", "db.jstests.longutf8string.save( {_id:'\\uffff\\uffff\\uffff\\uffff'} )" ); } private: void reset() { + OperationContextImpl txn; + DBDirectClient client(&txn); + client.dropCollection( ns() ); } - static const char *ns() { return "unittest.jstests.longutf8string"; } - DBDirectClient client; + static const char *ns() { return "unittest.jstests.longutf8string"; } }; class InvalidUTF8Check { @@ -1021,10 +1036,12 @@ namespace JSTests { public: virtual ~TestRoundTrip() {} void run() { - // Insert in Javascript -> Find using DBDirectClient // Drop the collection + OperationContextImpl txn; + DBDirectClient client(&txn); + client.dropCollection( "unittest.testroundtrip" ); // Insert in Javascript @@ -1080,8 +1097,6 @@ namespace JSTests { virtual string jsonOut() const { return json(); } - - DBDirectClient client; }; class DBRefTest : public TestRoundTrip { @@ -1993,7 +2008,9 @@ namespace JSTests { update.append( "_id" , "invalidstoredjs1" ); update.appendCode( "value" , "function () { db.test.find().forEach(function(obj) { continue; }); }" ); - DBDirectClient client; + OperationContextImpl txn; + DBDirectClient client(&txn); + client.update( "test.system.js" , query.obj() , update.obj() , true /* upsert */ ); scoped_ptr<Scope> s( globalScriptEngine->newScope() ); |