Skip to content

Commit

Permalink
cloud_storage: Use RPTEST_REQUIRE_EVENTUALLY macro
Browse files Browse the repository at this point in the history
  • Loading branch information
abhijat committed Oct 3, 2023
1 parent b51de62 commit 1c6a360
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions src/v/cloud_storage/tests/topic_recovery_service_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,35 +138,32 @@ class fixture
}

void wait_for_topic(model::topic_namespace tp_ns) {
tests::cooperative_spin_wait_with_timeout(
10s,
[this, tn = std::move(tp_ns)] {
const auto& topics
= app.controller->get_topics_state().local().all_topics();
const auto has_topic = std::find_if(
topics.cbegin(),
topics.cend(),
[&tn](const auto& tp_ns) {
return tp_ns == tn;
})
!= topics.cend();
return ss::make_ready_future<bool>(has_topic);
})
.get();
RPTEST_REQUIRE_EVENTUALLY(10s, [this, tn = std::move(tp_ns)] {
const auto& topics
= app.controller->get_topics_state().local().all_topics();
const auto has_topic = std::find_if(
topics.cbegin(),
topics.cend(),
[&tn](const auto& tp_ns) {
return tp_ns == tn;
})
!= topics.cend();
return ss::make_ready_future<bool>(has_topic);
});
}

using equals = ss::bool_class<struct equals_tag>;
void wait_for_n_requests(
size_t n,
equals e = equals::no,
std::optional<req_pred_t> predicate = std::nullopt) {
tests::cooperative_spin_wait_with_timeout(10s, [this, n, e, predicate] {
RPTEST_REQUIRE_EVENTUALLY(10s, [this, n, e, predicate] {
const auto matching_requests_size
= predicate ? get_requests(predicate.value()).size()
: get_requests().size();
return e ? matching_requests_size == n
: matching_requests_size >= n;
}).get();
});
}

cloud_storage::init_recovery_result
Expand Down

0 comments on commit 1c6a360

Please sign in to comment.