Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reconnection tests [12522] #45

Merged
merged 11 commits into from
Nov 22, 2021
14 changes: 3 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,17 +176,9 @@ endif()
# Logging
###############################################################################

if(NOT DEFINED LOG_LEVEL_INFO)
set(LOG_LEVEL_INFO OFF)
endif()

if(NOT DEFINED LOG_LEVEL_WARN)
set(LOG_LEVEL_WARN OFF)
endif()

if(NOT DEFINED LOG_LEVEL_ERROR)
SET(LOG_LEVEL_ERROR ON)
endif()
option(LOG_LEVEL_INFO OFF)
option(LOG_LEVEL_WARN OFF)
option(LOG_LEVEL_ERROR OFF)

add_definitions(-DLOG_LEVEL_INFO=$<STREQUAL:$<UPPER_CASE:${LOG_LEVEL_INFO}>,ON>)
add_definitions(-DLOG_LEVEL_WARN=$<STREQUAL:$<UPPER_CASE:${LOG_LEVEL_WARN}>,ON>)
Expand Down
8 changes: 4 additions & 4 deletions src/DSLog.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
#ifndef _EPROSIMA_IS_LOG_H_
#define _EPROSIMA_IS_LOG_H_

#if defined LOG_LEVEL_INFO && LOG_LEVEL_INFO
#if defined LOG_LEVEL_INFO && LOG_LEVEL_INFO
#define __INTERNALDEBUG
#define __DEBUG
#define __DEBUG
#undef LOG_NO_INFO
#undef LOG_NO_WARN
#undef LOG_NO_ERROR
#elif defined LOG_LEVEL_WARN && LOG_LEVEL_WARN
#elif defined LOG_LEVEL_WARN && LOG_LEVEL_WARN
#define LOG_NO_INFO
#undef LOG_NO_WARN
#undef LOG_NO_ERROR
#elif defined LOG_LEVEL_ERROR && LOG_LEVEL_ERROR
#elif defined LOG_LEVEL_ERROR && LOG_LEVEL_ERROR
#define LOG_NO_INFO
#define LOG_NO_WARN
#undef LOG_NO_ERROR
Expand Down
7 changes: 2 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "log/DSLog.h"
#include "version/config.h"

#if FASTRTPS_VERSION_MAJOR >= 2 && FASTRTPS_VERSION_MINOR >= 1
#if FASTRTPS_VERSION_MAJOR > 2 || (FASTRTPS_VERSION_MAJOR == 2 && FASTRTPS_VERSION_MINOR >= 1)
#include <fastdds/dds/log/StdoutErrConsumer.hpp>
#endif // if FASTRTPS_VERSION_MAJOR >= 2 && FASTRTPS_VERSION_MINOR >= 1
#include <fastrtps/xmlparser/XMLProfileManager.h>
Expand Down Expand Up @@ -48,10 +48,7 @@ int main(
Log::SetVerbosity(Log::Kind::Error);
#else
Log::SetVerbosity(Log::Kind::Error);
#endif // if defined LOG_LEVEL_INFO


// Log::SetCategoryFilter(std::regex("(DISCOVERY_SERVER)"));
#endif // if LOG_LEVEL_INFO

#if FASTRTPS_VERSION_MAJOR >= 2 && FASTRTPS_VERSION_MINOR >= 1
// Create a StdoutErrConsumer consumer that logs entries to stderr only when the Log::Kind is equal to WARNING
Expand Down
13 changes: 11 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ list(APPEND TEST_LIST
test_34_connect_locally_with_remote_server

test_38_self_connection

test_39_trivial_reconnect
test_40_trivial_server_reconnect
test_41_reconnect_with_clients
test_42_server_reconnect_with_clients
test_43_complex_reconnect
test_44_fast_discovery_server_tool_reconnect
test_45_trivial_client_reconnect

test_60_disconnection
)

Expand All @@ -103,13 +112,13 @@ if(fastrtps_VERSION VERSION_GREATER_EQUAL "2.3.0")
)
endif()

# Adding remote servers while running was introduced in Fast DDS v2.4.0
# Adding DNS and Environment modification while running was introduced in Fast DDS v2.4.0
if(fastrtps_VERSION VERSION_GREATER_EQUAL "2.4.0")
list(APPEND TEST_LIST
test_36_dns_environment_variable_setup
test_37_dns_fast_discovery_server_tool

test_39_environment_modification
test_50_environment_modification
)
endif()

