Skip to content

Commit

Permalink
Fix test CI
Browse files Browse the repository at this point in the history
Signed-off-by: Irene Bandera <irenebandera@eprosima.com>
  • Loading branch information
irenebm committed Nov 15, 2023
1 parent a0a57f5 commit f0f8cbc
Showing 1 changed file with 43 additions and 29 deletions.
72 changes: 43 additions & 29 deletions ddsrecorder/test/blackbox/mcap/McapFileCreationTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ eprosima::fastrtps::types::DynamicType_ptr dynamic_type_;
} // test

std::unique_ptr<DdsRecorder> create_recorder(
std::string file_name,
int downsampling,
const std::string& file_name,
const int downsampling,
DdsRecorderState recorder_state = DdsRecorderState::RUNNING,
unsigned int event_window = 20,
bool ros2_types = false)
const unsigned int event_window = 20,
const bool ros2_types = false)
{
YAML::Node yml;

Expand All @@ -110,10 +110,10 @@ std::unique_ptr<DdsRecorder> create_recorder(
);
}

void create_publisher(
std::string topic_name,
std::string type_name,
unsigned int domain)
eprosima::fastdds::dds::Publisher* create_publisher(
const std::string& topic_name,
const std::string& type_name,
const unsigned int domain)
{
eprosima::fastdds::dds::DomainParticipantQos pqos;
pqos.name("TypeIntrospectionExample_Participant_Publisher");
Expand Down Expand Up @@ -147,11 +147,13 @@ void create_publisher(

// Create the DDS DataWriter
test::writer_ = publisher_->create_datawriter(topic_, DATAWRITER_QOS_DEFAULT, nullptr);

return publisher_;
}

eprosima::fastrtps::types::DynamicData_ptr send_sample(
unsigned int index = 1,
unsigned int time_sleep = 100)
const unsigned int index = 1,
const unsigned int time_sleep = 100)
{
// Create and initialize new dynamic data
eprosima::fastrtps::types::DynamicData_ptr dynamic_data_;
Expand All @@ -171,21 +173,26 @@ eprosima::fastrtps::types::DynamicData_ptr send_sample(
}

eprosima::fastrtps::types::DynamicData_ptr record(
std::string file_name,
unsigned int num_msgs = 1,
unsigned int downsampling = 1,
bool ros2_types = false)
const std::string& file_name,
const unsigned int num_msgs = 1,
const unsigned int downsampling = 1,
const bool ros2_types = false)
{
eprosima::fastrtps::types::DynamicData_ptr send_data;

// Create Recorder
auto recorder = create_recorder(file_name, downsampling, DdsRecorderState::RUNNING, 20, ros2_types);

// Create Publisher
ros2_types ? create_publisher(test::ros2_topic_name, test::ros2_type_name, test::DOMAIN) : create_publisher(
test::dds_topic_name, test::dds_type_name, test::DOMAIN);


eprosima::fastdds::dds::Publisher* publisher;
if (ros2_types)
{
publisher = create_publisher(test::ros2_topic_name, test::ros2_type_name, test::DOMAIN);
}
else
{
publisher = create_publisher(test::dds_topic_name, test::dds_type_name, test::DOMAIN);
}

// Send data
for (unsigned int i = 0; i < num_msgs; i++)
Expand All @@ -197,7 +204,7 @@ eprosima::fastrtps::types::DynamicData_ptr record(
}

mcap::LinearMessageView get_msgs_mcap(
std::string file_name,
const std::string& file_name,
mcap::McapReader& mcap_reader_)
{
auto status = mcap_reader_.open(file_name);
Expand All @@ -208,22 +215,29 @@ mcap::LinearMessageView get_msgs_mcap(
}

std::tuple<unsigned int, double> record_with_transitions(
std::string file_name,
const std::string& file_name,
DdsRecorderState init_state,
unsigned int first_round,
unsigned int secound_round,
const unsigned int first_round,
const unsigned int secound_round,
DdsRecorderState current_state,
EventKind event = EventKind::NO_EVENT,
unsigned int event_window = 20,
const unsigned int event_window = 20,
unsigned int time_sleep = 0,
unsigned int downsampling = 1,
bool ros2_types = false)
const unsigned int downsampling = 1,
const bool ros2_types = false)
{
uint64_t current_time;
{
// Create Publisher
ros2_types ? create_publisher(test::ros2_topic_name, test::ros2_type_name, test::DOMAIN) : create_publisher(
test::dds_topic_name, test::dds_type_name, test::DOMAIN);
eprosima::fastdds::dds::Publisher* publisher;
if (ros2_types)
{
publisher = create_publisher(test::ros2_topic_name, test::ros2_type_name, test::DOMAIN);
}
else
{
publisher = create_publisher(test::dds_topic_name, test::dds_type_name, test::DOMAIN);
}

// Create Recorder
std::unique_ptr<DdsRecorder> recorder =
Expand Down Expand Up @@ -342,7 +356,7 @@ TEST(McapFileCreationTest, mcap_data_msgs)
TEST(McapFileCreationTest, mcap_dds_topic)
{

std::string file_name = "output_mcap_data_topic.mcap";
std::string file_name = "output_mcap_dds_topic.mcap";

record(file_name);

Expand All @@ -368,7 +382,7 @@ TEST(McapFileCreationTest, mcap_dds_topic)
TEST(McapFileCreationTest, mcap_ros2_topic)
{

std::string file_name = "output_mcap_data_topic.mcap";
std::string file_name = "output_mcap_ros2_topic.mcap";

record(file_name, 1, 1, true);

Expand Down

0 comments on commit f0f8cbc

Please sign in to comment.