From 4097eb04e11693135bcd60e416f6bc38f2301262 Mon Sep 17 00:00:00 2001 From: Alexander Zalyalov Date: Fri, 7 Nov 2025 15:30:30 +0000 Subject: [PATCH] test for invalid reassign --- ydb/core/mind/hive/hive_ut.cpp | 63 ++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/ydb/core/mind/hive/hive_ut.cpp b/ydb/core/mind/hive/hive_ut.cpp index 3cf9b5f5e17d..44b194f0c302 100644 --- a/ydb/core/mind/hive/hive_ut.cpp +++ b/ydb/core/mind/hive/hive_ut.cpp @@ -8229,6 +8229,69 @@ Y_UNIT_TEST_SUITE(THiveTest) { } } + Y_UNIT_TEST(TestReassignNonexistentTablet) { + TTestBasicRuntime runtime(1, false); + Setup(runtime, true); + + const ui64 hiveTablet = MakeDefaultHiveID(); + const ui64 testerTablet = MakeTabletID(false, 1); + const TActorId hiveActor = CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::Hive), &CreateDefaultHive); + runtime.EnableScheduleForActor(hiveActor); + MakeSureTabletIsUp(runtime, hiveTablet, 0); + TActorId sender = runtime.AllocateEdgeActor(0); + + { + TDispatchOptions options; + options.FinalEvents.emplace_back(TEvLocal::EvSyncTablets); + runtime.DispatchEvents(options); + } + + THolder createTablet = MakeHolder(testerTablet, 1, TTabletTypes::Dummy, BINDED_CHANNELS); + ui64 tablet = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(createTablet), 0, true); + + MakeSureTabletIsUp(runtime, tablet, 0); + + { + NActorsProto::TRemoteHttpInfo pb; + pb.SetMethod(HTTP_METHOD_POST); + pb.SetPath("/app"); + auto* p1 = pb.AddQueryParams(); + p1->SetKey("TabletID"); + p1->SetValue(TStringBuilder() << hiveTablet); + auto* p2 = pb.AddQueryParams(); + p2->SetKey("page"); + p2->SetValue("ReassignTablet"); + auto* p3 = pb.AddQueryParams(); + p3->SetKey("tablet"); + p3->SetValue("52"); + runtime.SendToPipe(hiveTablet, sender, new NMon::TEvRemoteHttpInfo(std::move(pb)), 0, GetPipeConfigWithRetries()); + + TAutoPtr handle; + auto resp = runtime.GrabEdgeEventRethrow(handle); + Ctest << "Hive response: " << resp->Json << Endl; + NJson::TJsonValue value; + ReadJsonTree(resp->Json, &value, false); + UNIT_ASSERT_VALUES_EQUAL(value["total"].GetIntegerSafe(), 0); + } + + // this must not block balancer + + { + THolder metrics = MakeHolder(); + NKikimrHive::TTabletMetrics* metric = metrics->Record.AddTabletMetrics(); + metric->SetTabletID(tablet); + metric->MutableResourceUsage()->SetNetwork(9000); + + runtime.SendToPipe(hiveTablet, sender, metrics.Release()); + } + + { + TDispatchOptions options; + options.FinalEvents.push_back(NHive::TEvPrivate::EvBalancerOut); + runtime.DispatchEvents(options); + } + } + Y_UNIT_TEST(TestTabletsStartingCounter) { TTestBasicRuntime runtime(1, false); Setup(runtime, true);