diff --git a/ddsrouter_core/include/ddsrouter_core/types/common/types.hpp b/ddsrouter_core/include/ddsrouter_core/types/common/types.hpp new file mode 100644 index 000000000..8fc1a7410 --- /dev/null +++ b/ddsrouter_core/include/ddsrouter_core/types/common/types.hpp @@ -0,0 +1,44 @@ +// Copyright 2021 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. + +/** + * @file types.hpp + * + * Contains auxiliary data types. + */ + +#ifndef _DDSROUTERCORE_TYPES_COMMON_TYPES_HPP_ +#define _DDSROUTERCORE_TYPES_COMMON_TYPES_HPP_ + +#include + +#include + +#include +#include + +namespace eprosima { +namespace ddsrouter { +namespace core { +namespace types { + +using GuidPrefixDataFilterType = utils::SharedAtomicable>; + + +} /* namespace types */ +} /* namespace core */ +} /* namespace ddsrouter */ +} /* namespace eprosima */ + +#endif /* _DDSROUTERCORE_TYPES_COMMON_TYPES_HPP_ */ diff --git a/ddsrouter_core/src/cpp/participant/implementations/rtps/CommonParticipant.cpp b/ddsrouter_core/src/cpp/participant/implementations/rtps/CommonParticipant.cpp index b365f796c..1c340ebb4 100644 --- a/ddsrouter_core/src/cpp/participant/implementations/rtps/CommonParticipant.cpp +++ b/ddsrouter_core/src/cpp/participant/implementations/rtps/CommonParticipant.cpp @@ -45,10 +45,14 @@ CommonParticipant::CommonParticipant( unsigned int max_history_depth) : BaseParticipant(participant_configuration, payload_pool, discovery_database) , max_history_depth_(max_history_depth) + , target_guids_writer_filter_(std::make_shared()) { create_participant_( domain_id, participant_attributes); + + // Add this same Participant to be filtered by the Writer + add_filter_guidprefix_(rtps_participant_->getGuid().guidPrefix); } CommonParticipant::~CommonParticipant() @@ -67,20 +71,33 @@ void CommonParticipant::onParticipantDiscovery( { if (info.status == fastrtps::rtps::ParticipantDiscoveryInfo::DISCOVERED_PARTICIPANT) { - logInfo(DDSROUTER_DISCOVERY, - "Found in Participant " << this->id_nts_() << " new Participant " << info.info.m_guid << "."); + // Check whether this Participant belongs to a local Dds Router and is such, filter its sources + if (is_local_ddsrouter_participant_(info)) + { + // Found local DDS Router, so filtering it + add_filter_guidprefix_(info.info.m_guid.guidPrefix); + logInfo(DDSROUTER_RTPSPARTICIPANT_DISCOVERY, + "Found in Participant " << this->id_nts_() << + " new Local Participant " << info.info.m_guid << + " that belongs to a DDS Router, so filtering it."); + } + else + { + logInfo(DDSROUTER_RTPSPARTICIPANT_DISCOVERY, + "Found in Participant " << this->id_nts_() << " new Participant " << info.info.m_guid << "."); + } } else if (info.status == fastrtps::rtps::ParticipantDiscoveryInfo::CHANGED_QOS_PARTICIPANT) { - logInfo(DDSROUTER_DISCOVERY, "Participant " << info.info.m_guid << " changed QoS."); + logInfo(DDSROUTER_RTPSPARTICIPANT_DISCOVERY, "Participant " << info.info.m_guid << " changed QoS."); } else if (info.status == fastrtps::rtps::ParticipantDiscoveryInfo::REMOVED_PARTICIPANT) { - logInfo(DDSROUTER_DISCOVERY, "Participant " << info.info.m_guid << " removed."); + logInfo(DDSROUTER_RTPSPARTICIPANT_DISCOVERY, "Participant " << info.info.m_guid << " removed."); } else { - logInfo(DDSROUTER_DISCOVERY, "Participant " << info.info.m_guid << " dropped."); + logInfo(DDSROUTER_RTPSPARTICIPANT_DISCOVERY, "Participant " << info.info.m_guid << " dropped."); } } } @@ -142,27 +159,27 @@ void CommonParticipant::onReaderDiscovery( if (info.status == fastrtps::rtps::ReaderDiscoveryInfo::DISCOVERED_READER) { - logInfo(DDSROUTER_DISCOVERY, + logInfo(DDSROUTER_RTPSPARTICIPANT_DISCOVERY, "Found in Participant " << this->id_nts_() << " new Reader " << info.info.guid() << "."); this->discovery_database_->add_endpoint(info_reader); } else if (info.status == fastrtps::rtps::ReaderDiscoveryInfo::CHANGED_QOS_READER) { - logInfo(DDSROUTER_DISCOVERY, "Reader " << info.info.guid() << " changed QoS."); + logInfo(DDSROUTER_RTPSPARTICIPANT_DISCOVERY, "Reader " << info.info.guid() << " changed QoS."); this->discovery_database_->update_endpoint(info_reader); } else if (info.status == fastrtps::rtps::ReaderDiscoveryInfo::REMOVED_READER) { - logInfo(DDSROUTER_DISCOVERY, "Reader " << info.info.guid() << " removed."); + logInfo(DDSROUTER_RTPSPARTICIPANT_DISCOVERY, "Reader " << info.info.guid() << " removed."); info_reader.active(false); this->discovery_database_->update_endpoint(info_reader); } else { - logInfo(DDSROUTER_DISCOVERY, "Reader " << info.info.guid() << " dropped."); + logInfo(DDSROUTER_RTPSPARTICIPANT_DISCOVERY, "Reader " << info.info.guid() << " dropped."); info_reader.active(false); this->discovery_database_->update_endpoint(info_reader); @@ -180,27 +197,27 @@ void CommonParticipant::onWriterDiscovery( if (info.status == fastrtps::rtps::WriterDiscoveryInfo::DISCOVERED_WRITER) { - logInfo(DDSROUTER_DISCOVERY, + logInfo(DDSROUTER_RTPSPARTICIPANT_DISCOVERY, "Found in Participant " << this->id_nts_() << " new Writer " << info.info.guid() << "."); this->discovery_database_->add_endpoint(info_writer); } else if (info.status == fastrtps::rtps::WriterDiscoveryInfo::CHANGED_QOS_WRITER) { - logInfo(DDSROUTER_DISCOVERY, "Writer " << info.info.guid() << " changed QoS."); + logInfo(DDSROUTER_RTPSPARTICIPANT_DISCOVERY, "Writer " << info.info.guid() << " changed QoS."); this->discovery_database_->update_endpoint(info_writer); } else if (info.status == fastrtps::rtps::WriterDiscoveryInfo::REMOVED_WRITER) { - logInfo(DDSROUTER_DISCOVERY, "Writer " << info.info.guid() << " removed."); + logInfo(DDSROUTER_RTPSPARTICIPANT_DISCOVERY, "Writer " << info.info.guid() << " removed."); info_writer.active(false); this->discovery_database_->update_endpoint(info_writer); } else { - logInfo(DDSROUTER_DISCOVERY, "Writer " << info.info.guid() << " dropped."); + logInfo(DDSROUTER_RTPSPARTICIPANT_DISCOVERY, "Writer " << info.info.guid() << " dropped."); info_writer.active(false); this->discovery_database_->update_endpoint(info_writer); @@ -245,6 +262,7 @@ std::shared_ptr CommonParticipant::create_writer_( this->payload_pool_, rtps_participant_, max_history_depth_, + target_guids_writer_filter_, this->configuration_->is_repeater); } @@ -258,6 +276,13 @@ std::shared_ptr CommonParticipant::create_reader_( rtps_participant_); } +void CommonParticipant::add_filter_guidprefix_(const types::GuidPrefix& guid_to_filter) noexcept +{ + // Lock to write + std::unique_lock lock(*target_guids_writer_filter_); + target_guids_writer_filter_->insert(guid_to_filter); +} + fastrtps::rtps::RTPSParticipantAttributes CommonParticipant::participant_attributes_( const configuration::ParticipantConfiguration* participant_configuration) @@ -267,9 +292,48 @@ CommonParticipant::participant_attributes_( // Add Participant name params.setName(participant_configuration->id.id_name().c_str()); + // Set property so other Routers know the Participants belongs to a Router and its kind + eprosima::fastrtps::rtps::Property router_kind_property; + router_kind_property.name(std::string(ROUTER_PROPERTY_KIND_NAME_)); + router_kind_property.value(std::string(types::PARTICIPANT_KIND_STRINGS[static_cast(participant_configuration->kind)])); + router_kind_property.propagate(true); + // Add it to properties + params.properties.properties().push_back(router_kind_property); + + // Set property so other Routers know the Participant is local or wan + eprosima::fastrtps::rtps::Property router_positioning_property; + router_positioning_property.name(std::string(ROUTER_PROPERTY_POSITIONING_NAME_)); + router_positioning_property.value( + std::string( + (participant_configuration->kind == types::ParticipantKind::local_discovery_server || + participant_configuration->kind == types::ParticipantKind::simple_rtps) + ? ROUTER_PROPERTY_POSITIONING_VALUE_LOCAL_ + : ROUTER_PROPERTY_POSITIONING_VALUE_WAN_)); + router_positioning_property.propagate(true); + // Add it to properties + params.properties.properties().push_back(router_positioning_property); + return params; } +bool CommonParticipant::is_local_ddsrouter_participant_(const fastrtps::rtps::ParticipantDiscoveryInfo& info) noexcept +{ + + // Check if router positioning property exist + for (auto pit = info.info.m_properties.begin(); + pit != info.info.m_properties.end(); + ++pit) + { + // Attribute found + if (pit->first() == std::string(ROUTER_PROPERTY_POSITIONING_NAME_)) + { + return pit->second() == std::string(ROUTER_PROPERTY_POSITIONING_VALUE_LOCAL_); + } + } + + return false; +} + } /* namespace rtps */ } /* namespace core */ } /* namespace ddsrouter */ diff --git a/ddsrouter_core/src/cpp/participant/implementations/rtps/CommonParticipant.hpp b/ddsrouter_core/src/cpp/participant/implementations/rtps/CommonParticipant.hpp index f889768a2..c94419c9f 100644 --- a/ddsrouter_core/src/cpp/participant/implementations/rtps/CommonParticipant.hpp +++ b/ddsrouter_core/src/cpp/participant/implementations/rtps/CommonParticipant.hpp @@ -86,12 +86,16 @@ class CommonParticipant types::Endpoint create_endpoint_from_info_( DiscoveryInfoKind& info); + void add_filter_guidprefix_(const types::GuidPrefix& guid_to_filter) noexcept; + ///// // RTPS specific methods static fastrtps::rtps::RTPSParticipantAttributes participant_attributes_( const configuration::ParticipantConfiguration* participant_configuration); + static bool is_local_ddsrouter_participant_(const fastrtps::rtps::ParticipantDiscoveryInfo& info) noexcept; + ///// // VARIABLES eprosima::fastrtps::rtps::RTPSParticipant* rtps_participant_; @@ -101,6 +105,21 @@ class CommonParticipant //! Maximum depth of RTPS History instances unsigned int max_history_depth_; + + /** + * @brief Collects these guid prefixes that the Writer must filter and not send messages to them. + * + * It does add also this same Participant. + */ + std::shared_ptr target_guids_writer_filter_; + + /* + * These constants set the name of property and values used in Property QoS + */ + static constexpr const char* ROUTER_PROPERTY_KIND_NAME_ = "fastdds.ddsrouter.kind"; + static constexpr const char* ROUTER_PROPERTY_POSITIONING_NAME_ = "fastdds.ddsrouter.positioning"; + static constexpr const char* ROUTER_PROPERTY_POSITIONING_VALUE_LOCAL_ = "local"; + static constexpr const char* ROUTER_PROPERTY_POSITIONING_VALUE_WAN_ = "wan"; }; } /* namespace rtps */ @@ -109,3 +128,4 @@ class CommonParticipant } /* namespace eprosima */ #endif /* __SRC_DDSROUTERCORE_PARTICIPANT_IMPLEMENTATIONS_RTPS_COMMONPARTICIPANT_HPP_ */ + diff --git a/ddsrouter_core/src/cpp/reader/implementations/rtps/Reader.cpp b/ddsrouter_core/src/cpp/reader/implementations/rtps/Reader.cpp index 95ff0b2f6..b5e319ca5 100644 --- a/ddsrouter_core/src/cpp/reader/implementations/rtps/Reader.cpp +++ b/ddsrouter_core/src/cpp/reader/implementations/rtps/Reader.cpp @@ -171,16 +171,16 @@ void Reader::enable_() noexcept on_data_available_(); } -bool Reader::come_from_this_participant_( +bool Reader::accept_message_from_this_source_( const fastrtps::rtps::CacheChange_t* change) const noexcept { - return come_from_this_participant_(change->writerGUID); + return accept_message_from_this_source_(change->writerGUID); } -bool Reader::come_from_this_participant_( +bool Reader::accept_message_from_this_source_( const fastrtps::rtps::GUID_t guid) const noexcept { - return guid.guidPrefix == rtps_reader_->getGuid().guidPrefix; + return true; } fastrtps::rtps::HistoryAttributes Reader::history_attributes_() const noexcept @@ -255,7 +255,7 @@ void Reader::onNewCacheChangeAdded( fastrtps::rtps::RTPSReader*, const fastrtps::rtps::CacheChange_t* const change) noexcept { - if (!come_from_this_participant_(change)) + if (accept_message_from_this_source_(change)) { // Do not remove previous received changes so they can be read when the reader is enabled if (enabled_) @@ -279,7 +279,7 @@ void Reader::onNewCacheChangeAdded( { logWarning( DDSROUTER_RTPS_READER_LISTENER, - "Ignoring data from this same Participant in reader " << *this << "."); + "Ignoring data from " << change->writerGUID << " in reader " << *this << "."); // If it is a message from this Participant, do not send it forward and remove it // TODO: do this more elegant @@ -291,7 +291,7 @@ void Reader::onReaderMatched( fastrtps::rtps::RTPSReader*, fastrtps::rtps::MatchingInfo& info) noexcept { - if (!come_from_this_participant_(info.remoteEndpointGuid)) + if (accept_message_from_this_source_(info.remoteEndpointGuid)) { if (info.status == fastrtps::rtps::MatchingStatus::MATCHED_MATCHING) { diff --git a/ddsrouter_core/src/cpp/reader/implementations/rtps/Reader.hpp b/ddsrouter_core/src/cpp/reader/implementations/rtps/Reader.hpp index 3c11d8c55..31850a1e8 100644 --- a/ddsrouter_core/src/cpp/reader/implementations/rtps/Reader.hpp +++ b/ddsrouter_core/src/cpp/reader/implementations/rtps/Reader.hpp @@ -28,10 +28,10 @@ #include #include -#include - #include +#include + namespace eprosima { namespace ddsrouter { namespace core { @@ -160,11 +160,11 @@ class Reader : public BaseReader, public fastrtps::rtps::ReaderListener // Reader specific methods //! Whether a change received is from this Participant (to avoid auto-feedback) - bool come_from_this_participant_( + bool accept_message_from_this_source_( const fastrtps::rtps::CacheChange_t* change) const noexcept; //! Whether a guid references this Participant (to avoid auto-feedback) - bool come_from_this_participant_( + bool accept_message_from_this_source_( const fastrtps::rtps::GUID_t guid) const noexcept; ///// diff --git a/ddsrouter_core/src/cpp/writer/implementations/rtps/Writer.cpp b/ddsrouter_core/src/cpp/writer/implementations/rtps/Writer.cpp index 01fec85fd..0fd075921 100644 --- a/ddsrouter_core/src/cpp/writer/implementations/rtps/Writer.cpp +++ b/ddsrouter_core/src/cpp/writer/implementations/rtps/Writer.cpp @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include namespace eprosima { @@ -41,9 +41,11 @@ Writer::Writer( std::shared_ptr payload_pool, fastrtps::rtps::RTPSParticipant* rtps_participant, unsigned int max_history_depth, + std::shared_ptr target_guids_filter, const bool repeater /* = false */) : BaseWriter(participant_id, topic, payload_pool) , repeater_(repeater) + , target_guids_filter_(target_guids_filter) { // TODO Use payload pool for this writer, so change does not need to be copied @@ -100,12 +102,12 @@ Writer::Writer( if (repeater) { // Use filter writer of origin - data_filter_ = std::make_unique(); + data_filter_ = std::make_unique(target_guids_filter); } else { // Use default filter - data_filter_ = std::make_unique(); + data_filter_ = std::make_unique(target_guids_filter); } rtps_writer_->reader_data_filter(data_filter_.get()); diff --git a/ddsrouter_core/src/cpp/writer/implementations/rtps/Writer.hpp b/ddsrouter_core/src/cpp/writer/implementations/rtps/Writer.hpp index 91286de17..782ddb813 100644 --- a/ddsrouter_core/src/cpp/writer/implementations/rtps/Writer.hpp +++ b/ddsrouter_core/src/cpp/writer/implementations/rtps/Writer.hpp @@ -27,7 +27,10 @@ #include #include +#include + #include +#include #include #include @@ -81,6 +84,7 @@ class Writer : public BaseWriter std::shared_ptr payload_pool, fastrtps::rtps::RTPSParticipant* rtps_participant, unsigned int max_history_depth, + std::shared_ptr target_guids_filter, const bool repeater = false); /** @@ -160,6 +164,9 @@ class Writer : public BaseWriter std::unique_ptr data_filter_; bool repeater_; + + //! Collects these guid prefixes that the Writer must filter when sending data. + std::shared_ptr target_guids_filter_; }; } /* namespace rtps */ diff --git a/ddsrouter_core/src/cpp/writer/implementations/rtps/filter/SelfDataFilter.cpp b/ddsrouter_core/src/cpp/writer/implementations/rtps/filter/GuidDataFilter.cpp similarity index 69% rename from ddsrouter_core/src/cpp/writer/implementations/rtps/filter/SelfDataFilter.cpp rename to ddsrouter_core/src/cpp/writer/implementations/rtps/filter/GuidDataFilter.cpp index ce87c314a..23c29c7a7 100644 --- a/ddsrouter_core/src/cpp/writer/implementations/rtps/filter/SelfDataFilter.cpp +++ b/ddsrouter_core/src/cpp/writer/implementations/rtps/filter/GuidDataFilter.cpp @@ -13,7 +13,7 @@ // limitations under the License. /** - * @file SelfDataFilter.cpp + * @file GuidDataFilter.cpp */ #include @@ -21,19 +21,26 @@ #include #include -#include +#include namespace eprosima { namespace ddsrouter { namespace core { namespace rtps { -bool SelfDataFilter::is_relevant( +GuidDataFilter::GuidDataFilter(std::shared_ptr target_guids_filter) + : target_guids_filter(target_guids_filter) +{ + // Do nothing +} + + +bool GuidDataFilter::is_relevant( const fastrtps::rtps::CacheChange_t& change, const fastrtps::rtps::GUID_t& reader_guid) const { - // It is relevant only if the reader does not belong to same participant as writer - return change.writerGUID.guidPrefix != reader_guid.guidPrefix; + std::shared_lock lock(*target_guids_filter); + return target_guids_filter->find(reader_guid.guidPrefix) == target_guids_filter->end(); } } /* namespace rtps */ diff --git a/ddsrouter_core/src/cpp/writer/implementations/rtps/filter/SelfDataFilter.hpp b/ddsrouter_core/src/cpp/writer/implementations/rtps/filter/GuidDataFilter.hpp similarity index 80% rename from ddsrouter_core/src/cpp/writer/implementations/rtps/filter/SelfDataFilter.hpp rename to ddsrouter_core/src/cpp/writer/implementations/rtps/filter/GuidDataFilter.hpp index 3184819f7..5e861716c 100644 --- a/ddsrouter_core/src/cpp/writer/implementations/rtps/filter/SelfDataFilter.hpp +++ b/ddsrouter_core/src/cpp/writer/implementations/rtps/filter/GuidDataFilter.hpp @@ -13,7 +13,7 @@ // limitations under the License. /** - * @file SelfDataFilter.hpp + * @file GuidDataFilter.hpp */ #ifndef __SRC_DDSROUTERCORE_PARTICIPANT_IMPLEMENTATIONS_RTPS_FILTER_SelfParticipantDataFilter_HPP_ @@ -21,6 +21,8 @@ #include +#include + ///// // Forward declarations namespace eprosima { @@ -40,11 +42,12 @@ namespace core { namespace rtps { /** - * This filter allows to not send messages from this Writer to the Readers in the same Participant. + * This filter filter messages to those readers belonging to a Participant present in the filter list given. */ -class SelfDataFilter : public fastdds::rtps::IReaderDataFilter +struct GuidDataFilter : public fastdds::rtps::IReaderDataFilter { -public: + + GuidDataFilter(std::shared_ptr target_guids_filter); /** * @brief Whether incoming change is relevant for this reader. @@ -56,6 +59,8 @@ class SelfDataFilter : public fastdds::rtps::IReaderDataFilter const fastrtps::rtps::CacheChange_t& change, const fastrtps::rtps::GUID_t& reader_guid ) const override; + + std::shared_ptr target_guids_filter; }; } /* namespace rtps */ diff --git a/ddsrouter_core/src/cpp/writer/implementations/rtps/filter/RepeaterDataFilter.cpp b/ddsrouter_core/src/cpp/writer/implementations/rtps/filter/RepeaterDataFilter.cpp index d685e5f6c..0e04723a6 100644 --- a/ddsrouter_core/src/cpp/writer/implementations/rtps/filter/RepeaterDataFilter.cpp +++ b/ddsrouter_core/src/cpp/writer/implementations/rtps/filter/RepeaterDataFilter.cpp @@ -32,11 +32,11 @@ bool RepeaterDataFilter::is_relevant( const fastrtps::rtps::CacheChange_t& change, const fastrtps::rtps::GUID_t& reader_guid) const { - if (!SelfDataFilter::is_relevant(change, reader_guid)) + if (!GuidDataFilter::is_relevant(change, reader_guid)) { logDebug( REPEATER_DATA_FILTER, - "Ignoring message by SelfDataFilter is_relevant result."); + "Ignoring message by GuidDataFilter is_relevant result."); // If origin filter does not pass this change, it is discarded return false; diff --git a/ddsrouter_core/src/cpp/writer/implementations/rtps/filter/RepeaterDataFilter.hpp b/ddsrouter_core/src/cpp/writer/implementations/rtps/filter/RepeaterDataFilter.hpp index 91f7737a9..24be8a669 100644 --- a/ddsrouter_core/src/cpp/writer/implementations/rtps/filter/RepeaterDataFilter.hpp +++ b/ddsrouter_core/src/cpp/writer/implementations/rtps/filter/RepeaterDataFilter.hpp @@ -19,7 +19,7 @@ #ifndef __SRC_DDSROUTERCORE_PARTICIPANT_IMPLEMENTATIONS_RTPS_FILTER_REPEATERDATAFILTER_HPP_ #define __SRC_DDSROUTERCORE_PARTICIPANT_IMPLEMENTATIONS_RTPS_FILTER_REPEATERDATAFILTER_HPP_ -#include +#include namespace eprosima { namespace ddsrouter { @@ -34,9 +34,10 @@ namespace rtps { * * This uses the RouterCacheChange extra information. */ -class RepeaterDataFilter : public SelfDataFilter +struct RepeaterDataFilter : public GuidDataFilter { -public: + + using GuidDataFilter::GuidDataFilter; /** * @brief Whether incoming change is relevant for this reader. diff --git a/ddsrouter_test/compose/CMakeLists.txt b/ddsrouter_test/compose/CMakeLists.txt index 048387af5..0e7c44c6c 100644 --- a/ddsrouter_test/compose/CMakeLists.txt +++ b/ddsrouter_test/compose/CMakeLists.txt @@ -18,6 +18,7 @@ set(TESTS repeater_tcp tcp udp + filter_local discovery_server ) diff --git a/ddsrouter_test/compose/filter_local/compose.yml b/ddsrouter_test/compose/filter_local/compose.yml new file mode 100644 index 000000000..a0a2e4f0d --- /dev/null +++ b/ddsrouter_test/compose/filter_local/compose.yml @@ -0,0 +1,70 @@ +# Test description: +# This test checks that 2 DDS Routers can work simultaneously over same local area network without creating a loop. +# There are a Pub and sub in domain 0, and a sub in domain 1; and 2 dds routers from domain 0 to 1. +# +# Note: +# The messages received in Subscriber 2 will be repeated, as both routers will transmit them. +# +# Test architecture: +# + +# TODO: add graph + +services: + + ddsrouter_1: + image: ${DDSROUTER_COMPOSE_TEST_DOCKER_IMAGE} + container_name: ddsrouter_1 + networks: + - std_net + volumes: + - ./ddsrouter_1.yaml:/config.yaml + command: ddsrouter -c /config.yaml --timeout 12 + + ddsrouter_2: + image: ${DDSROUTER_COMPOSE_TEST_DOCKER_IMAGE} + container_name: ddsrouter_2 + networks: + - std_net + volumes: + - ./ddsrouter_2.yaml:/config.yaml + command: ddsrouter -c /config.yaml --timeout 12 + + pub_edge_1: + image: ${DDSROUTER_COMPOSE_TEST_DOCKER_IMAGE} + container_name: pub_edge_1 + depends_on: + - ddsrouter_1 + - ddsrouter_2 + networks: + - std_net + command: install/BasicConfigurationExample/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample publisher --interval 100 --samples 110 --domain 1 + + sub_edge_1: + image: ${DDSROUTER_COMPOSE_TEST_DOCKER_IMAGE} + container_name: sub_edge_1 + depends_on: + - ddsrouter_1 + - ddsrouter_2 + networks: + - std_net + volumes: + - ../execute_and_validate_subscriber.py:/execute_and_validate_subscriber.py + command: python3 /execute_and_validate_subscriber.py --exe install/BasicConfigurationExample/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample --samples 20 --timeout 12 --domain 1 + + sub_edge_2: + image: ${DDSROUTER_COMPOSE_TEST_DOCKER_IMAGE} + container_name: sub_edge_2 + depends_on: + - ddsrouter_1 + - ddsrouter_2 + networks: + - std_net + volumes: + - ../execute_and_validate_subscriber.py:/execute_and_validate_subscriber.py + command: python3 /execute_and_validate_subscriber.py --exe install/BasicConfigurationExample/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample --samples 40 --timeout 12 --domain 2 --allow-duplicates + +networks: + std_net: + default: + driver: none diff --git a/ddsrouter_test/compose/filter_local/ddsrouter_1.yaml b/ddsrouter_test/compose/filter_local/ddsrouter_1.yaml new file mode 100644 index 000000000..c7c3d473f --- /dev/null +++ b/ddsrouter_test/compose/filter_local/ddsrouter_1.yaml @@ -0,0 +1,14 @@ +version: v3.0 + +participants: + + - name: EchoParticipant + kind: echo + + - name: 1_Simple_Participant_1 + kind: local + domain: 1 + + - name: 1_Simple_Participant_2 + kind: local + domain: 2 diff --git a/ddsrouter_test/compose/filter_local/ddsrouter_2.yaml b/ddsrouter_test/compose/filter_local/ddsrouter_2.yaml new file mode 100644 index 000000000..17900541a --- /dev/null +++ b/ddsrouter_test/compose/filter_local/ddsrouter_2.yaml @@ -0,0 +1,14 @@ +version: v3.0 + +participants: + + - name: EchoParticipant + kind: echo + + - name: 2_Simple_Participant_1 + kind: local + domain: 1 + + - name: 2_Simple_Participant_2 + kind: local + domain: 2