Skip to content

Commit dcdd81a

Browse files
committed
Added pulling
1 parent 2a97b98 commit dcdd81a

File tree

4 files changed

+34
-29
lines changed

4 files changed

+34
-29
lines changed

ydb/core/kqp/workload_service/ut/common/kqp_workload_service_ut_common.cpp

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,7 @@ class TWorkloadServiceYdbSetup : public IYdbSetup {
460460
}
461461
}
462462

463+
// Coomon helpers
463464
TTestActorRuntime* GetRuntime() const override {
464465
return Server_->GetRuntime();
465466
}
@@ -491,19 +492,6 @@ class TWorkloadServiceYdbSetup : public IYdbSetup {
491492
return event;
492493
}
493494

494-
static void WaitFor(TDuration timeout, TString description, std::function<bool(TString&)> callback) {
495-
TInstant start = TInstant::Now();
496-
while (TInstant::Now() - start <= timeout) {
497-
TString errorString;
498-
if (callback(errorString)) {
499-
return;
500-
}
501-
Cerr << "Wait " << description << " " << TInstant::Now() - start << ": " << errorString << "\n";
502-
Sleep(TDuration::Seconds(1));
503-
}
504-
UNIT_ASSERT_C(false, "Waiting " << description << " timeout");
505-
}
506-
507495
NMonitoring::TDynamicCounterPtr GetWorkloadManagerCounters(ui32 nodeIndex) const {
508496
return GetServiceCounters(GetRuntime()->GetAppData(nodeIndex).Counters, "kqp")
509497
->GetSubgroup("subsystem", "workload_manager");
@@ -598,6 +586,21 @@ TIntrusivePtr<IYdbSetup> TYdbSetupSettings::Create() const {
598586
return MakeIntrusive<TWorkloadServiceYdbSetup>(*this);
599587
}
600588

589+
//// IYdbSetup
590+
591+
void IYdbSetup::WaitFor(TDuration timeout, TString description, std::function<bool(TString&)> callback) {
592+
TInstant start = TInstant::Now();
593+
while (TInstant::Now() - start <= timeout) {
594+
TString errorString;
595+
if (callback(errorString)) {
596+
return;
597+
}
598+
Cerr << "Wait " << description << " " << TInstant::Now() - start << ": " << errorString << "\n";
599+
Sleep(TDuration::Seconds(1));
600+
}
601+
UNIT_ASSERT_C(false, "Waiting " << description << " timeout");
602+
}
603+
601604
//// TSampleQueriess
602605

603606
void TSampleQueries::CompareYson(const TString& expected, const TString& actual) {

ydb/core/kqp/workload_service/ut/common/kqp_workload_service_ut_common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,10 @@ class IYdbSetup : public TThrRefBase {
106106
virtual void StopWorkloadService(ui64 nodeIndex = 0) const = 0;
107107
virtual void ValidateWorkloadServiceCounters(bool checkTableCounters = true, const TString& poolId = "") const = 0;
108108

109+
// Coomon helpers
109110
virtual TTestActorRuntime* GetRuntime() const = 0;
110111
virtual const TYdbSetupSettings& GetSettings() const = 0;
112+
static void WaitFor(TDuration timeout, TString description, std::function<bool(TString&)> callback);
111113
};
112114

113115
// Test queries

ydb/core/kqp/workload_service/ut/kqp_workload_service_tables_ut.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,12 @@ Y_UNIT_TEST_SUITE(KqpWorkloadServiceTables) {
147147
ydb->WaitPoolHandlersCount(0);
148148

149149
// Check that lease expired
150-
const TDuration leaseDuration = TDuration::Seconds(30); // Same as pool_handlers_acors.cpp:LEASE_DURATION
151-
Sleep(leaseDuration + TDuration::Seconds(5)); // 5s for last pool refresh request
152-
CheckPoolDescription(ydb, 0, 0);
150+
IYdbSetup::WaitFor(TDuration::Seconds(60), "lease expiration", [ydb](TString& errorString) {
151+
auto description = ydb->GetPoolDescription(TDuration::Zero());
152+
153+
errorString = TStringBuilder() << "delayed = " << description.DelayedRequests << ", running = " << description.RunningRequests;
154+
return description.AmountRequests() == 0;
155+
});
153156
}
154157

155158
Y_UNIT_TEST(TestLeaseUpdates) {

ydb/core/kqp/workload_service/ut/kqp_workload_service_ut.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -444,19 +444,16 @@ Y_UNIT_TEST_SUITE(ResourcePoolsDdl) {
444444
DROP RESOURCE POOL )" << poolId << ";"
445445
);
446446

447-
TInstant start = TInstant::Now();
448-
while (TInstant::Now() - start <= FUTURE_WAIT_TIMEOUT) {
449-
if (ydb->Navigate(TStringBuilder() << ".resource_pools/" << poolId)->ResultSet.at(0).Kind == NSchemeCache::TSchemeCacheNavigate::EKind::KindUnknown) {
450-
auto result = ydb->ExecuteQuery(TSampleQueries::TSelect42::Query, settings);
451-
UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), NYdb::EStatus::NOT_FOUND, result.GetIssues().ToString());
452-
UNIT_ASSERT_STRING_CONTAINS(result.GetIssues().ToString(), TStringBuilder() << "Resource pool " << poolId << " not found");
453-
return;
454-
}
455-
456-
Cerr << "WaitPoolDrop " << TInstant::Now() - start << "\n";
457-
Sleep(TDuration::Seconds(1));
458-
}
459-
UNIT_ASSERT_C(false, "Pool drop waiting timeout");
447+
IYdbSetup::WaitFor(FUTURE_WAIT_TIMEOUT, "pool drop", [ydb, poolId](TString& errorString) {
448+
auto kind = ydb->Navigate(TStringBuilder() << ".resource_pools/" << poolId)->ResultSet.at(0).Kind;
449+
450+
errorString = TStringBuilder() << "kind = " << kind;
451+
return kind == NSchemeCache::TSchemeCacheNavigate::EKind::KindUnknown;
452+
});
453+
454+
auto result = ydb->ExecuteQuery(TSampleQueries::TSelect42::Query, settings);
455+
UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), NYdb::EStatus::NOT_FOUND, result.GetIssues().ToString());
456+
UNIT_ASSERT_STRING_CONTAINS(result.GetIssues().ToString(), TStringBuilder() << "Resource pool " << poolId << " not found");
460457
}
461458

462459
Y_UNIT_TEST(TestResourcePoolAcl) {

0 commit comments

Comments
 (0)