@@ -445,6 +445,15 @@ Y_UNIT_TEST_SUITE(THealthCheckTest) {
445
445
UNIT_ASSERT_VALUES_EQUAL (issueVdiscCount, issueVdiscNumber);
446
446
}
447
447
448
+ bool HasTabletIssue (const Ydb::Monitoring::SelfCheckResult& result) {
449
+ for (const auto & issue_log : result.issue_log ()) {
450
+ if (issue_log.level () == 4 && issue_log.type () == " TABLET" ) {
451
+ return true ;
452
+ }
453
+ }
454
+ return false ;
455
+ }
456
+
448
457
void ListingTest (int const groupNumber, int const vdiscPerGroupNumber, bool const isMergeRecords = false ) {
449
458
auto result = RequestHc (groupNumber, vdiscPerGroupNumber, isMergeRecords);
450
459
CheckHcResult (result, groupNumber, vdiscPerGroupNumber, isMergeRecords);
@@ -864,6 +873,15 @@ Y_UNIT_TEST_SUITE(THealthCheckTest) {
864
873
}
865
874
}
866
875
876
+ void AddBadServerlessTablet (TEvHive::TEvResponseHiveInfo::TPtr* ev) {
877
+ auto &record = (*ev)->Get ()->Record ;
878
+ auto * tablet = record.MutableTablets ()->Add ();
879
+ tablet->SetTabletID (1 );
880
+ tablet->MutableObjectDomain ()->SetSchemeShard (SERVERLESS_DOMAIN_KEY.OwnerId );
881
+ tablet->MutableObjectDomain ()->SetPathId (SERVERLESS_DOMAIN_KEY.LocalPathId );
882
+ tablet->SetRestartsPerPeriod (500 );
883
+ }
884
+
867
885
Y_UNIT_TEST (SpecificServerless) {
868
886
TPortManager tp;
869
887
ui16 port = tp.GetPort (2134 );
@@ -1163,6 +1181,102 @@ Y_UNIT_TEST_SUITE(THealthCheckTest) {
1163
1181
UNIT_ASSERT (!databaseFoundInResult);
1164
1182
}
1165
1183
1184
+ Y_UNIT_TEST (ServerlessBadTablets) {
1185
+ TPortManager tp;
1186
+ ui16 port = tp.GetPort (2134 );
1187
+ ui16 grpcPort = tp.GetPort (2135 );
1188
+ auto settings = TServerSettings (port)
1189
+ .SetNodeCount (1 )
1190
+ .SetDynamicNodeCount (1 )
1191
+ .SetUseRealThreads (false )
1192
+ .SetDomainName (" Root" );
1193
+ TServer server (settings);
1194
+ server.EnableGRpc (grpcPort);
1195
+ TClient client (settings);
1196
+ TTestActorRuntime& runtime = *server.GetRuntime ();
1197
+
1198
+ auto &dynamicNameserviceConfig = runtime.GetAppData ().DynamicNameserviceConfig ;
1199
+ dynamicNameserviceConfig->MaxStaticNodeId = runtime.GetNodeId (server.StaticNodes () - 1 );
1200
+ dynamicNameserviceConfig->MinDynamicNodeId = runtime.GetNodeId (server.StaticNodes ());
1201
+ dynamicNameserviceConfig->MaxDynamicNodeId = runtime.GetNodeId (server.StaticNodes () + server.DynamicNodes () - 1 );
1202
+
1203
+ ui32 sharedDynNodeId = runtime.GetNodeId (1 );
1204
+
1205
+ bool firstConsoleResponse = true ;
1206
+ auto observerFunc = [&](TAutoPtr<IEventHandle>& ev) {
1207
+ switch (ev->GetTypeRewrite ()) {
1208
+ case NConsole::TEvConsole::EvListTenantsResponse: {
1209
+ auto *x = reinterpret_cast <NConsole::TEvConsole::TEvListTenantsResponse::TPtr*>(&ev);
1210
+ AddPathsToListTenantsResponse (x, { " /Root/serverless" , " /Root/shared" });
1211
+ break ;
1212
+ }
1213
+ case NConsole::TEvConsole::EvGetTenantStatusResponse: {
1214
+ auto *x = reinterpret_cast <NConsole::TEvConsole::TEvGetTenantStatusResponse::TPtr*>(&ev);
1215
+ if (!firstConsoleResponse) {
1216
+ ChangeGetTenantStatusResponse (x, " /Root/serverless" );
1217
+ } else {
1218
+ firstConsoleResponse = false ;
1219
+ ChangeGetTenantStatusResponse (x, " /Root/shared" );
1220
+ }
1221
+ break ;
1222
+ }
1223
+ case TEvTxProxySchemeCache::EvNavigateKeySetResult: {
1224
+ auto *x = reinterpret_cast <TEvTxProxySchemeCache::TEvNavigateKeySetResult::TPtr*>(&ev);
1225
+ ChangeNavigateKeyResultServerless (x, NKikimrSubDomains::EServerlessComputeResourcesModeShared, runtime);
1226
+ break ;
1227
+ }
1228
+ case TEvHive::EvResponseHiveNodeStats: {
1229
+ auto *x = reinterpret_cast <TEvHive::TEvResponseHiveNodeStats::TPtr*>(&ev);
1230
+ ChangeResponseHiveNodeStats (x, sharedDynNodeId);
1231
+ break ;
1232
+ }
1233
+ case TEvHive::EvResponseHiveInfo: {
1234
+ auto *x = reinterpret_cast <TEvHive::TEvResponseHiveInfo::TPtr*>(&ev);
1235
+ AddBadServerlessTablet (x);
1236
+ break ;
1237
+ }
1238
+ case TEvSchemeShard::EvDescribeSchemeResult: {
1239
+ auto *x = reinterpret_cast <NSchemeShard::TEvSchemeShard::TEvDescribeSchemeResult::TPtr*>(&ev);
1240
+ ChangeDescribeSchemeResultServerless (x);
1241
+ break ;
1242
+ }
1243
+ case TEvBlobStorage::EvControllerConfigResponse: {
1244
+ auto *x = reinterpret_cast <TEvBlobStorage::TEvControllerConfigResponse::TPtr*>(&ev);
1245
+ AddGroupVSlotInControllerConfigResponseWithStaticGroup (x, NKikimrBlobStorage::TGroupStatus::FULL, TVDisks (1 ));
1246
+ break ;
1247
+ }
1248
+ case NSysView::TEvSysView::EvGetVSlotsResponse: {
1249
+ auto * x = reinterpret_cast <NSysView::TEvSysView::TEvGetVSlotsResponse::TPtr*>(&ev);
1250
+ AddVSlotsToSysViewResponse (x, 1 , TVDisks (1 ));
1251
+ break ;
1252
+ }
1253
+ case NSysView::TEvSysView::EvGetGroupsResponse: {
1254
+ auto * x = reinterpret_cast <NSysView::TEvSysView::TEvGetGroupsResponse::TPtr*>(&ev);
1255
+ AddGroupsToSysViewResponse (x);
1256
+ break ;
1257
+ }
1258
+ case NSysView::TEvSysView::EvGetStoragePoolsResponse: {
1259
+ auto * x = reinterpret_cast <NSysView::TEvSysView::TEvGetStoragePoolsResponse::TPtr*>(&ev);
1260
+ AddStoragePoolsToSysViewResponse (x);
1261
+ break ;
1262
+ }
1263
+ }
1264
+
1265
+ return TTestActorRuntime::EEventAction::PROCESS;
1266
+ };
1267
+ runtime.SetObserverFunc (observerFunc);
1268
+
1269
+ TActorId sender = runtime.AllocateEdgeActor ();
1270
+ TAutoPtr<IEventHandle> handle;
1271
+
1272
+ auto *request = new NHealthCheck::TEvSelfCheckRequest;
1273
+ request->Request .set_return_verbose_status (true );
1274
+ runtime.Send (new IEventHandle (NHealthCheck::MakeHealthCheckID (), sender, request, 0 ));
1275
+ const auto result = runtime.GrabEdgeEvent <NHealthCheck::TEvSelfCheckResult>(handle)->Result ;
1276
+ Ctest << result.ShortDebugString ();
1277
+ UNIT_ASSERT (HasTabletIssue (result));
1278
+ }
1279
+
1166
1280
Y_UNIT_TEST (DontIgnoreServerlessWithExclusiveNodesWhenNotSpecific) {
1167
1281
TPortManager tp;
1168
1282
ui16 port = tp.GetPort (2134 );
@@ -1858,15 +1972,6 @@ Y_UNIT_TEST_SUITE(THealthCheckTest) {
1858
1972
ShardsQuotaTest (105 , 0 , 0 , Ydb::Monitoring::StatusFlag::GREEN);
1859
1973
}
1860
1974
1861
- bool HasDeadTabletIssue (const Ydb::Monitoring::SelfCheckResult& result) {
1862
- for (const auto & issue_log : result.issue_log ()) {
1863
- if (issue_log.level () == 4 && issue_log.type () == " TABLET" ) {
1864
- return true ;
1865
- }
1866
- }
1867
- return false ;
1868
- }
1869
-
1870
1975
Y_UNIT_TEST (TestTabletIsDead) {
1871
1976
TPortManager tp;
1872
1977
ui16 port = tp.GetPort (2134 );
@@ -1894,7 +1999,7 @@ Y_UNIT_TEST_SUITE(THealthCheckTest) {
1894
1999
auto result = runtime->GrabEdgeEvent <NHealthCheck::TEvSelfCheckResult>(handle)->Result ;
1895
2000
Cerr << result.ShortDebugString ();
1896
2001
1897
- UNIT_ASSERT (HasDeadTabletIssue (result));
2002
+ UNIT_ASSERT (HasTabletIssue (result));
1898
2003
}
1899
2004
1900
2005
Y_UNIT_TEST (TestBootingTabletIsNotDead) {
@@ -1925,7 +2030,7 @@ Y_UNIT_TEST_SUITE(THealthCheckTest) {
1925
2030
auto result = runtime->GrabEdgeEvent <NHealthCheck::TEvSelfCheckResult>(handle)->Result ;
1926
2031
Cerr << result.ShortDebugString ();
1927
2032
1928
- UNIT_ASSERT (!HasDeadTabletIssue (result));
2033
+ UNIT_ASSERT (!HasTabletIssue (result));
1929
2034
}
1930
2035
1931
2036
Y_UNIT_TEST (TestReBootingTabletIsDead) {
@@ -1959,7 +2064,7 @@ Y_UNIT_TEST_SUITE(THealthCheckTest) {
1959
2064
auto result = runtime->GrabEdgeEvent <NHealthCheck::TEvSelfCheckResult>(handle)->Result ;
1960
2065
Cerr << result.ShortDebugString ();
1961
2066
1962
- UNIT_ASSERT (HasDeadTabletIssue (result));
2067
+ UNIT_ASSERT (HasTabletIssue (result));
1963
2068
}
1964
2069
}
1965
2070
}
0 commit comments