diff options
author | ADAM David Alan Martin <adam.martin@10gen.com> | 2016-12-14 14:39:44 -0500 |
---|---|---|
committer | ADAM David Alan Martin <adam.martin@10gen.com> | 2016-12-14 14:41:31 -0500 |
commit | 2fd5d3f6cecc0d4f8f3816031352d69ca80e5d1c (patch) | |
tree | 8350daf4d5225504853ff19f4b0117aaac805417 /src/mongo/db/storage/ephemeral_for_test | |
parent | 0590b0da70cfdad7edf8d214bbfb5d8d8b6e502e (diff) | |
download | mongo-2fd5d3f6cecc0d4f8f3816031352d69ca80e5d1c.tar.gz |
SERVER-27257 Deduplicate symbol `newHarnessHelper`
The `newHarnessHelper` function was defined by multiple test driver
modules, each one specializing it to return a specific kind of
storage test driver's `HarnessHelper`. The two different kinds
of `HarnessHelper` class were given a common base class, and the
`newHarnessHelper` function was changed to a single implementation.
This new implementation returns the results of a `HarnessHelper`
factory function which can be registered by a MONGO_INITIALIZER
statement.
Diffstat (limited to 'src/mongo/db/storage/ephemeral_for_test')
-rw-r--r-- | src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl_test.cpp | 17 | ||||
-rw-r--r-- | src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_record_store_test.cpp | 18 |
2 files changed, 27 insertions, 8 deletions
diff --git a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl_test.cpp b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl_test.cpp index 5a91de906f2..49cbc6d1762 100644 --- a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl_test.cpp +++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl_test.cpp @@ -31,16 +31,19 @@ #include "mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl.h" +#include "mongo/base/init.h" #include "mongo/db/storage/ephemeral_for_test/ephemeral_for_test_recovery_unit.h" #include "mongo/db/storage/sorted_data_interface_test_harness.h" #include "mongo/stdx/memory.h" #include "mongo/unittest/unittest.h" namespace mongo { +namespace { -class EphemeralForTestHarnessHelper final : public HarnessHelper { +class EphemeralForBtreeImplTestHarnessHelper final + : public virtual SortedDataInterfaceHarnessHelper { public: - EphemeralForTestHarnessHelper() : _order(Ordering::make(BSONObj())) {} + EphemeralForBtreeImplTestHarnessHelper() : _order(Ordering::make(BSONObj())) {} std::unique_ptr<SortedDataInterface> newSortedDataInterface(bool unique) final { return std::unique_ptr<SortedDataInterface>( @@ -56,7 +59,13 @@ private: Ordering _order; }; -std::unique_ptr<HarnessHelper> newHarnessHelper() { - return stdx::make_unique<EphemeralForTestHarnessHelper>(); +std::unique_ptr<HarnessHelper> makeHarnessHelper() { + return stdx::make_unique<EphemeralForBtreeImplTestHarnessHelper>(); } + +MONGO_INITIALIZER(RegisterHarnessFactory)(InitializerContext* const) { + mongo::registerHarnessHelperFactory(makeHarnessHelper); + return Status::OK(); } +} // namespace +} // namespace mongo diff --git a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_record_store_test.cpp b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_record_store_test.cpp index 5fa803ea2e0..153c34e2779 100644 --- a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_record_store_test.cpp +++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_record_store_test.cpp @@ -32,27 +32,31 @@ #include "mongo/db/storage/ephemeral_for_test/ephemeral_for_test_record_store.h" +#include "mongo/base/init.h" #include "mongo/db/storage/ephemeral_for_test/ephemeral_for_test_recovery_unit.h" #include "mongo/db/storage/record_store_test_harness.h" +#include "mongo/stdx/memory.h" #include "mongo/unittest/unittest.h" namespace mongo { +namespace { -class EphemeralForTestHarnessHelper final : public HarnessHelper { +class EphemeralForTestHarnessHelper final : public RecordStoreHarnessHelper { public: EphemeralForTestHarnessHelper() {} std::unique_ptr<RecordStore> newNonCappedRecordStore() final { return stdx::make_unique<EphemeralForTestRecordStore>("a.b", &data); } + std::unique_ptr<RecordStore> newCappedRecordStore(int64_t cappedSizeBytes, int64_t cappedMaxDocs) final { return stdx::make_unique<EphemeralForTestRecordStore>( "a.b", &data, true, cappedSizeBytes, cappedMaxDocs); } - RecoveryUnit* newRecoveryUnit() final { - return new EphemeralForTestRecoveryUnit(); + std::unique_ptr<RecoveryUnit> newRecoveryUnit() final { + return stdx::make_unique<EphemeralForTestRecoveryUnit>(); } bool supportsDocLocking() final { @@ -62,7 +66,13 @@ public: std::shared_ptr<void> data; }; -std::unique_ptr<HarnessHelper> newHarnessHelper() { +std::unique_ptr<HarnessHelper> makeHarnessHelper() { return stdx::make_unique<EphemeralForTestHarnessHelper>(); } + +MONGO_INITIALIZER(RegisterHarnessFactory)(InitializerContext* const) { + mongo::registerHarnessHelperFactory(makeHarnessHelper); + return Status::OK(); } +} // namespace +} // namespace mongo |