diff options
Diffstat (limited to 'searchcorespi/src/tests')
-rw-r--r-- | searchcorespi/src/tests/plugin/.gitignore | 5 | ||||
-rw-r--r-- | searchcorespi/src/tests/plugin/CMakeLists.txt | 32 | ||||
-rw-r--r-- | searchcorespi/src/tests/plugin/empty.cpp | 1 | ||||
-rw-r--r-- | searchcorespi/src/tests/plugin/factoryregistry_test.cpp | 59 | ||||
-rw-r--r-- | searchcorespi/src/tests/plugin/plugin.cpp | 78 | ||||
-rw-r--r-- | searchcorespi/src/tests/plugin/plugin_test.cpp | 37 |
6 files changed, 0 insertions, 212 deletions
diff --git a/searchcorespi/src/tests/plugin/.gitignore b/searchcorespi/src/tests/plugin/.gitignore deleted file mode 100644 index e49000038ad..00000000000 --- a/searchcorespi/src/tests/plugin/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -Makefile -.depend -*_test -searchcorespi_factoryregistry_test_app -searchcorespi_plugin_test_app diff --git a/searchcorespi/src/tests/plugin/CMakeLists.txt b/searchcorespi/src/tests/plugin/CMakeLists.txt deleted file mode 100644 index da785b09b6a..00000000000 --- a/searchcorespi/src/tests/plugin/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_library(searchcorespi_tplugin - SOURCES - plugin.cpp - DEPENDS - searchcorespi -) -vespa_add_library(searchcorespi_illegal-plugin - SOURCES - empty.cpp - DEPENDS - searchcorespi -) -vespa_add_executable(searchcorespi_plugin_test_app TEST - SOURCES - plugin_test.cpp - DEPENDS - searchcorespi -) -vespa_add_test( - NAME searchcorespi_plugin_test_app - COMMAND searchcorespi_plugin_test_app - ENVIRONMENT "LD_LIBRARY_PATH=." - DEPENDS searchcorespi_tplugin searchcorespi_illegal-plugin -) -vespa_add_executable(searchcorespi_factoryregistry_test_app TEST - SOURCES - factoryregistry_test.cpp - DEPENDS - searchcorespi -) -vespa_add_test(NAME searchcorespi_factoryregistry_test_app COMMAND searchcorespi_factoryregistry_test_app) diff --git a/searchcorespi/src/tests/plugin/empty.cpp b/searchcorespi/src/tests/plugin/empty.cpp deleted file mode 100644 index c7c47fc98c5..00000000000 --- a/searchcorespi/src/tests/plugin/empty.cpp +++ /dev/null @@ -1 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. diff --git a/searchcorespi/src/tests/plugin/factoryregistry_test.cpp b/searchcorespi/src/tests/plugin/factoryregistry_test.cpp deleted file mode 100644 index 10a1c95f191..00000000000 --- a/searchcorespi/src/tests/plugin/factoryregistry_test.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include <vespa/searchcorespi/plugin/factoryregistry.h> -#include <vespa/searchcorespi/plugin/iindexmanagerfactory.h> -#include <vespa/vespalib/stllike/string.h> -#include <vespa/vespalib/testkit/testapp.h> -#include <vespa/vespalib/util/exceptions.h> - -using vespalib::string; -using namespace searchcorespi; - -namespace { - -struct MyFactory : IIndexManagerFactory { - - virtual IIndexManager::UP createIndexManager(const IndexManagerConfig &, - const index::IndexMaintainerConfig &, - const index::IndexMaintainerContext &) override { - return IIndexManager::UP(); - } - virtual config::ConfigKeySet getConfigKeys( - const string &, - const search::index::Schema &, - const config::ConfigInstance &) override { - return config::ConfigKeySet(); - } -}; - -const string name = "factory"; - -TEST("require that factories can be added and removed") { - FactoryRegistry registry; - EXPECT_FALSE(registry.isRegistered(name)); - registry.add(name, IIndexManagerFactory::SP(new MyFactory)); - EXPECT_TRUE(registry.get(name).get()); - EXPECT_TRUE(registry.isRegistered(name)); - registry.remove(name); - EXPECT_EXCEPTION(registry.get(name), vespalib::IllegalArgumentException, - "No factory is registered with the name"); -} - -TEST("require that two factories with the same name cannot be added") { - FactoryRegistry registry; - registry.add(name, IIndexManagerFactory::SP(new MyFactory)); - EXPECT_EXCEPTION( - registry.add(name, IIndexManagerFactory::SP(new MyFactory)), - vespalib::IllegalArgumentException, - "A factory is already registered with the same name"); -} - -TEST("require that a non-existent factory cannot be removed") { - FactoryRegistry registry; - EXPECT_EXCEPTION(registry.remove(name), vespalib::IllegalArgumentException, - "No factory is registered with the name"); -} - -} // namespace - -TEST_MAIN() { TEST_RUN_ALL(); } diff --git a/searchcorespi/src/tests/plugin/plugin.cpp b/searchcorespi/src/tests/plugin/plugin.cpp deleted file mode 100644 index d32b02f45fd..00000000000 --- a/searchcorespi/src/tests/plugin/plugin.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/searchcorespi/plugin/iindexmanagerfactory.h> - -using namespace search; -using namespace search::index; -using namespace vespalib; -using namespace config; - -namespace searchcorespi { -class IndexManager : public searchcorespi::IIndexManager -{ -public: - - typedef search::SerialNum SerialNum; - typedef search::index::Schema Schema; - typedef document::Document Document; - using OnWriteDoneType = - const std::shared_ptr<search::IDestructorCallback> &; - virtual void putDocument(uint32_t, const Document &, SerialNum) override { } - virtual void removeDocument(uint32_t, SerialNum) override { } - virtual void commit(SerialNum, OnWriteDoneType) override { } - virtual void heartBeat(SerialNum ) override {} - void compactLidSpace(uint32_t, SerialNum) override {} - virtual SerialNum getCurrentSerialNum() const override { return 0; } - virtual SerialNum getFlushedSerialNum() const override { return 0; } - virtual IndexSearchable::SP getSearchable() const override { - IndexSearchable::SP s; - return s; - } - virtual SearchableStats getSearchableStats() const override { - SearchableStats s; - return s; - } - virtual searchcorespi::IFlushTarget::List getFlushTargets() override { - searchcorespi::IFlushTarget::List l; - return l; - } - virtual void setSchema(const Schema &, SerialNum) override { } - virtual void setMaxFlushed(uint32_t) override { } -}; - -class IndexManagerFactory : public searchcorespi::IIndexManagerFactory -{ -public: - virtual IIndexManager::UP createIndexManager(const IndexManagerConfig &managerCfg, - const index::IndexMaintainerConfig &maintainerConfig, - const index::IndexMaintainerContext &maintainerContext) override; - - virtual ConfigKeySet getConfigKeys(const string &configId, - const Schema &schema, - const ConfigInstance &rootConfig) override; -}; - -IIndexManager::UP -IndexManagerFactory::createIndexManager(const IndexManagerConfig &, - const index::IndexMaintainerConfig &, - const index::IndexMaintainerContext &) -{ - return IIndexManager::UP(new IndexManager()); -} - -ConfigKeySet -IndexManagerFactory::getConfigKeys(const string &, - const Schema &, - const ConfigInstance &) -{ - ConfigKeySet keys; - return keys; -} - -} - -searchcorespi::IIndexManagerFactory * -createIndexManagerFactory() -{ - return new searchcorespi::IndexManagerFactory(); -} - diff --git a/searchcorespi/src/tests/plugin/plugin_test.cpp b/searchcorespi/src/tests/plugin/plugin_test.cpp deleted file mode 100644 index 733c2834c24..00000000000 --- a/searchcorespi/src/tests/plugin/plugin_test.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include <vespa/vespalib/testkit/testapp.h> -#include <vespa/searchcorespi/plugin/factoryloader.h> -#include <vespa/vespalib/util/exceptions.h> - -using namespace searchcorespi; - -namespace { -TEST("require that plugins can be loaded.") { - FactoryLoader fl; - IIndexManagerFactory::UP f = fl.create("searchcorespi_tplugin"); - ASSERT_TRUE(f.get()); -} - -TEST("require that non-existent plugin causes failure") { - FactoryLoader fl; -#ifdef __APPLE__ - EXPECT_EXCEPTION(fl.create("no-such-plugin"), - vespalib::IllegalArgumentException, - "image not found"); -#else - EXPECT_EXCEPTION(fl.create("no-such-plugin"), - vespalib::IllegalArgumentException, - "cannot open shared object file"); -#endif -} - -TEST("require that missing factory function causes failure") { - FactoryLoader fl; - EXPECT_EXCEPTION(fl.create("searchcorespi_illegal-plugin"), - vespalib::IllegalArgumentException, - "Failed locating symbol 'createIndexManagerFactory'"); -} -} // namespace - -TEST_MAIN() { TEST_RUN_ALL(); } |