From 1bb2800fb1bf312689115a7230b1d3ead74d4ac6 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Sun, 20 Feb 2022 21:24:22 +0000 Subject: Use a common FNET_Transport owned by Proton in both SceduledExecutor and TransactionLogServer. This reduces the number of Transport object by 1 per document type and netto 1 in Proton. Each of them contains 2 threads. In addition it uses a common Transport for the RpcFileAcquirer objects used during config fetching. This prevents creating 3 temporary Transport objects on every reconfig. --- .../src/tests/proton/docsummary/docsummary.cpp | 10 ++-- .../document_subdbs/document_subdbs_test.cpp | 34 ++++++++----- .../tests/proton/documentdb/documentdb_test.cpp | 6 +-- .../documentdb/feedhandler/feedhandler_test.cpp | 10 +++- .../fileconfigmanager/fileconfigmanager_test.cpp | 59 ++++++++++++++-------- .../maintenancecontroller_test.cpp | 9 +++- .../proton_config_fetcher_test.cpp | 24 ++++++--- .../proton_disk_layout/proton_disk_layout_test.cpp | 13 ++++- .../disk_mem_usage_sampler_test.cpp | 27 ++++++---- .../shared_threading_service_test.cpp | 15 +++++- 10 files changed, 143 insertions(+), 64 deletions(-) (limited to 'searchcore/src/tests/proton') diff --git a/searchcore/src/tests/proton/docsummary/docsummary.cpp b/searchcore/src/tests/proton/docsummary/docsummary.cpp index 7eda54cdbee..faea1cc8b7c 100644 --- a/searchcore/src/tests/proton/docsummary/docsummary.cpp +++ b/searchcore/src/tests/proton/docsummary/docsummary.cpp @@ -176,10 +176,10 @@ class DBContext : public DummyDBOwner { public: DirMaker _dmk; - DummyFileHeaderContext _fileHeaderContext; - TransLogServer _tls; + DummyFileHeaderContext _fileHeaderContext; vespalib::ThreadStackExecutor _summaryExecutor; - MockSharedThreadingService _shared_service; + MockSharedThreadingService _shared_service; + TransLogServer _tls; storage::spi::dummy::DummyBucketExecutor _bucketExecutor; bool _mkdirOk; matching::QueryLimiter _queryLimiter; @@ -198,9 +198,9 @@ public: DBContext(const std::shared_ptr &repo, const char *docTypeName) : _dmk(docTypeName), _fileHeaderContext(), - _tls("tmp", 9013, ".", _fileHeaderContext), _summaryExecutor(8, 128_Ki), _shared_service(_summaryExecutor, _summaryExecutor), + _tls(_shared_service.transport(), "tmp", 9013, ".", _fileHeaderContext), _bucketExecutor(2), _mkdirOk(FastOS_File::MakeDirectory("tmpdb")), _queryLimiter(), @@ -223,7 +223,7 @@ public: std::make_shared(), _tuneFileDocumentDB, _hwInfo); _configMgr.forwardConfig(b); - _configMgr.nextGeneration(0ms); + _configMgr.nextGeneration(_shared_service.transport(), 0ms); if (! FastOS_File::MakeDirectory((std::string("tmpdb/") + docTypeName).c_str())) { LOG_ABORT("should not be reached"); } 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 b9e3549053a..397250f3d1e 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 @@ -36,6 +36,8 @@ #include #include #include +#include +#include using namespace cloud::config::filedistribution; using namespace document; @@ -261,7 +263,7 @@ struct MyConfigSnapshot DocBuilder _builder; DocumentDBConfig::SP _cfg; BootstrapConfig::SP _bootstrap; - MyConfigSnapshot(const Schema &schema, const vespalib::string &cfgDir) + MyConfigSnapshot(FNET_Transport & transport, const Schema &schema, const vespalib::string &cfgDir) : _schema(schema), _builder(_schema), _cfg(), @@ -279,7 +281,7 @@ struct MyConfigSnapshot ::config::DirSpec spec(cfgDir); DocumentDBConfigHelper mgr(spec, "searchdocument"); mgr.forwardConfig(_bootstrap); - mgr.nextGeneration(1ms); + mgr.nextGeneration(transport, 1ms); _cfg = mgr.getConfig(); } }; @@ -287,35 +289,41 @@ struct MyConfigSnapshot template struct FixtureBase { - ThreadStackExecutor _summaryExecutor; + FastOS_ThreadPool _threadPool; + FNET_Transport _transport; + ThreadStackExecutor _summaryExecutor; ExecutorThreadingService _writeService; - typename Traits::Config _cfg; + typename Traits::Config _cfg; std::shared_ptr _bucketDB; - BucketDBHandler _bucketDBHandler; + BucketDBHandler _bucketDBHandler; typename Traits::Context _ctx; - typename Traits::Schema _baseSchema; - MyConfigSnapshot::UP _snapshot; - DirectoryHandler _baseDir; - typename Traits::SubDB _subDb; - IFeedView::SP _tmpFeedView; + typename Traits::Schema _baseSchema; + MyConfigSnapshot::UP _snapshot; + DirectoryHandler _baseDir; + typename Traits::SubDB _subDb; + IFeedView::SP _tmpFeedView; FixtureBase() - : _summaryExecutor(1, 64_Ki), + : _threadPool(64_Ki), + _transport(), + _summaryExecutor(1, 64_Ki), _writeService(_summaryExecutor), _cfg(), _bucketDB(std::make_shared()), _bucketDBHandler(*_bucketDB), _ctx(_writeService, _bucketDB, _bucketDBHandler), _baseSchema(), - _snapshot(std::make_unique(_baseSchema, Traits::ConfigDir::dir())), + _snapshot(std::make_unique(_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 & calc) { vespalib::Gate gate; @@ -346,7 +354,7 @@ struct FixtureBase runInMasterAndSync([&]() { performReconfig(serialNum, reconfigSchema, reconfigConfigDir); }); } void performReconfig(SerialNum serialNum, const Schema &reconfigSchema, const vespalib::string &reconfigConfigDir) { - auto newCfg = std::make_unique(reconfigSchema, reconfigConfigDir); + auto newCfg = std::make_unique(_transport, reconfigSchema, reconfigConfigDir); DocumentDBConfig::ComparisonResult cmpResult; cmpResult.attributesChanged = true; cmpResult.documenttypesChanged = true; diff --git a/searchcore/src/tests/proton/documentdb/documentdb_test.cpp b/searchcore/src/tests/proton/documentdb/documentdb_test.cpp index 7ba3e0b8240..bef8d0c49bb 100644 --- a/searchcore/src/tests/proton/documentdb/documentdb_test.cpp +++ b/searchcore/src/tests/proton/documentdb/documentdb_test.cpp @@ -149,7 +149,7 @@ Fixture::Fixture(bool file_config) _bucketExecutor(2), _db(), _fileHeaderContext(), - _tls("tmp", 9014, ".", _fileHeaderContext), + _tls(_shared_service.transport(), "tmp", 9014, ".", _fileHeaderContext), _queryLimiter(), _clock() { @@ -165,7 +165,7 @@ Fixture::Fixture(bool file_config) std::make_shared(), tuneFileDocumentDB, HwInfo()); mgr.forwardConfig(b); - mgr.nextGeneration(0ms); + mgr.nextGeneration(_shared_service.transport(), 0ms); _db = DocumentDB::create(".", mgr.getConfig(), "tcp/localhost:9014", _queryLimiter, _clock, DocTypeName("typea"), makeBucketSpace(), *b->getProtonConfigSP(), _myDBOwner, _shared_service, _bucketExecutor, _tls, _dummy, @@ -183,7 +183,7 @@ std::unique_ptr Fixture::make_config_store() { if (_file_config) { - return std::make_unique("config", "", "typea"); + return std::make_unique(_shared_service.transport(), "config", "", "typea"); } else { return std::make_unique(); } diff --git a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp index 904937a26da..c20f14d2d81 100644 --- a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp +++ b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp @@ -33,7 +33,9 @@ #include #include #include +#include #include +#include #include LOG_SETUP("feedhandler_test"); @@ -407,6 +409,8 @@ struct MyTlsWriter : TlsWriter { struct FeedHandlerFixture { DummyFileHeaderContext _fileHeaderContext; + FastOS_ThreadPool _threadPool; + FNET_Transport _transport; TransLogServer tls; vespalib::string tlsSpec; vespalib::ThreadStackExecutor sharedExecutor; @@ -423,7 +427,9 @@ struct FeedHandlerFixture FeedHandler handler; FeedHandlerFixture() : _fileHeaderContext(), - tls("mytls", 9016, "mytlsdir", _fileHeaderContext, DomainConfig().setPartSizeLimit(0x10000)), + _threadPool(64_Ki), + _transport(), + tls(_transport, "mytls", 9016, "mytlsdir", _fileHeaderContext, DomainConfig().setPartSizeLimit(0x10000)), tlsSpec("tcp/localhost:9016"), sharedExecutor(1, 0x10000), writeService(sharedExecutor), @@ -437,6 +443,7 @@ struct FeedHandlerFixture handler(writeService, tlsSpec, schema.getDocType(), owner, writeFilter, replayConfig, tls, &tls_writer) { + _transport.Start(&_threadPool); _state.enterLoadState(); _state.enterReplayTransactionLogState(); handler.setActiveFeedView(&feedView); @@ -446,6 +453,7 @@ struct FeedHandlerFixture ~FeedHandlerFixture() { writeService.shutdown(); + _transport.ShutDown(true); } template 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 68b9d2f8d6e..aa525189b26 100644 --- a/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp +++ b/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp @@ -15,8 +15,11 @@ #include #include #include +#include #include #include +#include +#include using namespace cloud::config::filedistribution; using namespace config; @@ -39,7 +42,7 @@ using vespalib::nbostream; vespalib::string myId("myconfigid"); DocumentDBConfig::SP -makeBaseConfigSnapshot() +makeBaseConfigSnapshot(FNET_Transport & transport) { ::config::DirSpec spec(TEST_PATH("cfg")); @@ -52,7 +55,7 @@ makeBaseConfigSnapshot() std::make_shared(), std::make_shared(), HwInfo()); dbcm.forwardConfig(b); - dbcm.nextGeneration(0ms); + dbcm.nextGeneration(transport, 0ms); DocumentDBConfig::SP snap = dbcm.getConfig(); snap->setConfigId(myId); ASSERT_TRUE(snap); @@ -60,9 +63,9 @@ makeBaseConfigSnapshot() } void -saveBaseConfigSnapshot(const DocumentDBConfig &snap, SerialNum num) +saveBaseConfigSnapshot(FNET_Transport & transport, const DocumentDBConfig &snap, SerialNum num) { - FileConfigManager cm("out", myId, snap.getDocTypeName()); + FileConfigManager cm(transport, "out", myId, snap.getDocTypeName()); cm.saveConfig(snap, num); } @@ -125,55 +128,69 @@ addConfigsThatAreNotSavedToDisk(const DocumentDBConfig &cfg) return builder.build(); } -TEST_F("requireThatConfigCanBeSavedAndLoaded", DocumentDBConfig::SP(makeBaseConfigSnapshot())) +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))) { - DocumentDBConfig::SP fullCfg = addConfigsThatAreNotSavedToDisk(*f); - saveBaseConfigSnapshot(*fullCfg, 20); + DocumentDBConfig::SP fullCfg = addConfigsThatAreNotSavedToDisk(*f2); + saveBaseConfigSnapshot(f1.transport, *fullCfg, 20); DocumentDBConfig::SP esnap(makeEmptyConfigSnapshot()); { - FileConfigManager cm("out", myId, "dummy"); + FileConfigManager cm(f1.transport, "out", myId, "dummy"); cm.loadConfig(*esnap, 20, esnap); } - assertEqualSnapshot(*f, *esnap); + assertEqualSnapshot(*f2, *esnap); } -TEST_F("requireThatConfigCanBeSerializedAndDeserialized", DocumentDBConfig::SP(makeBaseConfigSnapshot())) +TEST_FF("requireThatConfigCanBeSerializedAndDeserialized", Fixture(), DocumentDBConfig::SP(makeBaseConfigSnapshot(f1.transport))) { - saveBaseConfigSnapshot(*f, 30); + saveBaseConfigSnapshot(f1.transport, *f2, 30); nbostream stream; { - FileConfigManager cm("out", myId, "dummy"); + FileConfigManager cm(f1.transport, "out", myId, "dummy"); cm.serializeConfig(30, stream); } { - FileConfigManager cm("out", myId, "dummy"); + FileConfigManager cm(f1.transport, "out", myId, "dummy"); cm.deserializeConfig(40, stream); } DocumentDBConfig::SP fsnap(makeEmptyConfigSnapshot()); { - FileConfigManager cm("out", myId, "dummy"); + FileConfigManager cm(f1.transport, "out", myId, "dummy"); cm.loadConfig(*fsnap, 40, fsnap); } - assertEqualSnapshot(*f, *fsnap); + assertEqualSnapshot(*f2, *fsnap); EXPECT_EQUAL("dummy", fsnap->getDocTypeName()); } -TEST_F("requireThatConfigCanBeLoadedWithoutExtraConfigsDataFile", DocumentDBConfig::SP(makeBaseConfigSnapshot())) +TEST_FF("requireThatConfigCanBeLoadedWithoutExtraConfigsDataFile", Fixture(), DocumentDBConfig::SP(makeBaseConfigSnapshot(f1.transport))) { - saveBaseConfigSnapshot(*f, 70); + saveBaseConfigSnapshot(f1.transport, *f2, 70); EXPECT_FALSE(vespalib::unlink("out/config-70/extraconfigs.dat")); DocumentDBConfig::SP esnap(makeEmptyConfigSnapshot()); { - FileConfigManager cm("out", myId, "dummy"); + FileConfigManager cm(f1.transport, "out", myId, "dummy"); cm.loadConfig(*esnap, 70, esnap); } } -TEST_F("requireThatVisibilityDelayIsPropagated", DocumentDBConfig::SP(makeBaseConfigSnapshot())) +TEST_FF("requireThatVisibilityDelayIsPropagated", Fixture(), DocumentDBConfig::SP(makeBaseConfigSnapshot(f1.transport))) { - saveBaseConfigSnapshot(*f, 80); + saveBaseConfigSnapshot(f1.transport, *f2, 80); DocumentDBConfig::SP esnap(makeEmptyConfigSnapshot()); { ProtonConfigBuilder protonConfigBuilder; @@ -182,7 +199,7 @@ TEST_F("requireThatVisibilityDelayIsPropagated", DocumentDBConfig::SP(makeBaseCo ddb.visibilitydelay = 61.0; protonConfigBuilder.documentdb.push_back(ddb); protonConfigBuilder.maxvisibilitydelay = 100.0; - FileConfigManager cm("out", myId, "dummy"); + FileConfigManager cm(f1.transport, "out", myId, "dummy"); cm.setProtonConfig(std::make_shared(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 9657619be40..45d4354564e 100644 --- a/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp +++ b/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -348,6 +349,8 @@ public: test::DiskMemUsageNotifier _diskMemUsageNotifier; BucketCreateNotifier _bucketCreateNotifier; MonitoredRefCount _refCount; + FastOS_ThreadPool _threadPool; + FNET_Transport _transport; MaintenanceController _mc; MaintenanceControllerFixture(); @@ -767,8 +770,11 @@ MaintenanceControllerFixture::MaintenanceControllerFixture() _attributeUsageFilter(), _bucketCreateNotifier(), _refCount(), - _mc(_threadService, _genericExecutor, _refCount, _docTypeName) + _threadPool(64_Ki), + _transport(), + _mc(_transport, _threadService, _genericExecutor, _refCount, _docTypeName) { + _transport.Start(&_threadPool); std::vector subDBs; subDBs.push_back(&_ready); subDBs.push_back(&_removed); @@ -779,6 +785,7 @@ MaintenanceControllerFixture::MaintenanceControllerFixture() MaintenanceControllerFixture::~MaintenanceControllerFixture() { + _transport.ShutDown(true); stopMaintenance(); } 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 3c9e9fc3a64..eaafd089a76 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 @@ -17,7 +17,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -63,6 +65,8 @@ struct DoctypeFixture { struct ConfigTestFixture { const std::string configId; + FastOS_ThreadPool threadPool; + FNET_Transport transport; ProtonConfigBuilder protonBuilder; DocumenttypesConfigBuilder documenttypesBuilder; FiledistributorrpcConfigBuilder filedistBuilder; @@ -74,6 +78,7 @@ struct ConfigTestFixture { ConfigTestFixture(const std::string & id) : configId(id), + threadPool(64_Ki), protonBuilder(), documenttypesBuilder(), filedistBuilder(), @@ -83,6 +88,7 @@ struct ConfigTestFixture { context(std::make_shared(set)), idcounter(-1) { + transport.Start(& threadPool); set.addBuilder(configId, &protonBuilder); set.addBuilder(configId, &documenttypesBuilder); set.addBuilder(configId, &filedistBuilder); @@ -90,6 +96,10 @@ struct ConfigTestFixture { addDocType("_alwaysthere_"); } + ~ConfigTestFixture() { + transport.ShutDown(true); + } + DoctypeFixture *addDocType(const std::string &name, bool isGlobal = false) { DocumenttypesConfigBuilder::Documenttype dt; dt.bodystruct = -1270491200; @@ -249,7 +259,7 @@ getDocumentDBConfig(ConfigTestFixture &f, DocumentDBConfigManager &mgr, const Hw { ConfigRetriever retriever(mgr.createConfigKeySet(), f.context); mgr.forwardConfig(f.getBootstrapConfig(1, hwInfo)); - mgr.update(retriever.getBootstrapConfigs()); // Cheating, but we only need the configs + mgr.update(f.transport, retriever.getBootstrapConfigs()); // Cheating, but we only need the configs return mgr.getConfig(); } @@ -300,8 +310,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(ConfigUri(f1.configId, f1.context), f2, 60s)) { - f3.start(); + ProtonConfigFetcher(f1.transport, ConfigUri(f1.configId, f1.context), f2, 60s)) { + f3.start(f1.threadPool); ASSERT_TRUE(f2._configured); ASSERT_TRUE(f1.configEqual(f2.getBootstrapConfig())); f2._configured = false; @@ -315,8 +325,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(ConfigUri(f1.configId, f1.context), f2, 60s)) { - f3.start(); + ProtonConfigFetcher(f1.transport, ConfigUri(f1.configId, f1.context), f2, 60s)) { + f3.start(f1.threadPool); f2._configured = false; f1.addDocType("typea"); @@ -335,8 +345,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(ConfigUri(f1.configId, f1.context), f2, 60s)) { - f3.start(); + ProtonConfigFetcher(f1.transport, ConfigUri(f1.configId, f1.context), f2, 60s)) { + f3.start(f1.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/proton_disk_layout_test.cpp b/searchcore/src/tests/proton/proton_disk_layout/proton_disk_layout_test.cpp index 17bd5991b68..015d649f755 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 @@ -9,6 +9,8 @@ #include #include #include +#include +#include using search::index::DummyFileHeaderContext; using search::transactionlog::client::TransLogClient; @@ -29,6 +31,8 @@ struct FixtureBase struct DiskLayoutFixture { DummyFileHeaderContext _fileHeaderContext; + FastOS_ThreadPool _threadPool; + FNET_Transport _transport; TransLogServer _tls; vespalib::string _tlsSpec; ProtonDiskLayout _diskLayout; @@ -91,13 +95,18 @@ struct DiskLayoutFixture { DiskLayoutFixture::DiskLayoutFixture() : _fileHeaderContext(), - _tls("tls", tlsPort, baseDir, _fileHeaderContext), + _threadPool(64_Ki), + _transport(), + _tls(_transport, "tls", tlsPort, baseDir, _fileHeaderContext), _tlsSpec(vespalib::make_string("tcp/localhost:%u", tlsPort)), _diskLayout(baseDir, _tlsSpec) { + _transport.Start(&_threadPool); } -DiskLayoutFixture::~DiskLayoutFixture() = default; +DiskLayoutFixture::~DiskLayoutFixture() { + _transport.ShutDown(true); +} struct Fixture : public FixtureBase, public DiskLayoutFixture { 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 0c80553e1e7..9d43007f907 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,8 +3,10 @@ #include #include #include +#include +#include +#include #include -#include #include #include @@ -38,16 +40,23 @@ public: }; struct DiskMemUsageSamplerTest : public ::testing::Test { - DiskMemUsageSampler sampler; - DiskMemUsageSamplerTest(): - sampler(".", - DiskMemUsageSampler::Config(0.8, 0.8, - 50ms, make_hw_info())) + FastOS_ThreadPool threadPool; + FNET_Transport transport; + std::unique_ptr sampler; + DiskMemUsageSamplerTest() + : threadPool(64_Ki), + transport(), + sampler(std::make_unique(transport, ".", DiskMemUsageSampler::Config(0.8, 0.8, 50ms, make_hw_info()))) { - sampler.add_transient_usage_provider(std::make_shared(50, 200)); - sampler.add_transient_usage_provider(std::make_shared(100, 150)); + transport.Start(&threadPool); + sampler->add_transient_usage_provider(std::make_shared(50, 200)); + sampler->add_transient_usage_provider(std::make_shared(100, 150)); } - const DiskMemUsageFilter& filter() const { return sampler.writeFilter(); } + ~DiskMemUsageSamplerTest() { + sampler.reset(); + transport.ShutDown(true); + } + const DiskMemUsageFilter& filter() const { return sampler->writeFilter(); } }; TEST_F(DiskMemUsageSamplerTest, resource_usage_is_sampled) 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 bede9f967a4..eb01b01c980 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 @@ -5,6 +5,9 @@ #include #include #include +#include +#include +#include #include using namespace proton; @@ -47,14 +50,22 @@ TEST(SharedThreadingServiceConfigTest, shared_threads_are_derived_from_cpu_cores class SharedThreadingServiceTest : public ::testing::Test { public: + FastOS_ThreadPool threadPool; + FNET_Transport transport; std::unique_ptr service; SharedThreadingServiceTest() - : service() + : threadPool(64_Ki), + transport(), + service() { + transport.Start(&threadPool); + } + ~SharedThreadingServiceTest() { + transport.ShutDown(true); } void setup(double concurrency, uint32_t cpu_cores) { service = std::make_unique( - SharedThreadingServiceConfig::make(make_proton_config(concurrency), HwInfo::Cpu(cpu_cores))); + SharedThreadingServiceConfig::make(make_proton_config(concurrency), HwInfo::Cpu(cpu_cores)), transport); } SequencedTaskExecutor* field_writer() { return dynamic_cast(service->field_writer()); -- cgit v1.2.3