aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/tests/proton/documentdb
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-02-20 21:24:22 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2022-02-20 23:46:18 +0000
commit1bb2800fb1bf312689115a7230b1d3ead74d4ac6 (patch)
tree29c84e9a2b9451e0fc4cd8d5e2908c26eb1758fd /searchcore/src/tests/proton/documentdb
parent1cfea65b9bc71b472e9dc3370b120cf428b6ece0 (diff)
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.
Diffstat (limited to 'searchcore/src/tests/proton/documentdb')
-rw-r--r--searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp34
-rw-r--r--searchcore/src/tests/proton/documentdb/documentdb_test.cpp6
-rw-r--r--searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp10
-rw-r--r--searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp59
-rw-r--r--searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp9
5 files changed, 79 insertions, 39 deletions
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 <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;
@@ -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 <typename Traits>
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::BucketDBOwner> _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<bucketdb::BucketDBOwner>()),
_bucketDBHandler(*_bucketDB),
_ctx(_writeService, _bucketDB, _bucketDBHandler),
_baseSchema(),
- _snapshot(std::make_unique<MyConfigSnapshot>(_baseSchema, Traits::ConfigDir::dir())),
+ _snapshot(std::make_unique<MyConfigSnapshot>(_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;
@@ -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<MyConfigSnapshot>(reconfigSchema, reconfigConfigDir);
+ auto newCfg = std::make_unique<MyConfigSnapshot>(_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<BucketspacesConfig>(),
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<ConfigStore>
Fixture::make_config_store()
{
if (_file_config) {
- return std::make_unique<FileConfigManager>("config", "", "typea");
+ return std::make_unique<FileConfigManager>(_shared_service.transport(), "config", "", "typea");
} else {
return std::make_unique<MemoryConfigStore>();
}
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 <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/util/lambdatask.h>
#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");
@@ -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 <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 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 <vespa/searchcore/proton/test/documentdb_config_builder.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;
@@ -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<BucketspacesConfig>(),
std::make_shared<TuneFileDocumentDB>(), 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<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 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 <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>
@@ -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<MyDocumentSubDB *> subDBs;
subDBs.push_back(&_ready);
subDBs.push_back(&_removed);
@@ -779,6 +785,7 @@ MaintenanceControllerFixture::MaintenanceControllerFixture()
MaintenanceControllerFixture::~MaintenanceControllerFixture()
{
+ _transport.ShutDown(true);
stopMaintenance();
}