@@ -2114,7 +2114,7 @@ Y_UNIT_TEST_SUITE(THealthCheckTest) {
2114
2114
TestConfigUpdateNodeRestartsPerPeriod (runtime, sender, nodeRestarts / 5 , nodeRestarts / 2 , nodeId, Ydb::Monitoring::StatusFlag::ORANGE);
2115
2115
}
2116
2116
2117
- Y_UNIT_TEST (LayoutIncorrect ) {
2117
+ void LayoutCorrectTest ( bool layoutCorrect ) {
2118
2118
TPortManager tp;
2119
2119
ui16 port = tp.GetPort (2134 );
2120
2120
ui16 grpcPort = tp.GetPort (2135 );
@@ -2136,13 +2136,11 @@ Y_UNIT_TEST_SUITE(THealthCheckTest) {
2136
2136
auto * x = reinterpret_cast <NSysView::TEvSysView::TEvGetGroupsResponse::TPtr*>(&ev);
2137
2137
auto & record = (*x)->Get ()->Record ;
2138
2138
for (auto & entry : *record.mutable_entries ()) {
2139
- entry.mutable_info ()->set_layoutcorrect (false );
2139
+ entry.mutable_info ()->set_layoutcorrect (layoutCorrect );
2140
2140
}
2141
-
2142
2141
break ;
2143
2142
}
2144
2143
}
2145
-
2146
2144
return TTestActorRuntime::EEventAction::PROCESS;
2147
2145
};
2148
2146
runtime.SetObserverFunc (observerFunc);
@@ -2153,32 +2151,51 @@ Y_UNIT_TEST_SUITE(THealthCheckTest) {
2153
2151
runtime.Send (new IEventHandle (NHealthCheck::MakeHealthCheckID (), sender, request, 0 ));
2154
2152
auto result = runtime.GrabEdgeEvent <NHealthCheck::TEvSelfCheckResult>(handle)->Result ;
2155
2153
2156
- UNIT_ASSERT_VALUES_EQUAL (result.self_check_result (), Ydb::Monitoring::SelfCheck::MAINTENANCE_REQUIRED);
2157
- UNIT_ASSERT_VALUES_EQUAL (result.database_status_size (), 1 );
2158
- const auto &database_status = result.database_status (0 );
2159
-
2160
- UNIT_ASSERT_VALUES_EQUAL (database_status.overall (), Ydb::Monitoring::StatusFlag::ORANGE);
2161
- UNIT_ASSERT_VALUES_EQUAL (database_status.storage ().overall (), Ydb::Monitoring::StatusFlag::ORANGE);
2162
- UNIT_ASSERT_VALUES_EQUAL (database_status.storage ().pools ().size (), 1 );
2163
- UNIT_ASSERT_VALUES_EQUAL (database_status.storage ().pools ()[0 ].overall (), Ydb::Monitoring::StatusFlag::ORANGE);
2164
- UNIT_ASSERT_VALUES_EQUAL (database_status.storage ().pools ()[0 ].groups ().size (), 1 );
2165
- UNIT_ASSERT_VALUES_EQUAL (database_status.storage ().pools ()[0 ].groups ()[0 ].overall (), Ydb::Monitoring::StatusFlag::ORANGE);
2154
+ if (layoutCorrect) {
2155
+ UNIT_ASSERT_VALUES_EQUAL (result.self_check_result (), Ydb::Monitoring::SelfCheck::GOOD);
2156
+ UNIT_ASSERT_VALUES_EQUAL (result.database_status_size (), 1 );
2157
+ const auto &database_status = result.database_status (0 );
2166
2158
2167
- for (const auto &issue_log : result.issue_log ()) {
2168
- if (issue_log.level () == 1 && issue_log.type () == " DATABASE" ) {
2169
- UNIT_ASSERT_VALUES_EQUAL (issue_log.location ().database ().name (), " /Root" );
2170
- UNIT_ASSERT_VALUES_EQUAL (issue_log.message (), " Database has storage issues" );
2171
- } else if (issue_log.level () == 2 && issue_log.type () == " STORAGE" ) {
2172
- UNIT_ASSERT_VALUES_EQUAL (issue_log.location ().database ().name (), " /Root" );
2173
- UNIT_ASSERT_VALUES_EQUAL (issue_log.message (), " Storage has no redundancy" );
2174
- } else if (issue_log.level () == 3 && issue_log.type () == " STORAGE_POOL" ) {
2175
- UNIT_ASSERT_VALUES_EQUAL (issue_log.location ().storage ().pool ().name (), " static" );
2176
- UNIT_ASSERT_VALUES_EQUAL (issue_log.message (), " Pool has no redundancy" );
2177
- } else if (issue_log.level () == 4 && issue_log.type () == " STORAGE_GROUP" ) {
2178
- UNIT_ASSERT_VALUES_EQUAL (issue_log.location ().storage ().pool ().name (), " static" );
2179
- UNIT_ASSERT_VALUES_EQUAL (issue_log.message (), " Group layout is incorrect" );
2159
+ UNIT_ASSERT_VALUES_EQUAL (database_status.storage ().overall (), Ydb::Monitoring::StatusFlag::GREEN);
2160
+ UNIT_ASSERT_VALUES_EQUAL (database_status.storage ().pools ().size (), 1 );
2161
+ UNIT_ASSERT_VALUES_EQUAL (database_status.storage ().pools ()[0 ].overall (), Ydb::Monitoring::StatusFlag::GREEN);
2162
+ UNIT_ASSERT_VALUES_EQUAL (database_status.storage ().pools ()[0 ].groups ().size (), 1 );
2163
+ UNIT_ASSERT_VALUES_EQUAL (database_status.storage ().pools ()[0 ].groups ()[0 ].overall (), Ydb::Monitoring::StatusFlag::GREEN);
2164
+ } else {
2165
+ UNIT_ASSERT_VALUES_EQUAL (result.self_check_result (), Ydb::Monitoring::SelfCheck::MAINTENANCE_REQUIRED);
2166
+ UNIT_ASSERT_VALUES_EQUAL (result.database_status_size (), 1 );
2167
+ const auto &database_status = result.database_status (0 );
2168
+
2169
+ UNIT_ASSERT_VALUES_EQUAL (database_status.overall (), Ydb::Monitoring::StatusFlag::ORANGE);
2170
+ UNIT_ASSERT_VALUES_EQUAL (database_status.storage ().overall (), Ydb::Monitoring::StatusFlag::ORANGE);
2171
+ UNIT_ASSERT_VALUES_EQUAL (database_status.storage ().pools ().size (), 1 );
2172
+ UNIT_ASSERT_VALUES_EQUAL (database_status.storage ().pools ()[0 ].overall (), Ydb::Monitoring::StatusFlag::ORANGE);
2173
+ UNIT_ASSERT_VALUES_EQUAL (database_status.storage ().pools ()[0 ].groups ().size (), 1 );
2174
+ UNIT_ASSERT_VALUES_EQUAL (database_status.storage ().pools ()[0 ].groups ()[0 ].overall (), Ydb::Monitoring::StatusFlag::ORANGE);
2175
+
2176
+ for (const auto &issue_log : result.issue_log ()) {
2177
+ if (issue_log.level () == 1 && issue_log.type () == " DATABASE" ) {
2178
+ UNIT_ASSERT_VALUES_EQUAL (issue_log.location ().database ().name (), " /Root" );
2179
+ } else if (issue_log.level () == 2 && issue_log.type () == " STORAGE" ) {
2180
+ UNIT_ASSERT_VALUES_EQUAL (issue_log.location ().database ().name (), " /Root" );
2181
+ UNIT_ASSERT_VALUES_EQUAL (issue_log.message (), " Storage has no redundancy" );
2182
+ } else if (issue_log.level () == 3 && issue_log.type () == " STORAGE_POOL" ) {
2183
+ UNIT_ASSERT_VALUES_EQUAL (issue_log.location ().storage ().pool ().name (), " static" );
2184
+ UNIT_ASSERT_VALUES_EQUAL (issue_log.message (), " Pool has no redundancy" );
2185
+ } else if (issue_log.level () == 4 && issue_log.type () == " STORAGE_GROUP" ) {
2186
+ UNIT_ASSERT_VALUES_EQUAL (issue_log.location ().storage ().pool ().name (), " static" );
2187
+ UNIT_ASSERT_VALUES_EQUAL (issue_log.message (), " Group layout is incorrect" );
2188
+ }
2180
2189
}
2181
2190
}
2182
2191
}
2192
+
2193
+ Y_UNIT_TEST (LayoutIncorrect) {
2194
+ LayoutCorrectTest (false );
2195
+ }
2196
+
2197
+ Y_UNIT_TEST (LayoutCorrect) {
2198
+ LayoutCorrectTest (true );
2199
+ }
2183
2200
}
2184
2201
}
0 commit comments