@@ -498,6 +498,104 @@ Y_UNIT_TEST_SUITE(TopicAutoscaling) {
498498 status = client.CommitOffset (TEST_TOPIC, 0 , TEST_CONSUMER, 0 ).GetValueSync ();
499499 UNIT_ASSERT_VALUES_EQUAL_C (NYdb::EStatus::BAD_REQUEST, status.GetStatus (), " The consumer cannot commit an offset for inactive, read-to-the-end partitions." );
500500 }
501+
502+ Y_UNIT_TEST (CreateAlterDescribe) {
503+ auto autoscalingTestTopic = " autoscalit-topic" ;
504+ TTopicSdkTestSetup setup = CreateSetup ();
505+ TTopicClient client = setup.MakeClient ();
506+
507+ auto minParts = 5 ;
508+ auto maxParts = 10 ;
509+ auto scaleUpPercent = 80 ;
510+ auto scaleDownPercent = 20 ;
511+ auto threshold = 500 ;
512+ auto strategy = EAutoscalingStrategy::ScaleUp;
513+
514+ TCreateTopicSettings createSettings;
515+ createSettings
516+ .BeginConfigurePartitioningSettings ()
517+ .MinActivePartitions (minParts)
518+ .MaxActivePartitions (maxParts)
519+ .BeginConfigureAutoscalingSettings ()
520+ .ScaleUpThresholdPercent (scaleUpPercent)
521+ .ScaleDownThresholdPercent (scaleDownPercent)
522+ .ThresholdTime (TDuration::Seconds (threshold))
523+ .Strategy (strategy)
524+ .EndConfigureAutoscalingSettings ()
525+ .EndConfigurePartitioningSettings ();
526+ client.CreateTopic (autoscalingTestTopic, createSettings).Wait ();
527+
528+ TDescribeTopicSettings descSettings;
529+
530+ auto describe = client.DescribeTopic (autoscalingTestTopic, descSettings).GetValueSync ();
531+ UNIT_ASSERT_VALUES_EQUAL_C (describe.GetStatus (), NYdb::EStatus::SUCCESS, describe.GetIssues ().ToString ());
532+
533+
534+ UNIT_ASSERT_VALUES_EQUAL (describe.GetTopicDescription ().GetPartitioningSettings ().GetMinActivePartitions (), minParts);
535+ UNIT_ASSERT_VALUES_EQUAL (describe.GetTopicDescription ().GetPartitioningSettings ().GetMaxActivePartitions (), maxParts);
536+ UNIT_ASSERT_VALUES_EQUAL (describe.GetTopicDescription ().GetPartitioningSettings ().GetAutoscalingSettings ().GetStrategy (), strategy);
537+ UNIT_ASSERT_VALUES_EQUAL (describe.GetTopicDescription ().GetPartitioningSettings ().GetAutoscalingSettings ().GetScaleDownThresholdPercent (), scaleDownPercent);
538+ UNIT_ASSERT_VALUES_EQUAL (describe.GetTopicDescription ().GetPartitioningSettings ().GetAutoscalingSettings ().GetScaleUpThresholdPercent (), scaleUpPercent);
539+ UNIT_ASSERT_VALUES_EQUAL (describe.GetTopicDescription ().GetPartitioningSettings ().GetAutoscalingSettings ().GetThresholdTime ().Seconds (), threshold);
540+
541+ auto alterMinParts = 10 ;
542+ auto alterMaxParts = 20 ;
543+ auto alterScaleUpPercent = 90 ;
544+ auto alterScaleDownPercent = 10 ;
545+ auto alterThreshold = 700 ;
546+ auto alterStrategy = EAutoscalingStrategy::ScaleUpAndDown;
547+
548+ TAlterTopicSettings alterSettings;
549+ alterSettings
550+ .BeginAlterPartitioningSettings ()
551+ .MinActivePartitions (alterMinParts)
552+ .MaxActivePartitions (alterMaxParts)
553+ .BeginAlterAutoscalingSettings ()
554+ .ScaleDownThresholdPercent (alterScaleDownPercent)
555+ .ScaleUpThresholdPercent (alterScaleUpPercent)
556+ .ThresholdTime (TDuration::Seconds (alterThreshold))
557+ .Strategy (alterStrategy)
558+ .EndAlterAutoscalingSettings ()
559+ .EndAlterTopicPartitioningSettings ();
560+
561+ client.AlterTopic (autoscalingTestTopic, alterSettings).Wait ();
562+
563+ auto describeAfterAlter = client.DescribeTopic (autoscalingTestTopic).GetValueSync ();
564+
565+ UNIT_ASSERT_VALUES_EQUAL (describeAfterAlter.GetTopicDescription ().GetPartitioningSettings ().GetMinActivePartitions (), alterMinParts);
566+ UNIT_ASSERT_VALUES_EQUAL (describeAfterAlter.GetTopicDescription ().GetPartitioningSettings ().GetMaxActivePartitions (), alterMaxParts);
567+ UNIT_ASSERT_VALUES_EQUAL (describeAfterAlter.GetTopicDescription ().GetPartitioningSettings ().GetAutoscalingSettings ().GetStrategy (), alterStrategy);
568+ UNIT_ASSERT_VALUES_EQUAL (describeAfterAlter.GetTopicDescription ().GetPartitioningSettings ().GetAutoscalingSettings ().GetScaleDownThresholdPercent (), alterScaleDownPercent);
569+ UNIT_ASSERT_VALUES_EQUAL (describeAfterAlter.GetTopicDescription ().GetPartitioningSettings ().GetAutoscalingSettings ().GetScaleUpThresholdPercent (), alterScaleUpPercent);
570+ UNIT_ASSERT_VALUES_EQUAL (describeAfterAlter.GetTopicDescription ().GetPartitioningSettings ().GetAutoscalingSettings ().GetThresholdTime ().Seconds (), alterThreshold);
571+ }
572+
573+ Y_UNIT_TEST (PartitionSplit_AutosplitByLoad) {
574+ TTopicSdkTestSetup setup = CreateSetup ();
575+ TTopicClient client = setup.MakeClient ();
576+
577+ TCreateTopicSettings createSettings;
578+ createSettings
579+ .BeginConfigurePartitioningSettings ()
580+ .MinActivePartitions (1 )
581+ .MaxActivePartitions (100 )
582+ .BeginConfigureAutoscalingSettings ()
583+ .ScaleUpThresholdPercent (2 )
584+ .ScaleDownThresholdPercent (1 )
585+ .ThresholdTime (TDuration::Seconds (1 ))
586+ .Strategy (EAutoscalingStrategy::ScaleUp)
587+ .EndConfigureAutoscalingSettings ()
588+ .EndConfigurePartitioningSettings ();
589+ client.CreateTopic (TEST_TOPIC, createSettings).Wait ();
590+
591+ auto msg = TString (" a" , 1_MB);
592+ auto writeSession = CreateWriteSession (client, " producer-1" , 0 );
593+ UNIT_ASSERT (writeSession->Write (Msg (msg, 1 )));
594+ UNIT_ASSERT (writeSession->Write (Msg (msg, 2 )));
595+ Sleep (TDuration::Seconds (5 ));
596+ auto describe = client.DescribeTopic (TEST_TOPIC).GetValueSync ();
597+ UNIT_ASSERT_EQUAL (describe.GetTopicDescription ().GetPartitions ().size (), 3 );
598+ }
501599}
502600
503601} // namespace NKikimr
0 commit comments