Skip to content

Add test for CDC topic control plane #11899

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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