fix(tiering tests): introduce wait until tieting entries num EQ/GT (#2559)

Signed-off-by: adi_holden <adi@dragonflydb.io>
This commit is contained in:
adiholden 2024-02-14 09:59:11 +02:00 committed by GitHub
parent 4afe278487
commit 7b61b4a8fe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 69 additions and 55 deletions

View file

@ -330,6 +330,17 @@ void BaseFamilyTest::WaitUntilLocked(DbIndex db_index, string_view key, double t
CHECK(IsLocked(db_index, key));
}
bool BaseFamilyTest::WaitUntilCondition(std::function<bool()> condition_cb,
std::chrono::milliseconds timeout_ms) {
auto step = 50us;
auto timeout_micro = chrono::duration_cast<chrono::microseconds>(timeout_ms);
int64_t steps = timeout_micro.count() / step.count();
do {
ThisFiber::SleepFor(step);
} while (!condition_cb() && --steps > 0);
return condition_cb();
}
RespExpr BaseFamilyTest::Run(ArgSlice list) {
if (!ProactorBase::IsProactorThread()) {
return pp_->at(0)->Await([&] { return this->Run(list); });