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

Small cleanups to the rosbag2 tests. #1792

Merged
merged 2 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class ClientManager : public rclcpp::Node
return true;
}

bool wait_for_srvice_to_be_ready(std::chrono::duration<double> timeout = std::chrono::seconds(5))
bool wait_for_service_to_be_ready(std::chrono::duration<double> timeout = std::chrono::seconds(5))
{
using clock = std::chrono::system_clock;
auto start = clock::now();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ TEST_P(Rosbag2CPPGetServiceInfoTest, get_service_info_for_bag_with_services_only
auto cleanup_process_handle = rcpputils::make_scope_exit(
[&]() {stop_spinning();});

ASSERT_TRUE(service_client_manager->wait_for_srvice_to_be_ready());
ASSERT_TRUE(service_client_manager->wait_for_service_to_be_ready());
ASSERT_TRUE(wait_for_subscriptions(*recorder, {"/test_service/_service_event"}));

constexpr size_t num_service_requests = 3;
Expand Down Expand Up @@ -252,8 +252,8 @@ TEST_P(Rosbag2CPPGetServiceInfoTest, get_service_info_for_bag_with_topics_and_se
std::make_shared<rosbag2_test_common::ClientManager<test_msgs::srv::BasicTypes>>(
"test_service2");

ASSERT_TRUE(service_client_manager1->wait_for_srvice_to_be_ready());
ASSERT_TRUE(service_client_manager2->wait_for_srvice_to_be_ready());
ASSERT_TRUE(service_client_manager1->wait_for_service_to_be_ready());
ASSERT_TRUE(service_client_manager2->wait_for_service_to_be_ready());

rosbag2_test_common::PublicationManager pub_manager;
auto message = get_messages_strings()[0];
Expand Down
18 changes: 9 additions & 9 deletions rosbag2_transport/test/rosbag2_transport/test_record_all.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ TEST_F(RecordIntegrationTestFixture, published_messages_from_multiple_topics_are
auto & writer = recorder->get_writer_handle();
auto & mock_writer = dynamic_cast<MockSequentialWriter &>(writer.get_implementation_handle());

size_t expected_messages = 4;
constexpr size_t expected_messages = 4;
auto ret = rosbag2_test_common::wait_until_shutdown(
std::chrono::seconds(5),
[&mock_writer, &expected_messages]() {
[&mock_writer]() {
return mock_writer.get_messages().size() >= expected_messages;
});
EXPECT_TRUE(ret) << "failed to capture expected messages in time";
Expand Down Expand Up @@ -104,8 +104,8 @@ TEST_F(RecordIntegrationTestFixture, published_messages_from_multiple_services_a

start_async_spin(recorder);

ASSERT_TRUE(client_manager_1->wait_for_srvice_to_be_ready());
ASSERT_TRUE(client_manager_2->wait_for_srvice_to_be_ready());
ASSERT_TRUE(client_manager_1->wait_for_service_to_be_ready());
ASSERT_TRUE(client_manager_2->wait_for_service_to_be_ready());

// By default, only client introspection is enabled.
// For one request, service event topic get 2 messages.
Expand All @@ -115,10 +115,10 @@ TEST_F(RecordIntegrationTestFixture, published_messages_from_multiple_services_a
auto & writer = recorder->get_writer_handle();
auto & mock_writer = dynamic_cast<MockSequentialWriter &>(writer.get_implementation_handle());

size_t expected_messages = 4;
constexpr size_t expected_messages = 4;
auto ret = rosbag2_test_common::wait_until_shutdown(
std::chrono::seconds(5),
[&mock_writer, &expected_messages]() {
[&mock_writer]() {
return mock_writer.get_messages().size() >= expected_messages;
});
EXPECT_TRUE(ret) << "failed to capture expected messages in time";
Expand Down Expand Up @@ -148,7 +148,7 @@ TEST_F(RecordIntegrationTestFixture, published_messages_from_topic_and_service_a

ASSERT_TRUE(pub_manager.wait_for_matched(string_topic.c_str()));

ASSERT_TRUE(client_manager_1->wait_for_srvice_to_be_ready());
ASSERT_TRUE(client_manager_1->wait_for_service_to_be_ready());

pub_manager.run_publishers();

Expand All @@ -159,10 +159,10 @@ TEST_F(RecordIntegrationTestFixture, published_messages_from_topic_and_service_a
auto & writer = recorder->get_writer_handle();
auto & mock_writer = dynamic_cast<MockSequentialWriter &>(writer.get_implementation_handle());

size_t expected_messages = 3;
constexpr size_t expected_messages = 3;
auto ret = rosbag2_test_common::wait_until_shutdown(
std::chrono::seconds(5),
[&mock_writer, &expected_messages]() {
[&mock_writer]() {
clalancette marked this conversation as resolved.
Show resolved Hide resolved
return mock_writer.get_messages().size() >= expected_messages;
});
EXPECT_TRUE(ret) << "failed to capture expected messages in time";
Expand Down
20 changes: 10 additions & 10 deletions rosbag2_transport/test/rosbag2_transport/test_record_regex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,11 +296,11 @@ TEST_F(RecordIntegrationTestFixture, regex_and_exclude_regex_service_recording)

start_async_spin(recorder);

ASSERT_TRUE(service_manager_v1->wait_for_srvice_to_be_ready());
ASSERT_TRUE(service_manager_v2->wait_for_srvice_to_be_ready());
ASSERT_TRUE(service_manager_e1->wait_for_srvice_to_be_ready());
ASSERT_TRUE(service_manager_b1->wait_for_srvice_to_be_ready());
ASSERT_TRUE(service_manager_b2->wait_for_srvice_to_be_ready());
ASSERT_TRUE(service_manager_v1->wait_for_service_to_be_ready());
ASSERT_TRUE(service_manager_v2->wait_for_service_to_be_ready());
ASSERT_TRUE(service_manager_e1->wait_for_service_to_be_ready());
ASSERT_TRUE(service_manager_b1->wait_for_service_to_be_ready());
ASSERT_TRUE(service_manager_b2->wait_for_service_to_be_ready());

auto & writer = recorder->get_writer_handle();
auto & mock_writer = dynamic_cast<MockSequentialWriter &>(writer.get_implementation_handle());
Expand Down Expand Up @@ -369,11 +369,11 @@ TEST_F(RecordIntegrationTestFixture, regex_and_exclude_service_service_recording

start_async_spin(recorder);

ASSERT_TRUE(service_manager_v1->wait_for_srvice_to_be_ready());
ASSERT_TRUE(service_manager_v2->wait_for_srvice_to_be_ready());
ASSERT_TRUE(service_manager_e1->wait_for_srvice_to_be_ready());
ASSERT_TRUE(service_manager_b1->wait_for_srvice_to_be_ready());
ASSERT_TRUE(service_manager_b2->wait_for_srvice_to_be_ready());
ASSERT_TRUE(service_manager_v1->wait_for_service_to_be_ready());
ASSERT_TRUE(service_manager_v2->wait_for_service_to_be_ready());
ASSERT_TRUE(service_manager_e1->wait_for_service_to_be_ready());
ASSERT_TRUE(service_manager_b1->wait_for_service_to_be_ready());
ASSERT_TRUE(service_manager_b2->wait_for_service_to_be_ready());

auto & writer = recorder->get_writer_handle();
auto & mock_writer = dynamic_cast<MockSequentialWriter &>(writer.get_implementation_handle());
Expand Down
Loading