Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sleep before getting publisher info. #646

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rcl/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function(test_target_function)
set(AMENT_GTEST_ARGS TIMEOUT 120)
endif()
rcl_add_custom_gtest(test_info_by_topic${target_suffix}
SRCS rcl/test_info_by_topic.cpp
SRCS rcl/test_info_by_topic.cpp rcl/wait_for_entity_helpers.cpp
ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME}
Expand Down
6 changes: 6 additions & 0 deletions rcl/test/rcl/test_info_by_topic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@

#include <gtest/gtest.h>

#include <chrono>
#include <memory>
#include <string>
#include <thread>

#include "rcl/error_handling.h"
#include "rcl/graph.h"
Expand All @@ -33,6 +35,8 @@

#include "osrf_testing_tools_cpp/scope_exit.hpp"

#include "wait_for_entity_helpers.hpp"

#ifdef RMW_IMPLEMENTATION
# define CLASSNAME_(NAME, SUFFIX) NAME ## __ ## SUFFIX
# define CLASSNAME(NAME, SUFFIX) CLASSNAME_(NAME, SUFFIX)
Expand Down Expand Up @@ -357,6 +361,8 @@ TEST_F(
&subscription_options);
ASSERT_EQ(ret, RCL_RET_OK) << rcl_get_error_string().str;
const std::string fqdn = std::string("/") + this->topic_name;
ASSERT_TRUE(wait_for_established_subscription(&publisher, 10, 100));
ASSERT_TRUE(wait_for_subscription_to_be_ready(&subscription, &this->context, 10, 100));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure this needs to be called here. I believe that we can confirm that graph cache is constructed vi wait_for_established_subscription.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This case tests both rcl_get_publishers_info_by_topic and rcl_get_subscriptions_info_by_topic, so I think we need to add a new wait_helper(such as wait_for_established_publisher) which is similar to wait_for_established_subscription. (make sure two directions are established.)

NOTE: wait_for_subscription_to_be_ready is used for a subscriber to wait to get message data from a publisher.
it means there should be a rcl_publish calling before (or at a new thread) and then rcl_take to get message data.
So we don't use it here.

// Get publishers info by topic
rmw_topic_endpoint_info_array_t topic_endpoint_info_array_pub =
rmw_get_zero_initialized_topic_endpoint_info_array();
Expand Down