|
6 | 6 | #include <ydb-cpp-sdk/client/topic/client.h> |
7 | 7 | #include <ydb-cpp-sdk/client/proto/accessor.h> |
8 | 8 | #include <ydb-cpp-sdk/client/draft/ydb_scripting.h> |
| 9 | +#include <ydb-cpp-sdk/client/draft/ydb_replication.h> |
9 | 10 |
|
10 | 11 | #include <library/cpp/threading/local_executor/local_executor.h> |
11 | 12 |
|
@@ -179,6 +180,22 @@ struct MainTestCase { |
179 | 180 | UNIT_ASSERT_C(res.IsSuccess(), res.GetIssues().ToString()); |
180 | 181 | } |
181 | 182 |
|
| 183 | + void DropTransfer() { |
| 184 | + auto res = Session.ExecuteQuery(Sprintf(R"( |
| 185 | + DROP TRANSFER `%s`; |
| 186 | + )", TransferName.data()), TTxControl::NoTx()).GetValueSync(); |
| 187 | + UNIT_ASSERT_C(res.IsSuccess(), res.GetIssues().ToString()); |
| 188 | + } |
| 189 | + |
| 190 | + auto DescribeTransfer() { |
| 191 | + NYdb::NReplication::TReplicationClient client(Driver); |
| 192 | + |
| 193 | + NYdb::NReplication::TDescribeReplicationSettings settings; |
| 194 | + settings.IncludeStats(true); |
| 195 | + |
| 196 | + return client.DescribeReplication(TString("/") + GetEnv("YDB_DATABASE") + "/" + TransferName, settings); |
| 197 | + } |
| 198 | + |
182 | 199 | void Write(const TMessage& message) { |
183 | 200 | TWriteSessionSettings writeSettings; |
184 | 201 | writeSettings.Path(TopicName); |
@@ -768,5 +785,51 @@ Y_UNIT_TEST_SUITE(Transfer) |
768 | 785 | }); |
769 | 786 | } |
770 | 787 |
|
| 788 | + Y_UNIT_TEST(DropTransfer) |
| 789 | + { |
| 790 | + MainTestCase testCase; |
| 791 | + testCase.Run({ |
| 792 | + .TableDDL = R"( |
| 793 | + CREATE TABLE `%s` ( |
| 794 | + Key Uint64 NOT NULL, |
| 795 | + Message Utf8 NOT NULL, |
| 796 | + PRIMARY KEY (Key) |
| 797 | + ) WITH ( |
| 798 | + STORE = COLUMN |
| 799 | + ); |
| 800 | + )", |
| 801 | + |
| 802 | + .Lambda = R"( |
| 803 | + $l = ($x) -> { |
| 804 | + return [ |
| 805 | + <| |
| 806 | + Key:CAST($x._offset AS Uint64), |
| 807 | + Message:CAST($x._data AS Utf8) |
| 808 | + |> |
| 809 | + ]; |
| 810 | + }; |
| 811 | + )", |
| 812 | + |
| 813 | + .Messages = {{"Message-1"}}, |
| 814 | + |
| 815 | + .Expectations = {{ |
| 816 | + _C("Key", ui64(0)), |
| 817 | + _C("Message", TString("Message-1")), |
| 818 | + }} |
| 819 | + }); |
| 820 | + |
| 821 | + { |
| 822 | + auto result = testCase.DescribeTransfer().ExtractValueSync(); |
| 823 | + UNIT_ASSERT_C(result.IsSuccess(), result.GetIssues().ToOneLineString()); |
| 824 | + } |
| 825 | + |
| 826 | + testCase.DropTransfer(); |
| 827 | + |
| 828 | + { |
| 829 | + auto result = testCase.DescribeTransfer().ExtractValueSync(); |
| 830 | + UNIT_ASSERT_C(!result.IsSuccess(), result.GetIssues().ToOneLineString()); |
| 831 | + } |
| 832 | + } |
| 833 | + |
771 | 834 | } |
772 | 835 |
|
0 commit comments