diff options
author | stanislav_shchetinin <st-shchetinin@ydb.tech> | 2025-07-16 16:03:13 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-07-16 16:03:13 +0300 |
commit | 8a54d2e8cc500770f51a93397d4296e2b5ac1e79 (patch) | |
tree | db5ccac082743991215c81097746f1529e486fb4 | |
parent | 0e204d553dd16f8369f42df0f80b63421e16f6e0 (diff) | |
download | ydb-8a54d2e8cc500770f51a93397d4296e2b5ac1e79.tar.gz |
Bridge Mode in CMS: testing nodes limits (#21190)
-rw-r--r-- | ydb/core/cms/cms_ut.cpp | 89 | ||||
-rw-r--r-- | ydb/core/cms/cms_ut_common.cpp | 4 | ||||
-rw-r--r-- | ydb/core/cms/cms_ut_common.h | 5 | ||||
-rw-r--r-- | ydb/core/testlib/basics/services.cpp | 2 |
4 files changed, 97 insertions, 3 deletions
diff --git a/ydb/core/cms/cms_ut.cpp b/ydb/core/cms/cms_ut.cpp index 60644d366eb..20a8945416c 100644 --- a/ydb/core/cms/cms_ut.cpp +++ b/ydb/core/cms/cms_ut.cpp @@ -2477,6 +2477,95 @@ Y_UNIT_TEST_SUITE(TCmsTest) { env.CheckPermissionRequest("user", true, false, true, true, MODE_KEEP_AVAILABLE, TStatus::DISALLOW_TEMP, MakeAction(TAction::RESTART_SERVICES, env.GetNodeId(5), 60000000, "storage")); } + + Y_UNIT_TEST(BridgeModeNodeLimit) + { + TTestEnvOpts opts(16); + opts.VDisks = 0; + opts.NToSelect = 8; + TCmsTestEnv env(opts.WithBridgeMode()); + + TTestActorRuntime::TEventObserver prev = env.SetObserverFunc([&](TAutoPtr<IEventHandle>& ev) { + if (ev->GetTypeRewrite() == TEvInterconnect::EvNodesInfo) { + auto *x = reinterpret_cast<TEvInterconnect::TEvNodesInfo::TPtr*>(&ev); + ChangePileMap(x); + } + return prev(ev); + }); + + // set limit + NKikimrCms::TCmsConfig config; + config.MutableClusterLimits()->SetDisabledNodesLimit(1); + env.SetCmsConfig(config); + + // Pile #1: We can lock one node. + env.CheckPermissionRequest("user", true, false, true, true, MODE_KEEP_AVAILABLE, TStatus::ALLOW, + MakeAction(TAction::RESTART_SERVICES, env.GetNodeId(0), 60000000, "storage")); + // Pile #0: We can lock one node. + env.CheckPermissionRequest("user", true, false, true, true, MODE_KEEP_AVAILABLE, TStatus::ALLOW, + MakeAction(TAction::RESTART_SERVICES, env.GetNodeId(9), 60000000, "storage")); + // Pile #1: We cannot lock more than one node. + env.CheckPermissionRequest("user", true, false, true, true, MODE_KEEP_AVAILABLE, TStatus::DISALLOW_TEMP, + MakeAction(TAction::RESTART_SERVICES, env.GetNodeId(2), 60000000, "storage")); + // Pile #0: We cannot lock more than one node. + env.CheckPermissionRequest("user", true, false, true, true, MODE_KEEP_AVAILABLE, TStatus::DISALLOW_TEMP, + MakeAction(TAction::RESTART_SERVICES, env.GetNodeId(11), 60000000, "storage")); + } + + Y_UNIT_TEST(BridgeModeSysTablets) { + TTestEnvOpts opts(12, 0); + TCmsTestEnv env(opts.WithBridgeMode(2, true)); + env.EnableSysNodeChecking(); + + TTestActorRuntime::TEventObserver prev = env.SetObserverFunc([&](TAutoPtr<IEventHandle>& ev) { + if (ev->GetTypeRewrite() == TEvInterconnect::EvNodesInfo) { + auto *x = reinterpret_cast<TEvInterconnect::TEvNodesInfo::TPtr*>(&ev); + ChangePileMap(x); + } + return prev(ev); + }); + + // Locking 3 nodes in each pile + env.CheckPermissionRequest("user", false, false, false, true, MODE_MAX_AVAILABILITY, TStatus::ALLOW, + MakeAction(TAction::RESTART_SERVICES, env.GetNodeId(0), 60000000, "storage")); + env.CheckPermissionRequest("user", false, false, false, true, MODE_MAX_AVAILABILITY, TStatus::ALLOW, + MakeAction(TAction::RESTART_SERVICES, env.GetNodeId(2), 60000000, "storage")); + env.CheckPermissionRequest("user", false, false, false, true, MODE_MAX_AVAILABILITY, TStatus::ALLOW, + MakeAction(TAction::RESTART_SERVICES, env.GetNodeId(4), 60000000, "storage")); + + env.CheckPermissionRequest("user", false, false, false, true, MODE_MAX_AVAILABILITY, TStatus::ALLOW, + MakeAction(TAction::RESTART_SERVICES, env.GetNodeId(1), 60000000, "storage")); + env.CheckPermissionRequest("user", false, false, false, true, MODE_MAX_AVAILABILITY, TStatus::ALLOW, + MakeAction(TAction::RESTART_SERVICES, env.GetNodeId(3), 60000000, "storage")); + env.CheckPermissionRequest("user", false, false, false, true, MODE_MAX_AVAILABILITY, TStatus::ALLOW, + MakeAction(TAction::RESTART_SERVICES, env.GetNodeId(5), 60000000, "storage")); + + // Pile #1: tablet 'FLAT_BS_CONTROLLER' has too many unavailable nodes. Locked: 3, down: 0, limit: 3 + env.CheckPermissionRequest("user", false, false, false, true, MODE_MAX_AVAILABILITY, TStatus::DISALLOW_TEMP, + MakeAction(TAction::RESTART_SERVICES, env.GetNodeId(6), 60000000, "storage")); + // Pile #2: tablet 'FLAT_BS_CONTROLLER' has too many unavailable nodes. Locked: 3, down: 0, limit: 3 + env.CheckPermissionRequest("user", false, false, false, true, MODE_MAX_AVAILABILITY, TStatus::DISALLOW_TEMP, + MakeAction(TAction::RESTART_SERVICES, env.GetNodeId(7), 60000000, "storage")); + + // Locking 5 nodes in each pile (MODE_KEEP_AVAILABLE) + env.CheckPermissionRequest("user", false, false, false, true, MODE_KEEP_AVAILABLE, TStatus::ALLOW, + MakeAction(TAction::RESTART_SERVICES, env.GetNodeId(6), 60000000, "storage")); + env.CheckPermissionRequest("user", false, false, false, true, MODE_KEEP_AVAILABLE, TStatus::ALLOW, + MakeAction(TAction::RESTART_SERVICES, env.GetNodeId(7), 60000000, "storage")); + + env.CheckPermissionRequest("user", false, false, false, true, MODE_KEEP_AVAILABLE, TStatus::ALLOW, + MakeAction(TAction::RESTART_SERVICES, env.GetNodeId(8), 60000000, "storage")); + env.CheckPermissionRequest("user", false, false, false, true, MODE_KEEP_AVAILABLE, TStatus::ALLOW, + MakeAction(TAction::RESTART_SERVICES, env.GetNodeId(9), 60000000, "storage")); + + // Pile #1: tablet 'FLAT_BS_CONTROLLER' has too many unavailable nodes. Locked: 5, down: 0, limit: 5 (MODE_KEEP_AVAILABLE) + env.CheckPermissionRequest("user", false, false, false, true, MODE_KEEP_AVAILABLE, TStatus::DISALLOW_TEMP, + MakeAction(TAction::RESTART_SERVICES, env.GetNodeId(10), 60000000, "storage")); + // Pile #0: tablet 'FLAT_BS_CONTROLLER' has too many unavailable nodes. Locked: 5, down: 0, limit: 5 (MODE_KEEP_AVAILABLE) + env.CheckPermissionRequest("user", false, false, false, true, MODE_KEEP_AVAILABLE, TStatus::DISALLOW_TEMP, + MakeAction(TAction::RESTART_SERVICES, env.GetNodeId(11), 60000000, "storage")); + + } } } diff --git a/ydb/core/cms/cms_ut_common.cpp b/ydb/core/cms/cms_ut_common.cpp index ec86e63462a..fcec4caf4e4 100644 --- a/ydb/core/cms/cms_ut_common.cpp +++ b/ydb/core/cms/cms_ut_common.cpp @@ -658,7 +658,9 @@ TCmsTestEnv::TCmsTestEnv(const TTestEnvOpts &options) for (ui32 i = 1; i <= GetNodeCount(); ++i) { ringGroupIdToNodeIds[i % options.PileCount].push_back(i - 1); } - auto setuper = CreateCustomStateStorageSetupper(ringGroups, ringGroupIdToNodeIds); + auto setuper = options.EnableSimpleStateStorageConfig + ? CreateCustomStateStorageSetupper(ringGroups, 3) + : CreateCustomStateStorageSetupper(ringGroups, ringGroupIdToNodeIds); for (ui32 nodeIndex = 0; nodeIndex < GetNodeCount(); ++nodeIndex) { setuper(*this, nodeIndex); diff --git a/ydb/core/cms/cms_ut_common.h b/ydb/core/cms/cms_ut_common.h index 6fc7dfe9a09..9a9a8338ee7 100644 --- a/ydb/core/cms/cms_ut_common.h +++ b/ydb/core/cms/cms_ut_common.h @@ -94,6 +94,7 @@ struct TTestEnvOpts { bool EnableSingleCompositeActionGroup; bool EnableDynamicGroups; bool IsBridgeMode; + bool EnableSimpleStateStorageConfig; using TNodeLocationCallback = std::function<TNodeLocation(ui32)>; TNodeLocationCallback NodeLocationCallback; @@ -118,6 +119,7 @@ struct TTestEnvOpts { , EnableSingleCompositeActionGroup(true) , EnableDynamicGroups(false) , IsBridgeMode(false) + , EnableSimpleStateStorageConfig(false) { } @@ -146,9 +148,10 @@ struct TTestEnvOpts { return *this; } - TTestEnvOpts& WithBridgeMode(ui32 pileCount = 2) { + TTestEnvOpts& WithBridgeMode(ui32 pileCount = 2, bool enableSimpleStateStorageConfig = false) { IsBridgeMode = true; PileCount = pileCount; + EnableSimpleStateStorageConfig = enableSimpleStateStorageConfig; return *this; } }; diff --git a/ydb/core/testlib/basics/services.cpp b/ydb/core/testlib/basics/services.cpp index a2bf1af4fbc..1f89bd35d12 100644 --- a/ydb/core/testlib/basics/services.cpp +++ b/ydb/core/testlib/basics/services.cpp @@ -320,7 +320,7 @@ namespace NPDisk { namespace { void AddReplicas(TStateStorageInfo::TRingGroup& group, const TVector<TActorId>& replicas) { - group.NToSelect = group.NToSelect ?: replicas.size(); + group.NToSelect = group.NToSelect ? group.NToSelect : replicas.size(); group.Rings.resize(replicas.size()); for (size_t i = 0; i < replicas.size(); ++i) { // one replica per ring |