summaryrefslogtreecommitdiff
path: root/src/mongo/dbtests
diff options
context:
space:
mode:
authorAndrew Morrow <acm@mongodb.com>2016-04-23 12:15:02 -0400
committerAndrew Morrow <acm@mongodb.com>2016-06-16 17:54:40 -0400
commitdc73a4b9567e1ebdb6ba6c9a41a919a0c7c6adf0 (patch)
tree88422fbc7bb522c3765ef8d723385098a06f0413 /src/mongo/dbtests
parent0884bee06018f5f450b431cf6c5ac5eeeab6827a (diff)
downloadmongo-dc73a4b9567e1ebdb6ba6c9a41a919a0c7c6adf0.tar.gz
SERVER-23103 Make service contexts responsible for creating DBDirectClients
Diffstat (limited to 'src/mongo/dbtests')
-rw-r--r--src/mongo/dbtests/framework.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/mongo/dbtests/framework.cpp b/src/mongo/dbtests/framework.cpp
index db8815b1e90..8876cd5aa6e 100644
--- a/src/mongo/dbtests/framework.cpp
+++ b/src/mongo/dbtests/framework.cpp
@@ -38,11 +38,13 @@
#include "mongo/base/status.h"
#include "mongo/db/client.h"
#include "mongo/db/concurrency/lock_state.h"
+#include "mongo/db/dbdirectclient.h"
#include "mongo/db/s/sharding_state.h"
#include "mongo/db/service_context.h"
#include "mongo/db/service_context_d.h"
#include "mongo/dbtests/dbtests.h"
#include "mongo/dbtests/framework_options.h"
+#include "mongo/scripting/dbdirectclient_factory.h"
#include "mongo/scripting/engine.h"
#include "mongo/stdx/mutex.h"
#include "mongo/util/assert_util.h"
@@ -75,11 +77,19 @@ int runDbTests(int argc, char** argv) {
Client::initThread("testsuite");
+ auto globalServiceContext = getGlobalServiceContext();
+
+ // DBTests run as if in the database, so allow them to create direct clients.
+ DBDirectClientFactory::get(globalServiceContext)
+ .registerImplementation([](OperationContext* txn) {
+ return std::unique_ptr<DBClientBase>(new DBDirectClient(txn));
+ });
+
srand((unsigned)frameworkGlobalParams.seed);
printBuildInfo();
- checked_cast<ServiceContextMongoD*>(getGlobalServiceContext())->createLockFile();
- getGlobalServiceContext()->initializeGlobalStorageEngine();
+ checked_cast<ServiceContextMongoD*>(globalServiceContext)->createLockFile();
+ globalServiceContext->initializeGlobalStorageEngine();
int ret = unittest::Suite::run(frameworkGlobalParams.suites,
frameworkGlobalParams.filter,