Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ydb/core/tablet/resource_broker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1302,7 +1302,7 @@ NKikimrResourceBroker::TResourceBrokerConfig MakeDefaultConfig()

const ui64 DefaultQueueCPU = 2;
const ui64 KqpRmQueueCPU = 4;
const ui64 TotalCPU = 20;
const ui64 TotalCPU = 256; // means unlimited

// Note: these memory limits will be overwritten by MemoryController
const ui64 KqpRmQueueMemory = 10_GB;
Expand Down
51 changes: 30 additions & 21 deletions ydb/core/tablet/resource_broker_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ namespace NKikimr {
using namespace NKikimrResourceBroker;
using namespace NResourceBroker;

static void SetupLogging(TTestActorRuntime& runtime) {
static void SetupLogging(TTestActorRuntime& runtime)
{
NActors::NLog::EPriority priority = ENABLE_DETAILED_RESOURCE_BROKER_LOG ? NLog::PRI_DEBUG : NLog::PRI_ERROR;
runtime.SetLogPriority(NKikimrServices::RESOURCE_BROKER, priority);
}

static NKikimrResourceBroker::TResourceBrokerConfig
MakeTestConfig()
static NKikimrResourceBroker::TResourceBrokerConfig MakeTestConfig()
{
NKikimrResourceBroker::TResourceBrokerConfig config;

Expand Down Expand Up @@ -71,16 +71,14 @@ MakeTestConfig()
return config;
}

static void
WaitForBootstrap(TTestActorRuntime &runtime)
static void WaitForBootstrap(TTestActorRuntime &runtime)
{
TDispatchOptions options;
options.FinalEvents.emplace_back(TEvents::TSystem::Bootstrap, 1);
UNIT_ASSERT(runtime.DispatchEvents(options));
}

static void
SubmitTask(TTestActorRuntime &runtime, TActorId broker, TActorId sender,
static void SubmitTask(TTestActorRuntime &runtime, TActorId broker, TActorId sender,
ui64 id, ui64 cpu, ui64 memory, const TString &type,
ui32 priority, TIntrusivePtr<TThrRefBase> cookie = nullptr)
{
Expand All @@ -94,8 +92,7 @@ SubmitTask(TTestActorRuntime &runtime, TActorId broker, TActorId sender,
runtime.Send(new IEventHandle(broker, sender, event.Release()));
}

static void
UpdateTask(TTestActorRuntime &runtime, TActorId broker, TActorId sender,
static void UpdateTask(TTestActorRuntime &runtime, TActorId broker, TActorId sender,
ui64 id, ui64 cpu, ui64 memory, ui32 priority, const TString &type,
bool resubmit = false)
{
Expand All @@ -107,8 +104,7 @@ UpdateTask(TTestActorRuntime &runtime, TActorId broker, TActorId sender,
runtime.Send(new IEventHandle(broker, sender, event.Release()));
}

static void
UpdateTaskCookie(TTestActorRuntime &runtime, TActorId broker, TActorId sender,
static void UpdateTaskCookie(TTestActorRuntime &runtime, TActorId broker, TActorId sender,
ui64 id, TIntrusivePtr<TThrRefBase> cookie)
{
TAutoPtr<TEvResourceBroker::TEvUpdateTaskCookie> event
Expand All @@ -117,17 +113,15 @@ UpdateTaskCookie(TTestActorRuntime &runtime, TActorId broker, TActorId sender,
runtime.Send(new IEventHandle(broker, sender, event.Release()));
}

static void
RemoveTask(TTestActorRuntime &runtime, TActorId broker, TActorId sender, ui64 id)
static void RemoveTask(TTestActorRuntime &runtime, TActorId broker, TActorId sender, ui64 id)
{
TAutoPtr<TEvResourceBroker::TEvRemoveTask> event
= new TEvResourceBroker::TEvRemoveTask(id);

runtime.Send(new IEventHandle(broker, sender, event.Release()));
}

static void
FinishTask(TTestActorRuntime &runtime, TActorId broker, TActorId sender, ui64 id)
static void FinishTask(TTestActorRuntime &runtime, TActorId broker, TActorId sender, ui64 id)
{
TAutoPtr<TEvResourceBroker::TEvFinishTask> event
= new TEvResourceBroker::TEvFinishTask(id);
Expand All @@ -147,8 +141,7 @@ WaitForResourceAllocation(TTestActorRuntime &runtime, ui64 id,
return reply->TaskId;
}

static void
WaitForError(TTestActorRuntime &runtime, ui64 id, TEvResourceBroker::TStatus::ECode code,
static void WaitForError(TTestActorRuntime &runtime, ui64 id, TEvResourceBroker::TStatus::ECode code,
TIntrusivePtr<TThrRefBase> cookie = nullptr)
{
TAutoPtr<IEventHandle> handle;
Expand All @@ -158,8 +151,7 @@ WaitForError(TTestActorRuntime &runtime, ui64 id, TEvResourceBroker::TStatus::EC
UNIT_ASSERT_VALUES_EQUAL(reply->Cookie, cookie);
}

static void
CheckCounters(::NMonitoring::TDynamicCounterPtr counters, const TString &group, const TString &name,
static void CheckCounters(::NMonitoring::TDynamicCounterPtr counters, const TString &group, const TString &name,
ui64 cpu, ui64 memory, ui64 finished, ui64 enqueued, ui64 infly)
{
auto g = counters->GetSubgroup(group, name);
Expand All @@ -185,14 +177,14 @@ static void CheckConfigure(TTestActorRuntime &runtime, TActorId broker, TActorId
UNIT_ASSERT_VALUES_EQUAL((int)rec.GetSuccess(), (int)success);
}

static
TIntrusivePtr<IResourceBroker> GetInstantResourceBroker(TTestActorRuntime &runtime, TActorId broker, TActorId sender) {
static TIntrusivePtr<IResourceBroker> GetInstantResourceBroker(TTestActorRuntime &runtime, TActorId broker, TActorId sender) {
runtime.Send(new IEventHandle(broker, sender, new TEvResourceBroker::TEvResourceBrokerRequest));
auto answer = runtime.GrabEdgeEvent<TEvResourceBroker::TEvResourceBrokerResponse>(sender);
return answer->Get()->ResourceBroker;
}

Y_UNIT_TEST_SUITE(TResourceBroker) {

Y_UNIT_TEST(TestErrors) {
TTestBasicRuntime runtime;
SetupTabletServices(runtime);
Expand Down Expand Up @@ -894,6 +886,7 @@ Y_UNIT_TEST_SUITE(TResourceBroker) {
};

Y_UNIT_TEST_SUITE(TResourceBrokerInstant) {

Y_UNIT_TEST(Test) {
TTestBasicRuntime runtime;
SetupTabletServices(runtime);
Expand Down Expand Up @@ -1007,6 +1000,7 @@ Y_UNIT_TEST_SUITE(TResourceBrokerInstant) {
CheckCounters(counters, "queue", "total", 210, 320, 1, 0, 2);
}
}

};

Y_UNIT_TEST_SUITE(TResourceBrokerConfig) {
Expand Down Expand Up @@ -1130,6 +1124,21 @@ Y_UNIT_TEST_SUITE(TResourceBrokerConfig) {
UNIT_ASSERT_VALUES_EQUAL(config.ShortDebugString(), "ResourceLimit { Cpu: 20 Memory: 2048 }");
}

Y_UNIT_TEST(DefaultConfig) {
auto config = MakeDefaultConfig();

Cerr << config.DebugString() << Endl;

ui64 queuesCpu = 0;
for (const auto& q : config.GetQueues()) {
queuesCpu += q.GetLimit().GetCpu();
}
Cerr << "Total queues cpu: " << queuesCpu;

// see https://github.com/ydb-platform/ydb/issues/18513
UNIT_ASSERT_LE(queuesCpu, config.GetResourceLimit().GetCpu());
}

} // TResourceBrokerConfig

} // NKikimr
Loading