Skip to content

Commit

Permalink
Refs #5060 Trying to make some tests more stable when using valgrind
Browse files Browse the repository at this point in the history
  • Loading branch information
Raquel Alvarez committed Jun 19, 2019
1 parent 6147b79 commit 8196486
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
32 changes: 16 additions & 16 deletions test/blackbox/BlackboxTestsLivelinessQos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ TEST(LivelinessQos, LongLiveliness_ManualByParticipant_Reliable)
uint32_t num_samples = 3;

// Liveliness lease duration and announcement period, in seconds
Duration_t liveliness_s(writer_sleep_ms * 2.0 * 1e-3);
Duration_t announcement_period(writer_sleep_ms * 2.0 * 1e-3 * 0.1);
Duration_t liveliness_s(writer_sleep_ms * 5.0 * 1e-3);
Duration_t announcement_period(writer_sleep_ms * 5.0 * 1e-3 * 0.1);

reader.reliability(RELIABLE_RELIABILITY_QOS)
.liveliness_kind(MANUAL_BY_PARTICIPANT_LIVELINESS_QOS)
Expand Down Expand Up @@ -265,7 +265,7 @@ TEST(LivelinessQos, LongLiveliness_ManualByParticipant_Reliable)
std::this_thread::sleep_for(std::chrono::milliseconds(writer_sleep_ms));
}
// Wait a bit longer
std::this_thread::sleep_for(std::chrono::milliseconds(writer_sleep_ms * 5));
std::this_thread::sleep_for(std::chrono::milliseconds(writer_sleep_ms * 10));
EXPECT_EQ(writer.times_liveliness_lost(), 1u);
EXPECT_EQ(reader.times_liveliness_lost(), 1u);
EXPECT_EQ(reader.times_liveliness_recovered(), 1u);
Expand All @@ -276,7 +276,7 @@ TEST(LivelinessQos, LongLiveliness_ManualByParticipant_Reliable)
std::this_thread::sleep_for(std::chrono::milliseconds(writer_sleep_ms));
}
// Wait a bit longer
std::this_thread::sleep_for(std::chrono::milliseconds(writer_sleep_ms * 5));
std::this_thread::sleep_for(std::chrono::milliseconds(writer_sleep_ms * 10));
EXPECT_EQ(writer.times_liveliness_lost(), 2u);
EXPECT_EQ(reader.times_liveliness_lost(), 2u);
EXPECT_EQ(reader.times_liveliness_recovered(), 2u);
Expand All @@ -296,8 +296,8 @@ TEST(LivelinessQos, LongLiveliness_ManualByParticipant_BestEffort)
uint32_t writer_samples = 3;

// Liveliness lease duration and announcement period, in seconds
Duration_t liveliness_s(writer_sleep_ms * 2.0 * 1e-3);
Duration_t announcement_period(writer_sleep_ms * 2.0 * 1e-3 * 0.1);
Duration_t liveliness_s(writer_sleep_ms * 5.0 * 1e-3);
Duration_t announcement_period(writer_sleep_ms * 5.0 * 1e-3 * 0.1);

reader.reliability(BEST_EFFORT_RELIABILITY_QOS)
.liveliness_kind(MANUAL_BY_PARTICIPANT_LIVELINESS_QOS)
Expand Down Expand Up @@ -328,7 +328,7 @@ TEST(LivelinessQos, LongLiveliness_ManualByParticipant_BestEffort)
std::this_thread::sleep_for(std::chrono::milliseconds(writer_sleep_ms));
}
// Wait a bit longer
std::this_thread::sleep_for(std::chrono::milliseconds(writer_sleep_ms * 5));
std::this_thread::sleep_for(std::chrono::milliseconds(writer_sleep_ms * 10));
EXPECT_EQ(writer.times_liveliness_lost(), 1u);
EXPECT_EQ(reader.times_liveliness_lost(), 1u);
EXPECT_EQ(reader.times_liveliness_recovered(), 1u);
Expand All @@ -339,7 +339,7 @@ TEST(LivelinessQos, LongLiveliness_ManualByParticipant_BestEffort)
std::this_thread::sleep_for(std::chrono::milliseconds(writer_sleep_ms));
}
// Wait a bit longer
std::this_thread::sleep_for(std::chrono::milliseconds(writer_sleep_ms * 5));
std::this_thread::sleep_for(std::chrono::milliseconds(writer_sleep_ms * 10));
EXPECT_EQ(writer.times_liveliness_lost(), 2u);
EXPECT_EQ(reader.times_liveliness_lost(), 2u);
EXPECT_EQ(reader.times_liveliness_recovered(), 2u);
Expand Down Expand Up @@ -481,8 +481,8 @@ TEST(LivelinessQos, LongLiveliness_ManualByTopic_Reliable)
uint32_t num_samples = 3;

