@@ -15,13 +15,13 @@ namespace NKikimr {
15
15
using namespace NKikimrResourceBroker ;
16
16
using namespace NResourceBroker ;
17
17
18
- static void SetupLogging (TTestActorRuntime& runtime) {
18
+ static void SetupLogging (TTestActorRuntime& runtime)
19
+ {
19
20
NActors::NLog::EPriority priority = ENABLE_DETAILED_RESOURCE_BROKER_LOG ? NLog::PRI_DEBUG : NLog::PRI_ERROR;
20
21
runtime.SetLogPriority (NKikimrServices::RESOURCE_BROKER, priority);
21
22
}
22
23
23
- static NKikimrResourceBroker::TResourceBrokerConfig
24
- MakeTestConfig ()
24
+ static NKikimrResourceBroker::TResourceBrokerConfig MakeTestConfig ()
25
25
{
26
26
NKikimrResourceBroker::TResourceBrokerConfig config;
27
27
@@ -71,16 +71,14 @@ MakeTestConfig()
71
71
return config;
72
72
}
73
73
74
- static void
75
- WaitForBootstrap (TTestActorRuntime &runtime)
74
+ static void WaitForBootstrap (TTestActorRuntime &runtime)
76
75
{
77
76
TDispatchOptions options;
78
77
options.FinalEvents .emplace_back (TEvents::TSystem::Bootstrap, 1 );
79
78
UNIT_ASSERT (runtime.DispatchEvents (options));
80
79
}
81
80
82
- static void
83
- SubmitTask (TTestActorRuntime &runtime, TActorId broker, TActorId sender,
81
+ static void SubmitTask (TTestActorRuntime &runtime, TActorId broker, TActorId sender,
84
82
ui64 id, ui64 cpu, ui64 memory, const TString &type,
85
83
ui32 priority, TIntrusivePtr<TThrRefBase> cookie = nullptr )
86
84
{
@@ -94,8 +92,7 @@ SubmitTask(TTestActorRuntime &runtime, TActorId broker, TActorId sender,
94
92
runtime.Send (new IEventHandle (broker, sender, event.Release ()));
95
93
}
96
94
97
- static void
98
- UpdateTask (TTestActorRuntime &runtime, TActorId broker, TActorId sender,
95
+ static void UpdateTask (TTestActorRuntime &runtime, TActorId broker, TActorId sender,
99
96
ui64 id, ui64 cpu, ui64 memory, ui32 priority, const TString &type,
100
97
bool resubmit = false )
101
98
{
@@ -107,8 +104,7 @@ UpdateTask(TTestActorRuntime &runtime, TActorId broker, TActorId sender,
107
104
runtime.Send (new IEventHandle (broker, sender, event.Release ()));
108
105
}
109
106
110
- static void
111
- UpdateTaskCookie (TTestActorRuntime &runtime, TActorId broker, TActorId sender,
107
+ static void UpdateTaskCookie (TTestActorRuntime &runtime, TActorId broker, TActorId sender,
112
108
ui64 id, TIntrusivePtr<TThrRefBase> cookie)
113
109
{
114
110
TAutoPtr<TEvResourceBroker::TEvUpdateTaskCookie> event
@@ -117,17 +113,15 @@ UpdateTaskCookie(TTestActorRuntime &runtime, TActorId broker, TActorId sender,
117
113
runtime.Send (new IEventHandle (broker, sender, event.Release ()));
118
114
}
119
115
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)
122
117
{
123
118
TAutoPtr<TEvResourceBroker::TEvRemoveTask> event
124
119
= new TEvResourceBroker::TEvRemoveTask (id);
125
120
126
121
runtime.Send (new IEventHandle (broker, sender, event.Release ()));
127
122
}
128
123
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)
131
125
{
132
126
TAutoPtr<TEvResourceBroker::TEvFinishTask> event
133
127
= new TEvResourceBroker::TEvFinishTask (id);
@@ -147,8 +141,7 @@ WaitForResourceAllocation(TTestActorRuntime &runtime, ui64 id,
147
141
return reply->TaskId ;
148
142
}
149
143
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,
152
145
TIntrusivePtr<TThrRefBase> cookie = nullptr )
153
146
{
154
147
TAutoPtr<IEventHandle> handle;
@@ -158,8 +151,7 @@ WaitForError(TTestActorRuntime &runtime, ui64 id, TEvResourceBroker::TStatus::EC
158
151
UNIT_ASSERT_VALUES_EQUAL (reply->Cookie , cookie);
159
152
}
160
153
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,
163
155
ui64 cpu, ui64 memory, ui64 finished, ui64 enqueued, ui64 infly)
164
156
{
165
157
auto g = counters->GetSubgroup (group, name);
@@ -185,14 +177,14 @@ static void CheckConfigure(TTestActorRuntime &runtime, TActorId broker, TActorId
185
177
UNIT_ASSERT_VALUES_EQUAL ((int )rec.GetSuccess (), (int )success);
186
178
}
187
179
188
- static
189
- TIntrusivePtr<IResourceBroker> GetInstantResourceBroker (TTestActorRuntime &runtime, TActorId broker, TActorId sender) {
180
+ static TIntrusivePtr<IResourceBroker> GetInstantResourceBroker (TTestActorRuntime &runtime, TActorId broker, TActorId sender) {
190
181
runtime.Send (new IEventHandle (broker, sender, new TEvResourceBroker::TEvResourceBrokerRequest));
191
182
auto answer = runtime.GrabEdgeEvent <TEvResourceBroker::TEvResourceBrokerResponse>(sender);
192
183
return answer->Get ()->ResourceBroker ;
193
184
}
194
185
195
186
Y_UNIT_TEST_SUITE (TResourceBroker) {
187
+
196
188
Y_UNIT_TEST (TestErrors) {
197
189
TTestBasicRuntime runtime;
198
190
SetupTabletServices (runtime);
@@ -894,6 +886,7 @@ Y_UNIT_TEST_SUITE(TResourceBroker) {
894
886
};
895
887
896
888
Y_UNIT_TEST_SUITE (TResourceBrokerInstant) {
889
+
897
890
Y_UNIT_TEST (Test) {
898
891
TTestBasicRuntime runtime;
899
892
SetupTabletServices (runtime);
@@ -1007,6 +1000,7 @@ Y_UNIT_TEST_SUITE(TResourceBrokerInstant) {
1007
1000
CheckCounters (counters, " queue" , " total" , 210 , 320 , 1 , 0 , 2 );
1008
1001
}
1009
1002
}
1003
+
1010
1004
};
1011
1005
1012
1006
Y_UNIT_TEST_SUITE (TResourceBrokerConfig) {
@@ -1130,6 +1124,21 @@ Y_UNIT_TEST_SUITE(TResourceBrokerConfig) {
1130
1124
UNIT_ASSERT_VALUES_EQUAL (config.ShortDebugString (), " ResourceLimit { Cpu: 20 Memory: 2048 }" );
1131
1125
}
1132
1126
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
+ // see https://github.com/ydb-platform/ydb/issues/18513
1139
+ UNIT_ASSERT_LE (queuesCpu, config.GetResourceLimit ().GetCpu ());
1140
+ }
1141
+
1133
1142
} // TResourceBrokerConfig
1134
1143
1135
1144
} // NKikimr
0 commit comments