diff options
22 files changed, 139 insertions, 128 deletions
diff --git a/searchcore/src/apps/tests/CMakeLists.txt b/searchcore/src/apps/tests/CMakeLists.txt index 12e19d40aca..532c89d6ab7 100644 --- a/searchcore/src/apps/tests/CMakeLists.txt +++ b/searchcore/src/apps/tests/CMakeLists.txt @@ -3,6 +3,7 @@ vespa_add_executable(searchcore_persistenceconformance_test_app TEST SOURCES persistenceconformance_test.cpp DEPENDS + searchcore_test searchcore_server searchcore_initializer searchcore_reprocessing diff --git a/searchcore/src/apps/vespa-transactionlog-inspect/vespa-transactionlog-inspect.cpp b/searchcore/src/apps/vespa-transactionlog-inspect/vespa-transactionlog-inspect.cpp index c5a163f20ed..40431b90e27 100644 --- a/searchcore/src/apps/vespa-transactionlog-inspect/vespa-transactionlog-inspect.cpp +++ b/searchcore/src/apps/vespa-transactionlog-inspect/vespa-transactionlog-inspect.cpp @@ -387,6 +387,7 @@ public: _server(_transport, _bopts.tlsName, _bopts.listenPort, _bopts.tlsDir, _fileHeader), _client(vespalib::make_string("tcp/localhost:%d", _bopts.listenPort)) { + _transport.Start(&_threadPool); } ~BaseUtility() override { _transport.ShutDown(true); diff --git a/searchcore/src/tests/proton/documentdb/CMakeLists.txt b/searchcore/src/tests/proton/documentdb/CMakeLists.txt index 8ebeaef9a99..d36368a8ebd 100644 --- a/searchcore/src/tests/proton/documentdb/CMakeLists.txt +++ b/searchcore/src/tests/proton/documentdb/CMakeLists.txt @@ -3,6 +3,7 @@ vespa_add_executable(searchcore_documentdb_test_app TEST SOURCES documentdb_test.cpp DEPENDS + searchcore_test searchcore_server searchcore_initializer searchcore_reprocessing diff --git a/searchcore/src/tests/proton/documentdb/document_subdbs/CMakeLists.txt b/searchcore/src/tests/proton/documentdb/document_subdbs/CMakeLists.txt index 0bc1235bb6f..2706d183988 100644 --- a/searchcore/src/tests/proton/documentdb/document_subdbs/CMakeLists.txt +++ b/searchcore/src/tests/proton/documentdb/document_subdbs/CMakeLists.txt @@ -3,6 +3,7 @@ vespa_add_executable(searchcore_document_subdbs_test_app TEST SOURCES document_subdbs_test.cpp DEPENDS + searchcore_test searchcore_server searchcore_initializer searchcore_reprocessing diff --git a/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp b/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp index 397250f3d1e..6e20d30fb36 100644 --- a/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp +++ b/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp @@ -25,6 +25,7 @@ #include <vespa/searchcore/proton/server/reconfig_params.h> #include <vespa/searchcore/proton/matching/querylimiter.h> #include <vespa/searchcore/proton/test/test.h> +#include <vespa/searchcore/proton/test/transport_helper.h> #include <vespa/searchcore/proton/test/thread_utils.h> #include <vespa/vespalib/util/idestructorcallback.h> #include <vespa/searchlib/index/docbuilder.h> @@ -36,8 +37,6 @@ #include <vespa/vespalib/util/threadstackexecutor.h> #include <vespa/vespalib/util/destructor_callbacks.h> #include <vespa/config/subscription/sourcespec.h> -#include <vespa/fastos/thread.h> -#include <vespa/fnet/transport.h> using namespace cloud::config::filedistribution; using namespace document; @@ -289,8 +288,7 @@ struct MyConfigSnapshot template <typename Traits> struct FixtureBase { - FastOS_ThreadPool _threadPool; - FNET_Transport _transport; + TransportMgr _transport; ThreadStackExecutor _summaryExecutor; ExecutorThreadingService _writeService; typename Traits::Config _cfg; @@ -303,8 +301,7 @@ struct FixtureBase typename Traits::SubDB _subDb; IFeedView::SP _tmpFeedView; FixtureBase() - : _threadPool(64_Ki), - _transport(), + : _transport(), _summaryExecutor(1, 64_Ki), _writeService(_summaryExecutor), _cfg(), @@ -312,18 +309,16 @@ struct FixtureBase _bucketDBHandler(*_bucketDB), _ctx(_writeService, _bucketDB, _bucketDBHandler), _baseSchema(), - _snapshot(std::make_unique<MyConfigSnapshot>(_transport, _baseSchema, Traits::ConfigDir::dir())), + _snapshot(std::make_unique<MyConfigSnapshot>(_transport.transport(), _baseSchema, Traits::ConfigDir::dir())), _baseDir(BASE_DIR + "/" + SUB_NAME, BASE_DIR), _subDb(_cfg._cfg, _ctx._ctx), _tmpFeedView() { - _transport.Start(&_threadPool); init(); } ~FixtureBase() { _writeService.master().execute(makeLambdaTask([this]() { _subDb.close(); })); _writeService.shutdown(); - _transport.ShutDown(true); } void setBucketStateCalculator(const std::shared_ptr<IBucketStateCalculator> & calc) { vespalib::Gate gate; @@ -354,7 +349,7 @@ struct FixtureBase runInMasterAndSync([&]() { performReconfig(serialNum, reconfigSchema, reconfigConfigDir); }); } void performReconfig(SerialNum serialNum, const Schema &reconfigSchema, const vespalib::string &reconfigConfigDir) { - auto newCfg = std::make_unique<MyConfigSnapshot>(_transport, reconfigSchema, reconfigConfigDir); + auto newCfg = std::make_unique<MyConfigSnapshot>(_transport.transport(), reconfigSchema, reconfigConfigDir); DocumentDBConfig::ComparisonResult cmpResult; cmpResult.attributesChanged = true; cmpResult.documenttypesChanged = true; diff --git a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp index c20f14d2d81..9a8d8bad60e 100644 --- a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp +++ b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp @@ -27,6 +27,7 @@ #include <vespa/searchcore/proton/server/i_feed_handler_owner.h> #include <vespa/searchcore/proton/server/ireplayconfig.h> #include <vespa/searchcore/proton/test/dummy_feed_view.h> +#include <vespa/searchcore/proton/test/transport_helper.h> #include <vespa/searchlib/index/docbuilder.h> #include <vespa/searchlib/index/dummyfileheadercontext.h> #include <vespa/searchlib/transactionlog/translogserver.h> @@ -35,7 +36,6 @@ #include <vespa/vespalib/util/exceptions.h> #include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/io/fileutil.h> -#include <vespa/fnet/transport.h> #include <vespa/log/log.h> LOG_SETUP("feedhandler_test"); @@ -409,8 +409,7 @@ struct MyTlsWriter : TlsWriter { struct FeedHandlerFixture { DummyFileHeaderContext _fileHeaderContext; - FastOS_ThreadPool _threadPool; - FNET_Transport _transport; + TransportMgr _transport; TransLogServer tls; vespalib::string tlsSpec; vespalib::ThreadStackExecutor sharedExecutor; @@ -427,9 +426,8 @@ struct FeedHandlerFixture FeedHandler handler; FeedHandlerFixture() : _fileHeaderContext(), - _threadPool(64_Ki), _transport(), - tls(_transport, "mytls", 9016, "mytlsdir", _fileHeaderContext, DomainConfig().setPartSizeLimit(0x10000)), + tls(_transport.transport(), "mytls", 9016, "mytlsdir", _fileHeaderContext, DomainConfig().setPartSizeLimit(0x10000)), tlsSpec("tcp/localhost:9016"), sharedExecutor(1, 0x10000), writeService(sharedExecutor), @@ -443,7 +441,6 @@ struct FeedHandlerFixture handler(writeService, tlsSpec, schema.getDocType(), owner, writeFilter, replayConfig, tls, &tls_writer) { - _transport.Start(&_threadPool); _state.enterLoadState(); _state.enterReplayTransactionLogState(); handler.setActiveFeedView(&feedView); @@ -453,7 +450,6 @@ struct FeedHandlerFixture ~FeedHandlerFixture() { writeService.shutdown(); - _transport.ShutDown(true); } template <class FunctionType> inline void runAsMaster(FunctionType &&function) { diff --git a/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp b/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp index aa525189b26..d51ea25f2f5 100644 --- a/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp +++ b/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp @@ -13,13 +13,12 @@ #include <vespa/searchcore/proton/server/bootstrapconfig.h> #include <vespa/searchcore/proton/server/fileconfigmanager.h> #include <vespa/searchcore/proton/test/documentdb_config_builder.h> +#include <vespa/searchcore/proton/test/transport_helper.h> #include <vespa/searchsummary/config/config-juniperrc.h> #include <vespa/vespalib/io/fileutil.h> -#include <vespa/vespalib/util/size_literals.h> #include <vespa/config-bucketspaces.h> #include <vespa/vespalib/testkit/test_kit.h> -#include <vespa/fastos/thread.h> -#include <vespa/fnet/transport.h> + using namespace cloud::config::filedistribution; using namespace config; @@ -128,69 +127,55 @@ addConfigsThatAreNotSavedToDisk(const DocumentDBConfig &cfg) return builder.build(); } -struct Fixture { - FastOS_ThreadPool threadPool; - FNET_Transport transport; - Fixture() - : threadPool(64_Ki), - transport() - { - transport.Start(&threadPool); - } - ~Fixture() { - transport.ShutDown(true); - } -}; - -TEST_FF("requireThatConfigCanBeSavedAndLoaded", Fixture(), DocumentDBConfig::SP(makeBaseConfigSnapshot(f1.transport))) +TEST_FF("requireThatConfigCanBeSavedAndLoaded", TransportMgr(), DocumentDBConfig::SP(makeBaseConfigSnapshot(f1.transport()))) { DocumentDBConfig::SP fullCfg = addConfigsThatAreNotSavedToDisk(*f2); - saveBaseConfigSnapshot(f1.transport, *fullCfg, 20); + saveBaseConfigSnapshot(f1.transport(), *fullCfg, 20); DocumentDBConfig::SP esnap(makeEmptyConfigSnapshot()); { - FileConfigManager cm(f1.transport, "out", myId, "dummy"); + FileConfigManager cm(f1.transport(), "out", myId, "dummy"); cm.loadConfig(*esnap, 20, esnap); } assertEqualSnapshot(*f2, *esnap); } -TEST_FF("requireThatConfigCanBeSerializedAndDeserialized", Fixture(), DocumentDBConfig::SP(makeBaseConfigSnapshot(f1.transport))) +TEST_FF("requireThatConfigCanBeSerializedAndDeserialized", TransportMgr(), DocumentDBConfig::SP(makeBaseConfigSnapshot(f1.transport()))) { - saveBaseConfigSnapshot(f1.transport, *f2, 30); + saveBaseConfigSnapshot(f1.transport(), *f2, 30); nbostream stream; { - FileConfigManager cm(f1.transport, "out", myId, "dummy"); + FileConfigManager cm(f1.transport(), "out", myId, "dummy"); cm.serializeConfig(30, stream); } { - FileConfigManager cm(f1.transport, "out", myId, "dummy"); + FileConfigManager cm(f1.transport(), "out", myId, "dummy"); cm.deserializeConfig(40, stream); } DocumentDBConfig::SP fsnap(makeEmptyConfigSnapshot()); { - FileConfigManager cm(f1.transport, "out", myId, "dummy"); + FileConfigManager cm(f1.transport(), "out", myId, "dummy"); cm.loadConfig(*fsnap, 40, fsnap); } assertEqualSnapshot(*f2, *fsnap); EXPECT_EQUAL("dummy", fsnap->getDocTypeName()); } -TEST_FF("requireThatConfigCanBeLoadedWithoutExtraConfigsDataFile", Fixture(), DocumentDBConfig::SP(makeBaseConfigSnapshot(f1.transport))) +TEST_FF("requireThatConfigCanBeLoadedWithoutExtraConfigsDataFile", TransportMgr(), DocumentDBConfig::SP(makeBaseConfigSnapshot(f1.transport()))) { - saveBaseConfigSnapshot(f1.transport, *f2, 70); + saveBaseConfigSnapshot(f1.transport(), *f2, 70); EXPECT_FALSE(vespalib::unlink("out/config-70/extraconfigs.dat")); DocumentDBConfig::SP esnap(makeEmptyConfigSnapshot()); { - FileConfigManager cm(f1.transport, "out", myId, "dummy"); + FileConfigManager cm(f1.transport(), "out", myId, "dummy"); cm.loadConfig(*esnap, 70, esnap); } } -TEST_FF("requireThatVisibilityDelayIsPropagated", Fixture(), DocumentDBConfig::SP(makeBaseConfigSnapshot(f1.transport))) +TEST_FF("requireThatVisibilityDelayIsPropagated", TransportMgr(), DocumentDBConfig::SP(makeBaseConfigSnapshot(f1.transport()))) { - saveBaseConfigSnapshot(f1.transport, *f2, 80); + saveBaseConfigSnapshot(f1.transport(), *f2, 80); DocumentDBConfig::SP esnap(makeEmptyConfigSnapshot()); { ProtonConfigBuilder protonConfigBuilder; @@ -199,7 +184,7 @@ TEST_FF("requireThatVisibilityDelayIsPropagated", Fixture(), DocumentDBConfig::S ddb.visibilitydelay = 61.0; protonConfigBuilder.documentdb.push_back(ddb); protonConfigBuilder.maxvisibilitydelay = 100.0; - FileConfigManager cm(f1.transport, "out", myId, "dummy"); + FileConfigManager cm(f1.transport(), "out", myId, "dummy"); cm.setProtonConfig(std::make_shared<ProtonConfig>(protonConfigBuilder)); cm.loadConfig(*esnap, 70, esnap); } diff --git a/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp b/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp index 45d4354564e..39a5c69376c 100644 --- a/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp +++ b/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp @@ -33,6 +33,7 @@ #include <vespa/searchcore/proton/test/disk_mem_usage_notifier.h> #include <vespa/searchcore/proton/test/mock_attribute_manager.h> #include <vespa/searchcore/proton/test/test.h> +#include <vespa/searchcore/proton/test/transport_helper.h> #include <vespa/searchlib/common/idocumentmetastore.h> #include <vespa/searchlib/index/docbuilder.h> #include <vespa/vespalib/data/slime/slime.h> @@ -43,7 +44,6 @@ #include <vespa/vespalib/util/monitored_refcount.h> #include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/util/threadstackexecutor.h> -#include <vespa/fnet/transport.h> #include <unistd.h> #include <thread> @@ -349,8 +349,7 @@ public: test::DiskMemUsageNotifier _diskMemUsageNotifier; BucketCreateNotifier _bucketCreateNotifier; MonitoredRefCount _refCount; - FastOS_ThreadPool _threadPool; - FNET_Transport _transport; + TransportMgr _transport; MaintenanceController _mc; MaintenanceControllerFixture(); @@ -770,11 +769,9 @@ MaintenanceControllerFixture::MaintenanceControllerFixture() _attributeUsageFilter(), _bucketCreateNotifier(), _refCount(), - _threadPool(64_Ki), _transport(), - _mc(_transport, _threadService, _genericExecutor, _refCount, _docTypeName) + _mc(_transport.transport(), _threadService, _genericExecutor, _refCount, _docTypeName) { - _transport.Start(&_threadPool); std::vector<MyDocumentSubDB *> subDBs; subDBs.push_back(&_ready); subDBs.push_back(&_removed); @@ -785,7 +782,6 @@ MaintenanceControllerFixture::MaintenanceControllerFixture() MaintenanceControllerFixture::~MaintenanceControllerFixture() { - _transport.ShutDown(true); stopMaintenance(); } diff --git a/searchcore/src/tests/proton/proton_config_fetcher/CMakeLists.txt b/searchcore/src/tests/proton/proton_config_fetcher/CMakeLists.txt index 88332f360ce..20629733f09 100644 --- a/searchcore/src/tests/proton/proton_config_fetcher/CMakeLists.txt +++ b/searchcore/src/tests/proton/proton_config_fetcher/CMakeLists.txt @@ -3,6 +3,7 @@ vespa_add_executable(searchcore_proton_config_fetcher_test_app TEST SOURCES proton_config_fetcher_test.cpp DEPENDS + searchcore_test searchcore_server searchcore_fconfig ) diff --git a/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp b/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp index eaafd089a76..b4193b0e0b2 100644 --- a/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp +++ b/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp @@ -9,6 +9,7 @@ #include <vespa/searchcore/proton/common/alloc_config.h> #include <vespa/searchcore/proton/common/hw_info.h> #include <vespa/searchcore/proton/common/subdbtype.h> +#include <vespa/searchcore/proton/test/transport_helper.h> #include <vespa/searchcore/config/config-ranking-constants.h> #include <vespa/searchcore/config/config-ranking-expressions.h> #include <vespa/searchcore/config/config-onnx-models.h> @@ -19,7 +20,6 @@ #include <vespa/vespalib/util/varholder.h> #include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/testkit/testapp.h> -#include <vespa/fnet/transport.h> #include <vespa/config/common/configcontext.h> #include <vespa/config-bucketspaces.h> #include <vespa/config-attributes.h> @@ -65,8 +65,7 @@ struct DoctypeFixture { struct ConfigTestFixture { const std::string configId; - FastOS_ThreadPool threadPool; - FNET_Transport transport; + TransportMgr transport; ProtonConfigBuilder protonBuilder; DocumenttypesConfigBuilder documenttypesBuilder; FiledistributorrpcConfigBuilder filedistBuilder; @@ -78,7 +77,6 @@ struct ConfigTestFixture { ConfigTestFixture(const std::string & id) : configId(id), - threadPool(64_Ki), protonBuilder(), documenttypesBuilder(), filedistBuilder(), @@ -88,7 +86,6 @@ struct ConfigTestFixture { context(std::make_shared<ConfigContext>(set)), idcounter(-1) { - transport.Start(& threadPool); set.addBuilder(configId, &protonBuilder); set.addBuilder(configId, &documenttypesBuilder); set.addBuilder(configId, &filedistBuilder); @@ -96,9 +93,7 @@ struct ConfigTestFixture { addDocType("_alwaysthere_"); } - ~ConfigTestFixture() { - transport.ShutDown(true); - } + ~ConfigTestFixture() = default; DoctypeFixture *addDocType(const std::string &name, bool isGlobal = false) { DocumenttypesConfigBuilder::Documenttype dt; @@ -259,7 +254,7 @@ getDocumentDBConfig(ConfigTestFixture &f, DocumentDBConfigManager &mgr, const Hw { ConfigRetriever retriever(mgr.createConfigKeySet(), f.context); mgr.forwardConfig(f.getBootstrapConfig(1, hwInfo)); - mgr.update(f.transport, retriever.getBootstrapConfigs()); // Cheating, but we only need the configs + mgr.update(f.transport.transport(), retriever.getBootstrapConfigs()); // Cheating, but we only need the configs return mgr.getConfig(); } @@ -310,8 +305,8 @@ TEST_FF("require that documentdb config manager builds schema with imported attr TEST_FFF("require that proton config fetcher follows changes to bootstrap", ConfigTestFixture("search"), ProtonConfigOwner(), - ProtonConfigFetcher(f1.transport, ConfigUri(f1.configId, f1.context), f2, 60s)) { - f3.start(f1.threadPool); + ProtonConfigFetcher(f1.transport.transport(), ConfigUri(f1.configId, f1.context), f2, 60s)) { + f3.start(f1.transport.threadPool()); ASSERT_TRUE(f2._configured); ASSERT_TRUE(f1.configEqual(f2.getBootstrapConfig())); f2._configured = false; @@ -325,8 +320,8 @@ TEST_FFF("require that proton config fetcher follows changes to bootstrap", TEST_FFF("require that proton config fetcher follows changes to doctypes", ConfigTestFixture("search"), ProtonConfigOwner(), - ProtonConfigFetcher(f1.transport, ConfigUri(f1.configId, f1.context), f2, 60s)) { - f3.start(f1.threadPool); + ProtonConfigFetcher(f1.transport.transport(), ConfigUri(f1.configId, f1.context), f2, 60s)) { + f3.start(f1.transport.threadPool()); f2._configured = false; f1.addDocType("typea"); @@ -345,8 +340,8 @@ TEST_FFF("require that proton config fetcher follows changes to doctypes", TEST_FFF("require that proton config fetcher reconfigures dbowners", ConfigTestFixture("search"), ProtonConfigOwner(), - ProtonConfigFetcher(f1.transport, ConfigUri(f1.configId, f1.context), f2, 60s)) { - f3.start(f1.threadPool); + ProtonConfigFetcher(f1.transport.transport(), ConfigUri(f1.configId, f1.context), f2, 60s)) { + f3.start(f1.transport.threadPool()); ASSERT_FALSE(f2.getDocumentDBConfig("typea")); // Add db and verify that config for db is provided diff --git a/searchcore/src/tests/proton/proton_disk_layout/CMakeLists.txt b/searchcore/src/tests/proton/proton_disk_layout/CMakeLists.txt index 1c22818630c..5b6c84393f7 100644 --- a/searchcore/src/tests/proton/proton_disk_layout/CMakeLists.txt +++ b/searchcore/src/tests/proton/proton_disk_layout/CMakeLists.txt @@ -3,6 +3,7 @@ vespa_add_executable(searchcore_proton_disk_layout_test_app TEST SOURCES proton_disk_layout_test.cpp DEPENDS + searchcore_test searchcore_server searchcore_fconfig ) diff --git a/searchcore/src/tests/proton/proton_disk_layout/proton_disk_layout_test.cpp b/searchcore/src/tests/proton/proton_disk_layout/proton_disk_layout_test.cpp index 015d649f755..08b9a55746b 100644 --- a/searchcore/src/tests/proton/proton_disk_layout/proton_disk_layout_test.cpp +++ b/searchcore/src/tests/proton/proton_disk_layout/proton_disk_layout_test.cpp @@ -2,6 +2,7 @@ #include <vespa/searchcore/proton/server/proton_disk_layout.h> #include <vespa/searchcore/proton/common/doctypename.h> +#include <vespa/searchcore/proton/test/transport_helper.h> #include <vespa/searchlib/index/dummyfileheadercontext.h> #include <vespa/searchlib/transactionlog/translogserver.h> #include <vespa/searchlib/transactionlog/translogclient.h> @@ -9,14 +10,13 @@ #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/test/insertion_operators.h> #include <vespa/vespalib/util/stringfmt.h> -#include <vespa/vespalib/util/size_literals.h> -#include <vespa/fnet/transport.h> using search::index::DummyFileHeaderContext; using search::transactionlog::client::TransLogClient; using search::transactionlog::TransLogServer; using proton::DocTypeName; using proton::ProtonDiskLayout; +using proton::TransportMgr; static constexpr unsigned int tlsPort = 9018; @@ -31,8 +31,7 @@ struct FixtureBase struct DiskLayoutFixture { DummyFileHeaderContext _fileHeaderContext; - FastOS_ThreadPool _threadPool; - FNET_Transport _transport; + TransportMgr _transport; TransLogServer _tls; vespalib::string _tlsSpec; ProtonDiskLayout _diskLayout; @@ -95,18 +94,14 @@ struct DiskLayoutFixture { DiskLayoutFixture::DiskLayoutFixture() : _fileHeaderContext(), - _threadPool(64_Ki), _transport(), - _tls(_transport, "tls", tlsPort, baseDir, _fileHeaderContext), + _tls(_transport.transport(), "tls", tlsPort, baseDir, _fileHeaderContext), _tlsSpec(vespalib::make_string("tcp/localhost:%u", tlsPort)), _diskLayout(baseDir, _tlsSpec) { - _transport.Start(&_threadPool); } -DiskLayoutFixture::~DiskLayoutFixture() { - _transport.ShutDown(true); -} +DiskLayoutFixture::~DiskLayoutFixture() = default; struct Fixture : public FixtureBase, public DiskLayoutFixture { diff --git a/searchcore/src/tests/proton/server/disk_mem_usage_sampler/CMakeLists.txt b/searchcore/src/tests/proton/server/disk_mem_usage_sampler/CMakeLists.txt index 02b3483153d..0b126ccff27 100644 --- a/searchcore/src/tests/proton/server/disk_mem_usage_sampler/CMakeLists.txt +++ b/searchcore/src/tests/proton/server/disk_mem_usage_sampler/CMakeLists.txt @@ -3,6 +3,7 @@ vespa_add_executable(searchcore_disk_mem_usage_sampler_test_app TEST SOURCES disk_mem_usage_sampler_test.cpp DEPENDS + searchcore_test searchcore_server GTest::GTest ) diff --git a/searchcore/src/tests/proton/server/disk_mem_usage_sampler/disk_mem_usage_sampler_test.cpp b/searchcore/src/tests/proton/server/disk_mem_usage_sampler/disk_mem_usage_sampler_test.cpp index 9d43007f907..9469c8b055f 100644 --- a/searchcore/src/tests/proton/server/disk_mem_usage_sampler/disk_mem_usage_sampler_test.cpp +++ b/searchcore/src/tests/proton/server/disk_mem_usage_sampler/disk_mem_usage_sampler_test.cpp @@ -3,9 +3,7 @@ #include <vespa/searchcore/proton/common/hw_info.h> #include <vespa/searchcore/proton/common/i_transient_resource_usage_provider.h> #include <vespa/searchcore/proton/server/disk_mem_usage_sampler.h> -#include <vespa/vespalib/util/size_literals.h> -#include <vespa/fnet/transport.h> -#include <vespa/fastos/thread.h> +#include <vespa/searchcore/proton/test/transport_helper.h> #include <vespa/vespalib/gtest/gtest.h> #include <thread> @@ -40,21 +38,17 @@ public: }; struct DiskMemUsageSamplerTest : public ::testing::Test { - FastOS_ThreadPool threadPool; - FNET_Transport transport; + TransportMgr transport; std::unique_ptr<DiskMemUsageSampler> sampler; DiskMemUsageSamplerTest() - : threadPool(64_Ki), - transport(), - sampler(std::make_unique<DiskMemUsageSampler>(transport, ".", DiskMemUsageSampler::Config(0.8, 0.8, 50ms, make_hw_info()))) + : transport(), + sampler(std::make_unique<DiskMemUsageSampler>(transport.transport(), ".", DiskMemUsageSampler::Config(0.8, 0.8, 50ms, make_hw_info()))) { - transport.Start(&threadPool); sampler->add_transient_usage_provider(std::make_shared<MyProvider>(50, 200)); sampler->add_transient_usage_provider(std::make_shared<MyProvider>(100, 150)); } ~DiskMemUsageSamplerTest() { sampler.reset(); - transport.ShutDown(true); } const DiskMemUsageFilter& filter() const { return sampler->writeFilter(); } }; diff --git a/searchcore/src/tests/proton/server/shared_threading_service/CMakeLists.txt b/searchcore/src/tests/proton/server/shared_threading_service/CMakeLists.txt index 9b40ae19c99..61325ccb125 100644 --- a/searchcore/src/tests/proton/server/shared_threading_service/CMakeLists.txt +++ b/searchcore/src/tests/proton/server/shared_threading_service/CMakeLists.txt @@ -3,6 +3,7 @@ vespa_add_executable(searchcore_shared_threading_service_test_app TEST SOURCES shared_threading_service_test.cpp DEPENDS + searchcore_test searchcore_server GTest::GTest ) diff --git a/searchcore/src/tests/proton/server/shared_threading_service/shared_threading_service_test.cpp b/searchcore/src/tests/proton/server/shared_threading_service/shared_threading_service_test.cpp index eb01b01c980..1b8c8d8491b 100644 --- a/searchcore/src/tests/proton/server/shared_threading_service/shared_threading_service_test.cpp +++ b/searchcore/src/tests/proton/server/shared_threading_service/shared_threading_service_test.cpp @@ -3,11 +3,9 @@ #include <vespa/searchcore/config/config-proton.h> #include <vespa/searchcore/proton/server/shared_threading_service.h> #include <vespa/searchcore/proton/server/shared_threading_service_config.h> +#include <vespa/searchcore/proton/test/transport_helper.h> #include <vespa/vespalib/util/isequencedtaskexecutor.h> #include <vespa/vespalib/util/sequencedtaskexecutor.h> -#include <vespa/vespalib/util/size_literals.h> -#include <vespa/fnet/transport.h> -#include <vespa/fastos/thread.h> #include <vespa/vespalib/gtest/gtest.h> using namespace proton; @@ -50,22 +48,16 @@ TEST(SharedThreadingServiceConfigTest, shared_threads_are_derived_from_cpu_cores class SharedThreadingServiceTest : public ::testing::Test { public: - FastOS_ThreadPool threadPool; - FNET_Transport transport; + TransportMgr transport; std::unique_ptr<SharedThreadingService> service; SharedThreadingServiceTest() - : threadPool(64_Ki), - transport(), + : transport(), service() - { - transport.Start(&threadPool); - } - ~SharedThreadingServiceTest() { - transport.ShutDown(true); - } + { } + ~SharedThreadingServiceTest() = default; void setup(double concurrency, uint32_t cpu_cores) { service = std::make_unique<SharedThreadingService>( - SharedThreadingServiceConfig::make(make_proton_config(concurrency), HwInfo::Cpu(cpu_cores)), transport); + SharedThreadingServiceConfig::make(make_proton_config(concurrency), HwInfo::Cpu(cpu_cores)), transport.transport()); } SequencedTaskExecutor* field_writer() { return dynamic_cast<SequencedTaskExecutor*>(service->field_writer()); diff --git a/searchcore/src/vespa/searchcore/bmcluster/CMakeLists.txt b/searchcore/src/vespa/searchcore/bmcluster/CMakeLists.txt index ac9ae5519f7..60d3a05502a 100644 --- a/searchcore/src/vespa/searchcore/bmcluster/CMakeLists.txt +++ b/searchcore/src/vespa/searchcore/bmcluster/CMakeLists.txt @@ -32,6 +32,7 @@ vespa_add_library(searchcore_bmcluster STATIC storage_api_rpc_bm_feed_handler.cpp storage_reply_error_checker.cpp DEPENDS + searchcore_test searchcore_server searchcore_initializer searchcore_reprocessing diff --git a/searchcore/src/vespa/searchcore/proton/test/CMakeLists.txt b/searchcore/src/vespa/searchcore/proton/test/CMakeLists.txt index 2c5dbe0317b..e6eda87f66e 100644 --- a/searchcore/src/vespa/searchcore/proton/test/CMakeLists.txt +++ b/searchcore/src/vespa/searchcore/proton/test/CMakeLists.txt @@ -7,8 +7,10 @@ vespa_add_library(searchcore_test STATIC clusterstatehandler.cpp documentdb_config_builder.cpp dummy_feed_view.cpp + mock_shared_threading_service.cpp userdocumentsbuilder.cpp threading_service_observer.cpp + transport_helper.cpp DEPENDS searchcore_fconfig ) diff --git a/searchcore/src/vespa/searchcore/proton/test/mock_shared_threading_service.cpp b/searchcore/src/vespa/searchcore/proton/test/mock_shared_threading_service.cpp new file mode 100644 index 00000000000..e976bf1d726 --- /dev/null +++ b/searchcore/src/vespa/searchcore/proton/test/mock_shared_threading_service.cpp @@ -0,0 +1,17 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "mock_shared_threading_service.h" + +namespace proton { + +MockSharedThreadingService::MockSharedThreadingService(ThreadExecutor& warmup_in, ThreadExecutor& shared_in) + : _warmup(warmup_in), + _shared(shared_in), + _invokeService(10ms), + _transportMgr() +{ +} + +MockSharedThreadingService::~MockSharedThreadingService() = default; + +} diff --git a/searchcore/src/vespa/searchcore/proton/test/mock_shared_threading_service.h b/searchcore/src/vespa/searchcore/proton/test/mock_shared_threading_service.h index df51698d13a..d33afcbec3d 100644 --- a/searchcore/src/vespa/searchcore/proton/test/mock_shared_threading_service.h +++ b/searchcore/src/vespa/searchcore/proton/test/mock_shared_threading_service.h @@ -1,41 +1,29 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once +#include "transport_helper.h" #include <vespa/searchcore/proton/server/i_shared_threading_service.h> #include <vespa/vespalib/util/invokeserviceimpl.h> -#include <vespa/fnet/transport.h> -#include <vespa/fastos/thread.h> -#include <vespa/vespalib/util/size_literals.h> namespace proton { class MockSharedThreadingService : public ISharedThreadingService { private: - vespalib::ThreadExecutor & _warmup; - vespalib::ThreadExecutor & _shared; - vespalib::InvokeServiceImpl _invokeService; - FastOS_ThreadPool _threadPool; - FNET_Transport _transport; + using ThreadExecutor = vespalib::ThreadExecutor; + ThreadExecutor & _warmup; + ThreadExecutor & _shared; + vespalib::InvokeServiceImpl _invokeService; + TransportMgr _transportMgr; public: - MockSharedThreadingService(vespalib::ThreadExecutor& warmup_in, - vespalib::ThreadExecutor& shared_in) - : _warmup(warmup_in), - _shared(shared_in), - _invokeService(10ms), - _threadPool(64_Ki), - _transport() - { - _transport.Start(&_threadPool); - } - ~MockSharedThreadingService() { - _transport.ShutDown(true); - } - vespalib::ThreadExecutor& warmup() override { return _warmup; } - vespalib::ThreadExecutor& shared() override { return _shared; } + MockSharedThreadingService(ThreadExecutor& warmup_in, + ThreadExecutor& shared_in); + ~MockSharedThreadingService() override; + ThreadExecutor& warmup() override { return _warmup; } + ThreadExecutor& shared() override { return _shared; } vespalib::ISequencedTaskExecutor* field_writer() override { return nullptr; } vespalib::InvokeService & invokeService() override { return _invokeService; } - FNET_Transport & transport() override { return _transport; } + FNET_Transport & transport() override { return _transportMgr.transport(); } }; } diff --git a/searchcore/src/vespa/searchcore/proton/test/transport_helper.cpp b/searchcore/src/vespa/searchcore/proton/test/transport_helper.cpp new file mode 100644 index 00000000000..10623fb0726 --- /dev/null +++ b/searchcore/src/vespa/searchcore/proton/test/transport_helper.cpp @@ -0,0 +1,21 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "transport_helper.h" +#include <vespa/fnet/transport.h> +#include <vespa/fastos/thread.h> +#include <vespa/vespalib/util/size_literals.h> + +namespace proton { + +TransportMgr::TransportMgr() + : _threadPool(std::make_unique<FastOS_ThreadPool>(64_Ki)), + _transport(std::make_unique<FNET_Transport>()) +{ + _transport->Start(_threadPool.get()); +} + +TransportMgr::~TransportMgr() { + _transport->ShutDown(true); +} + +} diff --git a/searchcore/src/vespa/searchcore/proton/test/transport_helper.h b/searchcore/src/vespa/searchcore/proton/test/transport_helper.h new file mode 100644 index 00000000000..09cca2dd007 --- /dev/null +++ b/searchcore/src/vespa/searchcore/proton/test/transport_helper.h @@ -0,0 +1,26 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#pragma once + +#include <memory> + +class FastOS_ThreadPool; +class FNET_Transport; + +namespace proton { + +/** + * Helper class contain a FNET_Transport object for use in tests. + **/ +class TransportMgr { +private: + std::unique_ptr<FastOS_ThreadPool> _threadPool; + std::unique_ptr<FNET_Transport> _transport; + +public: + TransportMgr(); + ~TransportMgr(); + FNET_Transport & transport() { return *_transport; } + FastOS_ThreadPool & threadPool() { return *_threadPool; } +}; + +} |