Skip to content

Commit

Permalink
Add test for CDC topic control plane (#11899)
Browse files Browse the repository at this point in the history
  • Loading branch information
nshestakov authored Nov 29, 2024
1 parent 38aef7d commit b71bea9
Showing 1 changed file with 86 additions and 0 deletions.
86 changes: 86 additions & 0 deletions ydb/core/persqueue/ut/ut_with_sdk/autoscaling_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,92 @@ Y_UNIT_TEST_SUITE(TopicAutoscaling) {
}
}

Y_UNIT_TEST(ControlPlane_CDC_Enable) {
TTopicSdkTestSetup setup = CreateSetup();
auto tableClient = setup.MakeTableClient();
auto session = tableClient.CreateSession().GetValueSync().GetSession();
auto client = setup.MakeClient();

ExecuteQuery(session, R"(
--!syntax_v1
CREATE TABLE `/Root/origin` (
id Uint64,
value Text,
PRIMARY KEY (id)
);
)");

ExecuteQuery(session, R"(
--!syntax_v1
ALTER TABLE `/Root/origin`
ADD CHANGEFEED `feed` WITH (
MODE = 'UPDATES',
FORMAT = 'JSON',
TOPIC_AUTO_PARTITIONING = 'DISABLED'
);
)");

{
TAlterTopicSettings alterSettings;
alterSettings
.BeginAlterPartitioningSettings()
.MinActivePartitions(3)
.MaxActivePartitions(107)
.BeginAlterAutoPartitioningSettings()
.Strategy(EAutoPartitioningStrategy::ScaleUp)
.EndAlterAutoPartitioningSettings()
.EndAlterTopicPartitioningSettings();
auto f = client.AlterTopic("/Root/origin/feed", alterSettings);
f.Wait();

auto v = f.GetValueSync();
UNIT_ASSERT_C(!v.IsSuccess(), "Error: " << v);
}
}

Y_UNIT_TEST(ControlPlane_CDC_Disable) {
TTopicSdkTestSetup setup = CreateSetup();
auto tableClient = setup.MakeTableClient();
auto session = tableClient.CreateSession().GetValueSync().GetSession();
auto client = setup.MakeClient();

ExecuteQuery(session, R"(
--!syntax_v1
CREATE TABLE `/Root/origin` (
id Uint64,
value Text,
PRIMARY KEY (id)
);
)");

ExecuteQuery(session, R"(
--!syntax_v1
ALTER TABLE `/Root/origin`
ADD CHANGEFEED `feed` WITH (
MODE = 'UPDATES',
FORMAT = 'JSON',
TOPIC_AUTO_PARTITIONING = 'ENABLED'
);
)");

{
TAlterTopicSettings alterSettings;
alterSettings
.BeginAlterPartitioningSettings()
.MinActivePartitions(3)
.MaxActivePartitions(107)
.BeginAlterAutoPartitioningSettings()
.Strategy(EAutoPartitioningStrategy::Disabled)
.EndAlterAutoPartitioningSettings()
.EndAlterTopicPartitioningSettings();
auto f = client.AlterTopic("/Root/origin/feed", alterSettings);
f.Wait();

auto v = f.GetValueSync();
UNIT_ASSERT_C(!v.IsSuccess(), "Error: " << v);
}
}

Y_UNIT_TEST(BalancingAfterSplit_sessionsWithPartition) {
TTopicSdkTestSetup setup = CreateSetup();
setup.CreateTopicWithAutoscale(TEST_TOPIC, TEST_CONSUMER, 1, 100);
Expand Down

0 comments on commit b71bea9

Please sign in to comment.