@@ -168,7 +168,7 @@ struct MainTestCase {
168
168
if (user) {
169
169
config.SetAuthToken (TStringBuilder () << user.value () << " @builtin" );
170
170
}
171
- // config.SetLog(std::unique_ptr<TLogBackend>(CreateLogBackend("cerr", ELogPriority::TLOG_INFO ).Release()))
171
+ // config.SetLog(std::unique_ptr<TLogBackend>(CreateLogBackend("cerr", ELogPriority::TLOG_DEBUG ).Release()));
172
172
return config;
173
173
}
174
174
@@ -184,7 +184,6 @@ struct MainTestCase {
184
184
, TransferName(TStringBuilder() << " Transfer_" << Id)
185
185
, Driver(CreateDriverConfig(ConnectionString, user))
186
186
, TableClient(Driver)
187
- , Session(TableClient.GetSession().GetValueSync().GetSession())
188
187
, TopicClient(Driver)
189
188
{
190
189
}
@@ -193,9 +192,13 @@ struct MainTestCase {
193
192
Driver.Stop (true );
194
193
}
195
194
195
+ auto Session () {
196
+ return TableClient.GetSession ().GetValueSync ().GetSession ();
197
+ }
198
+
196
199
void ExecuteDDL (const std::string& ddl, bool checkResult = true , const std::optional<std::string> expectedMessage = std::nullopt) {
197
200
Cerr << " DDL: " << ddl << Endl << Flush;
198
- auto res = Session.ExecuteQuery (ddl, TTxControl::NoTx ()).GetValueSync ();
201
+ auto res = Session () .ExecuteQuery (ddl, TTxControl::NoTx ()).GetValueSync ();
199
202
if (checkResult) {
200
203
if (expectedMessage) {
201
204
UNIT_ASSERT (!res.IsSuccess ());
@@ -211,7 +214,7 @@ struct MainTestCase {
211
214
auto ExecuteQuery (const std::string& query, bool retry = true ) {
212
215
for (size_t i = 10 ; i--;) {
213
216
Cerr << " >>>>> Query: " << query << Endl << Flush;
214
- auto res = Session.ExecuteQuery (query, TTxControl::NoTx ()).GetValueSync ();
217
+ auto res = Session () .ExecuteQuery (query, TTxControl::NoTx ()).GetValueSync ();
215
218
if (!res.IsSuccess ()) {
216
219
Cerr << " >>>>> Query error: " << res.GetIssues ().ToString () << Endl << Flush;
217
220
}
@@ -282,13 +285,41 @@ struct MainTestCase {
282
285
)" , SourceTableName.data (), ChangefeedName.data ()));
283
286
}
284
287
288
+ struct CreatTopicSettings {
289
+ size_t MinPartitionCount = 1 ;
290
+ size_t MaxPartitionCount = 100 ;
291
+ bool AutoPartitioningEnabled = false ;
292
+ };
293
+
285
294
void CreateTopic (size_t partitionCount = 10 ) {
286
- ExecuteDDL (Sprintf (R"(
287
- CREATE TOPIC `%s`
288
- WITH (
289
- min_active_partitions = %d
290
- );
291
- )" , TopicName.data (), partitionCount));
295
+ CreateTopic ({
296
+ .MinPartitionCount = partitionCount
297
+ });
298
+ }
299
+
300
+ void CreateTopic (const CreatTopicSettings& settings) {
301
+ if (settings.AutoPartitioningEnabled ) {
302
+ ExecuteDDL (Sprintf (R"(
303
+ CREATE TOPIC `%s`
304
+ WITH (
305
+ MIN_ACTIVE_PARTITIONS = %d,
306
+ MAX_ACTIVE_PARTITIONS = %d,
307
+ AUTO_PARTITIONING_STRATEGY = 'UP',
308
+ auto_partitioning_down_utilization_percent = 1,
309
+ auto_partitioning_up_utilization_percent=2,
310
+ auto_partitioning_stabilization_window = Interval('PT1S'),
311
+ partition_write_speed_bytes_per_second = 3
312
+ );
313
+ )" , TopicName.data (), settings.MinPartitionCount , settings.MaxPartitionCount ));
314
+ } else {
315
+ ExecuteDDL (Sprintf (R"(
316
+ CREATE TOPIC `%s`
317
+ WITH (
318
+ MIN_ACTIVE_PARTITIONS = %d
319
+
320
+ );
321
+ )" , TopicName.data (), settings.MinPartitionCount ));
322
+ }
292
323
}
293
324
294
325
void DropTopic () {
@@ -427,7 +458,7 @@ struct MainTestCase {
427
458
setOptions = TStringBuilder () << " SET (" << sb << " )" ;
428
459
}
429
460
430
- auto res = Session.ExecuteQuery (Sprintf (R"(
461
+ auto res = Session () .ExecuteQuery (Sprintf (R"(
431
462
%s;
432
463
433
464
ALTER TRANSFER `%s`
@@ -474,7 +505,7 @@ struct MainTestCase {
474
505
settings.IncludeStats (true );
475
506
476
507
auto c = TopicClient.DescribeConsumer (TopicName, consumerName, settings).GetValueSync ();
477
- UNIT_ASSERT (c.IsSuccess ());
508
+ UNIT_ASSERT_C (c.IsSuccess (), c. GetIssues (). ToOneLineString ());
478
509
return c;
479
510
}
480
511
@@ -554,7 +585,9 @@ struct MainTestCase {
554
585
settings.IncludeLocation (true );
555
586
settings.IncludeStats (true );
556
587
557
- return TopicClient.DescribeTopic (TopicName, settings).ExtractValueSync ();
588
+ auto result = TopicClient.DescribeTopic (TopicName, settings).ExtractValueSync ();
589
+ UNIT_ASSERT_C (result.IsSuccess (), result.GetIssues ().ToOneLineString ());
590
+ return result;
558
591
}
559
592
560
593
void CreateUser (const std::string& username) {
@@ -704,7 +737,6 @@ struct MainTestCase {
704
737
705
738
TDriver Driver;
706
739
TQueryClient TableClient;
707
- TSession Session;
708
740
TTopicClient TopicClient;
709
741
};
710
742
0 commit comments