diff options
author | Tor Egge <Tor.Egge@online.no> | 2024-05-21 12:54:22 +0200 |
---|---|---|
committer | Tor Egge <Tor.Egge@online.no> | 2024-05-21 12:54:22 +0200 |
commit | 1eb32c602b82ab851bbf7a78414b26479221bbc5 (patch) | |
tree | 4000b44179dce98daf005936107b5d6d9a35270f | |
parent | 2b08f380d52c7c5b5e5678f5f582fb93647c2529 (diff) |
Document searchcore unit test port number allocation.
7 files changed, 66 insertions, 10 deletions
diff --git a/searchcore/src/apps/tests/persistenceconformance_test.cpp b/searchcore/src/apps/tests/persistenceconformance_test.cpp index 71a1f475d1d..a7d8a7201af 100644 --- a/searchcore/src/apps/tests/persistenceconformance_test.cpp +++ b/searchcore/src/apps/tests/persistenceconformance_test.cpp @@ -17,6 +17,7 @@ #include <vespa/searchcore/proton/server/threading_service_config.h> #include <vespa/searchcore/proton/test/disk_mem_usage_notifier.h> #include <vespa/searchcore/proton/test/mock_shared_threading_service.h> +#include <vespa/searchcore/proton/test/port_numbers.h> #include <vespa/searchlib/attribute/interlock.h> #include <vespa/searchlib/index/dummyfileheadercontext.h> #include <vespa/searchlib/transactionlog/translogserver.h> @@ -66,6 +67,12 @@ using DocumenttypesConfigSP = DocumentDBConfig::DocumenttypesConfigSP; using DocumentDBMap = std::map<DocTypeName, DocumentDB::SP>; using DocTypeVector = std::vector<DocTypeName>; +namespace { + +constexpr int tls_port = proton::test::port_numbers::persistenceconformance_tls_port; + +} + void storeDocType(DocTypeVector *types, const DocumentType &type) { @@ -381,7 +388,7 @@ public: std::unique_ptr<PersistenceFactory> makeMyPersistenceFactory(const std::string &docType) { - return std::make_unique<MyPersistenceFactory>("testdb", 9017, SchemaConfigFactory::get(), docType); + return std::make_unique<MyPersistenceFactory>("testdb", tls_port, SchemaConfigFactory::get(), docType); } int diff --git a/searchcore/src/tests/proton/docsummary/docsummary_test.cpp b/searchcore/src/tests/proton/docsummary/docsummary_test.cpp index e8ed780ed82..173cfbbf052 100644 --- a/searchcore/src/tests/proton/docsummary/docsummary_test.cpp +++ b/searchcore/src/tests/proton/docsummary/docsummary_test.cpp @@ -18,6 +18,7 @@ #include <vespa/searchcore/proton/server/summaryadapter.h> #include <vespa/searchcore/proton/test/bucketfactory.h> #include <vespa/searchcore/proton/test/mock_shared_threading_service.h> +#include <vespa/searchcore/proton/test/port_numbers.h> #include <vespa/searchlib/attribute/interlock.h> #include <vespa/searchlib/engine/docsumapi.h> #include <vespa/searchlib/index/dummyfileheadercontext.h> @@ -63,6 +64,7 @@ #include <vespa/vespalib/data/slime/json_format.h> #include <vespa/vespalib/data/slime/slime.h> #include <vespa/vespalib/encoding/base64.h> +#include <vespa/vespalib/net/socket_spec.h> #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/geo/zcurve.h> #include <vespa/vespalib/util/destructor_callbacks.h> @@ -103,6 +105,16 @@ using vespalib::Slime; using vespalib::geo::ZCurve; using namespace vespalib::slime; +namespace { + +constexpr int tls_port = proton::test::port_numbers::docsummary_tls_port; + +vespalib::string tls_port_spec() { + return vespalib::SocketSpec::from_host_port("localhost", tls_port).spec(); +} + +} + namespace proton { class MockDocsumFieldWriterFactory : public search::docsummary::IDocsumFieldWriterFactory @@ -248,7 +260,7 @@ public: _fileHeaderContext(), _summaryExecutor(8), _shared_service(_summaryExecutor), - _tls(_shared_service.transport(), "tmp", 9013, ".", _fileHeaderContext), + _tls(_shared_service.transport(), "tmp", tls_port, ".", _fileHeaderContext), _made_dir(std::filesystem::create_directory(std::filesystem::path("tmpdb"))), _queryLimiter(), _dummy(), @@ -271,7 +283,7 @@ public: _configMgr.forwardConfig(b); _configMgr.nextGeneration(_shared_service.transport(), 0ms); std::filesystem::create_directory(std::filesystem::path(std::string("tmpdb/") + docTypeName)); - _ddb = DocumentDB::create("tmpdb", _configMgr.getConfig(), "tcp/localhost:9013", _queryLimiter, + _ddb = DocumentDB::create("tmpdb", _configMgr.getConfig(), tls_port_spec(), _queryLimiter, DocTypeName(docTypeName), makeBucketSpace(), *b->getProtonConfigSP(), *this, _shared_service, _tls, _dummy, _fileHeaderContext, std::make_shared<search::attribute::Interlock>(), diff --git a/searchcore/src/tests/proton/documentdb/documentdb_test.cpp b/searchcore/src/tests/proton/documentdb/documentdb_test.cpp index dbe5cd409b3..97c0331ce0b 100644 --- a/searchcore/src/tests/proton/documentdb/documentdb_test.cpp +++ b/searchcore/src/tests/proton/documentdb/documentdb_test.cpp @@ -20,6 +20,7 @@ #include <vespa/searchcore/proton/server/fileconfigmanager.h> #include <vespa/searchcore/proton/server/memoryconfigstore.h> #include <vespa/searchcore/proton/test/mock_shared_threading_service.h> +#include <vespa/searchcore/proton/test/port_numbers.h> #include <vespa/searchcorespi/index/indexflushtarget.h> #include <vespa/config-bucketspaces.h> #include <vespa/config/subscription/sourcespec.h> @@ -33,6 +34,7 @@ #include <vespa/searchlib/index/dummyfileheadercontext.h> #include <vespa/searchlib/transactionlog/translogserver.h> #include <vespa/vespalib/data/slime/slime.h> +#include <vespa/vespalib/net/socket_spec.h> #include <vespa/vespalib/stllike/asciistream.h> #include <vespa/vespalib/testkit/test_kit.h> #include <vespa/vespalib/util/size_literals.h> @@ -61,6 +63,12 @@ using vespalib::Slime; namespace { +constexpr int tls_port = proton::test::port_numbers::documentdb_tls_port; + +vespalib::string tls_port_spec() { + return vespalib::SocketSpec::from_host_port("localhost", tls_port).spec(); +} + void cleanup_dirs(bool file_config) { @@ -133,7 +141,7 @@ Fixture::Fixture(bool file_config) _hwInfo(), _db(), _fileHeaderContext(), - _tls(_shared_service.transport(), "tmp", 9014, ".", _fileHeaderContext), + _tls(_shared_service.transport(), "tmp", tls_port, ".", _fileHeaderContext), _queryLimiter() { auto documenttypesConfig = std::make_shared<DocumenttypesConfig>(); @@ -149,7 +157,7 @@ Fixture::Fixture(bool file_config) tuneFileDocumentDB, HwInfo()); mgr.forwardConfig(b); mgr.nextGeneration(_shared_service.transport(), 0ms); - _db = DocumentDB::create(".", mgr.getConfig(), "tcp/localhost:9014", _queryLimiter, DocTypeName("typea"), + _db = DocumentDB::create(".", mgr.getConfig(), tls_port_spec(), _queryLimiter, DocTypeName("typea"), makeBucketSpace(), *b->getProtonConfigSP(), _myDBOwner, _shared_service, _tls, _dummy, _fileHeaderContext, diff --git a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp index 20a6ac40de4..808c5743538 100644 --- a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp +++ b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp @@ -26,6 +26,7 @@ #include <vespa/searchcore/proton/feedoperation/updateoperation.h> #include <vespa/searchcore/proton/persistenceengine/i_resource_write_filter.h> #include <vespa/searchcore/proton/server/configstore.h> +#include <vespa/searchcore/proton/test/port_numbers.h> #include <vespa/document/util/feed_reject_helper.h> #include <vespa/searchcore/proton/server/ddbstate.h> #include <vespa/searchcore/proton/server/feedhandler.h> @@ -36,6 +37,7 @@ #include <vespa/searchlib/index/dummyfileheadercontext.h> #include <vespa/searchlib/test/doc_builder.h> #include <vespa/searchlib/transactionlog/translogserver.h> +#include <vespa/vespalib/net/socket_spec.h> #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/util/lambdatask.h> #include <vespa/vespalib/util/exceptions.h> @@ -79,6 +81,12 @@ using CountDownLatchUP = std::unique_ptr<vespalib::CountDownLatch>; namespace { +constexpr int tls_port = proton::test::port_numbers::feedhandler_tls_port; + +vespalib::string tls_port_spec() { + return vespalib::SocketSpec::from_host_port("localhost", tls_port).spec(); +} + struct Rendezvous { vespalib::Gate enter; vespalib::Gate leave; @@ -428,8 +436,8 @@ struct FeedHandlerFixture FeedHandlerFixture() : _fileHeaderContext(), _service(1), - tls(_service.transport(), "mytls", 9016, "mytlsdir", _fileHeaderContext, DomainConfig().setPartSizeLimit(0x10000)), - tlsSpec("tcp/localhost:9016"), + tls(_service.transport(), "mytls", tls_port, "mytlsdir", _fileHeaderContext, DomainConfig().setPartSizeLimit(0x10000)), + tlsSpec(tls_port_spec()), schema(), owner(), _state(), 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 09cec0d6d01..06264e3e642 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 @@ -48,6 +48,8 @@ using search::GrowStrategy; using vespalib::datastore::CompactionStrategy; using vespalib::HwInfo; +constexpr int proton_rpc_port = 9010; // Not used for listening in this test + struct DoctypeFixture { using UP = std::unique_ptr<DoctypeFixture>; AttributesConfigBuilder attributesBuilder; @@ -242,7 +244,7 @@ TEST_FFF("require that bootstrap config manager updates config", ConfigTestFixtu ConfigRetriever(f2.createConfigKeySet(), f1.context)) { f2.update(f3.getBootstrapConfigs()); ASSERT_TRUE(f1.configEqual(*f2.getConfig())); - f1.protonBuilder.rpcport = 9010; + f1.protonBuilder.rpcport = proton_rpc_port; ASSERT_FALSE(f1.configEqual(*f2.getConfig())); f1.reload(); f2.update(f3.getBootstrapConfigs()); @@ -316,7 +318,7 @@ TEST_FFF("require that proton config fetcher follows changes to bootstrap", ASSERT_TRUE(f2._configured); ASSERT_TRUE(f1.configEqual(*f2.getBootstrapConfig())); f2._configured = false; - f1.protonBuilder.rpcport = 9010; + f1.protonBuilder.rpcport = proton_rpc_port; f1.reload(); ASSERT_TRUE(f2.waitUntilConfigured(120s)); ASSERT_TRUE(f1.configEqual(*f2.getBootstrapConfig())); 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 49dbf43da67..411dd88f995 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/port_numbers.h> #include <vespa/searchcore/proton/test/transport_helper.h> #include <vespa/searchlib/index/dummyfileheadercontext.h> #include <vespa/searchlib/transactionlog/translogserver.h> @@ -19,7 +20,7 @@ using proton::DocTypeName; using proton::ProtonDiskLayout; using proton::Transport; -static constexpr unsigned int tlsPort = 9018; +static constexpr unsigned int tlsPort = proton::test::port_numbers::proton_disk_layout_tls_port; static const vespalib::string baseDir("testdb"); static const vespalib::string documentsDir(baseDir + "/documents"); diff --git a/searchcore/src/vespa/searchcore/proton/test/port_numbers.h b/searchcore/src/vespa/searchcore/proton/test/port_numbers.h new file mode 100644 index 00000000000..4526aaff948 --- /dev/null +++ b/searchcore/src/vespa/searchcore/proton/test/port_numbers.h @@ -0,0 +1,18 @@ +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#pragma once + +namespace proton::test::port_numbers { + +/* + * The following port numbers are used by unit tests in the searchcore + * module. They should all be in the range 9001..9499. + */ + +constexpr int docsummary_tls_port = 9013; +constexpr int documentdb_tls_port = 9014; +constexpr int feedhandler_tls_port = 9016; +constexpr int persistenceconformance_tls_port = 9017; +constexpr int proton_disk_layout_tls_port = 9018; + +} |