From b4c6462bbe9ece2ccb26d00713e85ef706fa57f2 Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Fri, 22 Feb 2019 10:30:21 -0800 Subject: [PATCH] Wait for action server before sending goal (#637) Signed-off-by: Shane Loretz --- rclcpp_action/test/test_client.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rclcpp_action/test/test_client.cpp b/rclcpp_action/test/test_client.cpp index c709e0331a..ee17a4a884 100644 --- a/rclcpp_action/test/test_client.cpp +++ b/rclcpp_action/test/test_client.cpp @@ -47,6 +47,8 @@ using namespace std::chrono_literals; +const auto WAIT_FOR_SERVER_TIMEOUT = 10s; + class TestClient : public ::testing::Test { protected: @@ -269,6 +271,7 @@ TEST_F(TestClient, construction_and_destruction) TEST_F(TestClient, async_send_goal_but_ignore_feedback_and_result) { auto action_client = rclcpp_action::create_client(client_node, action_name); + ASSERT_TRUE(action_client->wait_for_action_server(WAIT_FOR_SERVER_TIMEOUT)); ActionGoal bad_goal; bad_goal.order = -5; @@ -290,6 +293,7 @@ TEST_F(TestClient, async_send_goal_but_ignore_feedback_and_result) TEST_F(TestClient, async_send_goal_and_ignore_feedback_but_wait_for_result) { auto action_client = rclcpp_action::create_client(client_node, action_name); + ASSERT_TRUE(action_client->wait_for_action_server(WAIT_FOR_SERVER_TIMEOUT)); ActionGoal goal; goal.order = 5; @@ -311,6 +315,7 @@ TEST_F(TestClient, async_send_goal_and_ignore_feedback_but_wait_for_result) TEST_F(TestClient, async_send_goal_with_feedback_and_result) { auto action_client = rclcpp_action::create_client(client_node, action_name); + ASSERT_TRUE(action_client->wait_for_action_server(WAIT_FOR_SERVER_TIMEOUT)); ActionGoal goal; goal.order = 4; @@ -342,6 +347,7 @@ TEST_F(TestClient, async_send_goal_with_feedback_and_result) TEST_F(TestClient, async_cancel_one_goal) { auto action_client = rclcpp_action::create_client(client_node, action_name); + ASSERT_TRUE(action_client->wait_for_action_server(WAIT_FOR_SERVER_TIMEOUT)); ActionGoal goal; goal.order = 5; @@ -359,6 +365,7 @@ TEST_F(TestClient, async_cancel_one_goal) TEST_F(TestClient, async_cancel_all_goals) { auto action_client = rclcpp_action::create_client(client_node, action_name); + ASSERT_TRUE(action_client->wait_for_action_server(WAIT_FOR_SERVER_TIMEOUT)); ActionGoal goal; goal.order = 6; @@ -393,6 +400,7 @@ TEST_F(TestClient, async_cancel_all_goals) TEST_F(TestClient, async_cancel_some_goals) { auto action_client = rclcpp_action::create_client(client_node, action_name); + ASSERT_TRUE(action_client->wait_for_action_server(WAIT_FOR_SERVER_TIMEOUT)); ActionGoal goal; goal.order = 6;