// Liveliness lease duration and announcement period, in seconds
Duration_t liveliness_s(writer_sleep_ms * 2 * 1e-3);
Duration_t announcement_period(writer_sleep_ms * 2 * 1e-3 * 0.25);
Duration_t liveliness_s(writer_sleep_ms * 5 * 1e-3);
Duration_t announcement_period(writer_sleep_ms * 5 * 1e-3 * 0.1);

reader.reliability(RELIABLE_RELIABILITY_QOS)
.liveliness_kind(MANUAL_BY_TOPIC_LIVELINESS_QOS)
Expand Down Expand Up @@ -514,7 +514,7 @@ TEST(LivelinessQos, LongLiveliness_ManualByTopic_Reliable)
std::this_thread::sleep_for(std::chrono::milliseconds(writer_sleep_ms));
}
// Wait a bit longer
std::this_thread::sleep_for(std::chrono::milliseconds(writer_sleep_ms * 2));
std::this_thread::sleep_for(std::chrono::milliseconds(writer_sleep_ms * 10));
EXPECT_EQ(writer.times_liveliness_lost(), 1u);
EXPECT_EQ(reader.times_liveliness_lost(), 1u);
EXPECT_EQ(reader.times_liveliness_recovered(), 1u);
Expand All @@ -525,7 +525,7 @@ TEST(LivelinessQos, LongLiveliness_ManualByTopic_Reliable)
std::this_thread::sleep_for(std::chrono::milliseconds(writer_sleep_ms));
}
// Wait a bit longer
std::this_thread::sleep_for(std::chrono::milliseconds(writer_sleep_ms * 2));
std::this_thread::sleep_for(std::chrono::milliseconds(writer_sleep_ms * 10));
EXPECT_EQ(writer.times_liveliness_lost(), 2u);
EXPECT_EQ(reader.times_liveliness_lost(), 2u);
EXPECT_EQ(reader.times_liveliness_recovered(), 2u);
Expand All @@ -545,8 +545,8 @@ TEST(LivelinessQos, LongLiveliness_ManualByTopic_BestEffort)
uint32_t num_samples = 3;

// Liveliness lease duration and announcement period, in seconds
Duration_t liveliness_s(writer_sleep_ms * 2 * 1e-3);
Duration_t announcement_period(writer_sleep_ms * 2 * 1e-3 * 0.25);
Duration_t liveliness_s(writer_sleep_ms * 5 * 1e-3);
Duration_t announcement_period(writer_sleep_ms * 5 * 1e-3 * 0.1);

reader.reliability(BEST_EFFORT_RELIABILITY_QOS)
.liveliness_kind(MANUAL_BY_TOPIC_LIVELINESS_QOS)
Expand Down Expand Up @@ -578,7 +578,7 @@ TEST(LivelinessQos, LongLiveliness_ManualByTopic_BestEffort)
std::this_thread::sleep_for(std::chrono::milliseconds(writer_sleep_ms));
}
// Wait a bit longer
std::this_thread::sleep_for(std::chrono::milliseconds(writer_sleep_ms * 2));
std::this_thread::sleep_for(std::chrono::milliseconds(writer_sleep_ms * 10));
EXPECT_EQ(writer.times_liveliness_lost(), 1u);
EXPECT_EQ(reader.times_liveliness_lost(), 1u);
EXPECT_EQ(reader.times_liveliness_recovered(), 1u);
Expand All @@ -589,7 +589,7 @@ TEST(LivelinessQos, LongLiveliness_ManualByTopic_BestEffort)
std::this_thread::sleep_for(std::chrono::milliseconds(writer_sleep_ms));
}
// Wait a bit longer
std::this_thread::sleep_for(std::chrono::milliseconds(writer_sleep_ms * 2));
std::this_thread::sleep_for(std::chrono::milliseconds(writer_sleep_ms * 10));
EXPECT_EQ(writer.times_liveliness_lost(), 2u);
// Note that MANUAL_BY_TOPIC liveliness relies on sending heartbeats when using the assert method
// However best-effor writers do not send heartbeats, so the reader will never get notified
Expand Down
2 changes: 1 addition & 1 deletion test/unittest/rtps/writer/LivelinessManagerTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ TEST(LivelinessManagerTests, TimerExpired_ManualByParticipant)
EXPECT_EQ(env->num_writers_lost, 1u);

// Wait a bit longer so that second writer loses liveliness
std::this_thread::sleep_for(std::chrono::milliseconds(300));
std::this_thread::sleep_for(std::chrono::milliseconds(500));
EXPECT_EQ(env->writer_losing_liveliness, GUID_t(guidP, 2));
EXPECT_EQ(env->num_writers_lost, 2u);

Expand Down

0 comments on commit 8196486

Please sign in to comment.