Expand Down
40 changes: 40 additions & 0 deletions test/configuration/test_cases/test_39_trivial_reconnect_A.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<DS xmlns="http://www.eprosima.com/XMLSchemas/discovery-server" user_shutdown="false">

<servers>
<server name="server" profile_name="UDP server A" />
</servers>

<snapshots file="./test_39_trivial_reconnect_A.snapshot~">
<snapshot time="2">Knows server B</snapshot>
<snapshot time="7">Do not know server B</snapshot>
<snapshot time="11">Knows server B</snapshot>
</snapshots>

<profiles>
<participant profile_name="UDP server A">
<rtps>
<prefix>44.49.53.43.53.45.52.56.45.52.5F.31</prefix>
<builtin>
<discovery_config>
<discoveryProtocol>SERVER</discoveryProtocol>
<initialAnnouncements>
<count>0</count>
</initialAnnouncements>
<leaseAnnouncement>DURATION_INFINITY</leaseAnnouncement>
<leaseDuration>DURATION_INFINITY</leaseDuration>
</discovery_config>
<metatrafficUnicastLocatorList>
<locator>
<udpv4>
<address>127.0.0.1</address>
<port>39811</port>
</udpv4>
</locator>
</metatrafficUnicastLocatorList>
</builtin>
</rtps>
</participant>

</profiles>
</DS>
52 changes: 52 additions & 0 deletions test/configuration/test_cases/test_39_trivial_reconnect_B.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<DS xmlns="http://www.eprosima.com/XMLSchemas/discovery-server" user_shutdown="false">

<servers>
<server name="server" profile_name="UDP server B" />
</servers>

<snapshots file="./test_39_trivial_reconnect_B.snapshot~">
<snapshot time="2">Knows A</snapshot>
<snapshot time="5">Do not know A</snapshot>
</snapshots>

<profiles>

<participant profile_name="UDP server B">
<rtps>
<prefix>44.49.53.43.53.45.52.56.45.52.5F.32</prefix>
<builtin>
<discovery_config>
<discoveryProtocol>SERVER</discoveryProtocol>
<discoveryServersList>
<RemoteServer prefix="44.49.53.43.53.45.52.56.45.52.5F.31">
<metatrafficUnicastLocatorList>
<locator>
<udpv4>
<address>127.0.0.1</address>
<port>39811</port>
</udpv4>
</locator>
</metatrafficUnicastLocatorList>
</RemoteServer>
</discoveryServersList>
<initialAnnouncements>
<count>0</count>
</initialAnnouncements>
<leaseAnnouncement>DURATION_INFINITY</leaseAnnouncement>
<leaseDuration>DURATION_INFINITY</leaseDuration>
</discovery_config>
<metatrafficUnicastLocatorList>
<locator>
<udpv4>
<address>127.0.0.1</address>
<port>39812</port>
</udpv4>
</locator>
</metatrafficUnicastLocatorList>
</builtin>
</rtps>
</participant>

</profiles>
</DS>
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<DS xmlns="http://www.eprosima.com/XMLSchemas/discovery-server" user_shutdown="false">

<servers>
<server name="server" profile_name="UDP server A" />
</servers>

<snapshots file="./test_40_trivial_server_reconnect_A.snapshot~">
<snapshot time="2">Knows server B</snapshot>
<snapshot time="7">Do not know server B</snapshot>
<snapshot time="11">Knows server B</snapshot>
</snapshots>

<profiles>
<participant profile_name="UDP server A">
<rtps>
<prefix>44.49.53.43.53.45.52.56.45.52.5F.31</prefix>
<builtin>
<discovery_config>
<discoveryProtocol>SERVER</discoveryProtocol>
<discoveryServersList>
<RemoteServer prefix="44.49.53.43.53.45.52.56.45.52.5F.32">
<metatrafficUnicastLocatorList>
<locator>
<udpv4>
<address>127.0.0.1</address>
<port>40812</port>
</udpv4>
</locator>
</metatrafficUnicastLocatorList>
</RemoteServer>
</discoveryServersList>
<initialAnnouncements>
<count>0</count>
</initialAnnouncements>
<leaseAnnouncement>DURATION_INFINITY</leaseAnnouncement>
<leaseDuration>DURATION_INFINITY</leaseDuration>
</discovery_config>
<metatrafficUnicastLocatorList>
<locator>
<udpv4>
<address>127.0.0.1</address>
<port>40811</port>
</udpv4>
</locator>
</metatrafficUnicastLocatorList>
</builtin>
</rtps>
</participant>

