mirror of
https://github.com/wassname/ray.git
synced 2026-07-12 20:45:22 +08:00
[TEST]Move all WaitReady together (#12254)
This commit is contained in:
@@ -164,6 +164,11 @@ void TestSetupUtil::StopRaylet(const std::string &raylet_socket_name) {
|
||||
KillProcessBySocketName(raylet_socket_name);
|
||||
}
|
||||
|
||||
bool WaitReady(std::future<bool> future, const std::chrono::milliseconds &timeout_ms) {
|
||||
auto status = future.wait_for(timeout_ms);
|
||||
return status == std::future_status::ready && future.get();
|
||||
}
|
||||
|
||||
bool WaitForCondition(std::function<bool()> condition, int timeout_ms) {
|
||||
int wait_time = 0;
|
||||
while (true) {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <functional>
|
||||
#include <future>
|
||||
#include <string>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
@@ -42,6 +43,13 @@ class RayObject;
|
||||
// Magic argument to signal to mock_worker we should check message order.
|
||||
static const int64_t SHOULD_CHECK_MESSAGE_ORDER = 123450000;
|
||||
|
||||
/// Wait until the future is ready, or timeout is reached.
|
||||
///
|
||||
/// \param[in] future The future to wait for.
|
||||
/// \param[in] timeout_ms Timeout in milliseconds to wait for for.
|
||||
/// \return Whether the future is ready.
|
||||
bool WaitReady(std::future<bool> future, const std::chrono::milliseconds &timeout_ms);
|
||||
|
||||
/// Wait until the condition is met, or timeout is reached.
|
||||
///
|
||||
/// \param[in] condition The condition to wait for.
|
||||
|
||||
@@ -77,11 +77,6 @@ class GlobalStateAccessorTest : public ::testing::Test {
|
||||
TestSetupUtil::FlushAllRedisServers();
|
||||
}
|
||||
|
||||
bool WaitReady(std::future<bool> future, const std::chrono::milliseconds &timeout_ms) {
|
||||
auto status = future.wait_for(timeout_ms);
|
||||
return status == std::future_status::ready && future.get();
|
||||
}
|
||||
|
||||
// GCS server.
|
||||
gcs::GcsServerConfig config;
|
||||
std::unique_ptr<gcs::GcsServer> gcs_server_;
|
||||
|
||||
@@ -578,11 +578,6 @@ class ServiceBasedGcsClientTest : public ::testing::Test {
|
||||
return WaitReady(promise.get_future(), timeout_ms_);
|
||||
}
|
||||
|
||||
bool WaitReady(std::future<bool> future, const std::chrono::milliseconds &timeout_ms) {
|
||||
auto status = future.wait_for(timeout_ms);
|
||||
return status == std::future_status::ready && future.get();
|
||||
}
|
||||
|
||||
void CheckActorData(const gcs::ActorTableData &actor,
|
||||
rpc::ActorTableData_ActorState expected_state) {
|
||||
ASSERT_TRUE(actor.state() == expected_state);
|
||||
|
||||
@@ -433,11 +433,6 @@ class GcsServerTest : public ::testing::Test {
|
||||
return WaitReady(promise.get_future(), timeout_ms_);
|
||||
}
|
||||
|
||||
bool WaitReady(const std::future<bool> &future, uint64_t timeout_ms) {
|
||||
auto status = future.wait_for(std::chrono::milliseconds(timeout_ms));
|
||||
return status == std::future_status::ready;
|
||||
}
|
||||
|
||||
protected:
|
||||
// Gcs server
|
||||
std::unique_ptr<gcs::GcsServer> gcs_server_;
|
||||
@@ -449,7 +444,7 @@ class GcsServerTest : public ::testing::Test {
|
||||
std::unique_ptr<rpc::ClientCallManager> client_call_manager_;
|
||||
|
||||
// Timeout waiting for gcs server reply, default is 5s
|
||||
const uint64_t timeout_ms_ = 5000;
|
||||
const std::chrono::milliseconds timeout_ms_{5000};
|
||||
};
|
||||
|
||||
TEST_F(GcsServerTest, TestActorInfo) {
|
||||
|
||||
@@ -91,11 +91,6 @@ class GcsPubSubTest : public ::testing::Test {
|
||||
return WaitReady(promise.get_future(), timeout_ms_);
|
||||
}
|
||||
|
||||
bool WaitReady(std::future<bool> future, const std::chrono::milliseconds &timeout_ms) {
|
||||
auto status = future.wait_for(timeout_ms);
|
||||
return status == std::future_status::ready && future.get();
|
||||
}
|
||||
|
||||
template <typename Data>
|
||||
void WaitPendingDone(const std::vector<Data> &data, int expected_count) {
|
||||
auto condition = [this, &data, expected_count]() {
|
||||
|
||||
Reference in New Issue
Block a user