Skip to content

Commit

Permalink
Fix Latency test destruction (#5017) (#5020)
Browse files Browse the repository at this point in the history
Signed-off-by: Mario Dominguez <[email protected]>
(cherry picked from commit d559f71)

Co-authored-by: Mario Domínguez López <[email protected]>
  • Loading branch information
mergify[bot] and Mario-DL committed Jul 10, 2024
1 parent a886cff commit 2ffe303
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 46 deletions.
49 changes: 26 additions & 23 deletions test/performance/latency/LatencyTestPublisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,29 +56,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 @@ -677,6 +654,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 @@ -48,29 +48,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 @@ -635,6 +612,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

0 comments on commit 2ffe303

Please sign in to comment.