diff options
Diffstat (limited to 'src/mongo/db/storage')
6 files changed, 14 insertions, 5 deletions
diff --git a/src/mongo/db/storage/kv/SConscript b/src/mongo/db/storage/kv/SConscript index 7edb39d2366..384738813c0 100644 --- a/src/mongo/db/storage/kv/SConscript +++ b/src/mongo/db/storage/kv/SConscript @@ -114,6 +114,7 @@ env.CppUnitTest( 'kv_engine_mock', '$BUILD_DIR/mongo/db/catalog/collection_options', '$BUILD_DIR/mongo/db/namespace_string', + '$BUILD_DIR/mongo/db/service_context_test_fixture', '$BUILD_DIR/mongo/db/storage/devnull/storage_devnull_core', '$BUILD_DIR/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_record_store', ], @@ -131,6 +132,7 @@ env.CppUnitTest( 'kv_engine_mock', '$BUILD_DIR/mongo/db/catalog/collection_options', '$BUILD_DIR/mongo/db/namespace_string', + '$BUILD_DIR/mongo/db/service_context_test_fixture', '$BUILD_DIR/mongo/db/storage/devnull/storage_devnull_core', '$BUILD_DIR/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_record_store', ], diff --git a/src/mongo/db/storage/kv/kv_collection_catalog_entry_test.cpp b/src/mongo/db/storage/kv/kv_collection_catalog_entry_test.cpp index d2e4a77f7e9..b27937839b3 100644 --- a/src/mongo/db/storage/kv/kv_collection_catalog_entry_test.cpp +++ b/src/mongo/db/storage/kv/kv_collection_catalog_entry_test.cpp @@ -37,6 +37,7 @@ #include "mongo/db/index/multikey_paths.h" #include "mongo/db/index_names.h" #include "mongo/db/operation_context_noop.h" +#include "mongo/db/service_context_test_fixture.h" #include "mongo/db/storage/devnull/devnull_kv_engine.h" #include "mongo/db/storage/kv/kv_database_catalog_entry_mock.h" #include "mongo/db/storage/kv/kv_engine.h" @@ -48,7 +49,7 @@ namespace mongo { namespace { -class KVCollectionCatalogEntryTest : public unittest::Test { +class KVCollectionCatalogEntryTest : public ServiceContextTest { public: KVCollectionCatalogEntryTest() : _nss("unittests.kv_collection_catalog_entry"), diff --git a/src/mongo/db/storage/kv/kv_database_catalog_entry_test.cpp b/src/mongo/db/storage/kv/kv_database_catalog_entry_test.cpp index 0e122cf5603..353ce9f407f 100644 --- a/src/mongo/db/storage/kv/kv_database_catalog_entry_test.cpp +++ b/src/mongo/db/storage/kv/kv_database_catalog_entry_test.cpp @@ -33,6 +33,7 @@ #include "mongo/base/string_data.h" #include "mongo/db/catalog/collection_options.h" #include "mongo/db/operation_context_noop.h" +#include "mongo/db/service_context_test_fixture.h" #include "mongo/db/storage/devnull/devnull_kv_engine.h" #include "mongo/db/storage/kv/kv_prefix.h" #include "mongo/db/storage/kv/kv_storage_engine.h" @@ -42,7 +43,7 @@ namespace mongo { namespace { -TEST(KVDatabaseCatalogEntryTest, CreateCollectionValidNamespace) { +TEST_F(ServiceContextTest, CreateCollectionValidNamespace) { KVStorageEngine storageEngine( new DevNullKVEngine(), KVStorageEngineOptions{}, kvDatabaseCatalogEntryMockFactory); storageEngine.finishInit(); @@ -54,7 +55,7 @@ TEST(KVDatabaseCatalogEntryTest, CreateCollectionValidNamespace) { ASSERT_FALSE(collectionNamespaces.empty()); } -TEST(KVDatabaseCatalogEntryTest, CreateCollectionEmptyNamespace) { +TEST_F(ServiceContextTest, CreateCollectionEmptyNamespace) { KVStorageEngine storageEngine( new DevNullKVEngine(), KVStorageEngineOptions{}, kvDatabaseCatalogEntryMockFactory); storageEngine.finishInit(); @@ -84,7 +85,7 @@ public: }; // After createCollection fails, collection namespaces should remain empty. -TEST(KVDatabaseCatalogEntryTest, CreateCollectionInvalidRecordStore) { +TEST_F(ServiceContextTest, CreateCollectionInvalidRecordStore) { KVStorageEngine storageEngine(new InvalidRecordStoreKVEngine(), KVStorageEngineOptions{}, kvDatabaseCatalogEntryMockFactory); diff --git a/src/mongo/db/storage/wiredtiger/SConscript b/src/mongo/db/storage/wiredtiger/SConscript index 9d42061472d..72fb04cbcd3 100644 --- a/src/mongo/db/storage/wiredtiger/SConscript +++ b/src/mongo/db/storage/wiredtiger/SConscript @@ -128,6 +128,7 @@ if wiredtiger: '$BUILD_DIR/mongo/db/serveronly', '$BUILD_DIR/mongo/db/service_context', '$BUILD_DIR/mongo/db/service_context_d', + '$BUILD_DIR/mongo/db/service_context_test_fixture', '$BUILD_DIR/mongo/db/storage/storage_engine_metadata', '$BUILD_DIR/mongo/db/storage/storage_options', '$BUILD_DIR/mongo/db/storage/wiredtiger/storage_wiredtiger_core', diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_init_test.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_init_test.cpp index 164d52013dd..0815bcf0bc8 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_init_test.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_init_test.cpp @@ -31,6 +31,7 @@ #include "mongo/db/json.h" #include "mongo/db/service_context.h" +#include "mongo/db/service_context_test_fixture.h" #include "mongo/db/storage/storage_engine_init.h" #include "mongo/db/storage/storage_engine_metadata.h" #include "mongo/db/storage/storage_options.h" @@ -43,7 +44,7 @@ namespace { using namespace mongo; -class WiredTigerFactoryTest : public mongo::unittest::Test { +class WiredTigerFactoryTest : public ServiceContextTest { private: virtual void setUp() { ServiceContext* globalEnv = getGlobalServiceContext(); diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine_test.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine_test.cpp index 2832d72bbf2..77906f1b222 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine_test.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine_test.cpp @@ -47,6 +47,8 @@ namespace { class WiredTigerKVHarnessHelper : public KVHarnessHelper { public: WiredTigerKVHarnessHelper() : _dbpath("wt-kv-harness") { + if (!hasGlobalServiceContext()) + setGlobalServiceContext(ServiceContext::make()); _engine.reset(new WiredTigerKVEngine( kWiredTigerEngineName, _dbpath.path(), _cs.get(), "", 1, false, false, false, false)); repl::ReplicationCoordinator::set( @@ -57,6 +59,7 @@ public: virtual ~WiredTigerKVHarnessHelper() { _engine.reset(NULL); + // Cannot cleanup the global service context here, the test still have clients remaining. } virtual KVEngine* restartEngine() { |