diff options
author | azevaykin <[email protected]> | 2023-08-17 17:37:10 +0300 |
---|---|---|
committer | azevaykin <[email protected]> | 2023-08-17 18:14:46 +0300 |
commit | 3d7be3b7d4567fa3615dc4cf762a31fe9335143e (patch) | |
tree | 69d6d9396b70283678975aed05d5d9ab2bbbe7ea | |
parent | b5ebf0f8b199ddf8e17bf6c82e99a60db16e67fe (diff) |
Introduce constant DEFAULT_NODE_COUNT = 2 in tests
5 files changed, 19 insertions, 21 deletions
diff --git a/ydb/core/testlib/test_pq_client.h b/ydb/core/testlib/test_pq_client.h index ff578052a66..e8d1c66ca25 100644 --- a/ydb/core/testlib/test_pq_client.h +++ b/ydb/core/testlib/test_pq_client.h @@ -23,8 +23,9 @@ namespace NPersQueueTests { using namespace NNetClassifier; using namespace NKikimr::Tests; +const static ui32 PQ_DEFAULT_NODE_COUNT = 2; -inline Tests::TServerSettings PQSettings(ui16 port, ui32 nodesCount = 2, bool roundrobin = true, const TString& yql_timeout = "10", const THolder<TTempFileHandle>& netDataFile = nullptr) { +inline Tests::TServerSettings PQSettings(ui16 port = 0, ui32 nodesCount = PQ_DEFAULT_NODE_COUNT, bool roundrobin = true, const TString& yql_timeout = "10", const THolder<TTempFileHandle>& netDataFile = nullptr) { NKikimrPQ::TPQConfig pqConfig; NKikimrProto::TAuthConfig authConfig; authConfig.SetUseBlackBox(false); diff --git a/ydb/public/sdk/cpp/client/ydb_persqueue_core/ut/ut_utils/sdk_test_setup.h b/ydb/public/sdk/cpp/client/ydb_persqueue_core/ut/ut_utils/sdk_test_setup.h index cf1d08f0081..37ed5f1690d 100644 --- a/ydb/public/sdk/cpp/client/ydb_persqueue_core/ut/ut_utils/sdk_test_setup.h +++ b/ydb/public/sdk/cpp/client/ydb_persqueue_core/ut/ut_utils/sdk_test_setup.h @@ -23,10 +23,10 @@ public: SDKTestSetup(const TString& testCaseName, bool start = true, const TVector<NKikimrServices::EServiceKikimr>& logServices = TTestServer::LOGGED_SERVICES, NActors::NLog::EPriority logPriority = NActors::NLog::PRI_DEBUG, - ui32 nodeCount = 2, + ui32 nodeCount = NKikimr::NPersQueueTests::PQ_DEFAULT_NODE_COUNT, size_t topicPartitionsCount = 1) : TestCaseName(testCaseName) - , Server(false, Nothing(), logServices, logPriority) + , Server(NKikimr::NPersQueueTests::PQSettings(), false, logServices, logPriority, Nothing()) , TopicPartitionsCount(topicPartitionsCount) { InitOptions(nodeCount); @@ -35,7 +35,7 @@ public: } } - void InitOptions(ui32 nodeCount = 2) { + void InitOptions(ui32 nodeCount = NKikimr::NPersQueueTests::PQ_DEFAULT_NODE_COUNT) { Log.SetFormatter([testCaseName = TestCaseName](ELogPriority priority, TStringBuf message) { return TStringBuilder() << TInstant::Now() << " :" << testCaseName << " " << priority << ": " << message << Endl; }); diff --git a/ydb/public/sdk/cpp/client/ydb_persqueue_core/ut/ut_utils/test_server.h b/ydb/public/sdk/cpp/client/ydb_persqueue_core/ut/ut_utils/test_server.h index 1f8eebb07bd..9d38ee3e0fa 100644 --- a/ydb/public/sdk/cpp/client/ydb_persqueue_core/ut/ut_utils/test_server.h +++ b/ydb/public/sdk/cpp/client/ydb_persqueue_core/ut/ut_utils/test_server.h @@ -15,12 +15,15 @@ static constexpr int DEBUG_LOG_LEVEL = 7; class TTestServer { public: - TTestServer(bool start = true, TMaybe<TSimpleSharedPtr<TPortManager>> portManager = Nothing(), - const TVector<NKikimrServices::EServiceKikimr>& logServices = TTestServer::LOGGED_SERVICES, NActors::NLog::EPriority logPriority = NActors::NLog::PRI_DEBUG) + TTestServer(const NKikimr::Tests::TServerSettings& settings, + bool start = true, + const TVector<NKikimrServices::EServiceKikimr>& logServices = TTestServer::LOGGED_SERVICES, + NActors::NLog::EPriority logPriority = NActors::NLog::PRI_DEBUG, + TMaybe<TSimpleSharedPtr<TPortManager>> portManager = Nothing()) : PortManager(portManager.GetOrElse(MakeSimpleShared<TPortManager>())) , Port(PortManager->GetPort(2134)) , GrpcPort(PortManager->GetPort(2135)) - , ServerSettings(NKikimr::NPersQueueTests::PQSettings(Port).SetGrpcPort(GrpcPort)) + , ServerSettings(settings) , GrpcServerOptions(NGrpc::TServerOptions().SetHost("[::1]").SetPort(GrpcPort)) { auto loggerInitializer = [logServices, logPriority](NActors::TTestActorRuntime& runtime) { @@ -29,23 +32,18 @@ public: }; ServerSettings.SetLoggerInitializer(loggerInitializer); - if (start) { - StartServer(); - } - } - TTestServer(const NKikimr::Tests::TServerSettings& settings, bool start = true) - : PortManager(MakeSimpleShared<TPortManager>()) - , Port(PortManager->GetPort(2134)) - , GrpcPort(PortManager->GetPort(2135)) - , ServerSettings(settings) - , GrpcServerOptions(NGrpc::TServerOptions().SetHost("[::1]").SetPort(GrpcPort)) - { ServerSettings.Port = Port; ServerSettings.SetGrpcPort(GrpcPort); + if (start) StartServer(); } + TTestServer(bool start = true) + : TTestServer(NKikimr::NPersQueueTests::PQSettings(), start) + { + } + void StartServer(bool doClientInit = true, TMaybe<TString> databaseName = Nothing()) { Log.SetFormatter([](ELogPriority priority, TStringBuf message) { return TStringBuilder() << TInstant::Now() << " " << priority << ": " << message << Endl; diff --git a/ydb/public/sdk/cpp/client/ydb_persqueue_core/ut/ut_utils/ut_utils.h b/ydb/public/sdk/cpp/client/ydb_persqueue_core/ut/ut_utils/ut_utils.h index b43e369e22c..13c3881e1cc 100644 --- a/ydb/public/sdk/cpp/client/ydb_persqueue_core/ut/ut_utils/ut_utils.h +++ b/ydb/public/sdk/cpp/client/ydb_persqueue_core/ut/ut_utils/ut_utils.h @@ -19,7 +19,7 @@ public: TPersQueueYdbSdkTestSetup(const TString& testCaseName, bool start = true, const TVector<NKikimrServices::EServiceKikimr>& logServices = ::NPersQueue::TTestServer::LOGGED_SERVICES, NActors::NLog::EPriority logPriority = NActors::NLog::PRI_DEBUG, - ui32 nodeCount = 2, + ui32 nodeCount = NKikimr::NPersQueueTests::PQ_DEFAULT_NODE_COUNT, size_t topicPartitionsCount = 1) : SDKTestSetup(testCaseName, start, logServices, logPriority, nodeCount, topicPartitionsCount) { diff --git a/ydb/services/persqueue_v1/ut/persqueue_test_fixture.h b/ydb/services/persqueue_v1/ut/persqueue_test_fixture.h index 3d23cfd90b9..b413a75a558 100644 --- a/ydb/services/persqueue_v1/ut/persqueue_test_fixture.h +++ b/ydb/services/persqueue_v1/ut/persqueue_test_fixture.h @@ -63,8 +63,7 @@ static void ModifyTopicACL(NYdb::TDriver* driver, const TString& topic, const TV void InitializePQ() { Y_VERIFY(Server == nullptr); - PortManager = new TPortManager(); - Server = MakeHolder<NPersQueue::TTestServer>(false, PortManager); + Server = MakeHolder<NPersQueue::TTestServer>(false); Server->ServerSettings.PQConfig.SetTopicsAreFirstClassCitizen(TenantModeEnabled()); Server->ServerSettings.PQConfig.MutablePQDiscoveryConfig()->SetLBFrontEnabled(true); Server->ServerSettings.PQConfig.SetACLRetryTimeoutSec(1); |