Skip to content

Commit cf0f1f4

Browse files
[+] test
1 parent a5a6abf commit cf0f1f4

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

ydb/public/sdk/cpp/client/ydb_topic/ut/topic_to_table_ut.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ class TFixture : public NUnitTest::TBaseFixture {
4242
void WaitForEvent();
4343
};
4444

45+
struct TAlterTopicParameters {
46+
TMaybe<ui32> PartitionsCount;
47+
};
48+
4549
void SetUp(NUnitTest::TTestContext&) override;
4650

4751
NTable::TSession CreateTableSession();
@@ -67,6 +71,8 @@ class TFixture : public NUnitTest::TBaseFixture {
6771
std::optional<size_t> maxPartitionCount = std::nullopt);
6872
void DescribeTopic(const TString& path);
6973

74+
void AddConsumer(const TString& topic, const TVector<TString>& consumers);
75+
7076
void WriteToTopicWithInvalidTxId(bool invalidTxId);
7177

7278
TTopicWriteSessionPtr CreateTopicWriteSession(const TString& topicPath,
@@ -198,6 +204,7 @@ void TFixture::SetUp(NUnitTest::TTestContext&)
198204
{
199205
NKikimr::Tests::TServerSettings settings = TTopicSdkTestSetup::MakeServerSettings();
200206
settings.SetEnableTopicServiceTx(true);
207+
settings.SetEnablePQConfigTransactionsAtSchemeShard(true);
201208
Setup = std::make_unique<TTopicSdkTestSetup>(TEST_CASE_NAME, settings);
202209

203210
Driver = std::make_unique<TDriver>(Setup->MakeDriver());
@@ -329,6 +336,20 @@ void TFixture::CreateTopic(const TString& path,
329336
Setup->CreateTopic(path, consumer, partitionCount, maxPartitionCount);
330337
}
331338

339+
void TFixture::AddConsumer(const TString& path,
340+
const TVector<TString>& consumers)
341+
{
342+
NTopic::TTopicClient client(GetDriver());
343+
NTopic::TAlterTopicSettings settings;
344+
345+
for (const auto& consumer : consumers) {
346+
settings.BeginAddConsumer(consumer);
347+
}
348+
349+
auto result = client.AlterTopic(path, settings).GetValueSync();
350+
UNIT_ASSERT_C(result.IsSuccess(), result.GetIssues().ToString());
351+
}
352+
332353
void TFixture::DescribeTopic(const TString& path)
333354
{
334355
Setup->DescribeTopic(path);
@@ -871,6 +892,23 @@ void TFixture::RestartLongTxService()
871892
}
872893
}
873894

895+
Y_UNIT_TEST_F(WriteToTopic_Demo_39, TFixture)
896+
{
897+
CreateTopic("topic_A", TEST_CONSUMER);
898+
899+
NTable::TSession tableSession = CreateTableSession();
900+
NTable::TTransaction tx = BeginTx(tableSession);
901+
902+
WriteToTopic("topic_A", TEST_MESSAGE_GROUP_ID, "message #1", &tx);
903+
WriteToTopic("topic_A", TEST_MESSAGE_GROUP_ID, "message #2", &tx);
904+
905+
WaitForAcks("topic_A", TEST_MESSAGE_GROUP_ID);
906+
907+
AddConsumer("topic_A", {"consumer"});
908+
909+
CommitTx(tx, EStatus::SUCCESS);
910+
}
911+
874912
Y_UNIT_TEST_F(WriteToTopic_Demo_1, TFixture)
875913
{
876914
CreateTopic("topic_A");

0 commit comments

Comments
 (0)