aboutsummaryrefslogtreecommitdiffstats
path: root/storageserver/src/tests/storageservertest.cpp
diff options
context:
space:
mode:
authorTor Brede Vekterli <vekterli@vespa.ai>2024-05-14 12:31:29 +0000
committerTor Brede Vekterli <vekterli@vespa.ai>2024-05-15 15:04:35 +0000
commit1e234886e11e1d4b78507d240e3bd7234f203466 (patch)
treea229b74828312ee8ee84d9408e603d3df684ed70 /storageserver/src/tests/storageservertest.cpp
parentfc104fab59e2c4b74e07e1c5f2c253eea7efacfc (diff)
Remove usages of deprecated DirConfig in storage unit tests
Introduce a distinct `StorageConfigSet` which wraps the actual underlying config objects and exposes them through a unified `ConfigUri`.
Diffstat (limited to 'storageserver/src/tests/storageservertest.cpp')
-rw-r--r--storageserver/src/tests/storageservertest.cpp44
1 files changed, 20 insertions, 24 deletions
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());
}
}