@@ -1111,19 +1111,22 @@ Y_UNIT_TEST_SUITE(THiveTest) {
1111
1111
1112
1112
createTablets ();
1113
1113
1114
- ui32 nodeId = runtime.GetNodeId (2 );
1114
+ ui32 nodeIdx = 0 ;
1115
+ ui32 nodeId = runtime.GetNodeId (nodeIdx);
1115
1116
{
1116
1117
Ctest << " 1. Drain a node\n " ;
1117
1118
1118
1119
runtime.SendToPipe (hiveTablet, senderA, new TEvHive::TEvDrainNode (nodeId));
1119
1120
1120
1121
Ctest << " 2. Kill it & wait for hive to delete it\n " ;
1121
1122
1122
- SendKillLocal (runtime, 0 );
1123
+ SendKillLocal (runtime, nodeIdx );
1123
1124
{
1124
1125
TDispatchOptions options;
1125
1126
options.FinalEvents .emplace_back (NHive::TEvPrivate::EvDeleteNode);
1126
- runtime.DispatchEvents (options, TDuration::Seconds (6 ));
1127
+ runtime.DispatchEvents (options);
1128
+ runtime.AdvanceCurrentTime (TDuration::Seconds (2 ));
1129
+ runtime.DispatchEvents (options);
1127
1130
}
1128
1131
}
1129
1132
@@ -1144,7 +1147,7 @@ Y_UNIT_TEST_SUITE(THiveTest) {
1144
1147
};
1145
1148
1146
1149
Ctest << " 3. Start the node again\n " ;
1147
- CreateLocal (runtime, 0 );
1150
+ CreateLocal (runtime, nodeIdx );
1148
1151
1149
1152
{
1150
1153
TDispatchOptions options;
@@ -1157,8 +1160,19 @@ Y_UNIT_TEST_SUITE(THiveTest) {
1157
1160
runtime.Register (CreateTabletKiller (hiveTablet));
1158
1161
{
1159
1162
TDispatchOptions options;
1160
- options.FinalEvents .emplace_back (TEvLocal::EvStatus, NUM_NODES);
1161
- runtime.DispatchEvents (options);
1163
+ std::unordered_set<ui32> nodesConnected;
1164
+ auto observer = runtime.AddObserver <TEvLocal::TEvStatus>([&](auto && ev) { nodesConnected.insert (ev->Sender .NodeId ()); });
1165
+ auto waitFor = [&](const auto & condition, const TString& description) {
1166
+ while (!condition ()) {
1167
+ Ctest << " waiting for " << description << Endl;
1168
+ TDispatchOptions options;
1169
+ options.CustomFinalCondition = [&]() {
1170
+ return condition ();
1171
+ };
1172
+ runtime.DispatchEvents (options);
1173
+ }
1174
+ };
1175
+ waitFor ([&](){return nodesConnected.size () == NUM_NODES; }, " nodes to connect" );
1162
1176
}
1163
1177
1164
1178
Ctest << " 5. Ensure node is not down (by creating tablets)\n " ;
0 commit comments