diff options
Diffstat (limited to 'storageserver')
-rw-r--r-- | storageserver/src/tests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | storageserver/src/tests/storageservertest.cpp | 44 | ||||
-rw-r--r-- | storageserver/src/vespa/storageserver/app/dummyservicelayerprocess.h | 12 |
3 files changed, 28 insertions, 29 deletions
diff --git a/storageserver/src/tests/CMakeLists.txt b/storageserver/src/tests/CMakeLists.txt index 05ae89dcf89..db272ccc795 100644 --- a/storageserver/src/tests/CMakeLists.txt +++ b/storageserver/src/tests/CMakeLists.txt @@ -7,6 +7,7 @@ vespa_add_executable(storageserver_gtest_runner_app TEST gtest_runner.cpp DEPENDS storageserver_storageapp + storage_testcommon vdstestlib GTest::GTest ) diff --git a/storageserver/src/tests/storageservertest.cpp b/storageserver/src/tests/storageservertest.cpp index b18b241acaa..3e5edc23464 100644 --- a/storageserver/src/tests/storageservertest.cpp +++ b/storageserver/src/tests/storageservertest.cpp @@ -1,6 +1,7 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <tests/testhelper.h> +#include <tests/common/storage_config_set.h> #include <vespa/storage/storageserver/distributornode.h> #include <vespa/storage/storageserver/servicelayernode.h> #include <vespa/storageserver/app/distributorprocess.h> @@ -18,8 +19,8 @@ namespace storage { struct StorageServerTest : public ::testing::Test { std::unique_ptr<mbus::Slobrok> slobrok; - std::unique_ptr<vdstestlib::DirConfig> distConfig; - std::unique_ptr<vdstestlib::DirConfig> storConfig; + std::unique_ptr<StorageConfigSet> dist_config; + std::unique_ptr<StorageConfigSet> stor_config; StorageServerTest(); ~StorageServerTest() override; @@ -40,29 +41,29 @@ struct Node { virtual StorageNodeContext& getContext() = 0; }; -struct Distributor : public Node { +struct Distributor final : public Node { DistributorProcess _process; - explicit Distributor(vdstestlib::DirConfig& config); + explicit Distributor(const config::ConfigUri& config_uri); ~Distributor() override; StorageNode& getNode() override { return _process.getNode(); } StorageNodeContext& getContext() override { return _process.getContext(); } }; -struct Storage : public Node { +struct Storage final : public Node { DummyServiceLayerProcess _process; StorageComponent::UP _component; - explicit Storage(vdstestlib::DirConfig& config); + explicit Storage(const config::ConfigUri& config_uri); ~Storage() override; StorageNode& getNode() override { return _process.getNode(); } StorageNodeContext& getContext() override { return _process.getContext(); } }; -Distributor::Distributor(vdstestlib::DirConfig& config) - : _process(config::ConfigUri(config.getConfigId())) +Distributor::Distributor(const config::ConfigUri& config_uri) + : _process(config_uri) { _process.setupConfig(60000ms); _process.createNode(); @@ -70,8 +71,8 @@ Distributor::Distributor(vdstestlib::DirConfig& config) Distributor::~Distributor() = default; -Storage::Storage(vdstestlib::DirConfig& config) - : _process(config::ConfigUri(config.getConfigId())) +Storage::Storage(const config::ConfigUri& config_uri) + : _process(config_uri) { _process.setupConfig(60000ms); _process.createNode(); @@ -85,34 +86,29 @@ Storage::~Storage() = default; void StorageServerTest::SetUp() { - [[maybe_unused]] int systemResult = system("chmod -R 755 vdsroot"); - systemResult = system("rm -rf vdsroot*"); slobrok = std::make_unique<mbus::Slobrok>(); - distConfig = std::make_unique<vdstestlib::DirConfig>(getStandardConfig(false)); - storConfig = std::make_unique<vdstestlib::DirConfig>(getStandardConfig(true)); - addSlobrokConfig(*distConfig, *slobrok); - addSlobrokConfig(*storConfig, *slobrok); - systemResult = system("mkdir -p vdsroot/disks/d0"); - systemResult = system("mkdir -p vdsroot.distributor"); + dist_config = StorageConfigSet::make_distributor_node_config(); + stor_config = StorageConfigSet::make_storage_node_config(); + dist_config->set_slobrok_config_port(slobrok->port()); + stor_config->set_slobrok_config_port(slobrok->port()); } void StorageServerTest::TearDown() { - // TODO wipe temp dirs - storConfig.reset(nullptr); - distConfig.reset(nullptr); - slobrok.reset(nullptr); + stor_config.reset(); + dist_config.reset(); + slobrok.reset(); } TEST_F(StorageServerTest, distributor_server_can_be_instantiated) { - Distributor distServer(*distConfig); + Distributor distServer(dist_config->config_uri()); } TEST_F(StorageServerTest, storage_server_can_be_instantiated) { - Storage storServer(*storConfig); + Storage storServer(stor_config->config_uri()); } } diff --git a/storageserver/src/vespa/storageserver/app/dummyservicelayerprocess.h b/storageserver/src/vespa/storageserver/app/dummyservicelayerprocess.h index f4e3d386767..38eb1404c15 100644 --- a/storageserver/src/vespa/storageserver/app/dummyservicelayerprocess.h +++ b/storageserver/src/vespa/storageserver/app/dummyservicelayerprocess.h @@ -15,12 +15,14 @@ class DummyServiceLayerProcess : public ServiceLayerProcess { std::unique_ptr<spi::PersistenceProvider> _provider; public: - DummyServiceLayerProcess(const config::ConfigUri & configUri); - ~DummyServiceLayerProcess() { shutdown(); } + explicit DummyServiceLayerProcess(const config::ConfigUri & configUri); + ~DummyServiceLayerProcess() override { + DummyServiceLayerProcess::shutdown(); + } - virtual void shutdown() override; - virtual void setupProvider() override; - virtual spi::PersistenceProvider& getProvider() override { return *_provider; } + void shutdown() override; + void setupProvider() override; + spi::PersistenceProvider& getProvider() override { return *_provider; } }; } // storage |