Skip to content

Commit 17f9fca

Browse files
committed
add functional test
1 parent 10954f5 commit 17f9fca

File tree

1 file changed

+69
-3
lines changed

1 file changed

+69
-3
lines changed

ydb/tests/functional/transfer/main.cpp

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using namespace NYdb;
1414
using namespace NYdb::NQuery;
1515
using namespace NYdb::NTopic;
16+
using namespace NYdb::NReplication;
1617

1718
namespace {
1819

@@ -188,14 +189,22 @@ struct MainTestCase {
188189
}
189190

190191
auto DescribeTransfer() {
191-
NYdb::NReplication::TReplicationClient client(Driver);
192+
TReplicationClient client(Driver);
192193

193-
NYdb::NReplication::TDescribeReplicationSettings settings;
194+
TDescribeReplicationSettings settings;
194195
settings.IncludeStats(true);
195196

196197
return client.DescribeReplication(TString("/") + GetEnv("YDB_DATABASE") + "/" + TransferName, settings);
197198
}
198199

200+
auto DescribeTopic() {
201+
TDescribeTopicSettings settings;
202+
settings.IncludeLocation(true);
203+
settings.IncludeStats(true);
204+
205+
return TopicClient.DescribeTopic(TopicName, settings);
206+
}
207+
199208
void Write(const TMessage& message) {
200209
TWriteSessionSettings writeSettings;
201210
writeSettings.Path(TopicName);
@@ -255,7 +264,7 @@ struct MainTestCase {
255264
break;
256265
}
257266

258-
UNIT_ASSERT_C(attempt, "Unable to wait replication result");
267+
UNIT_ASSERT_C(attempt, "Unable to wait transfer result");
259268
Sleep(TDuration::Seconds(1));
260269
}
261270
}
@@ -828,6 +837,63 @@ Y_UNIT_TEST_SUITE(Transfer)
828837
{
829838
auto result = testCase.DescribeTransfer().ExtractValueSync();
830839
UNIT_ASSERT_C(!result.IsSuccess(), result.GetIssues().ToOneLineString());
840+
UNIT_ASSERT_VALUES_EQUAL(EStatus::SCHEME_ERROR, result.GetStatus());
841+
}
842+
}
843+
844+
Y_UNIT_TEST(CreateAndDropConsumer)
845+
{
846+
MainTestCase testCase;
847+
testCase.CreateTable(R"(
848+
CREATE TABLE `%s` (
849+
Key Uint64 NOT NULL,
850+
Message Utf8 NOT NULL,
851+
PRIMARY KEY (Key)
852+
) WITH (
853+
STORE = COLUMN
854+
);
855+
)");
856+
857+
testCase.CreateTopic();
858+
testCase.CreateTransfer(R"(
859+
$l = ($x) -> {
860+
return [
861+
<|
862+
Key:CAST($x._offset AS Uint64),
863+
Message:CAST($x._data AS Utf8)
864+
|>
865+
];
866+
};
867+
)");
868+
869+
for (size_t i = 20; i--; ) {
870+
auto result = testCase.DescribeTopic().ExtractValueSync();
871+
UNIT_ASSERT_C(result.IsSuccess(), result.GetIssues().ToOneLineString());
872+
auto& consumers = result.GetTopicDescription().GetConsumers();
873+
if (1 == consumers.size()) {
874+
UNIT_ASSERT_VALUES_EQUAL(1, consumers.size());
875+
Cerr << "Consumer name is '" << consumers[0].GetConsumerName() << "'" << Endl << Flush;
876+
UNIT_ASSERT_VALUES_EQUAL_C(35, consumers[0].GetConsumerName().size(), "Consumer name is random uuid");
877+
break;
878+
}
879+
880+
UNIT_ASSERT_C(i, "Unable to wait consumer has been created");
881+
Sleep(TDuration::Seconds(1));
882+
}
883+
884+
testCase.DropTransfer();
885+
886+
for (size_t i = 20; i--; ) {
887+
auto result = testCase.DescribeTopic().ExtractValueSync();
888+
UNIT_ASSERT_C(result.IsSuccess(), result.GetIssues().ToOneLineString());
889+
auto& consumers = result.GetTopicDescription().GetConsumers();
890+
if (0 == consumers.size()) {
891+
UNIT_ASSERT_VALUES_EQUAL(0, consumers.size());
892+
break;
893+
}
894+
895+
UNIT_ASSERT_C(i, "Unable to wait consumer has been removed");
896+
Sleep(TDuration::Seconds(1));
831897
}
832898
}
833899

0 commit comments

Comments
 (0)