diff --git a/ddsrouter_yaml/test/unittest/configuration/CMakeLists.txt b/ddsrouter_yaml/test/unittest/configuration/CMakeLists.txt index 57971c427..605cba920 100644 --- a/ddsrouter_yaml/test/unittest/configuration/CMakeLists.txt +++ b/ddsrouter_yaml/test/unittest/configuration/CMakeLists.txt @@ -40,6 +40,7 @@ set(TEST_LIST max_tx_rate max_rx_rate downsampling + xml_participant_endpoint_qos_mode ) set(TEST_EXTRA_LIBRARIES diff --git a/ddsrouter_yaml/test/unittest/configuration/YamlReaderConfigurationTest.cpp b/ddsrouter_yaml/test/unittest/configuration/YamlReaderConfigurationTest.cpp index 7de5213cc..15b4e3d2e 100644 --- a/ddsrouter_yaml/test/unittest/configuration/YamlReaderConfigurationTest.cpp +++ b/ddsrouter_yaml/test/unittest/configuration/YamlReaderConfigurationTest.cpp @@ -13,10 +13,12 @@ // limitations under the License. #include +#include #include #include +#include #include #include @@ -704,3 +706,121 @@ int main( ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } + +/** + * Test load of the endpoint QoS mode of the participants in the configuration. + * + * CASES: + * - local participant (no XML endpoint profiles) -> not an XML participant configuration (XML_DISABLED) + * - XML participant without endpoint-qos-mode -> XML_OVERRIDABLE (default) + * - XML participant with xml-overridable -> XML_OVERRIDABLE + * - XML participant with xml-standalone -> XML_STANDALONE + * - XML participant with disabled -> XML_DISABLED + * - XML participant with an unknown value -> ConfigurationException + * - endpoint-qos-mode in a participant that is not XML -> ConfigurationException + */ +TEST(YamlReaderConfigurationTest, xml_participant_endpoint_qos_mode) +{ + // One participant for each endpoint QoS mode + { + const char* yml_configuration = + R"( + version: v5.0 + participants: + - name: local_participant + kind: local + domain: 0 + - name: xml_default_participant + kind: xml + profile: participant_profile + - name: xml_overridable_participant + kind: xml + profile: participant_profile + endpoint-qos-mode: xml-overridable + - name: xml_standalone_participant + kind: xml + profile: participant_profile + endpoint-qos-mode: xml-standalone + - name: xml_disabled_participant + kind: xml + profile: participant_profile + endpoint-qos-mode: disabled + )"; + + ddsrouter::core::DdsRouterConfiguration configuration = + ddsrouter::yaml::YamlReaderConfiguration::load_ddsrouter_configuration(YAML::Load(yml_configuration)); + + std::map> participants; + for (const auto& participant : configuration.participants_configurations) + { + participants[participant.second->id] = participant.second; + } + ASSERT_EQ(5u, participants.size()); + + auto endpoint_qos_mode = [&participants](const std::string& name) + { + auto xml_configuration = + std::dynamic_pointer_cast( + participants.at(name)); + EXPECT_NE(nullptr, xml_configuration) << name << " is not an XML participant"; + return xml_configuration ? xml_configuration->endpoint_qos_mode + : ddspipe::participants::EndpointQoSMode::XML_DISABLED; + }; + + // XML_DISABLED: the local participant is not an XML participant, so it never looks up XML endpoint profiles + EXPECT_EQ(nullptr, + std::dynamic_pointer_cast( + participants.at("local_participant"))); + + // XML_OVERRIDABLE + EXPECT_EQ(ddspipe::participants::EndpointQoSMode::XML_OVERRIDABLE, + endpoint_qos_mode("xml_default_participant")); + EXPECT_EQ(ddspipe::participants::EndpointQoSMode::XML_OVERRIDABLE, + endpoint_qos_mode("xml_overridable_participant")); + + // XML_STANDALONE + EXPECT_EQ(ddspipe::participants::EndpointQoSMode::XML_STANDALONE, + endpoint_qos_mode("xml_standalone_participant")); + + // XML_DISABLED: XML participant that does not look up XML endpoint profiles + EXPECT_EQ(ddspipe::participants::EndpointQoSMode::XML_DISABLED, + endpoint_qos_mode("xml_disabled_participant")); + } + + // Unknown value + { + const char* yml_configuration = + R"( + version: v5.0 + participants: + - name: P1 + kind: echo + - name: P2 + kind: xml + profile: participant_profile + endpoint-qos-mode: xml-only + )"; + + EXPECT_THROW( + ddsrouter::yaml::YamlReaderConfiguration::load_ddsrouter_configuration(YAML::Load(yml_configuration)), + utils::ConfigurationException); + } + + // Set in a participant that is not XML + { + const char* yml_configuration = + R"( + version: v5.0 + participants: + - name: P1 + kind: echo + - name: P2 + kind: local + endpoint-qos-mode: xml-standalone + )"; + + EXPECT_THROW( + ddsrouter::yaml::YamlReaderConfiguration::load_ddsrouter_configuration(YAML::Load(yml_configuration)), + utils::ConfigurationException); + } +} diff --git a/ddsrouter_yaml/test/unittest/ddsrouter_yaml_validator/YamlValidatorDdsRouterTest.cpp b/ddsrouter_yaml/test/unittest/ddsrouter_yaml_validator/YamlValidatorDdsRouterTest.cpp index 89831a11d..9469bdbf0 100644 --- a/ddsrouter_yaml/test/unittest/ddsrouter_yaml_validator/YamlValidatorDdsRouterTest.cpp +++ b/ddsrouter_yaml/test/unittest/ddsrouter_yaml_validator/YamlValidatorDdsRouterTest.cpp @@ -32,6 +32,7 @@ std::string schema_path = "./ddsrouter_config_schema.json"; // Vectors with the valid and invalid YAML files std::vector valid_files = { "./valid_config_files_router/docu_example.yaml", + "./valid_config_files_router/endpoint_qos_mode.yaml", "./valid_config_files_router/schema_rules.yaml", // Config files copied automatically from DDS-Router/docs/resources/getting_started "./valid_config_files_router/client-ddsrouter.yaml", @@ -61,6 +62,8 @@ std::vector invalid_files = { "./invalid_config_files_router/ds_guid_id_out_of_range.yaml", "./invalid_config_files_router/ds_participant_no_listening_nor_connection_addresses.yaml", "./invalid_config_files_router/ds_with_transport.yaml", + "./invalid_config_files_router/endpoint_qos_mode_invalid_value.yaml", + "./invalid_config_files_router/endpoint_qos_mode_non_xml_participant.yaml", "./invalid_config_files_router/easy_mode_with_whitelist.yaml", "./invalid_config_files_router/filter_topic_no_name.yaml", "./invalid_config_files_router/initial_peers_no_addresses.yaml", diff --git a/ddsrouter_yaml/test/unittest/ddsrouter_yaml_validator/invalid_config_files_router/endpoint_qos_mode_invalid_value.yaml b/ddsrouter_yaml/test/unittest/ddsrouter_yaml_validator/invalid_config_files_router/endpoint_qos_mode_invalid_value.yaml new file mode 100644 index 000000000..868e3d65f --- /dev/null +++ b/ddsrouter_yaml/test/unittest/ddsrouter_yaml_validator/invalid_config_files_router/endpoint_qos_mode_invalid_value.yaml @@ -0,0 +1,11 @@ +version: v5.0 + +participants: + + - name: EchoParticipant + kind: echo + + - name: xml_participant + kind: xml + profile: custom_participant_configuration + endpoint-qos-mode: xml-only diff --git a/ddsrouter_yaml/test/unittest/ddsrouter_yaml_validator/invalid_config_files_router/endpoint_qos_mode_non_xml_participant.yaml b/ddsrouter_yaml/test/unittest/ddsrouter_yaml_validator/invalid_config_files_router/endpoint_qos_mode_non_xml_participant.yaml new file mode 100644 index 000000000..481e078c0 --- /dev/null +++ b/ddsrouter_yaml/test/unittest/ddsrouter_yaml_validator/invalid_config_files_router/endpoint_qos_mode_non_xml_participant.yaml @@ -0,0 +1,11 @@ +version: v5.0 + +participants: + + - name: EchoParticipant + kind: echo + + - name: simple_participant + kind: local + domain: 0 + endpoint-qos-mode: xml-standalone diff --git a/ddsrouter_yaml/test/unittest/ddsrouter_yaml_validator/valid_config_files_router/docu_example.yaml b/ddsrouter_yaml/test/unittest/ddsrouter_yaml_validator/valid_config_files_router/docu_example.yaml index 98976323c..c944895cc 100644 --- a/ddsrouter_yaml/test/unittest/ddsrouter_yaml_validator/valid_config_files_router/docu_example.yaml +++ b/ddsrouter_yaml/test/unittest/ddsrouter_yaml_validator/valid_config_files_router/docu_example.yaml @@ -190,6 +190,8 @@ participants: profile: custom_participant_configuration # Configure participant with this profile + endpoint-qos-mode: xml-overridable # XML endpoint profiles overridden by the Topic QoS (default) + # Custom generic forwarding route. routes: diff --git a/ddsrouter_yaml/test/unittest/ddsrouter_yaml_validator/valid_config_files_router/endpoint_qos_mode.yaml b/ddsrouter_yaml/test/unittest/ddsrouter_yaml_validator/valid_config_files_router/endpoint_qos_mode.yaml new file mode 100644 index 000000000..d8d36a7fc --- /dev/null +++ b/ddsrouter_yaml/test/unittest/ddsrouter_yaml_validator/valid_config_files_router/endpoint_qos_mode.yaml @@ -0,0 +1,31 @@ +version: v5.0 + +participants: + + # Not an XML participant: XML endpoint profiles are never looked up (XML_DISABLED) + - name: local_participant + kind: local + domain: 0 + + # XML participant without endpoint-qos-mode: xml-overridable by default (XML_OVERRIDABLE) + - name: xml_default_participant + kind: xml + profile: participant_profile + + # XML profile as base, overridden by the Topic QoS (XML_OVERRIDABLE) + - name: xml_overridable_participant + kind: xml + profile: participant_profile + endpoint-qos-mode: xml-overridable + + # XML profile used as is (XML_STANDALONE) + - name: xml_standalone_participant + kind: xml + profile: participant_profile + endpoint-qos-mode: xml-standalone + + # XML endpoint profiles not looked up (XML_DISABLED) + - name: xml_disabled_participant + kind: xml + profile: participant_profile + endpoint-qos-mode: disabled diff --git a/docs/rst/notes/forthcoming_version.rst b/docs/rst/notes/forthcoming_version.rst index eac3087ed..533cd8590 100644 --- a/docs/rst/notes/forthcoming_version.rst +++ b/docs/rst/notes/forthcoming_version.rst @@ -6,3 +6,10 @@ Forthcoming Version ################### +Next release will include the following **features**: + +* Add the ``endpoint-qos-mode`` tag to the XML Participant to choose how a matching XML endpoint profile is applied + (see :ref:`Endpoint QoS mode `). + By default (``xml-overridable``), the profile is used as base and its durability, reliability, ownership and history + are taken from the YAML configuration or from the discovered remote endpoints; ``xml-standalone`` applies the profile + as is; ``disabled`` does not look up any XML endpoint profile. diff --git a/docs/rst/user_manual/configuration.rst b/docs/rst/user_manual/configuration.rst index 6b44f8c50..fb65f0463 100644 --- a/docs/rst/user_manual/configuration.rst +++ b/docs/rst/user_manual/configuration.rst @@ -746,6 +746,7 @@ The tags of a Participant are arranged as follows, and the sections below follow tls: ... # TLS configuration (see WAN Configuration) profile: ... # XML profile of an XML Participant + endpoint-qos-mode: ... # How the XML endpoint profiles are applied in an XML Participant qos: ... # Topic QoS of the Participant @@ -1062,6 +1063,19 @@ It will use such profile for configuring the Participant. profile: participant_custom_configuration +.. _user_manual_configuration_endpoint_qos_mode: + +Endpoint QoS mode +----------------- + +Tag ``endpoint-qos-mode`` sets how an :ref:`XML Participant ` applies the XML endpoint +profiles: ``xml-overridable`` (default), ``xml-standalone`` or ``disabled``. +See :ref:`user_manual_participants_xml_endpoint_qos_mode`. + +.. code-block:: yaml + + endpoint-qos-mode: xml-standalone + .. _user_manual_configuration_participant_topic_qos: @@ -1357,6 +1371,8 @@ A complete example of all the configurations described on this page can be found profile: custom_participant_configuration # Configure participant with this profile + endpoint-qos-mode: xml-overridable # XML endpoint profiles overridden by the Topic QoS (default) + # Custom generic forwarding route. routes: diff --git a/docs/rst/user_manual/participants/xml.rst b/docs/rst/user_manual/participants/xml.rst index e28e8431a..40a0c64b4 100644 --- a/docs/rst/user_manual/participants/xml.rst +++ b/docs/rst/user_manual/participants/xml.rst @@ -83,6 +83,7 @@ Endpoint profiles When the XML Participant creates a :term:`DataWriter` or :term:`DataReader` for a topic, it looks for a loaded XML ``data_writer`` or ``data_reader`` profile to configure that endpoint. By default, the |ddsrouter| looks for a profile **whose name matches the topic name**. If a matching profile is found, the endpoint is configured using that profile's QoS, giving the user control over fields such as history, memory policy, transport, etc. +By default, ``durability``, ``reliability``, ``ownership`` and ``history`` are still taken from the YAML configuration and from discovery; see :ref:`user_manual_participants_xml_endpoint_qos_mode` to use the profile as is. If no matching profile exists, the endpoint falls back to default QoS with values derived from the YAML configuration and from discovery. .. note:: @@ -130,20 +131,48 @@ Like any other Topic QoS, ``endpoint-profile-name`` can be set in the :ref:`Manu Since XML profiles are loaded for the whole |ddsrouter| process, this is the way to apply different profiles to the same topic in different XML Participants. If no profile with that name is loaded, the |ddsrouter| does not look for a profile named after the topic; the endpoint falls back to default QoS instead. -Overriding profile QoS from the YAML configuration -"""""""""""""""""""""""""""""""""""""""""""""""""" +.. _user_manual_participants_xml_endpoint_qos_mode: -When a matching XML profile is applied, the following :ref:`Topic QoS ` override the corresponding values from the profile, but only if they are explicitly set in the YAML configuration (in the Manual Topics, the Participant Topic QoS or the Specs Topic QoS): -``durability``, ``reliability``, ``ownership`` and ``history-depth``. -Every other field keeps the value from the XML profile. +Endpoint QoS mode +""""""""""""""""" -QoS values that the |ddsrouter| learns from remote endpoints during discovery never override the XML profile. -Fields that are set neither in the XML profile nor in the YAML configuration therefore take the |fastdds| default values (e.g. ``KEEP_LAST`` history with depth ``1``), instead of being adapted to the discovered endpoints. +The ``endpoint-qos-mode`` tag of the XML Participant sets how a matching XML endpoint profile is applied: + +.. list-table:: + :header-rows: 1 + + * - Value + - Behavior + + * - ``xml-overridable`` (default) + - The XML profile is used as base. + ``durability``, ``reliability``, ``ownership`` and ``history`` are taken from the :ref:`Topic QoS `, with priority: + YAML configuration (Manual Topics, Participant Topic QoS or Specs Topic QoS) > QoS discovered from the remote endpoints > |ddsrouter| defaults. + Every other policy keeps the value of the XML profile. + + * - ``xml-standalone`` + - The XML profile is used as is. + Neither the YAML configuration nor the discovered QoS override it. + + * - ``disabled`` + - No XML endpoint profile is looked up, as if none were loaded: the endpoints take their QoS from the :ref:`Topic QoS `. + Useful to stop applying the XML endpoint profiles without removing them from the XML configuration. + +When no profile is found, the endpoint takes ``durability``, ``reliability``, ``ownership`` and ``history`` from the Topic QoS with ``xml-overridable`` and ``xml-standalone``. +The ``endpoint-qos-mode`` tag is only accepted by XML Participants. +The endpoints of any other Participant kind never look up XML endpoint profiles, so they always take their QoS from the Topic QoS. + +.. code-block:: yaml + + - name: xml_participant + kind: xml + profile: custom_participant_configuration + endpoint-qos-mode: xml-standalone # Use the XML endpoint profiles as is .. warning:: - Setting ``history-depth`` in the Specs Topic QoS overrides the history of every matching XML profile, even when it is set to its default value of ``5000``. - Likewise, if the remote DataWriters use ``EXCLUSIVE_OWNERSHIP_QOS``, set ``ownership`` either in the XML profile or in the YAML configuration, otherwise the DataReaders of the XML Participant will not match them. + With ``xml-standalone``, the endpoints of the XML Participant do not adapt to the QoS of the remote endpoints. + Make sure the XML profiles are compatible with them; e.g. if the remote DataWriters use ``EXCLUSIVE_OWNERSHIP_QOS``, set it in the ``data_writer`` and ``data_reader`` profiles, otherwise the endpoints of the XML Participant will not match them. Repeater @@ -166,3 +195,5 @@ Use |fastdds| or |ddsrouter| support to load XML configuration files as explaine kind: xml profile: custom_participant_configuration # Configure participant with this profile + + endpoint-qos-mode: xml-overridable # XML endpoint profiles overridden by the Topic QoS (default) diff --git a/resources/configurations/ddsrouter_config_schema.json b/resources/configurations/ddsrouter_config_schema.json index 9b15cb6f5..f5e0587b5 100644 --- a/resources/configurations/ddsrouter_config_schema.json +++ b/resources/configurations/ddsrouter_config_schema.json @@ -481,6 +481,14 @@ }, "profile":{ "type":"string" + }, + "endpoint-qos-mode":{ + "type":"string", + "enum":[ + "xml-overridable", + "xml-standalone", + "disabled" + ] } }, "required":[ @@ -559,6 +567,11 @@ "profile":{ "not":{ + } + }, + "endpoint-qos-mode":{ + "not":{ + } } } @@ -623,6 +636,11 @@ "profile":{ "not":{ + } + }, + "endpoint-qos-mode":{ + "not":{ + } } } @@ -714,6 +732,11 @@ "profile":{ "not":{ + } + }, + "endpoint-qos-mode":{ + "not":{ + } } } @@ -790,6 +813,11 @@ "profile":{ "not":{ + } + }, + "endpoint-qos-mode":{ + "not":{ + } } }