Skip to content

Commit

Permalink
Fix vhost test ShouldStatAllZeroesBlocks flakiness (#2070)
Browse files Browse the repository at this point in the history
  • Loading branch information
drbasic committed Sep 19, 2024
1 parent 9ed8d4f commit 324b827
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions cloud/blockstore/vhost-server/server_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,14 @@ class TServerTest
}

TCompleteStats GetStats(ui64 expectedCompleted) const
{
return GetStats(
[expectedCompleted](const TCompleteStats& stats)
{ return stats.SimpleStats.Completed == expectedCompleted; });
}

TCompleteStats GetStats(
std::function<bool(const TCompleteStats&)> func) const
{
// Without I/O, stats are synced every second and only if there is a
// pending GetStats call. The first call to GetStats might not bring the
Expand All @@ -251,7 +259,7 @@ class TServerTest
TCompleteStats stats;
for (int i = 0; i != 5; ++i) {
stats = Server->GetStats(prevStats);
if (stats.SimpleStats.Completed == expectedCompleted) {
if (func(stats)) {
break;
}
Sleep(TDuration::Seconds(1));
Expand Down Expand Up @@ -959,7 +967,9 @@ TEST_P(TServerTest, ShouldStatAllZeroesBlocks)
}

// validate stats
const auto completeStats = GetStats(0);
const auto completeStats =
GetStats([](const TCompleteStats& stats)
{ return stats.CriticalEvents.size() != 0; });
const auto& stats = completeStats.SimpleStats;

EXPECT_EQ(0u, stats.CompFailed);
Expand Down

0 comments on commit 324b827

Please sign in to comment.