aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorserg-belyakov <serg-belyakov@yandex-team.com>2023-01-26 10:45:50 +0300
committerserg-belyakov <serg-belyakov@yandex-team.com>2023-01-26 10:45:50 +0300
commitaa2d3064f9f20bb26e88c7bce3845c5e91d735aa (patch)
treed4ee60f141bd4d5c53866fb215fed9a86e33cab0
parentd67291f6f90ba2cce679652aef3a02dd31c696fa (diff)
downloadydb-aa2d3064f9f20bb26e88c7bce3845c5e91d735aa.tar.gz
Add UT for IC version control,
initial
-rw-r--r--library/cpp/actors/testlib/test_runtime.cpp4
-rw-r--r--library/cpp/actors/testlib/test_runtime.h5
-rw-r--r--ydb/core/actorlib_impl/CMakeLists.darwin.txt1
-rw-r--r--ydb/core/actorlib_impl/CMakeLists.linux-aarch64.txt1
-rw-r--r--ydb/core/actorlib_impl/CMakeLists.linux.txt1
-rw-r--r--ydb/core/actorlib_impl/test_interconnect_ut.cpp83
-rw-r--r--ydb/core/testlib/basics/runtime.cpp4
7 files changed, 99 insertions, 0 deletions
diff --git a/library/cpp/actors/testlib/test_runtime.cpp b/library/cpp/actors/testlib/test_runtime.cpp
index 9a4a1b7a2f..ad124bf258 100644
--- a/library/cpp/actors/testlib/test_runtime.cpp
+++ b/library/cpp/actors/testlib/test_runtime.cpp
@@ -1705,6 +1705,10 @@ namespace NActors {
common->ClusterUUID = ClusterUUID;
common->AcceptUUID = {ClusterUUID};
+ if (ICCommonSetupper) {
+ ICCommonSetupper(nodeIndex, common);
+ }
+
for (ui32 proxyNodeIndex = 0; proxyNodeIndex < NodeCount; ++proxyNodeIndex) {
if (proxyNodeIndex == nodeIndex)
continue;
diff --git a/library/cpp/actors/testlib/test_runtime.h b/library/cpp/actors/testlib/test_runtime.h
index 163f6bdfd9..343b417b35 100644
--- a/library/cpp/actors/testlib/test_runtime.h
+++ b/library/cpp/actors/testlib/test_runtime.h
@@ -476,6 +476,10 @@ namespace NActors {
UseRealInterconnect = true;
}
+ void SetICCommonSetupper(std::function<void(ui32, TIntrusivePtr<TInterconnectProxyCommon>)>&& icCommonSetupper) {
+ ICCommonSetupper = std::move(icCommonSetupper);
+ }
+
protected:
struct TNodeDataBase;
TNodeDataBase* GetRawNode(ui32 node) const {
@@ -522,6 +526,7 @@ namespace NActors {
const ui32 NodeCount;
const ui32 DataCenterCount;
const bool UseRealThreads;
+ std::function<void(ui32, TIntrusivePtr<TInterconnectProxyCommon>)> ICCommonSetupper;
ui64 LocalId;
TMutex Mutex;
diff --git a/ydb/core/actorlib_impl/CMakeLists.darwin.txt b/ydb/core/actorlib_impl/CMakeLists.darwin.txt
index 13ca0d3d97..3bb8e6dd5d 100644
--- a/ydb/core/actorlib_impl/CMakeLists.darwin.txt
+++ b/ydb/core/actorlib_impl/CMakeLists.darwin.txt
@@ -29,6 +29,7 @@ target_link_libraries(ydb-core-actorlib_impl PUBLIC
library-cpp-packedtypes
library-cpp-sliding_window
ydb-core-base
+ version
ydb-core-mon
ydb-core-node_whiteboard
ydb-core-protos
diff --git a/ydb/core/actorlib_impl/CMakeLists.linux-aarch64.txt b/ydb/core/actorlib_impl/CMakeLists.linux-aarch64.txt
index a22d40b59e..4a5c4eb794 100644
--- a/ydb/core/actorlib_impl/CMakeLists.linux-aarch64.txt
+++ b/ydb/core/actorlib_impl/CMakeLists.linux-aarch64.txt
@@ -30,6 +30,7 @@ target_link_libraries(ydb-core-actorlib_impl PUBLIC
library-cpp-packedtypes
library-cpp-sliding_window
ydb-core-base
+ version
ydb-core-mon
ydb-core-node_whiteboard
ydb-core-protos
diff --git a/ydb/core/actorlib_impl/CMakeLists.linux.txt b/ydb/core/actorlib_impl/CMakeLists.linux.txt
index a22d40b59e..4a5c4eb794 100644
--- a/ydb/core/actorlib_impl/CMakeLists.linux.txt
+++ b/ydb/core/actorlib_impl/CMakeLists.linux.txt
@@ -30,6 +30,7 @@ target_link_libraries(ydb-core-actorlib_impl PUBLIC
library-cpp-packedtypes
library-cpp-sliding_window
ydb-core-base
+ version
ydb-core-mon
ydb-core-node_whiteboard
ydb-core-protos
diff --git a/ydb/core/actorlib_impl/test_interconnect_ut.cpp b/ydb/core/actorlib_impl/test_interconnect_ut.cpp
index e906aaba34..392ac4b592 100644
--- a/ydb/core/actorlib_impl/test_interconnect_ut.cpp
+++ b/ydb/core/actorlib_impl/test_interconnect_ut.cpp
@@ -3,6 +3,7 @@
#include <library/cpp/actors/interconnect/events_local.h>
#include <ydb/core/testlib/basics/runtime.h>
#include <ydb/core/testlib/basics/appdata.h>
+#include <ydb/core/driver_lib/version/version.h>
#include <library/cpp/actors/core/event_local.h>
#include <library/cpp/actors/core/events.h>
#include <library/cpp/actors/protos/services_common.pb.h>
@@ -699,6 +700,88 @@ Y_UNIT_TEST_SUITE(TInterconnectTest) {
}
}
}
+
+ void TestConnectionWithDifferentVersions(
+ std::shared_ptr<NKikimrConfig::TCurrentCompatibilityInfo> node0,
+ std::shared_ptr<NKikimrConfig::TCurrentCompatibilityInfo> node1) {
+ TTestBasicRuntime runtime(2);
+ runtime.SetUseRealInterconnect();
+ runtime.SetICCommonSetupper([&](ui32 nodeNum, TIntrusivePtr<TInterconnectProxyCommon> common) {
+ common->CompatibilityInfo = TString();
+ NKikimrConfig::TCurrentCompatibilityInfo* current = nullptr;
+ if (nodeNum == 0) {
+ current = node0.get();
+ } else if (nodeNum == 1) {
+ current = node1.get();
+ }
+ Y_VERIFY(current);
+ Y_VERIFY(TCompatibilityInfo::MakeStored(NKikimrConfig::TCompatibilityRule::Interconnect, current)
+ .SerializeToString(&*common->CompatibilityInfo));
+
+ common->ValidateCompatibilityInfo =
+ [=](const TString& peer, TString& errorReason) {
+ NKikimrConfig::TStoredCompatibilityInfo peerPB;
+ if (!peerPB.ParseFromString(peer)) {
+ errorReason = "Cannot parse given CompatibilityInfo";
+ return false;
+ }
+
+ return TCompatibilityInfo::CheckCompatibility(current, &peerPB,
+ (ui32)NKikimrConfig::TCompatibilityRule::Interconnect, errorReason);
+ };
+ });
+ runtime.Initialize(TAppPrepare().Unwrap());
+
+ const auto edge = runtime.AllocateEdgeActor(0);
+ runtime.Send(new IEventHandle(runtime.GetInterconnectProxy(0, 1), edge, new TEvInterconnect::TEvConnectNode), 0, true);
+
+ TAutoPtr<IEventHandle> handle;
+ {
+ const auto event = runtime.GrabEdgeEvent<TEvInterconnect::TEvNodeConnected>(handle);
+ UNIT_ASSERT_EQUAL(event->NodeId, runtime.GetNodeId(1));
+ }
+ }
+
+ Y_UNIT_TEST(OldNbs) {
+ std::shared_ptr<NKikimrConfig::TCurrentCompatibilityInfo> node0 =
+ std::make_shared<NKikimrConfig::TCurrentCompatibilityInfo>();
+ {
+ node0->SetBuild("nbs");
+ auto* version = node0->MutableYdbVersion();
+ version->SetYear(22);
+ version->SetMajor(4);
+ version->SetMinor(1);
+ version->SetHotfix(0);
+ }
+
+ std::shared_ptr<NKikimrConfig::TCurrentCompatibilityInfo> node1 =
+ std::make_shared<NKikimrConfig::TCurrentCompatibilityInfo>();
+ {
+ node1->SetBuild("ydb");
+ auto* version = node1->MutableYdbVersion();
+ version->SetYear(23);
+ version->SetMajor(1);
+ version->SetMinor(1);
+ version->SetHotfix(0);
+
+ {
+ auto* nbsRule = node1->AddCanLoadFrom();
+ nbsRule->SetBuild("nbs");
+ nbsRule->SetComponentId((ui32)NKikimrConfig::TCompatibilityRule::Interconnect);
+
+ auto* bottomLimit = nbsRule->MutableBottomLimit();
+ bottomLimit->SetYear(22);
+ bottomLimit->SetMajor(4);
+
+ nbsRule->MutableUpperLimit()->CopyFrom(*version);
+
+ node1->AddStoresReadableBy()->CopyFrom(*nbsRule);
+ }
+ }
+
+ TestConnectionWithDifferentVersions(node0, node1);
+ TestConnectionWithDifferentVersions(node1, node0);
+ }
}
}
diff --git a/ydb/core/testlib/basics/runtime.cpp b/ydb/core/testlib/basics/runtime.cpp
index cd62ce82bf..282a5a471a 100644
--- a/ydb/core/testlib/basics/runtime.cpp
+++ b/ydb/core/testlib/basics/runtime.cpp
@@ -65,6 +65,10 @@ namespace NActors {
common->ClusterUUID = ClusterUUID;
common->AcceptUUID = {ClusterUUID};
+ if (ICCommonSetupper) {
+ ICCommonSetupper(num, common);
+ }
+
if (UseRealInterconnect) {
auto listener = new TInterconnectListenerTCP(nameNode.first, nameNode.second, common);
AddLocalService({}, TActorSetupCmd(listener, TMailboxType::Simple, InterconnectPoolId()), num);