Skip to content

Commit

Permalink
Add XSD for static discovery (#3404)
Browse files Browse the repository at this point in the history
* Refs #17824. Add XSD for static discovery

Signed-off-by: Ricardo González Moreno <[email protected]>

* Refs #17842: Include test

Signed-off-by: JesusPoderoso <[email protected]>

* Refs #17842: Update versions md

Signed-off-by: JesusPoderoso <[email protected]>

* Refs #17842: Include sampled blackbox xml in validation test

Signed-off-by: JesusPoderoso <[email protected]>

* Refs #17842: Update blackbox xml to pass validation

Signed-off-by: JesusPoderoso <[email protected]>

---------

Signed-off-by: Ricardo González Moreno <[email protected]>
Signed-off-by: JesusPoderoso <[email protected]>
Co-authored-by: JesusPoderoso <[email protected]>
  • Loading branch information
richiware and JesusPoderoso authored Jun 22, 2023
1 parent 1114723 commit 906e0a1
Show file tree
Hide file tree
Showing 11 changed files with 267 additions and 37 deletions.
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -554,12 +554,17 @@ install(FILES ${PROJECT_SOURCE_DIR}/LICENSE
COMPONENT licenses
)

# Install xml validator
# Install xml validators
install(FILES ${PROJECT_SOURCE_DIR}/resources/xsd/fastRTPS_profiles.xsd
DESTINATION ${DATA_INSTALL_DIR}
COMPONENT xsd
)

install(FILES ${PROJECT_SOURCE_DIR}/resources/xsd/fastdds_static_discovery.xsd
DESTINATION ${DATA_INSTALL_DIR}
COMPONENT xsd
)

option(INSTALL_EXAMPLES "Install example" OFF)

if(INSTALL_EXAMPLES)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<staticdiscovery>
<participant>
<name>HelloWorldPublisher</name>
<writer>
<userId>1</userId>
<entityId>2</entityId>
<participant>
<name>HelloWorldPublisher</name>
<writer>
<userId>1</userId>
<entityID>2</entityID>
<topicName>HelloWorldTopic</topicName>
<topicDataType>HelloWorld</topicDataType>
<topicKind>NO_KEY</topicKind>
<reliabilityQos>RELIABLE_RELIABILITY_QOS</reliabilityQos>
</writer>
</participant>
<topicDataType>HelloWorld</topicDataType>
<topicKind>NO_KEY</topicKind>
<reliabilityQos>RELIABLE_RELIABILITY_QOS</reliabilityQos>
</writer>
</participant>
</staticdiscovery>
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<staticdiscovery>
<participant>
<name>HelloWorldSubscriber</name>
<reader>
<userId>3</userId>
<entityId>4</entityId>
<participant>
<name>HelloWorldSubscriber</name>
<reader>
<userId>3</userId>
<entityID>4</entityID>
<topicName>HelloWorldTopic</topicName>
<topicDataType>HelloWorld</topicDataType>
<topicKind>NO_KEY</topicKind>
<reliabilityQos>RELIABLE_RELIABILITY_QOS</reliabilityQos>
</reader>
</participant>
<topicDataType>HelloWorld</topicDataType>
<topicKind>NO_KEY</topicKind>
<reliabilityQos>RELIABLE_RELIABILITY_QOS</reliabilityQos>
</reader>
</participant>
</staticdiscovery>
139 changes: 139 additions & 0 deletions resources/xsd/fastdds_static_discovery.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:simpleType name="topicKind">
<xs:restriction base="xs:string">
<xs:enumeration value="NO_KEY"/>
<xs:enumeration value="WITH_KEY"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="livelinessKind">
<xs:restriction base="xs:string">
<xs:enumeration value="AUTOMATIC_LIVELINESS_QOS"/>
<xs:enumeration value="MANUAL_BY_PARTICIPANT_LIVELINESS_QOS"/>
<xs:enumeration value="MANUAL_BY_TOPIC_LIVELINESS_QOS"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="ownershipKind">
<xs:restriction base="xs:string">
<xs:enumeration value="SHARED_OWNERSHIP_QOS"/>
<xs:enumeration value="EXCLUSIVE_OWNERSHIP_QOS"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="durationType">
<xs:sequence minOccurs="1" maxOccurs="unbounded">
<xs:choice minOccurs="1">
<xs:element name="sec" minOccurs="0" maxOccurs="1" nillable="true">
<xs:simpleType>
<xs:union>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:enumeration value="DURATION_INFINITY"/>
<xs:enumeration value="DURATION_INFINITE_SEC"/>
<!-- <xs:pattern value="\s*(DURATION_INFINITY|DURATION_INFINITE_SEC)\s*"/> -->
</xs:restriction>
</xs:simpleType>
<xs:simpleType>
<xs:restriction base="xs:unsignedInt"/>
</xs:simpleType>
</xs:union>
</xs:simpleType>
</xs:element>
<xs:element name="nanosec" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:union>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="DURATION_INFINITY"/>
<xs:enumeration value="DURATION_INFINITE_NSEC"/>
<!-- <xs:pattern value="\s*(DURATION_INFINITY|DURATION_INFINITE_NSEC)\s*"/> -->
</xs:restriction>
</xs:simpleType>
<xs:simpleType>
<xs:restriction base="xs:unsignedInt"/>
</xs:simpleType>
</xs:union>
</xs:simpleType>
</xs:element>
</xs:choice>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="leaseDurationType">
<xs:union>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:enumeration value="INF"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType>
<xs:restriction base="xs:unsignedInt"/>
</xs:simpleType>
</xs:union>
</xs:simpleType>
<xs:simpleType name="durabilityQosPolicyType">
<xs:restriction base="xs:string">
<xs:enumeration value="VOLATILE_DURABILITY_QOS"/>
<xs:enumeration value="TRANSIENT_LOCAL_DURABILITY_QOS"/>
<xs:enumeration value="TRANSIENT_DURABILITY_QOS"/>
<xs:enumeration value="PERSISTENT_DURABILITY_QOS"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="livelinessQosProfileType">
<xs:attribute name="kind" type="livelinessKind"/>
<xs:attribute name="leaseDuration_ms" type="leaseDurationType"/>
</xs:complexType>
<xs:simpleType name ="reliabilityQosPolicyType">
<xs:restriction base="xs:string">
<xs:enumeration value="BEST_EFFORT_RELIABILITY_QOS"/>
<xs:enumeration value="RELIABLE_RELIABILITY_QOS"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name ="ownershipQosPolicyType">
<xs:attribute name="kind" type="ownershipKind"/>
</xs:complexType>
<xs:complexType name="locatorType">
<xs:attribute name="address" type="xs:string"/>
<xs:attribute name="port" type="xs:positiveInteger"/>
</xs:complexType>
<xs:complexType name="disablePositiveAcksQosPolicyType">
<xs:all>
<xs:element name="enabled" type="xs:boolean" />
<xs:element name="duration" type="durationType" minOccurs="0"/>
</xs:all>
</xs:complexType>
<xs:complexType name="entityProfileType">
<xs:all>
<xs:element name="userId" type="xs:positiveInteger"/>
<xs:element name="entityID" type="xs:positiveInteger"/>
<xs:element name="expectsInlineQos" type="xs:boolean" minOccurs="0"/>
<xs:element name="topicName" type="xs:string"/>
<xs:element name="topicDataType" type="xs:string"/>
<xs:element name="topicKind" type="topicKind"/>
<xs:element name="partitionQos" type="xs:string" minOccurs="0"/>
<xs:element name="durabilityQos" type="durabilityQosPolicyType" minOccurs="0"/>
<xs:element name="livelinessQos" type="livelinessQosProfileType" minOccurs="0"/>
<xs:element name="reliabilityQos" type="reliabilityQosPolicyType" minOccurs="0"/>
<xs:element name="ownershipQos" type="ownershipQosPolicyType" minOccurs="0"/>
<xs:element name="multicastLocator" type="locatorType" minOccurs="0"/>
<xs:element name="unicastLocator" type="locatorType" minOccurs="0"/>
<xs:element name="disablePositiveAcks" type="disablePositiveAcksQosPolicyType" minOccurs="0"/>
</xs:all>
</xs:complexType>
<xs:complexType name="participantProfileType">
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:choice maxOccurs="unbounded">
<xs:element name="reader" type="entityProfileType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="writer" type="entityProfileType" minOccurs="0" maxOccurs="unbounded"/>
</xs:choice>
</xs:sequence>
</xs:complexType>
<xs:element name="staticdiscovery">
<xs:complexType>
<xs:sequence>
<xs:element name="participant" type="participantProfileType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
6 changes: 2 additions & 4 deletions test/blackbox/PubSubReaderPersistence_static_disc.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@
<reliabilityQos>RELIABLE_RELIABILITY_QOS</reliabilityQos>
<unicastLocator
address="127.0.0.1"
port="@W_UNICAST_PORT_RANDOM_NUMBER@">
</unicastLocator>
port="@W_UNICAST_PORT_RANDOM_NUMBER@"/>
<multicastLocator
address="127.0.0.1"
port="@MULTICAST_PORT_RANDOM_NUMBER@">
</multicastLocator>
port="@MULTICAST_PORT_RANDOM_NUMBER@"/>
<durabilityQos>TRANSIENT_DURABILITY_QOS</durabilityQos>
</writer>
</participant>
Expand Down
6 changes: 2 additions & 4 deletions test/blackbox/PubSubReader_static_disc.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@
<reliabilityQos>RELIABLE_RELIABILITY_QOS</reliabilityQos>
<unicastLocator
address="127.0.0.1"
port="@W_UNICAST_PORT_RANDOM_NUMBER@">
</unicastLocator>
port="@W_UNICAST_PORT_RANDOM_NUMBER@"/>
<multicastLocator
address="127.0.0.1"
port="@MULTICAST_PORT_RANDOM_NUMBER@">
</multicastLocator>
port="@MULTICAST_PORT_RANDOM_NUMBER@"/>
<durabilityQos>TRANSIENT_LOCAL_DURABILITY_QOS</durabilityQos>
</writer>
</participant>
Expand Down
6 changes: 2 additions & 4 deletions test/blackbox/PubSubWriterPersistence_static_disc.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@
<reliabilityQos>RELIABLE_RELIABILITY_QOS</reliabilityQos>
<unicastLocator
address="127.0.0.1"
port="@R_UNICAST_PORT_RANDOM_NUMBER@">
</unicastLocator>
port="@R_UNICAST_PORT_RANDOM_NUMBER@"/>
<multicastLocator
address="127.0.0.1"
port="@MULTICAST_PORT_RANDOM_NUMBER@">
</multicastLocator>
port="@MULTICAST_PORT_RANDOM_NUMBER@"/>
<durabilityQos>TRANSIENT_DURABILITY_QOS</durabilityQos>
</reader>
</participant>
Expand Down
6 changes: 2 additions & 4 deletions test/blackbox/PubSubWriter_static_disc.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@
<reliabilityQos>RELIABLE_RELIABILITY_QOS</reliabilityQos>
<unicastLocator
address="127.0.0.1"
port="@R_UNICAST_PORT_RANDOM_NUMBER@">
</unicastLocator>
port="@R_UNICAST_PORT_RANDOM_NUMBER@"/>
<multicastLocator
address="127.0.0.1"
port="@MULTICAST_PORT_RANDOM_NUMBER@">
</multicastLocator>
port="@MULTICAST_PORT_RANDOM_NUMBER@"/>
<durabilityQos>TRANSIENT_LOCAL_DURABILITY_QOS</durabilityQos>
</reader>
</participant>
Expand Down
55 changes: 55 additions & 0 deletions test/system/tools/fastdds/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,58 @@ endif()

# Define test
add_test(NAME xml.validate COMMAND ${env_fast_command} xml validate xmldocuments)

###############################################################################
# XML Static discovery validation
###############################################################################

# Copy the examples validation files over to the build directory
file(GLOB_RECURSE STATIC_DISC_XML_EXAMPLE ${CMAKE_CURRENT_SOURCE_DIR}/../../../../examples/*_static_disc.xml)

# for each xml file detected in examples folder
foreach(STATIC_DISC_XML_EXAMPLE_COMPLETE_PATH ${STATIC_DISC_XML_EXAMPLE})
# obtain the file name
get_filename_component(STATIC_DISC_XML_EXAMPLE ${STATIC_DISC_XML_EXAMPLE_COMPLETE_PATH} NAME_WE)
# copy the file from src to build folders
configure_file(
${STATIC_DISC_XML_EXAMPLE_COMPLETE_PATH} # from full src path
${CMAKE_CURRENT_BINARY_DIR}/xml_static_disc_docs/examples/${STATIC_DISC_XML_EXAMPLE}.xml # to relative build path
COPYONLY)
endforeach()

# Copy the test validation files over to the build directory
file(GLOB_RECURSE STATIC_DISC_XML_TEST ${CMAKE_CURRENT_SOURCE_DIR}/../*_static_disc.xml)

# for each xml file detected in test folder
foreach(STATIC_DISC_XML_TEST_COMPLETE_PATH ${STATIC_DISC_XML_TEST})
# obtain the file name
get_filename_component(STATIC_DISC_XML_TEST ${STATIC_DISC_XML_TEST_COMPLETE_PATH} NAME_WE)
# copy the file from src to build folders
configure_file(
${STATIC_DISC_XML_TEST_COMPLETE_PATH} # from full src path
${CMAKE_CURRENT_BINARY_DIR}/xml_static_disc_docs/test/system/${STATIC_DISC_XML_TEST}.xml # to relative build path
COPYONLY)
endforeach()

# Copy the sampled test files over to the build directory
file(GLOB_RECURSE STATIC_DISC_XML_SAMPLED_TEST ${CMAKE_CURRENT_SOURCE_DIR}/../../../blackbox/*_static_disc.xml.in)

# set the expected CMake variables for the samples
set(TOPIC_RANDOM_NUMBER "123")
set(W_UNICAST_PORT_RANDOM_NUMBER "456")
set(R_UNICAST_PORT_RANDOM_NUMBER "654")
set(MULTICAST_PORT_RANDOM_NUMBER "789")

# for each xml file detected in examples folder
foreach(STATIC_DISC_XML_SAMPLED_TEST_COMPLETE_PATH ${STATIC_DISC_XML_SAMPLED_TEST})
# obtain the file name
get_filename_component(STATIC_DISC_XML_SAMPLED_TEST ${STATIC_DISC_XML_SAMPLED_TEST_COMPLETE_PATH} NAME_WE)
# copy the file from src to build folders
configure_file(
${STATIC_DISC_XML_SAMPLED_TEST_COMPLETE_PATH} # from full src path
${CMAKE_CURRENT_BINARY_DIR}/xml_static_disc_docs/test/blackbox/${STATIC_DISC_XML_SAMPLED_TEST}.xml # to relative build path
)
endforeach()

# Define test
add_test(NAME xml.static_disc_validate COMMAND ${env_fast_command} xml validate xml_static_disc_docs -x ${CMAKE_SOURCE_DIR}/resources/xsd/fastdds_static_discovery.xsd)
38 changes: 38 additions & 0 deletions test/system/tools/xmlvalidation/discovery_static_disc.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<staticdiscovery>
<participant>
<name>writer_participant</name>
<writer>
<userId>1</userId>
<entityID>2</entityID>
<expectsInlineQos>true</expectsInlineQos>
<topicName>HelloWorldTopic</topicName>
<topicDataType>HelloWorld</topicDataType>
<topicKind>NO_KEY</topicKind>
<partitionQos>customqosgoeshere</partitionQos>
<durabilityQos>TRANSIENT_LOCAL_DURABILITY_QOS</durabilityQos>
<livelinessQos kind="MANUAL_BY_PARTICIPANT_LIVELINESS_QOS" leaseDuration_ms="INF"/>
<unicastLocator address="231.2.3.1" port="231"/>
<reliabilityQos>RELIABLE_RELIABILITY_QOS</reliabilityQos>
</writer>
</participant>
<participant>
<name>reader_participant</name>
<reader>
<userId>1</userId>
<entityID>2</entityID>
<expectsInlineQos>false</expectsInlineQos>
<topicName>HelloWorldTopic</topicName>
<topicDataType>HelloWorld</topicDataType>
<topicKind>WITH_KEY</topicKind>
<ownershipQos kind="SHARED_OWNERSHIP_QOS"/>
<multicastLocator address="123.1.2.3" port="123"/>
<livelinessQos kind="MANUAL_BY_TOPIC_LIVELINESS_QOS" leaseDuration_ms="2560"/>
<disablePositiveAcks>
<enabled>true</enabled>
<duration>
<sec>DURATION_INFINITY</sec>
</duration>
</disablePositiveAcks>
</reader>
</participant>
</staticdiscovery>
1 change: 1 addition & 0 deletions versions.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Forthcoming
* Fixed exported symbols on ContentFilteredTopic (ABI break)
* Deprecated the DDS:Crypto:AES-GCM-GMAC plugin configuration through the DomainParticipant PropertyPolicyQos (security vulnerability).
* `DomainParticipantListener::on_participant_discovery` changed behavior (fix API break in 2.10.0).
* Included XML schema for static discovery profile configuration.

Version 2.10.1
--------------
Expand Down

0 comments on commit 906e0a1

Please sign in to comment.