@@ -49,9 +49,9 @@ void SetBackgroundCleaning(TTestActorRuntime &runtime, TTestEnv& env, ui64 schem
49
49
}
50
50
51
51
void AsyncCreateTempTable (TTestActorRuntime& runtime, ui64 schemeShardId, ui64 txId, const TString& workingDir, const TString& scheme, const TActorId& ownerActorId, ui32 nodeIdx) {
52
- auto ev = CreateTableRequest (txId, workingDir, scheme);
52
+ auto ev = CreateIndexedTableRequest (txId, workingDir, scheme);
53
53
auto * tx = ev->Record .MutableTransaction (0 );
54
- auto * desc = tx->MutableCreateTable ();
54
+ auto * desc = tx->MutableCreateIndexedTable ()-> MutableTableDescription ();
55
55
desc->SetTemporary (true );
56
56
ActorIdToProto (ownerActorId, tx->MutableTempTableOwnerActorId ());
57
57
@@ -99,7 +99,7 @@ void CheckTable(
99
99
bool checkExists = true )
100
100
{
101
101
TVector<ui64> shards;
102
- auto description = DescribePrivatePath (runtime, schemeshardId, fullPath, true , true );
102
+ auto description = DescribePrivatePath (runtime, schemeshardId, fullPath, true , true );
103
103
if (!checkExists) {
104
104
UNIT_ASSERT (description.GetStatus () == NKikimrScheme::EStatus::StatusPathDoesNotExist);
105
105
return ;
@@ -131,11 +131,13 @@ Y_UNIT_TEST_SUITE(TSchemeshardBackgroundCleaningTest) {
131
131
132
132
ui64 txId = 100 ;
133
133
TestCreateTempTable (runtime, txId, " /MyRoot" , R"(
134
- Name: "TempTable"
135
- Columns { Name: "key" Type: "Uint64" }
136
- Columns { Name: "value" Type: "Utf8" }
137
- KeyColumnNames: ["key"]
138
- )" , ownerActorId, { NKikimrScheme::StatusAccepted }, 1 );
134
+ TableDescription {
135
+ Name: "TempTable"
136
+ Columns { Name: "key" Type: "Uint64" }
137
+ Columns { Name: "value" Type: "Utf8" }
138
+ KeyColumnNames: ["key"]
139
+ }
140
+ )" , ownerActorId, { NKikimrScheme::StatusAccepted }, 1 );
139
141
140
142
env.TestWaitNotification (runtime, txId);
141
143
@@ -165,12 +167,14 @@ Y_UNIT_TEST_SUITE(TSchemeshardBackgroundCleaningTest) {
165
167
auto ownerActorId = runtime.AllocateEdgeActor (1 );
166
168
167
169
ui64 txId = 100 ;
168
- TestCreateTempTable (runtime, txId, " /MyRoot" , R"(
169
- Name: "TempTable"
170
- Columns { Name: "key" Type: "Uint64" }
171
- Columns { Name: "value" Type: "Utf8" }
172
- KeyColumnNames: ["key"]
173
- )" , ownerActorId, { NKikimrScheme::StatusAccepted }, 1 );
170
+ TestCreateTempTable (runtime, txId, " /MyRoot" ,R"(
171
+ TableDescription {
172
+ Name: "TempTable"
173
+ Columns { Name: "key" Type: "Uint64" }
174
+ Columns { Name: "value" Type: "Utf8" }
175
+ KeyColumnNames: ["key"]
176
+ }
177
+ )" , ownerActorId, { NKikimrScheme::StatusAccepted }, 1 );
174
178
175
179
env.TestWaitNotification (runtime, txId);
176
180
@@ -203,20 +207,24 @@ Y_UNIT_TEST_SUITE(TSchemeshardBackgroundCleaningTest) {
203
207
auto ownerActorId = runtime.AllocateEdgeActor (1 );
204
208
ui64 txId = 100 ;
205
209
TestCreateTempTable (runtime, txId, " /MyRoot" , R"(
206
- Name: "TempTable1"
207
- Columns { Name: "key" Type: "Uint64" }
208
- Columns { Name: "value" Type: "Utf8" }
209
- KeyColumnNames: ["key"]
210
- )" , ownerActorId, { NKikimrScheme::StatusAccepted }, 1 );
210
+ TableDescription {
211
+ Name: "TempTable1"
212
+ Columns { Name: "key" Type: "Uint64" }
213
+ Columns { Name: "value" Type: "Utf8" }
214
+ KeyColumnNames: ["key"]
215
+ }
216
+ )" , ownerActorId, { NKikimrScheme::StatusAccepted }, 1 );
211
217
env.TestWaitNotification (runtime, txId);
212
218
213
219
++txId;
214
220
TestCreateTempTable (runtime, txId, " /MyRoot" , R"(
215
- Name: "TempTable2"
216
- Columns { Name: "key" Type: "Uint64" }
217
- Columns { Name: "value" Type: "Utf8" }
218
- KeyColumnNames: ["key"]
219
- )" , ownerActorId, { NKikimrScheme::StatusAccepted }, 1 );
221
+ TableDescription {
222
+ Name: "TempTable2"
223
+ Columns { Name: "key" Type: "Uint64" }
224
+ Columns { Name: "value" Type: "Utf8" }
225
+ KeyColumnNames: ["key"]
226
+ }
227
+ )" , ownerActorId, { NKikimrScheme::StatusAccepted }, 1 );
220
228
env.TestWaitNotification (runtime, txId);
221
229
222
230
CheckTable (runtime, " /MyRoot/TempTable1" );
@@ -252,21 +260,25 @@ Y_UNIT_TEST_SUITE(TSchemeshardBackgroundCleaningTest) {
252
260
auto ownerActorId1 = runtime.AllocateEdgeActor (1 );
253
261
ui64 txId1 = 100 ;
254
262
TestCreateTempTable (runtime, txId1, " /MyRoot" , R"(
255
- Name: "TempTable1"
256
- Columns { Name: "key" Type: "Uint64" }
257
- Columns { Name: "value" Type: "Utf8" }
258
- KeyColumnNames: ["key"]
259
- )" , ownerActorId1, { NKikimrScheme::StatusAccepted }, 1 );
263
+ TableDescription {
264
+ Name: "TempTable1"
265
+ Columns { Name: "key" Type: "Uint64" }
266
+ Columns { Name: "value" Type: "Utf8" }
267
+ KeyColumnNames: ["key"]
268
+ }
269
+ )" , ownerActorId1, { NKikimrScheme::StatusAccepted }, 1 );
260
270
env.TestWaitNotification (runtime, txId1);
261
271
262
272
auto ownerActorId2 = runtime.AllocateEdgeActor (2 );
263
273
ui64 txId2 = ++txId1;
264
274
TestCreateTempTable (runtime, txId2, " /MyRoot" , R"(
265
- Name: "TempTable2"
266
- Columns { Name: "key" Type: "Uint64" }
267
- Columns { Name: "value" Type: "Utf8" }
268
- KeyColumnNames: ["key"]
269
- )" , ownerActorId2, { NKikimrScheme::StatusAccepted }, 2 );
275
+ TableDescription {
276
+ Name: "TempTable2"
277
+ Columns { Name: "key" Type: "Uint64" }
278
+ Columns { Name: "value" Type: "Utf8" }
279
+ KeyColumnNames: ["key"]
280
+ }
281
+ )" , ownerActorId2, { NKikimrScheme::StatusAccepted }, 2 );
270
282
env.TestWaitNotification (runtime, txId2);
271
283
272
284
CheckTable (runtime, " /MyRoot/TempTable1" );
@@ -305,11 +317,13 @@ Y_UNIT_TEST_SUITE(TSchemeshardBackgroundCleaningTest) {
305
317
306
318
ui64 txId = 100 ;
307
319
TestCreateTempTable (runtime, txId, " /MyRoot" , R"(
308
- Name: "TempTable"
309
- Columns { Name: "key" Type: "Uint64" }
310
- Columns { Name: "value" Type: "Utf8" }
311
- KeyColumnNames: ["key"]
312
- )" , ownerActorId, { NKikimrScheme::StatusAccepted }, 1 );
320
+ TableDescription {
321
+ Name: "TempTable"
322
+ Columns { Name: "key" Type: "Uint64" }
323
+ Columns { Name: "value" Type: "Utf8" }
324
+ KeyColumnNames: ["key"]
325
+ }
326
+ )" , ownerActorId, { NKikimrScheme::StatusAccepted }, 1 );
313
327
314
328
env.TestWaitNotification (runtime, txId);
315
329
@@ -321,4 +335,92 @@ Y_UNIT_TEST_SUITE(TSchemeshardBackgroundCleaningTest) {
321
335
env.SimulateSleep (runtime, TDuration::Seconds (50 ));
322
336
CheckTable (runtime, " /MyRoot/TempTable" , TTestTxConfig::SchemeShard, false );
323
337
}
338
+
339
+ Y_UNIT_TEST (SchemeshardBackgroundCleaningTestSimpleDropIndex) {
340
+ TTestBasicRuntime runtime (3 );
341
+ TTestEnv env (runtime);
342
+
343
+ runtime.SetLogPriority (NKikimrServices::TX_DATASHARD, NLog::PRI_TRACE);
344
+ runtime.SetLogPriority (NKikimrServices::TX_PROXY, NLog::PRI_DEBUG);
345
+ runtime.SetLogPriority (NKikimrServices::FLAT_TX_SCHEMESHARD, NActors::NLog::PRI_TRACE);
346
+
347
+ SetBackgroundCleaning (runtime, env, TTestTxConfig::SchemeShard);
348
+ env.SimulateSleep (runtime, TDuration::Seconds (30 ));
349
+
350
+ auto ownerActorId = runtime.AllocateEdgeActor (1 );
351
+
352
+ ui64 txId = 100 ;
353
+ TestCreateTempTable (runtime, txId, " /MyRoot" , R"(
354
+ TableDescription {
355
+ Name: "TempTable"
356
+ Columns { Name: "key" Type: "Uint64" }
357
+ Columns { Name: "value" Type: "Utf8" }
358
+ KeyColumnNames: ["key"]
359
+ }
360
+ IndexDescription {
361
+ Name: "ValueIndex"
362
+ KeyColumnNames: ["value"]
363
+ }
364
+ )" , ownerActorId, { NKikimrScheme::StatusAccepted }, 1 );
365
+
366
+ env.TestWaitNotification (runtime, txId);
367
+
368
+ CheckTable (runtime, " /MyRoot/TempTable" );
369
+
370
+ TestLs (runtime, " /MyRoot/TempTable/ValueIndex" , TDescribeOptionsBuilder ().SetShowPrivateTable (true ), NLs::PathExist);
371
+
372
+ ++txId;
373
+ TestDropTempTable (runtime, txId, " /MyRoot" , " TempTable" , true );
374
+
375
+ env.SimulateSleep (runtime, TDuration::Seconds (50 ));
376
+ CheckTable (runtime, " /MyRoot/TempTable" , TTestTxConfig::SchemeShard, false );
377
+
378
+ TestLs (runtime, " /MyRoot/TempTable/ValueIndex" , TDescribeOptionsBuilder ().SetShowPrivateTable (true ), NLs::PathNotExist);
379
+ }
380
+
381
+ Y_UNIT_TEST (SchemeshardBackgroundCleaningTestSimpleCleanIndex) {
382
+ TTestBasicRuntime runtime (3 );
383
+ TTestEnv env (runtime);
384
+
385
+ runtime.SetLogPriority (NKikimrServices::TX_DATASHARD, NLog::PRI_TRACE);
386
+ runtime.SetLogPriority (NKikimrServices::TX_PROXY, NLog::PRI_DEBUG);
387
+ runtime.SetLogPriority (NKikimrServices::FLAT_TX_SCHEMESHARD, NActors::NLog::PRI_TRACE);
388
+
389
+ SetBackgroundCleaning (runtime, env, TTestTxConfig::SchemeShard);
390
+ env.SimulateSleep (runtime, TDuration::Seconds (30 ));
391
+
392
+ auto ownerActorId = runtime.AllocateEdgeActor (1 );
393
+
394
+ ui64 txId = 100 ;
395
+ TestCreateTempTable (runtime, txId, " /MyRoot" , R"(
396
+ TableDescription {
397
+ Name: "TempTable"
398
+ Columns { Name: "key" Type: "Uint64" }
399
+ Columns { Name: "value" Type: "Utf8" }
400
+ KeyColumnNames: ["key"]
401
+ }
402
+ IndexDescription {
403
+ Name: "ValueIndex"
404
+ KeyColumnNames: ["value"]
405
+ }
406
+ )" , ownerActorId, { NKikimrScheme::StatusAccepted }, 1 );
407
+
408
+ env.TestWaitNotification (runtime, txId);
409
+
410
+ CheckTable (runtime, " /MyRoot/TempTable" );
411
+
412
+ TestLs (runtime, " /MyRoot/TempTable/ValueIndex" , TDescribeOptionsBuilder ().SetShowPrivateTable (true ), NLs::PathExist);
413
+
414
+ const TActorId proxy = runtime.GetInterconnectProxy (1 , 0 );
415
+ runtime.Send (new IEventHandle (proxy, TActorId (), new TEvInterconnect::TEvDisconnect (), 0 , 0 ), 1 , true );
416
+ TDispatchOptions options;
417
+ options.FinalEvents .emplace_back (TEvInterconnect::EvNodeDisconnected);
418
+ runtime.DispatchEvents (options);
419
+
420
+ env.SimulateSleep (runtime, TDuration::Seconds (50 ));
421
+
422
+ CheckTable (runtime, " /MyRoot/TempTable" , TTestTxConfig::SchemeShard, false );
423
+
424
+ TestLs (runtime, " /MyRoot/TempTable/ValueIndex" , TDescribeOptionsBuilder ().SetShowPrivateTable (true ), NLs::PathNotExist);
425
+ }
324
426
};
0 commit comments