Skip to content

Commit

Permalink
Refs #12522: Add client reconnect test
Browse files Browse the repository at this point in the history
Signed-off-by: jparisu <javierparis@eprosima.com>
  • Loading branch information
jparisu committed Oct 28, 2021
1 parent 65298f7 commit 242f4b7
Show file tree
Hide file tree
Showing 6 changed files with 213 additions and 29 deletions.
12 changes: 0 additions & 12 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,6 @@ int main(
int argc,
char* argv[])
{
<<<<<<< HEAD

// Initialize loging
#if defined LOG_LEVEL_INFO
Log::SetVerbosity(Log::Kind::Info);
#elif defined LOG_LEVEL_WARN
Log::SetVerbosity(Log::Kind::Warning);
#elif defined LOG_LEVEL_ERROR
Log::SetVerbosity(Log::Kind::Error);
#endif // if defined LOG_LEVEL_INFO
=======
// Clear all the consumers.
Log::ClearConsumers();

Expand All @@ -60,7 +49,6 @@ int main(
#else
Log::SetVerbosity(Log::Kind::Error);
#endif
>>>>>>> 2e3b557... Revert "Revert "Reconnection tests [12522]""

#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
35 changes: 18 additions & 17 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,13 @@ list(APPEND TEST_LIST
test_42_server_reconnect_with_clients
test_43_complex_reconnect
test_44_fast_discovery_server_tool_reconnect
test_45_trivial_client_reconnect
)

# FASTDDS_ENVIRONMENT_FILE was introduced in Fast DDS v2.4.0
if(fastrtps_VERSION VERSION_GREATER_EQUAL "2.4.0")
list(APPEND TEST_LIST
test_39_environment_modification
test_50_environment_modification
)
endif()

Expand All @@ -133,22 +134,22 @@ set(TEST_CASE_LIST)

foreach(TEST IN LISTS TEST_LIST)

unset(TEST_NAME)
set(TEST_NAME "discovery_server_test.${TEST}.SHM_ON")
list(APPEND TEST_CASE_LIST ${TEST_NAME})
# Test with shared memory
add_test(NAME ${TEST_NAME}
COMMAND ${PYTHON_EXECUTABLE} ${RUN_TEST}
-e $<TARGET_FILE:${PROJECT_NAME}>
-p ${TESTS_PARAMS}
-f $<$<TARGET_EXISTS:fastdds::fast-discovery-server>:$<TARGET_FILE:fastdds::fast-discovery-server>>
-t ${TEST}
-s true
-i false) # Remove this argument to execute test with and without intraprocess
# --force-remove # Add this argument to erase every file generated during test execution
set_tests_properties(${TEST_NAME} PROPERTIES
REQUIRED_FILES ${RUN_TEST}
REQUIRED_FILES ${TESTS_PARAMS})
# unset(TEST_NAME)
# set(TEST_NAME "discovery_server_test.${TEST}.SHM_ON")
# list(APPEND TEST_CASE_LIST ${TEST_NAME})
# # Test with shared memory
# add_test(NAME ${TEST_NAME}
# COMMAND ${PYTHON_EXECUTABLE} ${RUN_TEST}
# -e $<TARGET_FILE:${PROJECT_NAME}>
# -p ${TESTS_PARAMS}
# -f $<$<TARGET_EXISTS:fastdds::fast-discovery-server>:$<TARGET_FILE:fastdds::fast-discovery-server>>
# -t ${TEST}
# -s true
# -i false) # Remove this argument to execute test with and without intraprocess
# # --force-remove # Add this argument to erase every file generated during test execution
# set_tests_properties(${TEST_NAME} PROPERTIES
# REQUIRED_FILES ${RUN_TEST}
# REQUIRED_FILES ${TESTS_PARAMS})

unset(TEST_NAME)
set(TEST_NAME "discovery_server_test.${TEST}.SHM_OFF")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<DS xmlns="http://www.eprosima.com/XMLSchemas/discovery-server" user_shutdown="false">

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

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

<profiles>
<participant profile_name="UDP_client1_server1" >
<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>45811</port>
</udpv4>
</locator>
</metatrafficUnicastLocatorList>
</RemoteServer>
</discoveryServersList>
<initialAnnouncements>
<count>0</count>
</initialAnnouncements>
<leaseAnnouncement>DURATION_INFINITY</leaseAnnouncement>
<leaseDuration>DURATION_INFINITY</leaseDuration>
</discovery_config>
</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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?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" />
</servers>

<snapshots file="./test_45_trivial_client_reconnect_server.snapshot~">
<snapshot time="4">Do know the client</snapshot>
</snapshots>

<profiles>
<participant profile_name="UDP server">
<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>45811</port>
</udpv4>
</locator>
</metatrafficUnicastLocatorList>
</builtin>
</rtps>
</participant>

</profiles>
</DS>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<DS_Snapshots xmlns="http://www.eprosima.com/XMLSchemas/ds-snapshot">
<DS_Snapshot timestamp="1635259147427" process_time="2000" last_pdp_callback_time="126" last_edp_callback_time="12" someone="true">
<description>Knows server B</description>
<ptdb guid_prefix="63.6c.69.65.6e.74.31.5f.73.31.5f.5f" guid_entity="0.0.1.c1">
<ptdi guid_prefix="44.49.53.43.53.45.52.56.45.52.5f.31" guid_entity="0.0.1.c1" server="false" alive="true" name="server" discovered_timestamp="126"/>
<ptdi guid_prefix="63.6c.69.65.6e.74.31.5f.73.31.5f.5f" guid_entity="0.0.1.c1" server="false" alive="true" name="" discovered_timestamp="12">
<publisher type="sample_type_1" topic="topic_1" guid_prefix="63.6c.69.65.6e.74.31.5f.73.31.5f.5f" guid_entity="0.0.1.3" discovered_timestamp="12"/>
</ptdi>
</ptdb>
</DS_Snapshot>
<DS_Snapshot timestamp="1635259150427" process_time="5000" last_pdp_callback_time="126" last_edp_callback_time="12" someone="true">
<description>Do not know server B</description>
<ptdb guid_prefix="63.6c.69.65.6e.74.31.5f.73.31.5f.5f" guid_entity="0.0.1.c1">
<ptdi guid_prefix="63.6c.69.65.6e.74.31.5f.73.31.5f.5f" guid_entity="0.0.1.c1" server="false" alive="true" name="" discovered_timestamp="12">
<publisher type="sample_type_1" topic="topic_1" guid_prefix="63.6c.69.65.6e.74.31.5f.73.31.5f.5f" guid_entity="0.0.1.3" discovered_timestamp="12"/>
</ptdi>
</ptdb>
</DS_Snapshot>
<DS_Snapshot timestamp="1635259155427" process_time="10000" last_pdp_callback_time="5004" last_edp_callback_time="12" someone="true">
<description>Knows server B</description>
<ptdb guid_prefix="63.6c.69.65.6e.74.31.5f.73.31.5f.5f" guid_entity="0.0.1.c1">
<ptdi guid_prefix="44.49.53.43.53.45.52.56.45.52.5f.31" guid_entity="0.0.1.c1" server="false" alive="true" name="server" discovered_timestamp="126"/>
<ptdi guid_prefix="63.6c.69.65.6e.74.31.5f.73.31.5f.5f" guid_entity="0.0.1.c1" server="false" alive="true" name="" discovered_timestamp="12">
<publisher type="sample_type_1" topic="topic_1" guid_prefix="63.6c.69.65.6e.74.31.5f.73.31.5f.5f" guid_entity="0.0.1.3" discovered_timestamp="12"/>
</ptdi>
</ptdb>
</DS_Snapshot>
</DS_Snapshots>
68 changes: 68 additions & 0 deletions test/configuration/tests_params.json
Original file line number Diff line number Diff line change
Expand Up @@ -2057,6 +2057,74 @@
}
},


