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>
22 lines
528 B
C++
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();
|
|
}
|
|
};
|