summaryrefslogtreecommitdiffstats
path: root/storage/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'storage/src/tests')
-rw-r--r--storage/src/tests/common/testhelper.h6
-rw-r--r--storage/src/tests/storageserver/changedbucketownershiphandlertest.cpp10
-rw-r--r--storage/src/tests/storageserver/communicationmanagertest.cpp26
-rw-r--r--storage/src/tests/storageserver/mergethrottlertest.cpp6
4 files changed, 25 insertions, 23 deletions
diff --git a/storage/src/tests/common/testhelper.h b/storage/src/tests/common/testhelper.h
index bfc5c7679e1..1f83e938409 100644
--- a/storage/src/tests/common/testhelper.h
+++ b/storage/src/tests/common/testhelper.h
@@ -1,5 +1,6 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
+#include <vespa/config/helper/configgetter.h>
#include <vespa/messagebus/testlib/slobrok.h>
#include <vespa/vdstestlib/config/dirconfig.h>
#include <fstream>
@@ -21,6 +22,11 @@ std::string getRootFolder(vdstestlib::DirConfig & dc);
void addSlobrokConfig(vdstestlib::DirConfig& dc,
const mbus::Slobrok& slobrok);
+template <typename ConfigT>
+std::unique_ptr<ConfigT> config_from(const ::config::ConfigUri& cfg_uri) {
+ return ::config::ConfigGetter<ConfigT>::getConfig(cfg_uri.getConfigId(), cfg_uri.getContext());
+}
+
// Class used to print start and end of test. Enable debug when you want to see
// which test creates what output or where we get stuck
struct TestName {
diff --git a/storage/src/tests/storageserver/changedbucketownershiphandlertest.cpp b/storage/src/tests/storageserver/changedbucketownershiphandlertest.cpp
index 639b3231028..50977b5ec8b 100644
--- a/storage/src/tests/storageserver/changedbucketownershiphandlertest.cpp
+++ b/storage/src/tests/storageserver/changedbucketownershiphandlertest.cpp
@@ -3,6 +3,7 @@
#include <tests/common/teststorageapp.h>
#include <tests/common/testhelper.h>
#include <tests/common/dummystoragelink.h>
+#include <vespa/config/helper/configgetter.hpp>
#include <vespa/document/base/testdocman.h>
#include <vespa/storage/bucketdb/storbucketdb.h>
#include <vespa/storage/persistence/messages.h>
@@ -124,11 +125,12 @@ ChangedBucketOwnershipHandlerTest::insertBuckets(uint32_t numBuckets,
void
ChangedBucketOwnershipHandlerTest::SetUp()
{
+ using vespa::config::content::PersistenceConfig;
vdstestlib::DirConfig config(getStandardConfig(true));
_app.reset(new TestServiceLayerApp);
_top.reset(new DummyStorageLink);
- _handler = new ChangedBucketOwnershipHandler(config::ConfigUri(config.getConfigId()),
+ _handler = new ChangedBucketOwnershipHandler(*config_from<PersistenceConfig>(config::ConfigUri(config.getConfigId())),
_app->getComponentRegister());
_top->push_back(std::unique_ptr<StorageLink>(_handler));
_bottom = new DummyStorageLink;
@@ -139,7 +141,7 @@ ChangedBucketOwnershipHandlerTest::SetUp()
auto pconfig = std::make_unique<vespa::config::content::PersistenceConfigBuilder>();
pconfig->abortOutdatedMutatingIdealStateOps = true;
pconfig->abortOutdatedMutatingExternalLoadOps = true;
- _handler->configure(std::move(pconfig));
+ _handler->on_configure(*pconfig);
}
namespace {
@@ -466,7 +468,7 @@ TEST_F(ChangedBucketOwnershipHandlerTest, abort_outdated_remove_location) {
TEST_F(ChangedBucketOwnershipHandlerTest, ideal_state_aborts_are_configurable) {
auto config = std::make_unique<vespa::config::content::PersistenceConfigBuilder>();
config->abortOutdatedMutatingIdealStateOps = false;
- _handler->configure(std::move(config));
+ _handler->on_configure(*config);
// Should not abort operation, even when ownership has changed.
expectChangeAbortsMessage<api::CreateBucketCommand>(false, getBucketToAbort());
}
@@ -508,7 +510,7 @@ TEST_F(ChangedBucketOwnershipHandlerTest, external_load_op_abort_updates_metric)
TEST_F(ChangedBucketOwnershipHandlerTest, external_load_op_aborts_are_configurable) {
auto config = std::make_unique<vespa::config::content::PersistenceConfigBuilder>();
config->abortOutdatedMutatingExternalLoadOps = false;
- _handler->configure(std::move(config));
+ _handler->on_configure(*config);
// Should not abort operation, even when ownership has changed.
document::DocumentId docId("id:foo:testdoctype1::bar");
expectChangeAbortsMessage<api::RemoveCommand>(
diff --git a/storage/src/tests/storageserver/communicationmanagertest.cpp b/storage/src/tests/storageserver/communicationmanagertest.cpp
index 70b8c40722c..04322562d08 100644
--- a/storage/src/tests/storageserver/communicationmanagertest.cpp
+++ b/storage/src/tests/storageserver/communicationmanagertest.cpp
@@ -29,14 +29,6 @@ vespalib::string _storage("storage");
using CommunicationManagerConfig = vespa::config::content::core::StorCommunicationmanagerConfig;
-namespace {
-
-std::unique_ptr<CommunicationManagerConfig> config_from(const config::ConfigUri& cfg_uri) {
- return config::ConfigGetter<CommunicationManagerConfig>::getConfig(cfg_uri.getConfigId(), cfg_uri.getContext());
-}
-
-}
-
struct CommunicationManagerTest : Test {
static constexpr uint32_t MESSAGE_WAIT_TIME_SEC = 60;
@@ -88,8 +80,10 @@ TEST_F(CommunicationManagerTest, simple) {
auto dist_cfg_uri = config::ConfigUri(distConfig.getConfigId());
auto stor_cfg_uri = config::ConfigUri(storConfig.getConfigId());
- CommunicationManager distributor(distNode.getComponentRegister(), dist_cfg_uri, *config_from(dist_cfg_uri));
- CommunicationManager storage(storNode.getComponentRegister(), stor_cfg_uri, *config_from(stor_cfg_uri));
+ CommunicationManager distributor(distNode.getComponentRegister(), dist_cfg_uri,
+ *config_from<CommunicationManagerConfig>(dist_cfg_uri));
+ CommunicationManager storage(storNode.getComponentRegister(), stor_cfg_uri,
+ *config_from<CommunicationManagerConfig>(stor_cfg_uri));
auto* distributorLink = new DummyStorageLink();
auto* storageLink = new DummyStorageLink();
distributor.push_back(std::unique_ptr<StorageLink>(distributorLink));
@@ -146,7 +140,8 @@ CommunicationManagerTest::doTestConfigPropagation(bool isContentNode)
}
auto cfg_uri = config::ConfigUri(config.getConfigId());
- CommunicationManager commMgr(node->getComponentRegister(), cfg_uri, *config_from(cfg_uri));
+ CommunicationManager commMgr(node->getComponentRegister(), cfg_uri,
+ *config_from<CommunicationManagerConfig>(cfg_uri));
auto* storageLink = new DummyStorageLink();
commMgr.push_back(std::unique_ptr<StorageLink>(storageLink));
commMgr.open();
@@ -191,7 +186,8 @@ TEST_F(CommunicationManagerTest, commands_are_dequeued_in_fifo_order) {
TestServiceLayerApp storNode(storConfig.getConfigId());
auto cfg_uri = config::ConfigUri(storConfig.getConfigId());
- CommunicationManager storage(storNode.getComponentRegister(), cfg_uri, *config_from(cfg_uri));
+ CommunicationManager storage(storNode.getComponentRegister(), cfg_uri,
+ *config_from<CommunicationManagerConfig>(cfg_uri));
auto* storageLink = new DummyStorageLink();
storage.push_back(std::unique_ptr<StorageLink>(storageLink));
storage.open();
@@ -224,7 +220,8 @@ TEST_F(CommunicationManagerTest, replies_are_dequeued_in_fifo_order) {
TestServiceLayerApp storNode(storConfig.getConfigId());
auto cfg_uri = config::ConfigUri(storConfig.getConfigId());
- CommunicationManager storage(storNode.getComponentRegister(), cfg_uri, *config_from(cfg_uri));
+ CommunicationManager storage(storNode.getComponentRegister(), cfg_uri,
+ *config_from<CommunicationManagerConfig>(cfg_uri));
auto* storageLink = new DummyStorageLink();
storage.push_back(std::unique_ptr<StorageLink>(storageLink));
storage.open();
@@ -265,7 +262,8 @@ struct CommunicationManagerFixture {
node = std::make_unique<TestServiceLayerApp>(stor_config.getConfigId());
auto cfg_uri = config::ConfigUri(stor_config.getConfigId());
- comm_mgr = std::make_unique<CommunicationManager>(node->getComponentRegister(), cfg_uri, *config_from(cfg_uri));
+ comm_mgr = std::make_unique<CommunicationManager>(node->getComponentRegister(), cfg_uri,
+ *config_from<CommunicationManagerConfig>(cfg_uri));
bottom_link = new DummyStorageLink();
comm_mgr->push_back(std::unique_ptr<StorageLink>(bottom_link));
comm_mgr->open();
diff --git a/storage/src/tests/storageserver/mergethrottlertest.cpp b/storage/src/tests/storageserver/mergethrottlertest.cpp
index 990a552780b..7a7f2551c2d 100644
--- a/storage/src/tests/storageserver/mergethrottlertest.cpp
+++ b/storage/src/tests/storageserver/mergethrottlertest.cpp
@@ -124,10 +124,6 @@ makeSystemStateCmd(const std::string& state)
return std::make_shared<api::SetSystemStateCommand>(lib::ClusterState(state));
}
-std::unique_ptr<StorServerConfig> config_from(const ::config::ConfigUri& cfg_uri) {
- return ::config::ConfigGetter<StorServerConfig>::getConfig(cfg_uri.getConfigId(), cfg_uri.getContext());
-}
-
} // anon ns
struct MergeThrottlerTest : Test {
@@ -176,7 +172,7 @@ MergeThrottlerTest::SetUp()
{
vdstestlib::DirConfig dir_config(getStandardConfig(true));
auto cfg_uri = ::config::ConfigUri(dir_config.getConfigId());
- auto config = config_from(cfg_uri);
+ auto config = config_from<StorServerConfig>(cfg_uri);
for (int i = 0; i < _storageNodeCount; ++i) {
auto server = std::make_unique<TestServiceLayerApp>(NodeIndex(i));