"test_45_trivial_client_reconnect":
{
"description": [
"Client connects with Server. Server leaves. Server turns back with same configuration."
],

"processes":
{
"client":
{
"xml_config_file": "<CONFIG_RELATIVE_PATH>/test_cases/test_45_trivial_client_reconnect_client.xml",
"validation":
{
"exit_code_validation":
{
"expected_exit_code": 0
},
"stderr_validation":
{
"err_expected_lines": 0
},
"count_lines_validation":
{
"file_path": "<CONFIG_RELATIVE_PATH>/test_solutions/test_45_trivial_client_reconnect_client.snapshot"
},
"ground_truth_validation":
{
"file_path": "<CONFIG_RELATIVE_PATH>/test_solutions/test_45_trivial_client_reconnect_client.snapshot"
}
}
},

"server_0":
{
"xml_config_file": "<CONFIG_RELATIVE_PATH>/test_cases/test_45_trivial_client_reconnect_server.xml",
"validation":
{
"exit_code_validation":
{
"expected_exit_code": 0
},
"stderr_validation":
{
"err_expected_lines": 0
}
}
},

"server_1":
{
"creation_time": 6,
"xml_config_file": "<CONFIG_RELATIVE_PATH>/test_cases/test_45_trivial_client_reconnect_server.xml",
"validation":
{
"exit_code_validation":
{
"expected_exit_code": 0
},
"stderr_validation":
{
"err_expected_lines": 0
}
}
}
}
},

"test_50_environment_modification":
{
"description": [
Expand Down

0 comments on commit 242f4b7

Please sign in to comment.