diff options
Diffstat (limited to 'storage/src/tests/storageserver')
10 files changed, 140 insertions, 112 deletions
diff --git a/storage/src/tests/storageserver/bouncertest.cpp b/storage/src/tests/storageserver/bouncertest.cpp index 296ed6d23bc..11742dd658f 100644 --- a/storage/src/tests/storageserver/bouncertest.cpp +++ b/storage/src/tests/storageserver/bouncertest.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/common/dummystoragelink.h> +#include <tests/common/storage_config_set.h> #include <tests/common/testhelper.h> #include <tests/common/teststorageapp.h> #include <vespa/config/common/exceptions.h> @@ -26,6 +27,7 @@ using namespace ::testing; namespace storage { struct BouncerTest : public Test { + std::unique_ptr<StorageConfigSet> _config; std::unique_ptr<TestStorageApp> _node; std::unique_ptr<DummyStorageLink> _upper; Bouncer* _manager; @@ -57,15 +59,15 @@ BouncerTest::BouncerTest() } void BouncerTest::setUpAsNode(const lib::NodeType& type) { - vdstestlib::DirConfig config(getStandardConfig(type == lib::NodeType::STORAGE)); + _config = StorageConfigSet::make_node_config(type == lib::NodeType::STORAGE); if (type == lib::NodeType::STORAGE) { - _node = std::make_unique<TestServiceLayerApp>(NodeIndex(2), config.getConfigId()); + _node = std::make_unique<TestServiceLayerApp>(NodeIndex(2), _config->config_uri()); } else { - _node = std::make_unique<TestDistributorApp>(NodeIndex(2), config.getConfigId()); + _node = std::make_unique<TestDistributorApp>(NodeIndex(2), _config->config_uri()); } _upper = std::make_unique<DummyStorageLink>(); using StorBouncerConfig = vespa::config::content::core::StorBouncerConfig; - auto cfg_uri = config::ConfigUri(config.getConfigId()); + auto& cfg_uri = _config->config_uri(); auto cfg = config::ConfigGetter<StorBouncerConfig>::getConfig(cfg_uri.getConfigId(), cfg_uri.getContext()); _manager = new Bouncer(_node->getComponentRegister(), *cfg); _lower = new DummyStorageLink(); diff --git a/storage/src/tests/storageserver/changedbucketownershiphandlertest.cpp b/storage/src/tests/storageserver/changedbucketownershiphandlertest.cpp index 50977b5ec8b..8982b02f2b7 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 <tests/common/storage_config_set.h> #include <vespa/config/helper/configgetter.hpp> #include <vespa/document/base/testdocman.h> #include <vespa/storage/bucketdb/storbucketdb.h> @@ -28,11 +29,12 @@ using namespace ::testing; namespace storage { struct ChangedBucketOwnershipHandlerTest : Test { + std::unique_ptr<StorageConfigSet> _config; std::unique_ptr<TestServiceLayerApp> _app; - std::unique_ptr<DummyStorageLink> _top; - ChangedBucketOwnershipHandler* _handler; - DummyStorageLink* _bottom; - document::TestDocMan _testDocRepo; + std::unique_ptr<DummyStorageLink> _top; + ChangedBucketOwnershipHandler* _handler; + DummyStorageLink* _bottom; + document::TestDocMan _testDocRepo; // TODO test: down edge triggered on cluster state with cluster down? @@ -126,11 +128,12 @@ 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_from<PersistenceConfig>(config::ConfigUri(config.getConfigId())), + _config = StorageConfigSet::make_storage_node_config(); + _app = std::make_unique<TestServiceLayerApp>(NodeIndex(0), _config->config_uri()); + _top = std::make_unique<DummyStorageLink>(); + + _handler = new ChangedBucketOwnershipHandler(*config_from<PersistenceConfig>(_config->config_uri()), _app->getComponentRegister()); _top->push_back(std::unique_ptr<StorageLink>(_handler)); _bottom = new DummyStorageLink; diff --git a/storage/src/tests/storageserver/communicationmanagertest.cpp b/storage/src/tests/storageserver/communicationmanagertest.cpp index 04322562d08..b741d79582f 100644 --- a/storage/src/tests/storageserver/communicationmanagertest.cpp +++ b/storage/src/tests/storageserver/communicationmanagertest.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/common/dummystoragelink.h> +#include <tests/common/storage_config_set.h> #include <tests/common/testhelper.h> #include <tests/common/teststorageapp.h> #include <vespa/config/helper/configgetter.hpp> @@ -65,20 +66,20 @@ wait_for_slobrok_visibility(const CommunicationManager& mgr, TEST_F(CommunicationManagerTest, simple) { mbus::Slobrok slobrok; - vdstestlib::DirConfig distConfig(getStandardConfig(false)); - vdstestlib::DirConfig storConfig(getStandardConfig(true)); - distConfig.getConfig("stor-server").set("node_index", "1"); - storConfig.getConfig("stor-server").set("node_index", "1"); - addSlobrokConfig(distConfig, slobrok); - addSlobrokConfig(storConfig, slobrok); + auto dist_config = StorageConfigSet::make_distributor_node_config(); + auto stor_config = StorageConfigSet::make_storage_node_config(); + dist_config->set_node_index(1); + stor_config->set_node_index(1); + dist_config->set_slobrok_config_port(slobrok.port()); + stor_config->set_slobrok_config_port(slobrok.port()); + + auto& dist_cfg_uri = dist_config->config_uri(); + auto& stor_cfg_uri = stor_config->config_uri(); // Set up a "distributor" and a "storage" node with communication // managers and a dummy storage link below we can use for testing. - TestServiceLayerApp storNode(storConfig.getConfigId()); - TestDistributorApp distNode(distConfig.getConfigId()); - - auto dist_cfg_uri = config::ConfigUri(distConfig.getConfigId()); - auto stor_cfg_uri = config::ConfigUri(storConfig.getConfigId()); + TestServiceLayerApp storNode(stor_cfg_uri); + TestDistributorApp distNode(dist_cfg_uri); CommunicationManager distributor(distNode.getComponentRegister(), dist_cfg_uri, *config_from<CommunicationManagerConfig>(dist_cfg_uri)); @@ -123,23 +124,22 @@ void CommunicationManagerTest::doTestConfigPropagation(bool isContentNode) { mbus::Slobrok slobrok; - vdstestlib::DirConfig config(getStandardConfig(isContentNode)); - config.getConfig("stor-server").set("node_index", "1"); - auto& cfg = config.getConfig("stor-communicationmanager"); - cfg.set("mbus_content_node_max_pending_count", "12345"); - cfg.set("mbus_content_node_max_pending_size", "555666"); - cfg.set("mbus_distributor_node_max_pending_count", "6789"); - cfg.set("mbus_distributor_node_max_pending_size", "777888"); - addSlobrokConfig(config, slobrok); + auto config = StorageConfigSet::make_node_config(isContentNode); + config->set_node_index(1); + config->set_slobrok_config_port(slobrok.port()); + config->communication_manager_config().mbusContentNodeMaxPendingCount = 12345; + config->communication_manager_config().mbusContentNodeMaxPendingSize = 555666; + config->communication_manager_config().mbusDistributorNodeMaxPendingCount = 6789; + config->communication_manager_config().mbusDistributorNodeMaxPendingSize = 777888; + auto& cfg_uri = config->config_uri(); std::unique_ptr<TestStorageApp> node; if (isContentNode) { - node = std::make_unique<TestServiceLayerApp>(config.getConfigId()); + node = std::make_unique<TestServiceLayerApp>(cfg_uri); } else { - node = std::make_unique<TestDistributorApp>(config.getConfigId()); + node = std::make_unique<TestDistributorApp>(cfg_uri); } - auto cfg_uri = config::ConfigUri(config.getConfigId()); CommunicationManager commMgr(node->getComponentRegister(), cfg_uri, *config_from<CommunicationManagerConfig>(cfg_uri)); auto* storageLink = new DummyStorageLink(); @@ -180,12 +180,12 @@ TEST_F(CommunicationManagerTest, stor_pending_limit_configs_are_propagated_to_me TEST_F(CommunicationManagerTest, commands_are_dequeued_in_fifo_order) { mbus::Slobrok slobrok; - vdstestlib::DirConfig storConfig(getStandardConfig(true)); - storConfig.getConfig("stor-server").set("node_index", "1"); - addSlobrokConfig(storConfig, slobrok); - TestServiceLayerApp storNode(storConfig.getConfigId()); + auto config = StorageConfigSet::make_storage_node_config(); + config->set_node_index(1); + config->set_slobrok_config_port(slobrok.port()); + auto& cfg_uri = config->config_uri(); + TestServiceLayerApp storNode(cfg_uri); - auto cfg_uri = config::ConfigUri(storConfig.getConfigId()); CommunicationManager storage(storNode.getComponentRegister(), cfg_uri, *config_from<CommunicationManagerConfig>(cfg_uri)); auto* storageLink = new DummyStorageLink(); @@ -214,12 +214,12 @@ TEST_F(CommunicationManagerTest, commands_are_dequeued_in_fifo_order) { TEST_F(CommunicationManagerTest, replies_are_dequeued_in_fifo_order) { mbus::Slobrok slobrok; - vdstestlib::DirConfig storConfig(getStandardConfig(true)); - storConfig.getConfig("stor-server").set("node_index", "1"); - addSlobrokConfig(storConfig, slobrok); - TestServiceLayerApp storNode(storConfig.getConfigId()); + auto config = StorageConfigSet::make_storage_node_config(); + config->set_node_index(1); + config->set_slobrok_config_port(slobrok.port()); + auto& cfg_uri = config->config_uri(); + TestServiceLayerApp storNode(cfg_uri); - auto cfg_uri = config::ConfigUri(storConfig.getConfigId()); CommunicationManager storage(storNode.getComponentRegister(), cfg_uri, *config_from<CommunicationManagerConfig>(cfg_uri)); auto* storageLink = new DummyStorageLink(); @@ -249,19 +249,21 @@ struct MockMbusReplyHandler : mbus::IReplyHandler { }; struct CommunicationManagerFixture { + std::unique_ptr<StorageConfigSet> config; MockMbusReplyHandler reply_handler; mbus::Slobrok slobrok; std::unique_ptr<TestServiceLayerApp> node; std::unique_ptr<CommunicationManager> comm_mgr; DummyStorageLink* bottom_link; - CommunicationManagerFixture() { - vdstestlib::DirConfig stor_config(getStandardConfig(true)); - stor_config.getConfig("stor-server").set("node_index", "1"); - addSlobrokConfig(stor_config, slobrok); + CommunicationManagerFixture() + : config(StorageConfigSet::make_storage_node_config()) + { + config->set_node_index(1); + config->set_slobrok_config_port(slobrok.port()); + auto& cfg_uri = config->config_uri(); - node = std::make_unique<TestServiceLayerApp>(stor_config.getConfigId()); - auto cfg_uri = config::ConfigUri(stor_config.getConfigId()); + node = std::make_unique<TestServiceLayerApp>(cfg_uri); comm_mgr = std::make_unique<CommunicationManager>(node->getComponentRegister(), cfg_uri, *config_from<CommunicationManagerConfig>(cfg_uri)); bottom_link = new DummyStorageLink(); diff --git a/storage/src/tests/storageserver/documentapiconvertertest.cpp b/storage/src/tests/storageserver/documentapiconvertertest.cpp index eb4789b25d4..1eb6bf5dd9a 100644 --- a/storage/src/tests/storageserver/documentapiconvertertest.cpp +++ b/storage/src/tests/storageserver/documentapiconvertertest.cpp @@ -159,28 +159,46 @@ TEST_F(DocumentApiConverterTest, forwarded_put) { } TEST_F(DocumentApiConverterTest, update) { - auto update = std::make_shared<document::DocumentUpdate>(*_repo, _html_type, defaultDocId); - documentapi::UpdateDocumentMessage updateMsg(update); - updateMsg.setOldTimestamp(1234); - updateMsg.setNewTimestamp(5678); - updateMsg.setCondition(my_condition); - - auto updateCmd = toStorageAPI<api::UpdateCommand>(updateMsg); - EXPECT_EQ(defaultBucket, updateCmd->getBucket()); - ASSERT_EQ(update.get(), updateCmd->getUpdate().get()); - EXPECT_EQ(api::Timestamp(1234), updateCmd->getOldTimestamp()); - EXPECT_EQ(api::Timestamp(5678), updateCmd->getTimestamp()); - EXPECT_EQ(my_condition, updateCmd->getCondition()); - - auto mbusReply = updateMsg.createReply(); - ASSERT_TRUE(mbusReply.get()); - toStorageAPI<api::UpdateReply>(*mbusReply, *updateCmd); - - auto mbusUpdate = toDocumentAPI<documentapi::UpdateDocumentMessage>(*updateCmd); - ASSERT_EQ((&mbusUpdate->getDocumentUpdate()), update.get()); - EXPECT_EQ(api::Timestamp(1234), mbusUpdate->getOldTimestamp()); - EXPECT_EQ(api::Timestamp(5678), mbusUpdate->getNewTimestamp()); - EXPECT_EQ(my_condition, mbusUpdate->getCondition()); + auto do_test_update = [&](bool create_if_missing) { + auto update = std::make_shared<document::DocumentUpdate>(*_repo, _html_type, defaultDocId); + update->setCreateIfNonExistent(create_if_missing); + documentapi::UpdateDocumentMessage updateMsg(update); + updateMsg.setOldTimestamp(1234); + updateMsg.setNewTimestamp(5678); + updateMsg.setCondition(my_condition); + EXPECT_FALSE(updateMsg.has_cached_create_if_missing()); + EXPECT_EQ(updateMsg.create_if_missing(), create_if_missing); + + auto updateCmd = toStorageAPI<api::UpdateCommand>(updateMsg); + EXPECT_EQ(defaultBucket, updateCmd->getBucket()); + ASSERT_EQ(update.get(), updateCmd->getUpdate().get()); + EXPECT_EQ(api::Timestamp(1234), updateCmd->getOldTimestamp()); + EXPECT_EQ(api::Timestamp(5678), updateCmd->getTimestamp()); + EXPECT_EQ(my_condition, updateCmd->getCondition()); + EXPECT_FALSE(updateCmd->has_cached_create_if_missing()); + EXPECT_EQ(updateCmd->create_if_missing(), create_if_missing); + + auto mbusReply = updateMsg.createReply(); + ASSERT_TRUE(mbusReply.get()); + toStorageAPI<api::UpdateReply>(*mbusReply, *updateCmd); + + auto mbusUpdate = toDocumentAPI<documentapi::UpdateDocumentMessage>(*updateCmd); + ASSERT_EQ((&mbusUpdate->getDocumentUpdate()), update.get()); + EXPECT_EQ(api::Timestamp(1234), mbusUpdate->getOldTimestamp()); + EXPECT_EQ(api::Timestamp(5678), mbusUpdate->getNewTimestamp()); + EXPECT_EQ(my_condition, mbusUpdate->getCondition()); + EXPECT_EQ(mbusUpdate->create_if_missing(), create_if_missing); + + // Cached value of create_if_missing should override underlying update's value + updateCmd->set_cached_create_if_missing(!create_if_missing); + EXPECT_TRUE(updateCmd->has_cached_create_if_missing()); + EXPECT_EQ(updateCmd->create_if_missing(), !create_if_missing); + mbusUpdate = toDocumentAPI<documentapi::UpdateDocumentMessage>(*updateCmd); + EXPECT_TRUE(mbusUpdate->has_cached_create_if_missing()); + EXPECT_EQ(mbusUpdate->create_if_missing(), !create_if_missing); + }; + do_test_update(false); + do_test_update(true); } TEST_F(DocumentApiConverterTest, remove) { diff --git a/storage/src/tests/storageserver/mergethrottlertest.cpp b/storage/src/tests/storageserver/mergethrottlertest.cpp index cdf203b8a39..bc1c7f60706 100644 --- a/storage/src/tests/storageserver/mergethrottlertest.cpp +++ b/storage/src/tests/storageserver/mergethrottlertest.cpp @@ -1,10 +1,12 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <tests/common/dummystoragelink.h> +#include <tests/common/storage_config_set.h> #include <tests/common/testhelper.h> #include <tests/common/teststorageapp.h> #include <vespa/config/helper/configgetter.hpp> #include <vespa/document/test/make_document_bucket.h> #include <vespa/messagebus/dynamicthrottlepolicy.h> +#include <vespa/storage/config/config-stor-server.h> #include <vespa/storage/persistence/messages.h> #include <vespa/storage/storageserver/mergethrottler.h> #include <vespa/storageapi/message/bucket.h> @@ -36,9 +38,8 @@ using StorServerConfigBuilder = vespa::config::content::core::StorServerConfigBu vespalib::string _storage("storage"); std::unique_ptr<StorServerConfig> default_server_config() { - vdstestlib::DirConfig dir_config(getStandardConfig(true)); - auto cfg_uri = ::config::ConfigUri(dir_config.getConfigId()); - return config_from<StorServerConfig>(cfg_uri); + auto config = StorageConfigSet::make_storage_node_config(); + return config_from<StorServerConfig>(config->config_uri()); } struct MergeBuilder { @@ -153,8 +154,9 @@ struct MergeThrottlerTest : Test { static constexpr int _messageWaitTime = 100; // Using n storage node links and dummy servers - std::vector<std::shared_ptr<DummyStorageLink> > _topLinks; - std::vector<std::shared_ptr<TestServiceLayerApp> > _servers; + std::unique_ptr<StorageConfigSet> _config; + std::vector<std::shared_ptr<DummyStorageLink>> _topLinks; + std::vector<std::shared_ptr<TestServiceLayerApp>> _servers; std::vector<MergeThrottler*> _throttlers; std::vector<DummyStorageLink*> _bottomLinks; @@ -198,14 +200,14 @@ MergeThrottlerTest::~MergeThrottlerTest() = default; void MergeThrottlerTest::SetUp() { - auto config = default_server_config(); + _config = StorageConfigSet::make_storage_node_config(); for (int i = 0; i < _storageNodeCount; ++i) { - auto server = std::make_unique<TestServiceLayerApp>(NodeIndex(i)); + auto server = std::make_unique<TestServiceLayerApp>(NodeIndex(i), _config->config_uri()); server->setClusterState(lib::ClusterState("distributor:100 storage:100 version:1")); std::unique_ptr<DummyStorageLink> top; top = std::make_unique<DummyStorageLink>(); - auto* throttler = new MergeThrottler(*config, server->getComponentRegister(), vespalib::HwInfo()); + auto* throttler = new MergeThrottler(_config->server_config(), server->getComponentRegister(), vespalib::HwInfo()); // MergeThrottler will be sandwiched in between two dummy links top->push_back(std::unique_ptr<StorageLink>(throttler)); auto* bottom = new DummyStorageLink; diff --git a/storage/src/tests/storageserver/rpc/cluster_controller_rpc_api_service_test.cpp b/storage/src/tests/storageserver/rpc/cluster_controller_rpc_api_service_test.cpp index 6e9485e24d4..c3641b9bc56 100644 --- a/storage/src/tests/storageserver/rpc/cluster_controller_rpc_api_service_test.cpp +++ b/storage/src/tests/storageserver/rpc/cluster_controller_rpc_api_service_test.cpp @@ -1,5 +1,6 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#include <tests/common/storage_config_set.h> #include <vespa/document/bucket/fixed_bucket_spaces.h> #include <vespa/fnet/frt/rpcrequest.h> #include <vespa/messagebus/testlib/slobrok.h> @@ -11,7 +12,6 @@ #include <vespa/storageapi/message/state.h> #include <vespa/vdslib/state/clusterstate.h> #include <vespa/vespalib/stllike/asciistream.h> -#include <tests/common/testhelper.h> #include <vespa/vespalib/gtest/gtest.h> #include <vector> @@ -43,7 +43,7 @@ struct DummyReturnHandler : FRT_IReturnHandler { struct FixtureBase { mbus::Slobrok slobrok; - vdstestlib::DirConfig config; + std::unique_ptr<StorageConfigSet> config; MockOperationDispatcher dispatcher; std::unique_ptr<SharedRpcResources> shared_rpc_resources; std::unique_ptr<ClusterControllerApiRpcService> cc_service; @@ -52,12 +52,12 @@ struct FixtureBase { FRT_RPCRequest* bound_request{nullptr}; FixtureBase() - : config(getStandardConfig(true)) + : config(StorageConfigSet::make_storage_node_config()) { - config.getConfig("stor-server").set("node_index", "1"); - addSlobrokConfig(config, slobrok); + config->set_node_index(1); + config->set_slobrok_config_port(slobrok.port()); - shared_rpc_resources = std::make_unique<SharedRpcResources>(config::ConfigUri(config.getConfigId()), 0, 1, 1); + shared_rpc_resources = std::make_unique<SharedRpcResources>(config->config_uri(), 0, 1, 1); cc_service = std::make_unique<ClusterControllerApiRpcService>(dispatcher, *shared_rpc_resources); shared_rpc_resources->start_server_and_register_slobrok("my_cool_rpc_test"); } diff --git a/storage/src/tests/storageserver/rpc/storage_api_rpc_service_test.cpp b/storage/src/tests/storageserver/rpc/storage_api_rpc_service_test.cpp index 72ddc89f9d3..010f2b441ef 100644 --- a/storage/src/tests/storageserver/rpc/storage_api_rpc_service_test.cpp +++ b/storage/src/tests/storageserver/rpc/storage_api_rpc_service_test.cpp @@ -1,6 +1,6 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <tests/common/testhelper.h> +#include <tests/common/storage_config_set.h> #include <vespa/document/base/testdocman.h> #include <vespa/document/repo/documenttyperepo.h> #include <vespa/document/fieldvalue/stringfieldvalue.h> @@ -102,7 +102,7 @@ vespalib::string to_slobrok_id(const api::StorageMessageAddress& address) { class RpcNode { protected: - vdstestlib::DirConfig _config; + std::unique_ptr<StorageConfigSet> _config; std::shared_ptr<const document::DocumentTypeRepo> _doc_type_repo; LockingMockOperationDispatcher _messages; std::unique_ptr<MessageCodecProvider> _codec_provider; @@ -111,17 +111,15 @@ protected: vespalib::string _slobrok_id; public: RpcNode(uint16_t node_index, bool is_distributor, const mbus::Slobrok& slobrok) - : _config(getStandardConfig(true)), + : _config(StorageConfigSet::make_node_config(!is_distributor)), _doc_type_repo(document::TestDocRepo().getTypeRepoSp()), _node_address(make_address(node_index, is_distributor)), _slobrok_id(to_slobrok_id(_node_address)) { - auto& cfg = _config.getConfig("stor-server"); - cfg.set("node_index", std::to_string(node_index)); - cfg.set("is_distributor", is_distributor ? "true" : "false"); - addSlobrokConfig(_config, slobrok); + _config->set_node_index(node_index); + _config->set_slobrok_config_port(slobrok.port()); - _shared_rpc_resources = std::make_unique<SharedRpcResources>(config::ConfigUri(_config.getConfigId()), 0, 1, 1); + _shared_rpc_resources = std::make_unique<SharedRpcResources>(_config->config_uri(), 0, 1, 1); // TODO make codec provider into interface so we can test decode-failures more easily? _codec_provider = std::make_unique<MessageCodecProvider>(_doc_type_repo); } diff --git a/storage/src/tests/storageserver/service_layer_error_listener_test.cpp b/storage/src/tests/storageserver/service_layer_error_listener_test.cpp index 63d8eec6dc3..b84f96dd847 100644 --- a/storage/src/tests/storageserver/service_layer_error_listener_test.cpp +++ b/storage/src/tests/storageserver/service_layer_error_listener_test.cpp @@ -1,12 +1,12 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#include <tests/common/storage_config_set.h> #include <tests/common/testhelper.h> #include <tests/common/teststorageapp.h> #include <vespa/config/helper/configgetter.hpp> #include <vespa/storage/storageserver/mergethrottler.h> #include <vespa/storage/storageserver/service_layer_error_listener.h> #include <vespa/storageframework/defaultimplementation/component/componentregisterimpl.h> -#include <vespa/vdstestlib/config/dirconfig.h> #include <vespa/vespalib/gtest/gtest.h> using namespace ::testing; @@ -37,10 +37,10 @@ private: struct Fixture { using StorServerConfig = vespa::config::content::core::StorServerConfig; - vdstestlib::DirConfig config{getStandardConfig(true)}; - TestServiceLayerApp app; + std::unique_ptr<StorageConfigSet> config{StorageConfigSet::make_storage_node_config()}; + TestServiceLayerApp app{config->config_uri()}; ServiceLayerComponent component{app.getComponentRegister(), "dummy"}; - MergeThrottler merge_throttler{*config_from<StorServerConfig>(config::ConfigUri(config.getConfigId())), + MergeThrottler merge_throttler{*config_from<StorServerConfig>(config->config_uri()), app.getComponentRegister(), vespalib::HwInfo()}; TestShutdownListener shutdown_listener; ServiceLayerErrorListener error_listener{component, merge_throttler}; diff --git a/storage/src/tests/storageserver/statemanagertest.cpp b/storage/src/tests/storageserver/statemanagertest.cpp index 2a5af397aca..b785bc141b6 100644 --- a/storage/src/tests/storageserver/statemanagertest.cpp +++ b/storage/src/tests/storageserver/statemanagertest.cpp @@ -1,13 +1,14 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#include <tests/common/dummystoragelink.h> +#include <tests/common/storage_config_set.h> +#include <tests/common/teststorageapp.h> +#include <tests/common/testhelper.h> #include <vespa/storageapi/message/bucket.h> #include <vespa/storageapi/message/state.h> #include <vespa/vdslib/state/cluster_state_bundle.h> #include <vespa/vdslib/state/clusterstate.h> #include <vespa/storage/storageserver/statemanager.h> -#include <tests/common/teststorageapp.h> -#include <tests/common/testhelper.h> -#include <tests/common/dummystoragelink.h> #include <vespa/vespalib/data/slime/slime.h> #include <vespa/vespalib/gtest/gtest.h> @@ -20,6 +21,7 @@ using namespace ::testing; namespace storage { struct StateManagerTest : Test, NodeStateReporter { + std::unique_ptr<StorageConfigSet> _config; std::unique_ptr<TestServiceLayerApp> _node; std::unique_ptr<DummyStorageLink> _upper; StateManager* _manager; @@ -46,7 +48,8 @@ struct StateManagerTest : Test, NodeStateReporter { }; StateManagerTest::StateManagerTest() - : _node(), + : _config(), + _node(), _upper(), _manager(nullptr), _lower(nullptr) @@ -56,7 +59,8 @@ StateManagerTest::StateManagerTest() void StateManagerTest::SetUp() { - _node = std::make_unique<TestServiceLayerApp>(NodeIndex(2)); + _config = StorageConfigSet::make_storage_node_config(); + _node = std::make_unique<TestServiceLayerApp>(NodeIndex(2), _config->config_uri()); // Clock will increase 1 sec per call. _node->getClock().setAbsoluteTimeInSeconds(1); _upper = std::make_unique<DummyStorageLink>(); diff --git a/storage/src/tests/storageserver/statereportertest.cpp b/storage/src/tests/storageserver/statereportertest.cpp index 43eb37afe15..29d3daf9b86 100644 --- a/storage/src/tests/storageserver/statereportertest.cpp +++ b/storage/src/tests/storageserver/statereportertest.cpp @@ -1,14 +1,15 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#include <tests/common/dummystoragelink.h> +#include <tests/common/storage_config_set.h> +#include <tests/common/teststorageapp.h> +#include <tests/common/testhelper.h> #include <vespa/storageframework/defaultimplementation/clock/fakeclock.h> #include <vespa/storage/persistence/filestorage/filestormanager.h> #include <vespa/storage/persistence/filestorage/filestormetrics.h> #include <vespa/storage/storageserver/applicationgenerationfetcher.h> #include <vespa/storage/storageserver/statereporter.h> #include <vespa/metrics/metricmanager.h> -#include <tests/common/teststorageapp.h> -#include <tests/common/testhelper.h> -#include <tests/common/dummystoragelink.h> #include <vespa/config/common/exceptions.h> #include <vespa/vespalib/data/slime/slime.h> #include <vespa/vespalib/data/simple_buffer.h> @@ -35,7 +36,7 @@ struct StateReporterTest : Test { std::unique_ptr<DummyStorageLink> _top; DummyApplicationGenerationFether _generationFetcher; std::unique_ptr<StateReporter> _stateReporter; - std::unique_ptr<vdstestlib::DirConfig> _config; + std::unique_ptr<StorageConfigSet> _config; std::unique_ptr<metrics::MetricSet> _topSet; std::unique_ptr<metrics::MetricManager> _metricManager; std::shared_ptr<FileStorMetrics> _filestorMetrics; @@ -68,10 +69,8 @@ StateReporterTest::StateReporterTest() StateReporterTest::~StateReporterTest() = default; void StateReporterTest::SetUp() { - _config = std::make_unique<vdstestlib::DirConfig>(getStandardConfig(true, "statereportertest")); - assert(system(("rm -rf " + getRootFolder(*_config)).c_str()) == 0); - - _node = std::make_unique<TestServiceLayerApp>(NodeIndex(0), _config->getConfigId()); + _config = StorageConfigSet::make_storage_node_config(); + _node = std::make_unique<TestServiceLayerApp>(NodeIndex(0), _config->config_uri()); _node->setupDummyPersistence(); _clock = &_node->getClock(); _clock->setAbsoluteTimeInSeconds(1000000); @@ -91,7 +90,7 @@ void StateReporterTest::SetUp() { _filestorMetrics->initDiskMetrics(1, 1); _topSet->registerMetric(*_filestorMetrics); - _metricManager->init(config::ConfigUri(_config->getConfigId())); + _metricManager->init(_config->config_uri()); } void StateReporterTest::TearDown() { |