Skip to content

add test for drop transfer #15204

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 1 commit into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
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
8 changes: 7 additions & 1 deletion ydb/public/tools/lib/cmds/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,12 @@ def deploy(arguments):
if kafka_api_port != 0:
optionals['kafka_api_port'] = kafka_api_port

enabled_grpc_services = arguments.enabled_grpc_services.copy() # type: typing.List[str]
if 'YDB_GRPC_SERVICES' in os.environ:
services = os.environ['YDB_GRPC_SERVICES'].split(",")
for service in services:
enabled_grpc_services.append(service)

configuration = KikimrConfigGenerator(
erasure=parse_erasure(arguments),
binary_paths=[arguments.ydb_binary_path] if arguments.ydb_binary_path else None,
Expand All @@ -375,7 +381,7 @@ def deploy(arguments):
use_log_files=not arguments.dont_use_log_files,
default_users=default_users(),
extra_feature_flags=enable_feature_flags,
extra_grpc_services=arguments.enabled_grpc_services,
extra_grpc_services=enabled_grpc_services,
generic_connector_config=generic_connector_config(),
**optionals
)
Expand Down
63 changes: 63 additions & 0 deletions ydb/tests/functional/transfer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <ydb-cpp-sdk/client/topic/client.h>
#include <ydb-cpp-sdk/client/proto/accessor.h>
#include <ydb-cpp-sdk/client/draft/ydb_scripting.h>
#include <ydb-cpp-sdk/client/draft/ydb_replication.h>

#include <library/cpp/threading/local_executor/local_executor.h>

Expand Down Expand Up @@ -179,6 +180,22 @@ struct MainTestCase {
UNIT_ASSERT_C(res.IsSuccess(), res.GetIssues().ToString());
}

void DropTransfer() {
auto res = Session.ExecuteQuery(Sprintf(R"(
DROP TRANSFER `%s`;
)", TransferName.data()), TTxControl::NoTx()).GetValueSync();
UNIT_ASSERT_C(res.IsSuccess(), res.GetIssues().ToString());
}

auto DescribeTransfer() {
NYdb::NReplication::TReplicationClient client(Driver);

NYdb::NReplication::TDescribeReplicationSettings settings;
settings.IncludeStats(true);

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

void Write(const TMessage& message) {
TWriteSessionSettings writeSettings;
writeSettings.Path(TopicName);
Expand Down Expand Up @@ -768,5 +785,51 @@ Y_UNIT_TEST_SUITE(Transfer)
});
}

Y_UNIT_TEST(DropTransfer)
{
MainTestCase testCase;
testCase.Run({
.TableDDL = R"(
CREATE TABLE `%s` (
Key Uint64 NOT NULL,
Message Utf8 NOT NULL,
PRIMARY KEY (Key)
) WITH (
STORE = COLUMN
);
)",

.Lambda = R"(
$l = ($x) -> {
return [
<|
Key:CAST($x._offset AS Uint64),
Message:CAST($x._data AS Utf8)
|>
];
};
)",

.Messages = {{"Message-1"}},

.Expectations = {{
_C("Key", ui64(0)),
_C("Message", TString("Message-1")),
}}
});

{
auto result = testCase.DescribeTransfer().ExtractValueSync();
UNIT_ASSERT_C(result.IsSuccess(), result.GetIssues().ToOneLineString());
}

testCase.DropTransfer();

{
auto result = testCase.DescribeTransfer().ExtractValueSync();
UNIT_ASSERT_C(!result.IsSuccess(), result.GetIssues().ToOneLineString());
}
}

}

1 change: 1 addition & 0 deletions ydb/tests/functional/transfer/ya.make
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ ENV(YDB_USE_IN_MEMORY_PDISKS=true)
ENV(YDB_ERASURE=block_4-2)

ENV(YDB_FEATURE_FLAGS="enable_topic_transfer")
ENV(YDB_GRPC_SERVICES="replication")

PEERDIR(
library/cpp/threading/local_executor
Expand Down
Loading