From 5a478fcda298ffe7a38aca377719ca99cb12b106 Mon Sep 17 00:00:00 2001 From: Alexander Zalyalov Date: Fri, 18 Oct 2024 15:09:48 +0000 Subject: [PATCH] fix waiting in test --- ydb/core/mind/hive/hive_ut.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/ydb/core/mind/hive/hive_ut.cpp b/ydb/core/mind/hive/hive_ut.cpp index 495c439092d9..a0b38dfcc0c1 100644 --- a/ydb/core/mind/hive/hive_ut.cpp +++ b/ydb/core/mind/hive/hive_ut.cpp @@ -1123,7 +1123,9 @@ Y_UNIT_TEST_SUITE(THiveTest) { { TDispatchOptions options; options.FinalEvents.emplace_back(NHive::TEvPrivate::EvDeleteNode); - runtime.DispatchEvents(options, TDuration::Seconds(6)); + runtime.DispatchEvents(options); + runtime.AdvanceCurrentTime(TDuration::Seconds(2)); + runtime.DispatchEvents(options); } } @@ -1157,8 +1159,19 @@ Y_UNIT_TEST_SUITE(THiveTest) { runtime.Register(CreateTabletKiller(hiveTablet)); { TDispatchOptions options; - options.FinalEvents.emplace_back(TEvLocal::EvStatus, NUM_NODES); - runtime.DispatchEvents(options); + std::unordered_set nodesConnected; + auto observer = runtime.AddObserver([&](auto&& ev) { nodesConnected.insert(ev->Sender.NodeId()); }); + auto waitFor = [&](const auto& condition, const TString& description) { + while (!condition()) { + Ctest << "waiting for " << description << Endl; + TDispatchOptions options; + options.CustomFinalCondition = [&]() { + return condition(); + }; + runtime.DispatchEvents(options); + } + }; + waitFor([&](){return nodesConnected.size() == NUM_NODES; }, "nodes to connect"); } Ctest << "5. Ensure node is not down (by creating tablets)\n";