diff options
author | andrew-rykov <arykov@ydb.tech> | 2023-05-22 12:20:09 +0300 |
---|---|---|
committer | andrew-rykov <arykov@ydb.tech> | 2023-05-22 12:20:09 +0300 |
commit | 7e30013ec8d66953ed20fa0f332a4bcd021756b9 (patch) | |
tree | 741a9b313cb09e7efcb2009646bfc9acc1d8b371 | |
parent | 15a58b55da960ce2000a126854d322f1cd05dd23 (diff) | |
download | ydb-7e30013ec8d66953ed20fa0f332a4bcd021756b9.tar.gz |
added extra tests
added groupIssues counter
added more testes
more tests
-rw-r--r-- | ydb/core/health_check/health_check_ut.cpp | 189 |
1 files changed, 134 insertions, 55 deletions
diff --git a/ydb/core/health_check/health_check_ut.cpp b/ydb/core/health_check/health_check_ut.cpp index 331ad9e05f..d78beec2fd 100644 --- a/ydb/core/health_check/health_check_ut.cpp +++ b/ydb/core/health_check/health_check_ut.cpp @@ -79,7 +79,7 @@ Y_UNIT_TEST_SUITE(THealthCheckTest) { } }; - void AddGroupVSlotInControllerConfigResponse(TEvBlobStorage::TEvControllerConfigResponse::TPtr* ev, int groupCount, int vslotCount) { + void AddGroupVSlotInControllerConfigResponse(TEvBlobStorage::TEvControllerConfigResponse::TPtr* ev, int groupCount, int vslotCount, TString erasurespecies = NHealthCheck::TSelfCheckRequest::BLOCK_4_2) { auto& pbRecord = (*ev)->Get()->Record; auto pbConfig = pbRecord.mutable_response()->mutable_status(0)->mutable_baseconfig(); @@ -88,6 +88,7 @@ Y_UNIT_TEST_SUITE(THealthCheckTest) { auto vslotIdSample = pbConfig->group(0).vslotid(0); pbConfig->clear_group(); pbConfig->clear_vslot(); + pbConfig->clear_pdisk(); auto groupId = GROUP_START_ID; auto vslotId = VCARD_START_ID; @@ -96,7 +97,7 @@ Y_UNIT_TEST_SUITE(THealthCheckTest) { auto group = pbConfig->add_group(); group->CopyFrom(groupSample); group->set_groupid(groupId); - group->set_erasurespecies("block-4-2"); + group->set_erasurespecies(erasurespecies); group->clear_vslotid(); for (int j = 0; j < vslotCount; j++) { @@ -135,7 +136,7 @@ Y_UNIT_TEST_SUITE(THealthCheckTest) { } } - void AddVSlotInVDiskStateResponse(NNodeWhiteboard::TEvWhiteboard::TEvVDiskStateResponse::TPtr* ev, TVector<Ydb::Monitoring::StatusFlag::Status> vdiskStatuses) { + void AddVSlotInVDiskStateResponse(NNodeWhiteboard::TEvWhiteboard::TEvVDiskStateResponse::TPtr* ev, const TVector<Ydb::Monitoring::StatusFlag::Status>& vdiskStatuses) { auto& pbRecord = (*ev)->Get()->Record; auto sample = pbRecord.vdiskstateinfo(0); @@ -151,6 +152,7 @@ Y_UNIT_TEST_SUITE(THealthCheckTest) { state->CopyFrom(sample); state->mutable_vdiskid()->set_vdisk(vslotId++); state->mutable_vdiskid()->set_groupid(groupId); + state->set_pdiskid(100); state->set_vdiskstate(NKikimrWhiteboard::EVDiskState::PDiskError); break; } @@ -159,6 +161,7 @@ Y_UNIT_TEST_SUITE(THealthCheckTest) { state->CopyFrom(sample); state->mutable_vdiskid()->set_vdisk(vslotId++); state->mutable_vdiskid()->set_groupid(groupId); + state->set_pdiskid(100); state->set_vdiskstate(NKikimrWhiteboard::EVDiskState::OK); state->set_replicated(false); break; @@ -168,6 +171,7 @@ Y_UNIT_TEST_SUITE(THealthCheckTest) { state->CopyFrom(sample); state->mutable_vdiskid()->set_vdisk(vslotId++); state->mutable_vdiskid()->set_groupid(groupId); + state->set_pdiskid(100); state->set_vdiskstate(NKikimrWhiteboard::EVDiskState::SyncGuidRecovery); break; } @@ -188,7 +192,7 @@ Y_UNIT_TEST_SUITE(THealthCheckTest) { TServer server(settings); server.EnableGRpc(grpcPort); TClient client(settings); - TTestActorRuntime &runtime = *server.GetRuntime(); + TTestActorRuntime& runtime = *server.GetRuntime(); TActorId sender = runtime.AllocateEdgeActor(); TAutoPtr<IEventHandle> handle; @@ -257,7 +261,7 @@ Y_UNIT_TEST_SUITE(THealthCheckTest) { UNIT_ASSERT_VALUES_EQUAL(issueVdiscCount, issueVdiscNumber); } - Y_UNIT_TEST(OrangeGroupWhenRedBlueVdisks) { + void CheckGroupStatusDependsOnVdisks(TString erasurespecies, const Ydb::Monitoring::StatusFlag::Status expectiongGroupStatus, const TVector<Ydb::Monitoring::StatusFlag::Status>& vdiskStatuses) { TPortManager tp; ui16 port = tp.GetPort(2134); ui16 grpcPort = tp.GetPort(2135); @@ -268,7 +272,7 @@ Y_UNIT_TEST_SUITE(THealthCheckTest) { TServer server(settings); server.EnableGRpc(grpcPort); TClient client(settings); - TTestActorRuntime &runtime = *server.GetRuntime(); + TTestActorRuntime& runtime = *server.GetRuntime(); TActorId sender = runtime.AllocateEdgeActor(); TAutoPtr<IEventHandle> handle; @@ -287,12 +291,17 @@ Y_UNIT_TEST_SUITE(THealthCheckTest) { } case TEvBlobStorage::EvControllerConfigResponse: { auto *x = reinterpret_cast<TEvBlobStorage::TEvControllerConfigResponse::TPtr*>(&ev); - AddGroupVSlotInControllerConfigResponse(x, 1, 2); + AddGroupVSlotInControllerConfigResponse(x, 1, vdiskStatuses.size(), erasurespecies); break; } case NNodeWhiteboard::TEvWhiteboard::EvVDiskStateResponse: { auto *x = reinterpret_cast<NNodeWhiteboard::TEvWhiteboard::TEvVDiskStateResponse::TPtr*>(&ev); - AddVSlotInVDiskStateResponse(x, {Ydb::Monitoring::StatusFlag::RED, Ydb::Monitoring::StatusFlag::BLUE}); + AddVSlotInVDiskStateResponse(x, vdiskStatuses); + break; + } + case NNodeWhiteboard::TEvWhiteboard::EvPDiskStateResponse: { + auto *x = reinterpret_cast<NNodeWhiteboard::TEvWhiteboard::TEvPDiskStateResponse::TPtr*>(&ev); + (*x)->Get()->Record.clear_pdiskstateinfo(); break; } } @@ -304,56 +313,14 @@ Y_UNIT_TEST_SUITE(THealthCheckTest) { auto *request = new NHealthCheck::TEvSelfCheckRequest; runtime.Send(new IEventHandle(NHealthCheck::MakeHealthCheckID(), sender, request, 0)); NHealthCheck::TEvSelfCheckResult* result = runtime.GrabEdgeEvent<NHealthCheck::TEvSelfCheckResult>(handle); - + int groupIssuesCount = 0; for (const auto& issue_log : result->Result.Getissue_log()) { if (issue_log.type() == "STORAGE_GROUP" && issue_log.location().storage().pool().name() == "/Root:test") { - UNIT_ASSERT_VALUES_EQUAL((int)issue_log.status(), (int)Ydb::Monitoring::StatusFlag::ORANGE); + UNIT_ASSERT_VALUES_EQUAL((int)issue_log.status(), (int)expectiongGroupStatus); + groupIssuesCount++; } } - } - - Y_UNIT_TEST(IssuesGroupsListing) { - int groupNumber = NHealthCheck::TSelfCheckRequest::MERGING_IGNORE_SIZE; - ListingTest(groupNumber, 1); - } - - Y_UNIT_TEST(IssuesVCardListing) { - int vcardNumber = NHealthCheck::TSelfCheckRequest::MERGING_IGNORE_SIZE; - ListingTest(1, vcardNumber); - } - - Y_UNIT_TEST(IssuesGroupsVCardListing) { - int groupNumber = NHealthCheck::TSelfCheckRequest::MERGING_IGNORE_SIZE; - int vcardNumber = NHealthCheck::TSelfCheckRequest::MERGING_IGNORE_SIZE; - ListingTest(groupNumber, vcardNumber); - } - - Y_UNIT_TEST(IssuesGroupsMerging) { - int groupNumber = NHealthCheck::TSelfCheckRequest::MERGER_ISSUE_LIMIT; - ListingTest(groupNumber, 1); - } - - Y_UNIT_TEST(IssuesVCardMerging) { - int vcardNumber = NHealthCheck::TSelfCheckRequest::MERGER_ISSUE_LIMIT; - ListingTest(1, vcardNumber); - } - - Y_UNIT_TEST(IssuesGroupsVCardMerging) { - int groupNumber = NHealthCheck::TSelfCheckRequest::MERGER_ISSUE_LIMIT; - int vcardNumber = NHealthCheck::TSelfCheckRequest::MERGER_ISSUE_LIMIT; - ListingTest(groupNumber, vcardNumber); - } - - Y_UNIT_TEST(IssuesGroupsDeleting) { - ListingTest(100, 1); - } - - Y_UNIT_TEST(IssuesVCardDeleting) { - ListingTest(1, 100); - } - - Y_UNIT_TEST(IssuesGroupsVCardDeleting) { - ListingTest(100, 100); + UNIT_ASSERT_VALUES_EQUAL(groupIssuesCount, 1); } void ChangeUsageDescribeSchemeResult(TEvSchemeShard::TEvDescribeSchemeResult::TPtr* ev, ui64 size, ui64 quota) { @@ -378,7 +345,7 @@ Y_UNIT_TEST_SUITE(THealthCheckTest) { TServer server(settings); server.EnableGRpc(grpcPort); TClient client(settings); - TTestActorRuntime &runtime = *server.GetRuntime(); + TTestActorRuntime& runtime = *server.GetRuntime(); TActorId sender = runtime.AllocateEdgeActor(); TAutoPtr<IEventHandle> handle; @@ -410,6 +377,118 @@ Y_UNIT_TEST_SUITE(THealthCheckTest) { UNIT_ASSERT_VALUES_EQUAL(storageIssuesCount, storageIssuesNumber); } + Y_UNIT_TEST(IssuesGroupsListing) { + int groupNumber = NHealthCheck::TSelfCheckRequest::MERGING_IGNORE_SIZE; + ListingTest(groupNumber, 1); + } + + Y_UNIT_TEST(IssuesVCardListing) { + int vcardNumber = NHealthCheck::TSelfCheckRequest::MERGING_IGNORE_SIZE; + ListingTest(1, vcardNumber); + } + + Y_UNIT_TEST(IssuesGroupsVCardListing) { + int groupNumber = NHealthCheck::TSelfCheckRequest::MERGING_IGNORE_SIZE; + int vcardNumber = NHealthCheck::TSelfCheckRequest::MERGING_IGNORE_SIZE; + ListingTest(groupNumber, vcardNumber); + } + + Y_UNIT_TEST(IssuesGroupsMerging) { + int groupNumber = NHealthCheck::TSelfCheckRequest::MERGER_ISSUE_LIMIT; + ListingTest(groupNumber, 1); + } + + Y_UNIT_TEST(IssuesVCardMerging) { + int vcardNumber = NHealthCheck::TSelfCheckRequest::MERGER_ISSUE_LIMIT; + ListingTest(1, vcardNumber); + } + + Y_UNIT_TEST(IssuesGroupsVCardMerging) { + int groupNumber = NHealthCheck::TSelfCheckRequest::MERGER_ISSUE_LIMIT; + int vcardNumber = NHealthCheck::TSelfCheckRequest::MERGER_ISSUE_LIMIT; + ListingTest(groupNumber, vcardNumber); + } + + Y_UNIT_TEST(IssuesGroupsDeleting) { + ListingTest(100, 1); + } + + Y_UNIT_TEST(IssuesVCardDeleting) { + ListingTest(1, 100); + } + + Y_UNIT_TEST(IssuesGroupsVCardDeleting) { + ListingTest(100, 100); + } + + Y_UNIT_TEST(NoneRedGroupWhenRedVdisk) { + CheckGroupStatusDependsOnVdisks(NHealthCheck::TSelfCheckRequest::NONE, Ydb::Monitoring::StatusFlag::RED, {Ydb::Monitoring::StatusFlag::RED}); + } + + Y_UNIT_TEST(NoneRedGroupWhenBlueVdisk) { + CheckGroupStatusDependsOnVdisks(NHealthCheck::TSelfCheckRequest::NONE, Ydb::Monitoring::StatusFlag::RED, {Ydb::Monitoring::StatusFlag::BLUE}); + } + + Y_UNIT_TEST(NoneYellowGroupWhenYellowVdisk) { + CheckGroupStatusDependsOnVdisks(NHealthCheck::TSelfCheckRequest::NONE, Ydb::Monitoring::StatusFlag::YELLOW, {Ydb::Monitoring::StatusFlag::YELLOW}); + } + + Y_UNIT_TEST(Block42RedGroupWhen3RedVdisks) { + CheckGroupStatusDependsOnVdisks(NHealthCheck::TSelfCheckRequest::BLOCK_4_2, Ydb::Monitoring::StatusFlag::RED, {Ydb::Monitoring::StatusFlag::RED, Ydb::Monitoring::StatusFlag::RED, Ydb::Monitoring::StatusFlag::RED}); + } + + Y_UNIT_TEST(Block42RedGroupWhen2RedBlueVdisks) { + CheckGroupStatusDependsOnVdisks(NHealthCheck::TSelfCheckRequest::BLOCK_4_2, Ydb::Monitoring::StatusFlag::RED, {Ydb::Monitoring::StatusFlag::RED, Ydb::Monitoring::StatusFlag::RED, Ydb::Monitoring::StatusFlag::BLUE}); + } + + Y_UNIT_TEST(Block42OrangeGroupWhen2RedVdisks) { + CheckGroupStatusDependsOnVdisks(NHealthCheck::TSelfCheckRequest::BLOCK_4_2, Ydb::Monitoring::StatusFlag::ORANGE, {Ydb::Monitoring::StatusFlag::RED, Ydb::Monitoring::StatusFlag::RED}); + } + + Y_UNIT_TEST(Block42OrangeGroupWhenRedBlueVdisks) { + CheckGroupStatusDependsOnVdisks(NHealthCheck::TSelfCheckRequest::BLOCK_4_2, Ydb::Monitoring::StatusFlag::ORANGE, {Ydb::Monitoring::StatusFlag::RED, Ydb::Monitoring::StatusFlag::BLUE}); + } + + Y_UNIT_TEST(Block42YellowGroupWhenRedVdisk) { + CheckGroupStatusDependsOnVdisks(NHealthCheck::TSelfCheckRequest::BLOCK_4_2, Ydb::Monitoring::StatusFlag::YELLOW, {Ydb::Monitoring::StatusFlag::RED}); + } + + Y_UNIT_TEST(Block42BlueGroupWhenBlueVdisk) { + CheckGroupStatusDependsOnVdisks(NHealthCheck::TSelfCheckRequest::BLOCK_4_2, Ydb::Monitoring::StatusFlag::BLUE, {Ydb::Monitoring::StatusFlag::BLUE}); + } + + Y_UNIT_TEST(Block42YellowGroupWhenYellowVdisk) { + CheckGroupStatusDependsOnVdisks(NHealthCheck::TSelfCheckRequest::BLOCK_4_2, Ydb::Monitoring::StatusFlag::YELLOW, {Ydb::Monitoring::StatusFlag::YELLOW}); + } + + Y_UNIT_TEST(Mirrot3dcYellowGroupWhen3RedVdisks) { + CheckGroupStatusDependsOnVdisks(NHealthCheck::TSelfCheckRequest::MIRROR_3_DC, Ydb::Monitoring::StatusFlag::YELLOW, {Ydb::Monitoring::StatusFlag::RED, Ydb::Monitoring::StatusFlag::RED, Ydb::Monitoring::StatusFlag::RED}); + } + + Y_UNIT_TEST(Mirrot3dcYellowGroupWhen2RedBlueVdisks) { + CheckGroupStatusDependsOnVdisks(NHealthCheck::TSelfCheckRequest::MIRROR_3_DC, Ydb::Monitoring::StatusFlag::YELLOW, {Ydb::Monitoring::StatusFlag::RED, Ydb::Monitoring::StatusFlag::RED, Ydb::Monitoring::StatusFlag::BLUE}); + } + + Y_UNIT_TEST(Mirrot3dcYellowGroupWhen2RedVdisks) { + CheckGroupStatusDependsOnVdisks(NHealthCheck::TSelfCheckRequest::MIRROR_3_DC, Ydb::Monitoring::StatusFlag::YELLOW, {Ydb::Monitoring::StatusFlag::RED, Ydb::Monitoring::StatusFlag::RED}); + } + + Y_UNIT_TEST(Mirrot3dcYellowGroupWhenRedBlueVdisks) { + CheckGroupStatusDependsOnVdisks(NHealthCheck::TSelfCheckRequest::MIRROR_3_DC, Ydb::Monitoring::StatusFlag::YELLOW, {Ydb::Monitoring::StatusFlag::RED, Ydb::Monitoring::StatusFlag::BLUE}); + } + + Y_UNIT_TEST(Mirrot3dcYellowGroupWhenRedVdisk) { + CheckGroupStatusDependsOnVdisks(NHealthCheck::TSelfCheckRequest::MIRROR_3_DC, Ydb::Monitoring::StatusFlag::YELLOW, {Ydb::Monitoring::StatusFlag::RED}); + } + + Y_UNIT_TEST(Mirrot3dcBlueGroupWhenBlueVdisk) { + CheckGroupStatusDependsOnVdisks(NHealthCheck::TSelfCheckRequest::MIRROR_3_DC, Ydb::Monitoring::StatusFlag::BLUE, {Ydb::Monitoring::StatusFlag::BLUE}); + } + + Y_UNIT_TEST(Mirrot3dcYellowGroupWhenYellowVdisk) { + CheckGroupStatusDependsOnVdisks(NHealthCheck::TSelfCheckRequest::MIRROR_3_DC, Ydb::Monitoring::StatusFlag::YELLOW, {Ydb::Monitoring::StatusFlag::YELLOW}); + } + Y_UNIT_TEST(StorageLimit95) { StorageTest(95, 100, 1, Ydb::Monitoring::StatusFlag::RED); } |