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

Make WaitForAllNodesAlive in test_graph.cpp more reliable #854

Merged
Merged
Changes from 1 commit
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
26 changes: 12 additions & 14 deletions rcl/test/rcl/test_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -946,25 +946,23 @@ class NodeGraphMultiNodeFixture : public CLASSNAME(TestGraphFixture, RMW_IMPLEME

void WaitForAllNodesAlive()
{
rcl_ret_t ret;
rcutils_string_array_t node_names = rcutils_get_zero_initialized_string_array();
rcutils_string_array_t node_namespaces = rcutils_get_zero_initialized_string_array();
OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT(
{
ret = rcutils_string_array_fini(&node_names);
ASSERT_EQ(RCUTILS_RET_OK, ret);
ret = rcutils_string_array_fini(&node_namespaces);
ASSERT_EQ(RCUTILS_RET_OK, ret);
});
// wait for all 3 nodes to be discovered: remote_node, old_node, node
size_t attempts = 0;
size_t max_attempts = 4;
while (node_names.size < 3) {
size_t max_attempts = 10;
rcutils_string_array_t node_names = rcutils_get_zero_initialized_string_array();
rcutils_string_array_t node_namespaces = rcutils_get_zero_initialized_string_array();
do {
std::this_thread::sleep_for(std::chrono::seconds(1));
ret = rcl_get_node_names(this->remote_node_ptr, allocator, &node_names, &node_namespaces);
node_names = rcutils_get_zero_initialized_string_array();
node_namespaces = rcutils_get_zero_initialized_string_array();
ASSERT_EQ(
RCL_RET_OK,
rcl_get_node_names(this->remote_node_ptr, allocator, &node_names, &node_namespaces));
attempts++;
ASSERT_EQ(RCUTILS_RET_OK, rcutils_string_array_fini(&node_names));
ASSERT_EQ(RCUTILS_RET_OK, rcutils_string_array_fini(&node_namespaces));
wjwwood marked this conversation as resolved.
Show resolved Hide resolved
ASSERT_LE(attempts, max_attempts) << "Unable to attain all required nodes";
}
} while (node_names.size < 3);
}

/**
Expand Down