From afdd8eaf022b2e40ccf56adc2641e528c208ddff Mon Sep 17 00:00:00 2001 From: Tor Brede Vekterli Date: Mon, 13 May 2024 15:07:48 +0000 Subject: [PATCH] Cleanup old and unused configs in tests --- storage/src/tests/common/testhelper.cpp | 20 ------------ storage/src/tests/common/teststorageapp.cpp | 5 ++- .../filestorage/filestormanagertest.cpp | 31 +++---------------- .../tests/persistence/mergehandlertest.cpp | 6 ++-- 4 files changed, 10 insertions(+), 52 deletions(-) diff --git a/storage/src/tests/common/testhelper.cpp b/storage/src/tests/common/testhelper.cpp index 4ca935b79043..f295d955ab29 100644 --- a/storage/src/tests/common/testhelper.cpp +++ b/storage/src/tests/common/testhelper.cpp @@ -36,18 +36,6 @@ vdstestlib::DirConfig getStandardConfig(bool storagenode, const std::string & ro std::string clusterName("storage"); vdstestlib::DirConfig dc; vdstestlib::DirConfig::Config* config; - config = &dc.addConfig("fleetcontroller"); - config->set("cluster_name", clusterName); - config->set("index", "0"); - config->set("zookeeper_server", "\"\""); - config->set("total_distributor_count", "10"); - config->set("total_storage_count", "10"); - config = &dc.addConfig("upgrading"); - config = &dc.addConfig("load-type"); - config = &dc.addConfig("bucket"); - config = &dc.addConfig("messagebus"); - config = &dc.addConfig("stor-prioritymapping"); - config = &dc.addConfig("stor-bucketdbupdater"); config = &dc.addConfig("metricsmanager"); config->set("consumer[2]"); config->set("consumer[0].name", "\"status\""); @@ -71,16 +59,8 @@ vdstestlib::DirConfig getStandardConfig(bool storagenode, const std::string & ro // Easier to see what goes wrong with only 1 thread per disk. config->set("num_threads", "1"); config->set("num_response_threads", "1"); - config->set("maximum_versions_of_single_document_stored", "0"); - config->set("keep_remove_time_period", "2000000000"); - config->set("revert_time_period", "2000000000"); - // Don't want test to call exit() - config->set("fail_disk_after_error_count", "0"); - config = &dc.addConfig("stor-bouncer"); config = &dc.addConfig("stor-server"); config->set("cluster_name", clusterName); - config->set("enable_dead_lock_detector", "false"); - config->set("enable_dead_lock_detector_warnings", "false"); config->set("max_merges_per_node", "25"); config->set("max_merge_queue_size", "20"); config->set("resource_exhaustion_merge_back_pressure_duration_secs", "15.0"); diff --git a/storage/src/tests/common/teststorageapp.cpp b/storage/src/tests/common/teststorageapp.cpp index e2e2de107029..9e421051184c 100644 --- a/storage/src/tests/common/teststorageapp.cpp +++ b/storage/src/tests/common/teststorageapp.cpp @@ -35,17 +35,16 @@ TestStorageApp::TestStorageApp(StorageComponentRegisterImpl::UP compReg, _node_identity("test_cluster", type, index), _initialized(false) { - // Use config to adjust values + // Use config to adjust values vespalib::string clusterName = "mycluster"; uint32_t redundancy = 2; uint32_t nodeCount = 10; if (!configId.empty()) { config::ConfigUri uri(configId); - std::unique_ptr serverConfig = config::ConfigGetter::getConfig(uri.getConfigId(), uri.getContext()); + auto serverConfig = config::ConfigGetter::getConfig(uri.getConfigId(), uri.getContext()); clusterName = serverConfig->clusterName; if (index == 0xffff) index = serverConfig->nodeIndex; redundancy = config::ConfigGetter::getConfig(uri.getConfigId(), uri.getContext())->redundancy; - nodeCount = config::ConfigGetter::getConfig(uri.getConfigId(), uri.getContext())->totalStorageCount; } else { if (index == 0xffff) index = 0; } diff --git a/storage/src/tests/persistence/filestorage/filestormanagertest.cpp b/storage/src/tests/persistence/filestorage/filestormanagertest.cpp index f12b85eb2ea1..2680eacf49c6 100644 --- a/storage/src/tests/persistence/filestorage/filestormanagertest.cpp +++ b/storage/src/tests/persistence/filestorage/filestormanagertest.cpp @@ -93,8 +93,6 @@ struct FileStorTestBase : Test { enum {LONG_WAITTIME=60}; unique_ptr _node; std::unique_ptr config; - std::unique_ptr config2; - std::unique_ptr smallConfig; const int32_t _waitTime; const document::DocumentType* _testdoctype1; @@ -167,27 +165,8 @@ struct FileStorTestBase : Test { std::string rootOfRoot = "filestormanagertest"; config = std::make_unique(getStandardConfig(true, rootOfRoot)); - config2 = std::make_unique(*config); - config2->getConfig("stor-server").set("root_folder", rootOfRoot + "-vdsroot.2"); - config2->getConfig("stor-devices").set("root_folder", rootOfRoot + "-vdsroot.2"); - config2->getConfig("stor-server").set("node_index", "1"); - - smallConfig = std::make_unique(*config); - vdstestlib::DirConfig::Config& c(smallConfig->getConfig("stor-filestor", true)); - c.set("initial_index_read", "128"); - c.set("use_direct_io", "false"); - c.set("maximum_gap_to_read_through", "64"); - - assert(system(vespalib::make_string("rm -rf %s", getRootFolder(*config).c_str()).c_str()) == 0); - assert(system(vespalib::make_string("rm -rf %s", getRootFolder(*config2).c_str()).c_str()) == 0); - assert(system(vespalib::make_string("mkdir -p %s/disks/d0", getRootFolder(*config).c_str()).c_str()) == 0); - assert(system(vespalib::make_string("mkdir -p %s/disks/d0", getRootFolder(*config2).c_str()).c_str()) == 0); - try { - _node = std::make_unique(NodeIndex(0), config->getConfigId()); - _node->setupDummyPersistence(); - } catch (config::InvalidConfigException& e) { - fprintf(stderr, "%s\n", e.what()); - } + _node = std::make_unique(NodeIndex(0), config->getConfigId()); + _node->setupDummyPersistence(); _testdoctype1 = _node->getTypeRepo()->getDocumentType("testdoctype1"); } @@ -227,10 +206,10 @@ struct TestFileStorComponents { DummyStorageLink top; FileStorManager* manager; - explicit TestFileStorComponents(FileStorTestBase& test, bool use_small_config = false) + explicit TestFileStorComponents(FileStorTestBase& test) : manager(nullptr) { - auto config_uri = config::ConfigUri((use_small_config ? test.smallConfig : test.config)->getConfigId()); + auto config_uri = config::ConfigUri(test.config->getConfigId()); auto config = config_from(config_uri); auto fsm = std::make_unique(*config, test._node->getPersistenceProvider(), test._node->getComponentRegister(), *test._node, test._node->get_host_info()); @@ -1255,7 +1234,7 @@ createIterator(DummyStorageLink& link, } TEST_F(FileStorManagerTest, visiting) { - TestFileStorComponents c(*this, true); + TestFileStorComponents c(*this); auto& top = c.top; // Adding documents to two buckets which we are going to visit // We want one bucket in one slotfile, and one bucket with a file split diff --git a/storage/src/tests/persistence/mergehandlertest.cpp b/storage/src/tests/persistence/mergehandlertest.cpp index 4bd0570efa8f..e865c87e15e3 100644 --- a/storage/src/tests/persistence/mergehandlertest.cpp +++ b/storage/src/tests/persistence/mergehandlertest.cpp @@ -220,11 +220,11 @@ void MergeHandlerTest::setUpChain(ChainPos pos) { _nodes.clear(); if (pos != FRONT) { - _nodes.push_back(api::MergeBucketCommand::Node(2, false)); + _nodes.emplace_back(2, false); } - _nodes.push_back(api::MergeBucketCommand::Node(0, false)); + _nodes.emplace_back(0, false); if (pos != BACK) { - _nodes.push_back(api::MergeBucketCommand::Node(1, false)); + _nodes.emplace_back(1, false); } }