@@ -155,14 +155,36 @@ TPathId ResolvePathId(TTestActorRuntime& runtime, const TString& path, TPathId*
155155 *domainKey = resultEntry.DomainInfo ->DomainKey ;
156156 }
157157
158- if (saTabletId && resultEntry.DomainInfo ->Params .HasStatisticsAggregator ()) {
159- *saTabletId = resultEntry.DomainInfo ->Params .GetStatisticsAggregator ();
158+ if (saTabletId) {
159+ if (resultEntry.DomainInfo ->Params .HasStatisticsAggregator ()) {
160+ *saTabletId = resultEntry.DomainInfo ->Params .GetStatisticsAggregator ();
161+ } else {
162+ auto resourcesDomainKey = resultEntry.DomainInfo ->ResourcesDomainKey ;
163+ auto request = std::make_unique<TNavigate>();
164+ auto & entry = request->ResultSet .emplace_back ();
165+ entry.TableId = TTableId (resourcesDomainKey.OwnerId , resourcesDomainKey.LocalPathId );
166+ entry.RequestType = TNavigate::TEntry::ERequestType::ByTableId;
167+ entry.Operation = TNavigate::EOp::OpPath;
168+ entry.RedirectRequired = false ;
169+ runtime.Send (MakeSchemeCacheID (), sender, new TEvRequest (request.release ()));
170+
171+ auto ev = runtime.GrabEdgeEventRethrow <TEvResponse>(sender);
172+ UNIT_ASSERT (ev);
173+ UNIT_ASSERT (ev->Get ());
174+ std::unique_ptr<TNavigate> response (ev->Get ()->Request .Release ());
175+ UNIT_ASSERT (response->ResultSet .size () == 1 );
176+ auto & secondResultEntry = response->ResultSet [0 ];
177+
178+ if (secondResultEntry.DomainInfo ->Params .HasStatisticsAggregator ()) {
179+ *saTabletId = secondResultEntry.DomainInfo ->Params .GetStatisticsAggregator ();
180+ }
181+ }
160182 }
161183
162184 return resultEntry.TableId .PathId ;
163185}
164186
165- NKikimrScheme::TEvDescribeSchemeResult DescribeTable (TTestActorRuntime& runtime, TActorId sender, const TString & path)
187+ NKikimrScheme::TEvDescribeSchemeResult DescribeTable (TTestActorRuntime& runtime, TActorId sender, const TString& path)
166188{
167189 TAutoPtr<IEventHandle> handle;
168190
@@ -175,7 +197,7 @@ NKikimrScheme::TEvDescribeSchemeResult DescribeTable(TTestActorRuntime& runtime,
175197 return *reply->MutableRecord ();
176198}
177199
178- TVector<ui64> GetTableShards (TTestActorRuntime& runtime, TActorId sender, const TString & path)
200+ TVector<ui64> GetTableShards (TTestActorRuntime& runtime, TActorId sender, const TString& path)
179201{
180202 TVector<ui64> shards;
181203 auto lsResult = DescribeTable (runtime, sender, path);
@@ -185,7 +207,7 @@ TVector<ui64> GetTableShards(TTestActorRuntime& runtime, TActorId sender, const
185207 return shards;
186208}
187209
188- TVector<ui64> GetColumnTableShards (TTestActorRuntime& runtime, TActorId sender,const TString & path)
210+ TVector<ui64> GetColumnTableShards (TTestActorRuntime& runtime, TActorId sender, const TString& path)
189211{
190212 TVector<ui64> shards;
191213 auto lsResult = DescribeTable (runtime, sender, path);
@@ -301,6 +323,42 @@ std::vector<TTableInfo> CreateDatabaseColumnTables(TTestEnv& env, ui8 tableCount
301323 return ret;
302324}
303325
326+ std::vector<TTableInfo> CreateServerlessDatabaseColumnTables (TTestEnv& env, ui8 tableCount, ui8 shardCount) {
327+ auto init = [&] () {
328+ CreateDatabase (env, " Shared" );
329+ };
330+ std::thread initThread (init);
331+
332+ auto & runtime = *env.GetServer ().GetRuntime ();
333+ runtime.SimulateSleep (TDuration::Seconds (5 ));
334+ initThread.join ();
335+
336+ TPathId domainKey;
337+ ResolvePathId (runtime, " /Root/Shared" , &domainKey);
338+
339+ auto init2 = [&] () {
340+ CreateServerlessDatabase (env, " Serverless" , domainKey);
341+ for (ui8 tableId = 1 ; tableId <= tableCount; tableId++) {
342+ CreateColumnStoreTable (env, " Serverless" , Sprintf (" Table%u" , tableId), shardCount);
343+ }
344+ };
345+ std::thread init2Thread (init2);
346+
347+ runtime.SimulateSleep (TDuration::Seconds (5 ));
348+ init2Thread.join ();
349+
350+ auto sender = runtime.AllocateEdgeActor ();
351+ std::vector<TTableInfo> ret;
352+ for (ui8 tableId = 1 ; tableId <= tableCount; tableId++) {
353+ TTableInfo tableInfo;
354+ const TString path = Sprintf (" /Root/Serverless/Table%u" , tableId);
355+ tableInfo.ShardIds = GetColumnTableShards (runtime, sender, path);
356+ tableInfo.PathId = ResolvePathId (runtime, path, &tableInfo.DomainKey , &tableInfo.SaTabletId );
357+ ret.emplace_back (tableInfo);
358+ }
359+ return ret;
360+ }
361+
304362void DropTable (TTestEnv& env, const TString& databaseName, const TString& tableName) {
305363 TTableClient client (env.GetDriver ());
306364 auto session = client.CreateSession ().GetValueSync ().GetSession ();
0 commit comments