</profiles>
</DS>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<DS xmlns="http://www.eprosima.com/XMLSchemas/discovery-server" user_shutdown="false">

<servers>
<server name="server" profile_name="UDP server B" />
</servers>

<snapshots file="./test_40_trivial_server_reconnect_B.snapshot~">
<snapshot time="3">Knows A</snapshot>
<snapshot time="5">Do not know A</snapshot>
</snapshots>

<profiles>

<participant profile_name="UDP server B">
<rtps>
<prefix>44.49.53.43.53.45.52.56.45.52.5F.32</prefix>
<builtin>
<discovery_config>
<discoveryProtocol>SERVER</discoveryProtocol>
<initialAnnouncements>
<count>0</count>
</initialAnnouncements>
<leaseAnnouncement>DURATION_INFINITY</leaseAnnouncement>
<leaseDuration>DURATION_INFINITY</leaseDuration>
</discovery_config>
<metatrafficUnicastLocatorList>
<locator>
<udpv4>
<address>127.0.0.1</address>
<port>40812</port>
</udpv4>
</locator>
</metatrafficUnicastLocatorList>
</builtin>
</rtps>
</participant>

</profiles>
</DS>
89 changes: 89 additions & 0 deletions test/configuration/test_cases/test_41_reconnect_with_clients_A.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<DS xmlns="http://www.eprosima.com/XMLSchemas/discovery-server" user_shutdown="false">

<servers>
<server name="server" profile_name="UDP server A" />
</servers>

<clients>
<client name="client1" profile_name="UDP_client1_serverA">
<publisher topic="topic1"/>
</client>
</clients>

<snapshots file="./test_41_reconnect_with_clients_A.snapshot~">
<snapshot time="2">Knows server B, client A and client B</snapshot>
<snapshot time="12">Do not know server B</snapshot>
<snapshot time="18">Knows server B, client A and client B</snapshot>
</snapshots>

<profiles>

<participant profile_name="UDP_client1_serverA" >
<rtps>
<prefix>63.6c.69.65.6e.74.31.5f.73.31.5f.5f</prefix>
<builtin>
<discovery_config>
<discoveryProtocol>CLIENT</discoveryProtocol>
<discoveryServersList>
<RemoteServer prefix="44.49.53.43.53.45.52.56.45.52.5F.31">
<metatrafficUnicastLocatorList>
<locator>
<udpv4>
<address>127.0.0.1</address>
<port>41811</port>
</udpv4>
</locator>
</metatrafficUnicastLocatorList>
</RemoteServer>
</discoveryServersList>
<initialAnnouncements>
<count>0</count>
</initialAnnouncements>
<leaseAnnouncement>DURATION_INFINITY</leaseAnnouncement>
<leaseDuration>DURATION_INFINITY</leaseDuration>
</discovery_config>
</builtin>
</rtps>
</participant>

<participant profile_name="UDP server A">
<rtps>
<prefix>44.49.53.43.53.45.52.56.45.52.5F.31</prefix>
<builtin>
<discovery_config>
<discoveryProtocol>SERVER</discoveryProtocol>
<initialAnnouncements>
<count>0</count>
</initialAnnouncements>
<leaseAnnouncement>DURATION_INFINITY</leaseAnnouncement>
<leaseDuration>DURATION_INFINITY</leaseDuration>
</discovery_config>
<metatrafficUnicastLocatorList>
<locator>
<udpv4>
<address>127.0.0.1</address>
<port>41811</port>
</udpv4>
</locator>
</metatrafficUnicastLocatorList>
</builtin>
</rtps>
</participant>

<topic profile_name="topic1">
<name>topic_1</name>
<dataType>sample_type_1</dataType>
</topic>

<types>
<type>
<struct name="sample_type_1">
<member name="index" type="uint32" />
<member name="message" type="string" />
</struct>
</type>
</types>

</profiles>
</DS>
Loading