Skip to content

Commit

Permalink
Feature flag for topic transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
nshestakov committed Jan 9, 2025
1 parent bc52487 commit d089f37
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 8 deletions.
1 change: 1 addition & 0 deletions ydb/core/protos/feature_flags.proto
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,5 @@ message TFeatureFlags {
optional bool EnableDataShardInMemoryStateMigrationAcrossGenerations = 160 [default = false];
optional bool DisableLocalDBEraseCache = 161 [default = false];
optional bool EnableExportChecksums = 162 [default = false];
optional bool EnableTopicTransfer = 163 [default = false];
}
1 change: 1 addition & 0 deletions ydb/core/testlib/basics/feature_flags.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class TTestFeatureFlagsHolder {
FEATURE_FLAG_SETTER(EnableTopicAutopartitioningForCDC)
FEATURE_FLAG_SETTER(EnableFollowerStats)
FEATURE_FLAG_SETTER(EnableExportChecksums)
FEATURE_FLAG_SETTER(EnableTopicTransfer)

#undef FEATURE_FLAG_SETTER
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ struct TTransferStrategy : public IStrategy {
};

bool Validate(TProposeResponse& result, const NKikimrSchemeOp::TReplicationDescription& desc) const override {
if (!AppData()->FeatureFlags.GetEnableTopicTransfer()) {
result.SetError(NKikimrScheme::StatusInvalidParameter, "Topic transfer creation is disabled");
return true;
}
if (!desc.GetConfig().HasTransferSpecific()) {
result.SetError(NKikimrScheme::StatusInvalidParameter, "Wrong transfer configuration");
return true;
Expand Down
1 change: 1 addition & 0 deletions ydb/core/tx/schemeshard/ut_helpers/test_env.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ NSchemeShardUT_Private::TTestEnv::TTestEnv(TTestActorRuntime& runtime, const TTe
app.SetEnableTopicAutopartitioningForCDC(opts.EnableTopicAutopartitioningForCDC_);
app.SetEnableBackupService(opts.EnableBackupService_);
app.SetEnableExportChecksums(true);
app.SetEnableTopicTransfer(opts.EnableTopicTransfer_);

app.ColumnShardConfig.SetDisabledOnSchemeShard(false);

Expand Down
1 change: 1 addition & 0 deletions ydb/core/tx/schemeshard/ut_helpers/test_env.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ namespace NSchemeShardUT_Private {
OPTION(std::optional<bool>, EnableParameterizedDecimal, std::nullopt);
OPTION(std::optional<bool>, EnableTopicAutopartitioningForCDC, std::nullopt);
OPTION(std::optional<bool>, EnableBackupService, std::nullopt);
OPTION(std::optional<bool>, EnableTopicTransfer, std::nullopt);

#undef OPTION
};
Expand Down
32 changes: 24 additions & 8 deletions ydb/core/tx/schemeshard/ut_transfer/ut_transfer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Y_UNIT_TEST_SUITE(TTransferTests) {

Y_UNIT_TEST(Create) {
TTestBasicRuntime runtime;
TTestEnv env(runtime, TTestEnvOptions().InitYdbDriver(true));
TTestEnv env(runtime, TTestEnvOptions().InitYdbDriver(true).EnableTopicTransfer(true));
ui64 txId = 100;

SetupLogging(runtime);
Expand All @@ -52,9 +52,25 @@ Y_UNIT_TEST_SUITE(TTransferTests) {
});
}

Y_UNIT_TEST(Create_Disabled) {
TTestBasicRuntime runtime;
TTestEnv env(runtime, TTestEnvOptions().InitYdbDriver(true).EnableTopicTransfer(false));
ui64 txId = 100;

SetupLogging(runtime);

TestCreateTransfer(runtime, ++txId, "/MyRoot", DefaultScheme("Transfer"),
{NKikimrScheme::StatusInvalidParameter});
env.TestWaitNotification(runtime, txId);

TestDescribeResult(DescribePath(runtime, "/MyRoot/Transfer"), {
NLs::PathNotExist
});
}

Y_UNIT_TEST(CreateSequential) {
TTestBasicRuntime runtime;
TTestEnv env(runtime, TTestEnvOptions().InitYdbDriver(true));
TTestEnv env(runtime, TTestEnvOptions().InitYdbDriver(true).EnableTopicTransfer(true));
ui64 txId = 100;

SetupLogging(runtime);
Expand All @@ -80,7 +96,7 @@ Y_UNIT_TEST_SUITE(TTransferTests) {

Y_UNIT_TEST(CreateInParallel) {
TTestBasicRuntime runtime;
TTestEnv env(runtime, TTestEnvOptions().InitYdbDriver(true));
TTestEnv env(runtime, TTestEnvOptions().InitYdbDriver(true).EnableTopicTransfer(true));
ui64 txId = 100;

SetupLogging(runtime);
Expand Down Expand Up @@ -116,7 +132,7 @@ Y_UNIT_TEST_SUITE(TTransferTests) {

Y_UNIT_TEST(CreateDropRecreate) {
TTestBasicRuntime runtime;
TTestEnv env(runtime, TTestEnvOptions().InitYdbDriver(true));
TTestEnv env(runtime, TTestEnvOptions().InitYdbDriver(true).EnableTopicTransfer(true));
ui64 txId = 100;

SetupLogging(runtime);
Expand Down Expand Up @@ -145,7 +161,7 @@ Y_UNIT_TEST_SUITE(TTransferTests) {

Y_UNIT_TEST(CreateWithoutCredentials) {
TTestBasicRuntime runtime;
TTestEnv env(runtime, TTestEnvOptions().InitYdbDriver(true));
TTestEnv env(runtime, TTestEnvOptions().InitYdbDriver(true).EnableTopicTransfer(true));
ui64 txId = 100;

SetupLogging(runtime);
Expand All @@ -170,7 +186,7 @@ Y_UNIT_TEST_SUITE(TTransferTests) {

Y_UNIT_TEST(CreateWrongConfig) {
TTestBasicRuntime runtime;
TTestEnv env(runtime, TTestEnvOptions().InitYdbDriver(true));
TTestEnv env(runtime, TTestEnvOptions().InitYdbDriver(true).EnableTopicTransfer(true));
ui64 txId = 100;

SetupLogging(runtime);
Expand All @@ -195,7 +211,7 @@ Y_UNIT_TEST_SUITE(TTransferTests) {

Y_UNIT_TEST(ConsistencyLevel) {
TTestBasicRuntime runtime;
TTestEnv env(runtime, TTestEnvOptions().InitYdbDriver(true));
TTestEnv env(runtime, TTestEnvOptions().InitYdbDriver(true).EnableTopicTransfer(true));
ui64 txId = 100;

SetupLogging(runtime);
Expand Down Expand Up @@ -266,7 +282,7 @@ Y_UNIT_TEST_SUITE(TTransferTests) {

Y_UNIT_TEST(Alter) {
TTestBasicRuntime runtime;
TTestEnv env(runtime, TTestEnvOptions().InitYdbDriver(true));
TTestEnv env(runtime, TTestEnvOptions().InitYdbDriver(true).EnableTopicTransfer(true));
ui64 txId = 100;

SetupLogging(runtime);
Expand Down

0 comments on commit d089f37

Please sign in to comment.