Skip to content

Commit 2c76553

Browse files
authored
fix waiting in test (#10626)
1 parent 550f3b3 commit 2c76553

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

ydb/core/mind/hive/hive_ut.cpp

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,19 +1111,22 @@ Y_UNIT_TEST_SUITE(THiveTest) {
11111111

11121112
createTablets();
11131113

1114-
ui32 nodeId = runtime.GetNodeId(2);
1114+
ui32 nodeIdx = 0;
1115+
ui32 nodeId = runtime.GetNodeId(nodeIdx);
11151116
{
11161117
Ctest << "1. Drain a node\n";
11171118

11181119
runtime.SendToPipe(hiveTablet, senderA, new TEvHive::TEvDrainNode(nodeId));
11191120

11201121
Ctest << "2. Kill it & wait for hive to delete it\n";
11211122

1122-
SendKillLocal(runtime, 0);
1123+
SendKillLocal(runtime, nodeIdx);
11231124
{
11241125
TDispatchOptions options;
11251126
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);
11271130
}
11281131
}
11291132

@@ -1144,7 +1147,7 @@ Y_UNIT_TEST_SUITE(THiveTest) {
11441147
};
11451148

11461149
Ctest << "3. Start the node again\n";
1147-
CreateLocal(runtime, 0);
1150+
CreateLocal(runtime, nodeIdx);
11481151

11491152
{
11501153
TDispatchOptions options;
@@ -1157,8 +1160,19 @@ Y_UNIT_TEST_SUITE(THiveTest) {
11571160
runtime.Register(CreateTabletKiller(hiveTablet));
11581161
{
11591162
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");
11621176
}
11631177

11641178
Ctest << "5. Ensure node is not down (by creating tablets)\n";

0 commit comments

Comments
 (0)