Skip to content

Commit

Permalink
Revert "Revert "Reconnection tests [12522]""
Browse files Browse the repository at this point in the history
Signed-off-by: RaulSanchez <raul@eprosima.com>
  • Loading branch information
rsanchez15 committed Oct 6, 2021
1 parent 1e4d454 commit 2e3b557
Show file tree
Hide file tree
Showing 29 changed files with 1,859 additions and 25 deletions.
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
19 changes: 9 additions & 10 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
#include <fastrtps/Domain.h>
Expand All @@ -35,21 +35,20 @@ using namespace std;

int main(int argc, char * argv[])
{
// Clear all the consumers.
Log::ClearConsumers();

// Initialize loging
#if defined LOG_LEVEL_INFO
#if LOG_LEVEL_INFO
Log::SetVerbosity(Log::Kind::Info);
#elif defined LOG_LEVEL_WARN
#elif LOG_LEVEL_WARN
Log::SetVerbosity(Log::Kind::Warning);
#elif defined LOG_LEVEL_ERROR
#elif LOG_LEVEL_ERROR
Log::SetVerbosity(Log::Kind::Error);
#else
Log::SetVerbosity(Log::Kind::Error);
#endif

// Clear all the consumers.
Log::ClearConsumers();

Log::SetVerbosity(Log::Kind::Error);
// Log::SetCategoryFilter(std::regex("(INTRAPROCESS)"));

#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
// This allows the test validate the output of the executions
Expand Down
5 changes: 5 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ endif()
# These tests run in all Fast DDS 2.x branches
list(APPEND TEST_LIST
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
)

# The above TEST_LIST has tests that spawn multiple test cases, we need a new variable to enumerate them
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="6">Do not know server B</snapshot>
<snapshot time="10">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="4">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="8">Do not know server B</snapshot>
<snapshot time="13">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

0 comments on commit 2e3b557

Please sign in to comment.