Files
scylladb/test/lib/eventually.cc
Benny Halevy 32b7cab917 tests: loading_cache_test: use manual_clock
Relying on a real-time clock like lowres_clock
can be flaky (in particular in debug mode).
Use manual_clock instead to harden the test against
timing issues.

Fixes #20322

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
2025-01-23 09:28:08 +02:00

22 lines
528 B
C++

/*
* Copyright (C) 2019-present ScyllaDB
*/
/*
* SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
*/
#include "test/lib/eventually.hh"
sleep_fn seastar_sleep_fn = [] (std::chrono::milliseconds ms) -> future<> {
return seastar::sleep(ms);
};
sleep_fn manual_clock_sleep_fn = [] (std::chrono::milliseconds ms) -> future<> {
auto end = manual_clock::now() + ms;
while (manual_clock::now() < end) {
manual_clock::advance(std::chrono::milliseconds(1));
co_await yield();
}
};