-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Strip replaying methods from McapFileReadTest & McapFileReadWithTypeTest
Signed-off-by: tempate <[email protected]>
- Loading branch information
Showing
35 changed files
with
538 additions
and
323 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include <chrono> | ||
#include <memory> | ||
#include <string> | ||
#include <thread> | ||
|
||
#include <gtest/gtest.h> | ||
|
||
#include <fastdds/dds/domain/DomainParticipantListener.hpp> | ||
|
||
#include <cpp_utils/testing/gtest_aux.hpp> | ||
|
||
#include <ddsrecorder_yaml/recorder/YamlReaderConfiguration.hpp> | ||
|
||
#include <tool/DdsReplayer.hpp> | ||
|
||
#include "../resources/constants.hpp" | ||
#include "../resources/dds/DataToCheck.hpp" | ||
#include "../resources/dds/HelloWorldDynTypesSubscriber.h" | ||
#include "../resources/dds/HelloWorldSubscriber.h" | ||
|
||
using namespace eprosima; | ||
|
||
|
||
class FileReadTest : public testing::Test | ||
{ | ||
|
||
protected: | ||
|
||
/** | ||
* The order in which objects are created is relevant; | ||
* if the replayer was created before the subscriber, | ||
* a segmentation fault may occur as the dynamic type | ||
* could be received by the subscriber's participant | ||
* before the DDS subscriber is created (which is required | ||
* for creating a DataReader with the received type). | ||
*/ | ||
DataToCheck replay_( | ||
const std::string& configuration_path, | ||
const std::string& input_file, | ||
bool publish_types = false, | ||
bool is_ros2_topic = false) | ||
{ | ||
DataToCheck data; | ||
|
||
// Create Subscriber | ||
std::unique_ptr<fastdds::dds::DomainParticipantListener> subscriber; | ||
|
||
const auto topic_name = is_ros2_topic ? test::ROS2_TOPIC_NAME : test::DDS_TOPIC_NAME; | ||
|
||
if (publish_types) | ||
{ | ||
subscriber = std::make_unique<HelloWorldDynTypesSubscriber>(topic_name, test::DOMAIN, data); | ||
} | ||
else | ||
{ | ||
subscriber = std::make_unique<HelloWorldSubscriber>(topic_name, test::DOMAIN, data); | ||
} | ||
|
||
// Configuration | ||
ddsrecorder::yaml::ReplayerConfiguration configuration(configuration_path); | ||
configuration.replayer_configuration->domain.domain_id = test::DOMAIN; | ||
|
||
// Create replayer instance | ||
auto replayer = std::make_unique<ddsrecorder::replayer::DdsReplayer>(configuration, input_file); | ||
|
||
// Give time for replayer and subscriber to match. | ||
// Waiting for the subscriber to match the replayer | ||
// before starting to replay messages does not ensure | ||
// that no samples will be lost (even if using reliable QoS). | ||
// This is because endpoint matching does not occur | ||
// at the same exact moment in both ends of communication, | ||
// so the replayer's writer might have not yet matched the | ||
// subscriber even if the latter already has (matched the writer). | ||
// Transient local QoS would be a solution for this, | ||
// but it is not used as it might pollute frequency arrival | ||
// measurements. | ||
std::this_thread::sleep_for(std::chrono::seconds(1)); | ||
|
||
// Start replaying data | ||
replayer->process_file(); | ||
|
||
replayer->stop(); | ||
|
||
// Replayer waits on destruction a maximum of wait-all-acked-timeout | ||
// ms until all sent msgs are acknowledged | ||
return data; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.