Skip to content

Commit 2b53ebe

Browse files
authored
Merge 0b774bc into 29e1e45
2 parents 29e1e45 + 0b774bc commit 2b53ebe

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

ydb/library/actors/testlib/test_runtime.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,12 @@ namespace NActors {
804804
LogBackend = logBackend;
805805
}
806806

807+
void TTestActorRuntimeBase::SetLogBackendFactory(std::function<TAutoPtr<TLogBackend>()> logBackendFactory) {
808+
Y_ABORT_UNLESS(!IsInitialized);
809+
TGuard<TMutex> guard(Mutex);
810+
LogBackendFactory = logBackendFactory;
811+
}
812+
807813
void TTestActorRuntimeBase::SetLogPriority(NActors::NLog::EComponent component, NActors::NLog::EPriority priority) {
808814
TGuard<TMutex> guard(Mutex);
809815
for (ui32 nodeIndex = 0; nodeIndex < NodeCount; ++nodeIndex) {
@@ -1761,6 +1767,9 @@ namespace NActors {
17611767
}
17621768

17631769
if (!SingleSysEnv) { // Single system env should do this self
1770+
if (LogBackendFactory) {
1771+
LogBackend = LogBackendFactory();
1772+
}
17641773
TAutoPtr<TLogBackend> logBackend = LogBackend ? LogBackend : NActors::CreateStderrBackend();
17651774
NActors::TLoggerActor *loggerActor = new NActors::TLoggerActor(node->LogSettings,
17661775
logBackend, GetCountersForComponent(node->DynamicCounters, "utils"));

ydb/library/actors/testlib/test_runtime.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ namespace NActors {
249249
}
250250
TDuration SetReschedulingDelay(TDuration delay);
251251
void SetLogBackend(const TAutoPtr<TLogBackend> logBackend);
252+
void SetLogBackendFactory(std::function<TAutoPtr<TLogBackend>()> logBackendFactory);
252253
void SetLogPriority(NActors::NLog::EComponent component, NActors::NLog::EPriority priority);
253254
TIntrusivePtr<ITimeProvider> GetTimeProvider();
254255
TIntrusivePtr<IMonotonicTimeProvider> GetMonotonicTimeProvider();
@@ -654,6 +655,7 @@ namespace NActors {
654655
ui64 DispatcherRandomSeed;
655656
TIntrusivePtr<IRandomProvider> DispatcherRandomProvider;
656657
TAutoPtr<TLogBackend> LogBackend;
658+
std::function<TAutoPtr<TLogBackend>()> LogBackendFactory;
657659
bool NeedMonitoring;
658660
ui16 MonitoringPortOffset = 0;
659661
bool MonitoringTypeAsync = false;

ydb/tests/tools/kqprun/src/ydb_setup.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,11 @@ class TYdbSetup::TImpl {
9393

9494
runtime.SetLogPriority(service, NActors::NLog::EPriority(setting.GetLevel()));
9595
}
96+
97+
runtime.SetLogBackendFactory([this]() { return CreateLogBackend(); });
9698
};
9799

98100
serverSettings.SetLoggerInitializer(loggerInitializer);
99-
serverSettings.SetLogBackend(CreateLogBackend());
100101
}
101102

102103
void SetFunctionRegistry(NKikimr::Tests::TServerSettings& serverSettings) const {
@@ -244,12 +245,13 @@ class TYdbSetup::TImpl {
244245
NKikimr::NKqp::TEvFetchScriptResultsResponse::TPtr FetchScriptExecutionResultsRequest(const TString& operation, i32 resultSetId) const {
245246
TString executionId = *NKikimr::NKqp::ScriptExecutionIdFromOperation(operation);
246247

247-
NActors::TActorId edgeActor = GetRuntime()->AllocateEdgeActor();
248+
ui32 nodeIndex = RandomNumber(Settings_.NodeCount);
249+
NActors::TActorId edgeActor = GetRuntime()->AllocateEdgeActor(nodeIndex);
248250
auto rowsLimit = Settings_.AppConfig.GetQueryServiceConfig().GetScriptResultRowsLimit();
249251
auto sizeLimit = Settings_.AppConfig.GetQueryServiceConfig().GetScriptResultSizeLimit();
250252
NActors::IActor* fetchActor = NKikimr::NKqp::CreateGetScriptExecutionResultActor(edgeActor, Settings_.DomainName, executionId, resultSetId, 0, rowsLimit, sizeLimit, TInstant::Max());
251253

252-
GetRuntime()->Register(fetchActor, RandomNumber(Settings_.NodeCount));
254+
GetRuntime()->Register(fetchActor, nodeIndex);
253255

254256
return GetRuntime()->GrabEdgeEvent<NKikimr::NKqp::TEvFetchScriptResultsResponse>(edgeActor);
255257
}
@@ -303,10 +305,11 @@ class TYdbSetup::TImpl {
303305

304306
template <typename TRequest, typename TResponse>
305307
typename TResponse::TPtr RunKqpProxyRequest(THolder<TRequest> event) const {
306-
NActors::TActorId edgeActor = GetRuntime()->AllocateEdgeActor();
307-
NActors::TActorId kqpProxy = NKikimr::NKqp::MakeKqpProxyID(GetRuntime()->GetNodeId(RandomNumber(Settings_.NodeCount)));
308+
ui32 nodeIndex = RandomNumber(Settings_.NodeCount);
309+
NActors::TActorId edgeActor = GetRuntime()->AllocateEdgeActor(nodeIndex);
310+
NActors::TActorId kqpProxy = NKikimr::NKqp::MakeKqpProxyID(GetRuntime()->GetNodeId(nodeIndex));
308311

309-
GetRuntime()->Send(kqpProxy, edgeActor, event.Release());
312+
GetRuntime()->Send(kqpProxy, edgeActor, event.Release(), nodeIndex);
310313

311314
return GetRuntime()->GrabEdgeEvent<TResponse>(edgeActor);
312315
}

0 commit comments

Comments
 (0)