@@ -15,13 +15,13 @@ namespace NKikimr {
1515using namespace NKikimrResourceBroker ;
1616using namespace NResourceBroker ;
1717
18- static void SetupLogging (TTestActorRuntime& runtime) {
18+ static void SetupLogging (TTestActorRuntime& runtime)
19+ {
1920 NActors::NLog::EPriority priority = ENABLE_DETAILED_RESOURCE_BROKER_LOG ? NLog::PRI_DEBUG : NLog::PRI_ERROR;
2021 runtime.SetLogPriority (NKikimrServices::RESOURCE_BROKER, priority);
2122}
2223
23- static NKikimrResourceBroker::TResourceBrokerConfig
24- MakeTestConfig ()
24+ static NKikimrResourceBroker::TResourceBrokerConfig MakeTestConfig ()
2525{
2626 NKikimrResourceBroker::TResourceBrokerConfig config;
2727
@@ -71,16 +71,14 @@ MakeTestConfig()
7171 return config;
7272}
7373
74- static void
75- WaitForBootstrap (TTestActorRuntime &runtime)
74+ static void WaitForBootstrap (TTestActorRuntime &runtime)
7675{
7776 TDispatchOptions options;
7877 options.FinalEvents .emplace_back (TEvents::TSystem::Bootstrap, 1 );
7978 UNIT_ASSERT (runtime.DispatchEvents (options));
8079}
8180
82- static void
83- SubmitTask (TTestActorRuntime &runtime, TActorId broker, TActorId sender,
81+ static void SubmitTask (TTestActorRuntime &runtime, TActorId broker, TActorId sender,
8482 ui64 id, ui64 cpu, ui64 memory, const TString &type,
8583 ui32 priority, TIntrusivePtr<TThrRefBase> cookie = nullptr )
8684{
@@ -94,8 +92,7 @@ SubmitTask(TTestActorRuntime &runtime, TActorId broker, TActorId sender,
9492 runtime.Send (new IEventHandle (broker, sender, event.Release ()));
9593}
9694
97- static void
98- UpdateTask (TTestActorRuntime &runtime, TActorId broker, TActorId sender,
95+ static void UpdateTask (TTestActorRuntime &runtime, TActorId broker, TActorId sender,
9996 ui64 id, ui64 cpu, ui64 memory, ui32 priority, const TString &type,
10097 bool resubmit = false )
10198{
@@ -107,8 +104,7 @@ UpdateTask(TTestActorRuntime &runtime, TActorId broker, TActorId sender,
107104 runtime.Send (new IEventHandle (broker, sender, event.Release ()));
108105}
109106
110- static void
111- UpdateTaskCookie (TTestActorRuntime &runtime, TActorId broker, TActorId sender,
107+ static void UpdateTaskCookie (TTestActorRuntime &runtime, TActorId broker, TActorId sender,
112108 ui64 id, TIntrusivePtr<TThrRefBase> cookie)
113109{
114110 TAutoPtr<TEvResourceBroker::TEvUpdateTaskCookie> event
@@ -117,17 +113,15 @@ UpdateTaskCookie(TTestActorRuntime &runtime, TActorId broker, TActorId sender,
117113 runtime.Send (new IEventHandle (broker, sender, event.Release ()));
118114}
119115
120- static void
121- RemoveTask (TTestActorRuntime &runtime, TActorId broker, TActorId sender, ui64 id)
116+ static void RemoveTask (TTestActorRuntime &runtime, TActorId broker, TActorId sender, ui64 id)
122117{
123118 TAutoPtr<TEvResourceBroker::TEvRemoveTask> event
124119 = new TEvResourceBroker::TEvRemoveTask (id);
125120
126121 runtime.Send (new IEventHandle (broker, sender, event.Release ()));
127122}
128123
129- static void
130- FinishTask (TTestActorRuntime &runtime, TActorId broker, TActorId sender, ui64 id)
124+ static void FinishTask (TTestActorRuntime &runtime, TActorId broker, TActorId sender, ui64 id)
131125{
132126 TAutoPtr<TEvResourceBroker::TEvFinishTask> event
133127 = new TEvResourceBroker::TEvFinishTask (id);
@@ -147,8 +141,7 @@ WaitForResourceAllocation(TTestActorRuntime &runtime, ui64 id,
147141 return reply->TaskId ;
148142}
149143
150- static void
151- WaitForError (TTestActorRuntime &runtime, ui64 id, TEvResourceBroker::TStatus::ECode code,
144+ static void WaitForError (TTestActorRuntime &runtime, ui64 id, TEvResourceBroker::TStatus::ECode code,
152145 TIntrusivePtr<TThrRefBase> cookie = nullptr )
153146{
154147 TAutoPtr<IEventHandle> handle;
@@ -158,8 +151,7 @@ WaitForError(TTestActorRuntime &runtime, ui64 id, TEvResourceBroker::TStatus::EC
158151 UNIT_ASSERT_VALUES_EQUAL (reply->Cookie , cookie);
159152}
160153
161- static void
162- CheckCounters (::NMonitoring::TDynamicCounterPtr counters, const TString &group, const TString &name,
154+ static void CheckCounters (::NMonitoring::TDynamicCounterPtr counters, const TString &group, const TString &name,
163155 ui64 cpu, ui64 memory, ui64 finished, ui64 enqueued, ui64 infly)
164156{
165157 auto g = counters->GetSubgroup (group, name);
@@ -185,14 +177,14 @@ static void CheckConfigure(TTestActorRuntime &runtime, TActorId broker, TActorId
185177 UNIT_ASSERT_VALUES_EQUAL ((int )rec.GetSuccess (), (int )success);
186178}
187179
188- static
189- TIntrusivePtr<IResourceBroker> GetInstantResourceBroker (TTestActorRuntime &runtime, TActorId broker, TActorId sender) {
180+ static TIntrusivePtr<IResourceBroker> GetInstantResourceBroker (TTestActorRuntime &runtime, TActorId broker, TActorId sender) {
190181 runtime.Send (new IEventHandle (broker, sender, new TEvResourceBroker::TEvResourceBrokerRequest));
191182 auto answer = runtime.GrabEdgeEvent <TEvResourceBroker::TEvResourceBrokerResponse>(sender);
192183 return answer->Get ()->ResourceBroker ;
193184}
194185
195186Y_UNIT_TEST_SUITE (TResourceBroker) {
187+
196188 Y_UNIT_TEST (TestErrors) {
197189 TTestBasicRuntime runtime;
198190 SetupTabletServices (runtime);
@@ -894,6 +886,7 @@ Y_UNIT_TEST_SUITE(TResourceBroker) {
894886};
895887
896888Y_UNIT_TEST_SUITE (TResourceBrokerInstant) {
889+
897890 Y_UNIT_TEST (Test) {
898891 TTestBasicRuntime runtime;
899892 SetupTabletServices (runtime);
@@ -1007,6 +1000,7 @@ Y_UNIT_TEST_SUITE(TResourceBrokerInstant) {
10071000 CheckCounters (counters, " queue" , " total" , 210 , 320 , 1 , 0 , 2 );
10081001 }
10091002 }
1003+
10101004};
10111005
10121006Y_UNIT_TEST_SUITE (TResourceBrokerConfig) {
@@ -1130,6 +1124,30 @@ Y_UNIT_TEST_SUITE(TResourceBrokerConfig) {
11301124 UNIT_ASSERT_VALUES_EQUAL (config.ShortDebugString (), " ResourceLimit { Cpu: 20 Memory: 2048 }" );
11311125 }
11321126
1127+ Y_UNIT_TEST (DefaultConfig) {
1128+ auto config = MakeDefaultConfig ();
1129+
1130+ Cerr << config.DebugString () << Endl;
1131+
1132+ ui64 queuesCpu = 0 ;
1133+ for (const auto & q : config.GetQueues ()) {
1134+ queuesCpu += q.GetLimit ().GetCpu ();
1135+ }
1136+ Cerr << " Total queues cpu: " << queuesCpu;
1137+
1138+ auto getCpu = [&](const TString& queue) {
1139+ for (const auto & q : config.GetQueues ()) {
1140+ if (q.GetName () == queue) {
1141+ return q.GetLimit ().GetCpu ();
1142+ }
1143+ }
1144+ Y_ASSERT (false );
1145+ };
1146+
1147+ // see https://github.com/ydb-platform/ydb/issues/18513
1148+ UNIT_ASSERT_LT (getCpu (" queue_build_index" ) + getCpu (" queue_restore" ), config.GetResourceLimit ().GetCpu ());
1149+ }
1150+
11331151} // TResourceBrokerConfig
11341152
11351153} // NKikimr
0 commit comments