Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
Signed-off-by: M. Fatih Cırıt <[email protected]>
  • Loading branch information
M. Fatih Cırıt committed Jun 4, 2024
1 parent ffde108 commit 1c119e6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion common/autoware_control_center/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<test_depend>ament_cmake_ros</test_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>autoware_lint_common</test_depend>
<test_depend>autoware_testing</test_depend>
<!-- <test_depend>autoware_testing</test_depend>-->
<test_depend>autoware_utils</test_depend>
<test_depend>ros_testing</test_depend>

Expand Down
28 changes: 13 additions & 15 deletions common/autoware_control_center/test/test_cc_heartbeat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,35 +61,33 @@ class ControlCenterHeartbeatTest : public ::testing::Test

TEST_F(ControlCenterHeartbeatTest, HeartbeatHandling)
{
RCLCPP_INFO(rclcpp::get_logger("test"), "Test started");
const std::string node_name = "node_test_heartbeat";
const std::string ns;
const auto [uuid, node] = test::register_node(node_name, ns);
const auto [uuid, node] = test::register_node("node_test_heartbeat", "");

// Send a heartbeat and verify node status is updated
auto hb_healthy_init = test::generate_hb_healthy();

RCLCPP_INFO(rclcpp::get_logger("test"), "Sending heartbeat");
auto pub_hb = test::send_first_heartbeat(node, deadline_ms_, hb_healthy_init);
RCLCPP_INFO(rclcpp::get_logger("test"), "Sent heartbeat");
test::send_heartbeat(node, pub_hb, test::generate_hb_healthy());
RCLCPP_INFO(rclcpp::get_logger("test"), "Sent 2nd heartbeat");

// wait for the heartbeat to be processed
std::this_thread::sleep_for(std::chrono::duration<double, std::milli>(node_period_ms_ * 1.5));
RCLCPP_INFO(rclcpp::get_logger("test"), "Slept a bit");
double sleep_duration_ms = node_period_ms_ * 1.5;
ASSERT_LE(sleep_duration_ms, deadline_ms_);

std::this_thread::sleep_for(std::chrono::duration<double, std::milli>(sleep_duration_ms));

autoware_control_center_msgs::msg::NodeReport report;
ASSERT_TRUE(test::wait_for_node_report(node->get_fully_qualified_name(), report));
ASSERT_EQ(report.status_activity.status, hb_healthy_init->status_activity.status);
ASSERT_EQ(report.status_operational.status, hb_healthy_init->status_operational.status);

test::send_heartbeat(node, pub_hb, test::generate_hb_healthy());
std::this_thread::sleep_for(std::chrono::duration<double, std::milli>(deadline_ms_ * 0.8));
test::send_heartbeat(node, pub_hb, test::generate_hb_healthy());

// Send another heartbeat to make sure it is not marked as dead
test::send_heartbeat(node, pub_hb, test::generate_hb_healthy());
}

TEST_F(ControlCenterHeartbeatTest, HeartbeatMissedDeadline)
{
const std::string node_name = "node_test_heartbeat";
const std::string ns;
const auto [uuid, node] = test::register_node(node_name, ns);
const auto [uuid, node] = test::register_node("node_test_heartbeat", "");

// Send a heartbeat
auto pub_hb = test::send_first_heartbeat(node, deadline_ms_, test::generate_hb_healthy());
Expand Down

0 comments on commit 1c119e6

Please sign in to comment.