Skip to content

Commit

Permalink
[deflakey] Deflakey gcs_heartbeat_manager_test (#28142)
Browse files Browse the repository at this point in the history
The heartbeat check is every seconds, so it could happen < 1s, which means it could happen very soon. This PR decrease the check period.
  • Loading branch information
fishbone authored Aug 30, 2022
1 parent ffe12a5 commit 4bff702
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/ray/gcs/gcs_server/test/gcs_heartbeat_manager_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class GcsHeartbeatManagerTest : public ::testing::Test {
RayConfig::instance().initialize(
R"(
{
"num_heartbeats_timeout": 2,
"gcs_failover_worker_reconnect_timeout": 4
"num_heartbeats_timeout": 3,
"gcs_failover_worker_reconnect_timeout": 5
}
)");
}
Expand Down Expand Up @@ -68,13 +68,13 @@ TEST_F(GcsHeartbeatManagerTest, TestBasicTimeout) {

while (true) {
absl::MutexLock lock(&mutex_);
if (absl::Now() - start >= absl::Seconds(1)) {
if (absl::Now() - start >= absl::Microseconds(1800)) {
break;
}
ASSERT_TRUE(dead_nodes.empty());
}

std::this_thread::sleep_for(2s);
std::this_thread::sleep_for(3s);

{
absl::MutexLock lock(&mutex_);
Expand All @@ -89,7 +89,7 @@ TEST_F(GcsHeartbeatManagerTest, TestBasicReport) {

while (true) {
absl::MutexLock lock(&mutex_);
if (absl::Now() - start >= absl::Seconds(3)) {
if (absl::Now() - start >= absl::Seconds(4)) {
break;
}
ASSERT_TRUE(dead_nodes.empty());
Expand Down Expand Up @@ -124,13 +124,13 @@ TEST_F(GcsHeartbeatManagerTest, TestBasicRestart) {

while (true) {
absl::MutexLock lock(&mutex_);
if (absl::Now() - start >= absl::Seconds(3)) {
if (absl::Now() - start >= absl::Seconds(4)) {
break;
}
ASSERT_TRUE(dead_nodes.empty());
}

std::this_thread::sleep_for(2s);
std::this_thread::sleep_for(3s);
{
absl::MutexLock lock(&mutex_);
ASSERT_EQ(std::vector<NodeID>{node_1}, dead_nodes);
Expand All @@ -153,7 +153,7 @@ TEST_F(GcsHeartbeatManagerTest, TestBasicRestart2) {

heartbeat_manager->Initialize(init_data);

while (absl::Now() - start < absl::Seconds(1)) {
while (absl::Now() - start < absl::Seconds(2)) {
io_service.post(
[&]() {
rpc::ReportHeartbeatReply reply;
Expand All @@ -169,13 +169,13 @@ TEST_F(GcsHeartbeatManagerTest, TestBasicRestart2) {

while (true) {
absl::MutexLock lock(&mutex_);
if (absl::Now() - start >= absl::Seconds(1)) {
if (absl::Now() - start >= absl::Seconds(2)) {
break;
}
ASSERT_TRUE(dead_nodes.empty());
}

std::this_thread::sleep_for(2s);
std::this_thread::sleep_for(3s);
{
absl::MutexLock lock(&mutex_);
ASSERT_EQ(std::vector<NodeID>{node_1}, dead_nodes);
Expand Down

0 comments on commit 4bff702

Please sign in to comment.