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

[21232] Fix Latency tests - 2.x backports (backport #5017) #5021

Merged
merged 1 commit into from
Sep 3, 2024
Merged
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
49 changes: 26 additions & 23 deletions test/performance/latency/LatencyTestPublisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,29 +54,6 @@ LatencyTestPublisher::LatencyTestPublisher()

LatencyTestPublisher::~LatencyTestPublisher()
{
// Static type endpoints shpuld have been removed for each payload iteration
if (dynamic_types_)
{
destroy_data_endpoints();
}
else if (nullptr != data_writer_
|| nullptr != data_reader_
|| nullptr != latency_data_pub_topic_
|| nullptr != latency_data_sub_topic_
|| !latency_data_type_)
{
EPROSIMA_LOG_ERROR(LATENCYPUBLISHER, "ERROR unregistering the DATA type and/or removing the endpoints");
}

subscriber_->delete_datareader(command_reader_);
participant_->delete_subscriber(subscriber_);

publisher_->delete_datawriter(command_writer_);
participant_->delete_publisher(publisher_);

participant_->delete_topic(latency_command_sub_topic_);
participant_->delete_topic(latency_command_pub_topic_);

std::string TestCommandType("TestCommandType");
participant_->unregister_type(TestCommandType);

Expand Down Expand Up @@ -675,6 +652,32 @@ void LatencyTestPublisher::run()
}
}

void LatencyTestPublisher::destroy_user_entities()
{
// Static type endpoints shpuld have been removed for each payload iteration
if (dynamic_types_)
{
destroy_data_endpoints();
}
else if (nullptr != data_writer_
|| nullptr != data_reader_
|| nullptr != latency_data_pub_topic_
|| nullptr != latency_data_sub_topic_
|| !latency_data_type_)
{
EPROSIMA_LOG_ERROR(LATENCYPUBLISHER, "ERROR unregistering the DATA type and/or removing the endpoints");
}

subscriber_->delete_datareader(command_reader_);
participant_->delete_subscriber(subscriber_);

publisher_->delete_datawriter(command_writer_);
participant_->delete_publisher(publisher_);

participant_->delete_topic(latency_command_sub_topic_);
participant_->delete_topic(latency_command_pub_topic_);
}

void LatencyTestPublisher::export_csv(
const std::string& data_name,
const std::string& str_reliable,
Expand Down
2 changes: 2 additions & 0 deletions test/performance/latency/LatencyTestPublisher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ class LatencyTestPublisher

void run();

void destroy_user_entities();

private:

bool init_dynamic_types();
Expand Down
49 changes: 26 additions & 23 deletions test/performance/latency/LatencyTestSubscriber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,6 @@ LatencyTestSubscriber::LatencyTestSubscriber()

LatencyTestSubscriber::~LatencyTestSubscriber()
{
// Static type endpoints should have been remove for each payload iteration
if (dynamic_types_)
{
destroy_data_endpoints();
}
else if (nullptr != data_writer_
|| nullptr != data_reader_
|| nullptr != latency_data_pub_topic_
|| nullptr != latency_data_sub_topic_
|| !latency_data_type_)
{
EPROSIMA_LOG_ERROR(LATENCYSUBSCRIBER, "ERROR unregistering the DATA type and/or removing the endpoints");
}

subscriber_->delete_datareader(command_reader_);
participant_->delete_subscriber(subscriber_);

publisher_->delete_datawriter(command_writer_);
participant_->delete_publisher(publisher_);

participant_->delete_topic(latency_command_sub_topic_);
participant_->delete_topic(latency_command_pub_topic_);

std::string TestCommandType("TestCommandType");
participant_->unregister_type(TestCommandType);

Expand Down Expand Up @@ -633,6 +610,32 @@ void LatencyTestSubscriber::run()
}
}

void LatencyTestSubscriber::destroy_user_entities()
{
// Static type endpoints should have been remove for each payload iteration
if (dynamic_types_)
{
destroy_data_endpoints();
}
else if (nullptr != data_writer_
|| nullptr != data_reader_
|| nullptr != latency_data_pub_topic_
|| nullptr != latency_data_sub_topic_
|| !latency_data_type_)
{
EPROSIMA_LOG_ERROR(LATENCYSUBSCRIBER, "ERROR unregistering the DATA type and/or removing the endpoints");
}

subscriber_->delete_datareader(command_reader_);
participant_->delete_subscriber(subscriber_);

publisher_->delete_datawriter(command_writer_);
participant_->delete_publisher(publisher_);

participant_->delete_topic(latency_command_sub_topic_);
participant_->delete_topic(latency_command_pub_topic_);
}

bool LatencyTestSubscriber::test(
uint32_t datasize)
{
Expand Down
2 changes: 2 additions & 0 deletions test/performance/latency/LatencyTestSubscriber.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ class LatencyTestSubscriber

void run();

void destroy_user_entities();

bool test(
uint32_t datasize);

Expand Down
9 changes: 9 additions & 0 deletions test/performance/latency/main_LatencyTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ int main(
dynamic_types, data_sharing, data_loans, shared_memory, forced_domain, data_sizes))
{
latency_publisher.run();
latency_publisher.destroy_user_entities();
}
else
{
Expand All @@ -519,6 +520,7 @@ int main(
xml_config_file, dynamic_types, data_sharing, data_loans, shared_memory, forced_domain, data_sizes))
{
latency_subscriber.run();
latency_subscriber.destroy_user_entities();
}
else
{
Expand Down Expand Up @@ -569,6 +571,13 @@ int main(
{
sub.join();
}

for (auto& sub : latency_subscribers)
{
sub->destroy_user_entities();
}

latency_publisher.destroy_user_entities();
}
else
{
Expand Down
Loading