@@ -81,19 +81,24 @@ Y_UNIT_TEST_SUITE(TAsyncIndexTests) {
8181 return ev;
8282 }
8383
84+ template <typename C>
85+ TVector<ui64> MakeTabletIds (const C& partitions) {
86+ TVector<ui64> tabletIds;
87+ for (const auto & x : partitions) {
88+ tabletIds.push_back (x.GetDatashardId ());
89+ }
90+ return tabletIds;
91+ }
92+
8493 TVector<ui64> Prepare (TTestActorRuntime& runtime, const TString& mainTablePath, const TVector<ui32>& recordIds, bool block = false ) {
8594 ui64 mainTableId = 0 ;
8695 TVector<ui64> mainTabletIds;
8796 TVector<std::pair<TString, TString>> rows;
8897
8998 {
9099 auto tableDesc = DescribePath (runtime, mainTablePath, true , true );
91- const auto & tablePartitions = tableDesc.GetPathDescription ().GetTablePartitions ();
92-
93100 mainTableId = tableDesc.GetPathId ();
94- for (const auto & partition : tablePartitions) {
95- mainTabletIds.push_back (partition.GetDatashardId ());
96- }
101+ mainTabletIds = MakeTabletIds (tableDesc.GetPathDescription ().GetTablePartitions ());
97102 }
98103
99104 for (ui32 i : recordIds) {
@@ -183,22 +188,42 @@ Y_UNIT_TEST_SUITE(TAsyncIndexTests) {
183188 return writtenToMainTable;
184189 }
185190
191+ enum ESplitOp {
192+ SPLIT_OP_MAIN = 0x01 ,
193+ SPLIT_OP_INDEX = 0x02 ,
194+ SPLIT_OP_BOTH = 0x03 ,
195+ };
196+
186197 template <typename T>
187- void SplitWithReboots (
198+ void SplitWithReboots (ESplitOp op,
188199 const std::function<void (T&, TTestActorRuntime&)>& init,
189- const std::function<void (T&, TTestActorRuntime&, const TVector<ui64>& tablets )>& split)
200+ const std::function<ui64 (T&, TTestActorRuntime&, const TString&, const TVector<ui64>&)>& split)
190201 {
191202 T t;
192203 t.Run ([&](TTestActorRuntime& runtime, bool & activeZone) {
193204 TVector<ui64> mainTabletIds;
205+ TVector<ui64> indexTabletIds;
206+
194207 {
195208 TInactiveZone inactive (activeZone);
209+ runtime.SetLogPriority (NKikimrServices::CHANGE_EXCHANGE, NActors::NLog::PRI_DEBUG);
196210
197211 init (t, runtime);
212+
213+ auto indexDesc = DescribePrivatePath (runtime, " /MyRoot/Table/UserDefinedIndex/indexImplTable" , true , true );
214+ indexTabletIds = MakeTabletIds (indexDesc.GetPathDescription ().GetTablePartitions ());
198215 mainTabletIds = Prepare (runtime, " /MyRoot/Table" , {1 , 10 , 100 });
199216 }
200217
201- split (t, runtime, mainTabletIds);
218+ TVector<ui64> txIds;
219+ if (op & SPLIT_OP_MAIN) {
220+ txIds.push_back (split (t, runtime, " /MyRoot/Table" , mainTabletIds));
221+ }
222+ if (op & SPLIT_OP_INDEX) {
223+ txIds.push_back (split (t, runtime, " /MyRoot/Table/UserDefinedIndex/indexImplTable" , indexTabletIds));
224+ }
225+ t.TestEnv ->TestWaitNotification (runtime, txIds);
226+
202227 {
203228 TInactiveZone inactive (activeZone);
204229
@@ -219,23 +244,61 @@ Y_UNIT_TEST_SUITE(TAsyncIndexTests) {
219244 }
220245
221246 template <typename T>
222- void SplitWithReboots (const std::function<void (T&, TTestActorRuntime&)>& init) {
223- SplitWithReboots<T>(init, [](T& t, TTestActorRuntime& runtime, const TVector<ui64>& tablets) {
247+ void SplitWithReboots (ESplitOp op, const std::function<void (T&, TTestActorRuntime&)>& init) {
248+ SplitWithReboots<T>(op, init, [](T& t, TTestActorRuntime& runtime, const TString& path , const TVector<ui64>& tablets) {
224249 UNIT_ASSERT_VALUES_EQUAL (tablets.size (), 1 );
225- TestSplitTable (runtime, ++t.TxId , " /MyRoot/Table " , Sprintf (R"(
250+ TestSplitTable (runtime, ++t.TxId , path , Sprintf (R"(
226251 SourceTabletId: %lu
227252 SplitBoundary {
228253 KeyPrefix {
229254 Tuple { Optional { Uint32: 50 } }
230255 }
231256 }
232257 )" , tablets[0 ]));
258+ return t.TxId ;
259+ });
260+ }
261+
262+ Y_UNIT_TEST_WITH_REBOOTS (SplitMainWithReboots) {
263+ SplitWithReboots<T>(SPLIT_OP_MAIN, [](T& t, TTestActorRuntime& runtime) {
264+ TestCreateIndexedTable (runtime, ++t.TxId , " /MyRoot" , R"(
265+ TableDescription {
266+ Name: "Table"
267+ Columns { Name: "key" Type: "Uint32" }
268+ Columns { Name: "indexed" Type: "Uint32" }
269+ KeyColumnNames: ["key"]
270+ }
271+ IndexDescription {
272+ Name: "UserDefinedIndex"
273+ KeyColumnNames: ["indexed"]
274+ Type: EIndexTypeGlobalAsync
275+ }
276+ )" );
277+ t.TestEnv ->TestWaitNotification (runtime, t.TxId );
278+ });
279+ }
280+
281+ Y_UNIT_TEST_WITH_REBOOTS (SplitIndexWithReboots) {
282+ SplitWithReboots<T>(SPLIT_OP_INDEX, [](T& t, TTestActorRuntime& runtime) {
283+ TestCreateIndexedTable (runtime, ++t.TxId , " /MyRoot" , R"(
284+ TableDescription {
285+ Name: "Table"
286+ Columns { Name: "key" Type: "Uint32" }
287+ Columns { Name: "indexed" Type: "Uint32" }
288+ KeyColumnNames: ["key"]
289+ }
290+ IndexDescription {
291+ Name: "UserDefinedIndex"
292+ KeyColumnNames: ["indexed"]
293+ Type: EIndexTypeGlobalAsync
294+ }
295+ )" );
233296 t.TestEnv ->TestWaitNotification (runtime, t.TxId );
234297 });
235298 }
236299
237- Y_UNIT_TEST_WITH_REBOOTS (SplitWithReboots ) {
238- SplitWithReboots<T>([](T& t, TTestActorRuntime& runtime) {
300+ Y_UNIT_TEST_WITH_REBOOTS (SplitBothWithReboots ) {
301+ SplitWithReboots<T>(SPLIT_OP_BOTH, [](T& t, TTestActorRuntime& runtime) {
239302 TestCreateIndexedTable (runtime, ++t.TxId , " /MyRoot" , R"(
240303 TableDescription {
241304 Name: "Table"
@@ -254,7 +317,7 @@ Y_UNIT_TEST_SUITE(TAsyncIndexTests) {
254317 }
255318
256319 Y_UNIT_TEST_WITH_REBOOTS (CdcAndSplitWithReboots) {
257- SplitWithReboots<T>([](T& t, TTestActorRuntime& runtime) {
320+ SplitWithReboots<T>(SPLIT_OP_MAIN, [](T& t, TTestActorRuntime& runtime) {
258321 TestCreateIndexedTable (runtime, ++t.TxId , " /MyRoot" , R"(
259322 TableDescription {
260323 Name: "Table"
@@ -283,19 +346,79 @@ Y_UNIT_TEST_SUITE(TAsyncIndexTests) {
283346 }
284347
285348 template <typename T>
286- void MergeWithReboots (const std::function<void (T&, TTestActorRuntime&)>& init) {
287- SplitWithReboots<T>(init, [](T& t, TTestActorRuntime& runtime, const TVector<ui64>& tablets) {
349+ void MergeWithReboots (ESplitOp op, const std::function<void (T&, TTestActorRuntime&)>& init) {
350+ SplitWithReboots<T>(op, init, [](T& t, TTestActorRuntime& runtime, const TString& path , const TVector<ui64>& tablets) {
288351 UNIT_ASSERT_VALUES_EQUAL (tablets.size (), 2 );
289- TestSplitTable (runtime, ++t.TxId , " /MyRoot/Table " , Sprintf (R"(
352+ TestSplitTable (runtime, ++t.TxId , path , Sprintf (R"(
290353 SourceTabletId: %lu
291354 SourceTabletId: %lu
292355 )" , tablets[0 ], tablets[1 ]));
356+ return t.TxId ;
357+ });
358+ }
359+
360+ Y_UNIT_TEST_WITH_REBOOTS (MergeMainWithReboots) {
361+ MergeWithReboots<T>(SPLIT_OP_MAIN, [](T& t, TTestActorRuntime& runtime) {
362+ TestCreateIndexedTable (runtime, ++t.TxId , " /MyRoot" , R"(
363+ TableDescription {
364+ Name: "Table"
365+ Columns { Name: "key" Type: "Uint32" }
366+ Columns { Name: "indexed" Type: "Uint32" }
367+ KeyColumnNames: ["key"]
368+ SplitBoundary {
369+ KeyPrefix {
370+ Tuple { Optional { Uint32: 50 } }
371+ }
372+ }
373+ PartitionConfig {
374+ PartitioningPolicy {
375+ MinPartitionsCount: 1
376+ }
377+ }
378+ }
379+ IndexDescription {
380+ Name: "UserDefinedIndex"
381+ KeyColumnNames: ["indexed"]
382+ Type: EIndexTypeGlobalAsync
383+ }
384+ )" );
385+ t.TestEnv ->TestWaitNotification (runtime, t.TxId );
386+ });
387+ }
388+
389+ Y_UNIT_TEST_WITH_REBOOTS (MergeIndexWithReboots) {
390+ MergeWithReboots<T>(SPLIT_OP_INDEX, [](T& t, TTestActorRuntime& runtime) {
391+ TestCreateIndexedTable (runtime, ++t.TxId , " /MyRoot" , R"(
392+ TableDescription {
393+ Name: "Table"
394+ Columns { Name: "key" Type: "Uint32" }
395+ Columns { Name: "indexed" Type: "Uint32" }
396+ KeyColumnNames: ["key"]
397+ }
398+ IndexDescription {
399+ Name: "UserDefinedIndex"
400+ KeyColumnNames: ["indexed"]
401+ Type: EIndexTypeGlobalAsync
402+ IndexImplTableDescription {
403+ SplitBoundary {
404+ KeyPrefix {
405+ Tuple { Optional { Uint32: 50 } }
406+ }
407+ }
408+ PartitionConfig {
409+ PartitioningPolicy {
410+ MinPartitionsCount: 1
411+ }
412+ }
413+ }
414+ }
415+ )" );
293416 t.TestEnv ->TestWaitNotification (runtime, t.TxId );
294417 });
295418 }
296419
297- Y_UNIT_TEST_WITH_REBOOTS (MergeWithReboots ) {
298- MergeWithReboots<T>([](T& t, TTestActorRuntime& runtime) {
420+ Y_UNIT_TEST_WITH_REBOOTS (MergeBothWithReboots ) {
421+ MergeWithReboots<T>(SPLIT_OP_BOTH, [](T& t, TTestActorRuntime& runtime) {
299422 TestCreateIndexedTable (runtime, ++t.TxId , " /MyRoot" , R"(
300423 TableDescription {
301424 Name: "Table"
@@ -317,14 +440,26 @@ Y_UNIT_TEST_SUITE(TAsyncIndexTests) {
317440 Name: "UserDefinedIndex"
318441 KeyColumnNames: ["indexed"]
319442 Type: EIndexTypeGlobalAsync
443+ IndexImplTableDescription {
444+ SplitBoundary {
445+ KeyPrefix {
446+ Tuple { Optional { Uint32: 50 } }
447+ }
448+ }
449+ PartitionConfig {
450+ PartitioningPolicy {
451+ MinPartitionsCount: 1
452+ }
453+ }
454+ }
320455 }
321456 )" );
322457 t.TestEnv ->TestWaitNotification (runtime, t.TxId );
323458 });
324459 }
325460
326461 Y_UNIT_TEST_WITH_REBOOTS (CdcAndMergeWithReboots) {
327- MergeWithReboots<T>([](T& t, TTestActorRuntime& runtime) {
462+ MergeWithReboots<T>(SPLIT_OP_MAIN, [](T& t, TTestActorRuntime& runtime) {
328463 TestCreateIndexedTable (runtime, ++t.TxId , " /MyRoot" , R"(
329464 TableDescription {
330465 Name: "Table"
0 commit comments