@@ -5238,7 +5238,7 @@ Y_UNIT_TEST_SUITE(TImportTests) {
5238
5238
std::function<void (TTestBasicRuntime&)> Checker;
5239
5239
};
5240
5240
5241
- TGeneratedChangefeed GenChangefeed (ui64 num = 1 ) {
5241
+ TGeneratedChangefeed GenChangefeed (ui64 num = 1 , bool isPartitioningAvailable = true ) {
5242
5242
const TString changefeedName = TStringBuilder () << " updates_feed" << num;
5243
5243
const auto changefeedPath = TStringBuilder () << " /" << changefeedName;
5244
5244
@@ -5251,10 +5251,10 @@ Y_UNIT_TEST_SUITE(TImportTests) {
5251
5251
5252
5252
const auto topicDesc = R"(
5253
5253
partitioning_settings {
5254
- min_active_partitions: 1
5255
- max_active_partitions: 1
5254
+ min_active_partitions: 2
5255
+ max_active_partitions: 3
5256
5256
auto_partitioning_settings {
5257
- strategy: AUTO_PARTITIONING_STRATEGY_DISABLED
5257
+ strategy: AUTO_PARTITIONING_STRATEGY_SCALE_UP
5258
5258
partition_write_speed {
5259
5259
stabilization_window {
5260
5260
seconds: 300
@@ -5303,40 +5303,50 @@ Y_UNIT_TEST_SUITE(TImportTests) {
5303
5303
attr.emplace (NAttr::EKeys::TOPIC_DESCRIPTION, topicDesc);
5304
5304
return {
5305
5305
{changefeedPath, GenerateTestData ({EPathTypeCdcStream, changefeedDesc, std::move (attr)})},
5306
- [changefeedPath = TString (changefeedPath)](TTestBasicRuntime& runtime) {
5306
+ [changefeedPath = TString (changefeedPath), isPartitioningAvailable ](TTestBasicRuntime& runtime) {
5307
5307
TestDescribeResult (DescribePath (runtime, " /MyRoot/Table" + changefeedPath, false , false , true ), {
5308
5308
NLs::PathExist,
5309
5309
});
5310
5310
TestDescribeResult (DescribePath (runtime, " /MyRoot/Table" + changefeedPath + " /streamImpl" , false , false , true ), {
5311
- NLs::ConsumerExist (" my_consumer" )
5311
+ NLs::ConsumerExist (" my_consumer" ),
5312
+ NLs::MinTopicPartitionsCountEqual (isPartitioningAvailable ? 2 : 1 ),
5313
+ NLs::MaxTopicPartitionsCountEqual (3 ),
5312
5314
});
5313
5315
}
5314
5316
};
5315
5317
}
5316
5318
5317
- TVector<std::function<void (TTestBasicRuntime&)>> GenChangefeeds (THashMap<TString, TTestDataWithScheme>& bucketContent, ui64 count = 1 ) {
5319
+ TVector<std::function<void (TTestBasicRuntime&)>> GenChangefeeds (
5320
+ THashMap<TString, TTestDataWithScheme>& bucketContent,
5321
+ ui64 count = 1 ,
5322
+ bool isPartitioningAvailable = true )
5323
+ {
5318
5324
TVector<std::function<void (TTestBasicRuntime&)>> checkers;
5319
5325
checkers.reserve (count);
5320
5326
for (ui64 i = 1 ; i <= count; ++i) {
5321
- auto genChangefeed = GenChangefeed (i);
5327
+ auto genChangefeed = GenChangefeed (i, isPartitioningAvailable );
5322
5328
bucketContent.emplace (genChangefeed.Changefeed );
5323
5329
checkers.push_back (genChangefeed.Checker );
5324
5330
}
5325
5331
return checkers;
5326
5332
}
5327
5333
5328
- std::function<void (TTestBasicRuntime&)> AddedSchemeCommon (THashMap<TString, TTestDataWithScheme>& bucketContent, const TString& permissions) {
5329
- const auto data = GenerateTestData (R"(
5334
+ std::function<void (TTestBasicRuntime&)> AddedSchemeCommon (
5335
+ THashMap<TString, TTestDataWithScheme>& bucketContent,
5336
+ const TString& permissions,
5337
+ const TString& pkType)
5338
+ {
5339
+ const auto data = GenerateTestData (Sprintf (R"(
5330
5340
columns {
5331
5341
name: "key"
5332
- type { optional_type { item { type_id: UTF8 } } }
5342
+ type { optional_type { item { type_id: %s } } }
5333
5343
}
5334
5344
columns {
5335
5345
name: "value"
5336
5346
type { optional_type { item { type_id: UTF8 } } }
5337
5347
}
5338
5348
primary_key: "key"
5339
- )" , {{ " a " , 1 }}, permissions);
5349
+ )" , pkType. c_str ()), {{pkType == " UTF8 " ? " a " : " " , 1 }}, permissions);
5340
5350
5341
5351
bucketContent.emplace (" " , data);
5342
5352
return [](TTestBasicRuntime& runtime) {
@@ -5346,11 +5356,17 @@ Y_UNIT_TEST_SUITE(TImportTests) {
5346
5356
};
5347
5357
}
5348
5358
5349
- std::function<void (TTestBasicRuntime&)> AddedScheme (THashMap<TString, TTestDataWithScheme>& bucketContent) {
5350
- return AddedSchemeCommon (bucketContent, " " );
5359
+ std::function<void (TTestBasicRuntime&)> AddedScheme (
5360
+ THashMap<TString, TTestDataWithScheme>& bucketContent,
5361
+ const TString& pkType)
5362
+ {
5363
+ return AddedSchemeCommon (bucketContent, " " , pkType);
5351
5364
}
5352
5365
5353
- std::function<void (TTestBasicRuntime&)> AddedSchemeWithPermissions (THashMap<TString, TTestDataWithScheme>& bucketContent) {
5366
+ std::function<void (TTestBasicRuntime&)> AddedSchemeWithPermissions (
5367
+ THashMap<TString, TTestDataWithScheme>& bucketContent,
5368
+ const TString& pkType)
5369
+ {
5354
5370
const auto permissions = R"(
5355
5371
actions {
5356
5372
change_owner: "eve"
@@ -5374,34 +5390,22 @@ Y_UNIT_TEST_SUITE(TImportTests) {
5374
5390
}
5375
5391
}
5376
5392
)" ;
5377
- return AddedSchemeCommon (bucketContent, permissions);
5393
+ return AddedSchemeCommon (bucketContent, permissions, pkType );
5378
5394
}
5379
5395
5380
- using SchemeFunction = std::function<std::function<void (TTestBasicRuntime&)>(THashMap<TString, TTestDataWithScheme>&)>;
5396
+ using SchemeFunction = std::function<std::function<void (TTestBasicRuntime&)>(THashMap<TString, TTestDataWithScheme>&, const TString& )>;
5381
5397
5382
- void TestImportChangefeeds (ui64 countChangefeed, SchemeFunction addedScheme) {
5398
+ void TestImportChangefeeds (ui64 countChangefeed, SchemeFunction addedScheme, const TString& pkType = " UTF8 " ) {
5383
5399
TTestBasicRuntime runtime;
5384
5400
TTestEnv env (runtime);
5385
5401
ui64 txId = 100 ;
5386
5402
runtime.GetAppData ().FeatureFlags .SetEnableChangefeedsImport (true );
5387
5403
runtime.SetLogPriority (NKikimrServices::IMPORT, NActors::NLog::PRI_TRACE);
5388
5404
5389
- const auto data = GenerateTestData (R"(
5390
- columns {
5391
- name: "key"
5392
- type { optional_type { item { type_id: UTF8 } } }
5393
- }
5394
- columns {
5395
- name: "value"
5396
- type { optional_type { item { type_id: UTF8 } } }
5397
- }
5398
- primary_key: "key"
5399
- )" );
5400
-
5401
5405
THashMap<TString, TTestDataWithScheme> bucketContent (countChangefeed + 1 );
5402
5406
5403
- auto checkerTable = addedScheme (bucketContent);
5404
- auto checkersChangefeeds = GenChangefeeds (bucketContent, countChangefeed);
5407
+ auto checkerTable = addedScheme (bucketContent, pkType );
5408
+ auto checkersChangefeeds = GenChangefeeds (bucketContent, countChangefeed, pkType == " UINT32 " || pkType == " UINT64 " );
5405
5409
5406
5410
TPortManager portManager;
5407
5411
const ui16 port = portManager.GetPort ();
@@ -5431,6 +5435,17 @@ Y_UNIT_TEST_SUITE(TImportTests) {
5431
5435
TestImportChangefeeds (1 , AddedScheme);
5432
5436
}
5433
5437
5438
+ // Explicit specification of the number of partitions when creating CDC
5439
+ // is possible only if the first component of the primary key
5440
+ // of the source table is Uint32 or Uint64
5441
+ Y_UNIT_TEST (ChangefeedWithPartitioning) {
5442
+ TestImportChangefeeds (1 , AddedScheme, " UINT32" );
5443
+ }
5444
+
5445
+ Y_UNIT_TEST (ChangefeedsWithPartitioning) {
5446
+ TestImportChangefeeds (3 , AddedScheme, " UINT64" );
5447
+ }
5448
+
5434
5449
Y_UNIT_TEST (Changefeeds) {
5435
5450
TestImportChangefeeds (3 , AddedScheme);
5436
5451
}
0 commit comments