Skip to content

Commit

Permalink
Refs #21095: Create a test for each transport and intialize to ::1 wh…
Browse files Browse the repository at this point in the history
…en ipv6 is used

Signed-off-by: Mario Dominguez <[email protected]>
  • Loading branch information
Mario-DL committed Jun 12, 2024
1 parent 1ac88f3 commit 7f9022c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
25 changes: 21 additions & 4 deletions examples/cpp/discovery_server/CLIParser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ class CLIParser

bool uses_ipv6 = false;
bool listening_address_was_set = false;
bool connection_address_was_set = false;

for (int i = 2; i < argc; ++i)
{
std::string arg = argv[i];
Expand Down Expand Up @@ -323,6 +325,7 @@ class CLIParser
{
config.srv_config.is_also_client = true;
}
connection_address_was_set = true;
}
else
{
Expand Down Expand Up @@ -687,11 +690,25 @@ class CLIParser
}
}

if (uses_ipv6
&& !listening_address_was_set
&& config.entity == CLIParser::EntityKind::SERVER)
// change default values if IPv6 is used
// and user did not specified ones
if (uses_ipv6)
{
config.srv_config.listening_address = "::1";
if (config.entity == CLIParser::EntityKind::SERVER &&
!listening_address_was_set)
{
config.srv_config.listening_address = "::1";
}

if (!connection_address_was_set)
{
config.pub_config.connection_address = "::1";
config.sub_config.connection_address = "::1";
if (config.srv_config.is_also_client)
{
config.srv_config.connection_address = "::1";
}
}
}

return config;
Expand Down
4 changes: 0 additions & 4 deletions examples/cpp/discovery_server/ClientPublisherApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ ClientPublisherApp::ClientPublisherApp(
case TransportKind::TCPv4:
{
auto descriptor_tmp = std::make_shared<eprosima::fastdds::rtps::TCPv4TransportDescriptor>();
// descriptor_tmp->interfaceWhiteList.push_back(ip_server_address);
// One listening port must be added either in the pub or the sub
descriptor_tmp->add_listener_port(0);
descriptor = descriptor_tmp;

Expand All @@ -129,8 +127,6 @@ ClientPublisherApp::ClientPublisherApp(
case TransportKind::TCPv6:
{
auto descriptor_tmp = std::make_shared<eprosima::fastdds::rtps::TCPv6TransportDescriptor>();
// descriptor_tmp->interfaceWhiteList.push_back(ip_server_address);
// One listening port must be added either in the pub or the sub
descriptor_tmp->add_listener_port(0);
descriptor = descriptor_tmp;

Expand Down
5 changes: 4 additions & 1 deletion test/examples/test_discovery_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
('--connection-port 11500 --samples 10', '--connection-port 11500 --samples 10', '--listening-port 11500 --timeout 5', '--id 2 --listening-port 11400 --timeout 1'),
('--transport tcpv4 --samples 10', '--transport tcpv4 --samples 10', '--transport tcpv4 --timeout 5', '--id 2 --listening-port 11400 --timeout 1'),
('--connection-ds-id 1 --samples 10', '--connection-ds-id 1 --samples 10', '--id 1 --timeout 5', '--id 2 --listening-port 11400 --timeout 1'),
('--connection-ds-id 1 --samples 10', '--connection-ds-id 2 --connection-port 11400 --samples 10', '--id 1 --timeout 5 --connection-ds-id 2 --connection-port 11400', '--id 2 --listening-port 11400 --timeout 5')
('--connection-ds-id 1 --samples 10', '--connection-ds-id 2 --connection-port 11400 --samples 10', '--id 1 --timeout 5 --connection-ds-id 2 --connection-port 11400', '--id 2 --listening-port 11400 --timeout 5'),
('--transport udpv6 --connection-ds-id 1 --samples 10', '--transport udpv6 --connection-ds-id 2 --connection-port 18000 --samples 10', '--transport udpv6 --id 1 --timeout 5 --connection-ds-id 2 --connection-port 18000', '--transport udpv6 --id 2 --listening-port 18000 --timeout 5'),
('--transport tcpv4 --connection-ds-id 1 --samples 10', '--transport tcpv4 --connection-ds-id 2 --connection-port 18000 --samples 10', '--transport tcpv4 --id 1 --timeout 5 --connection-ds-id 2 --connection-port 18000', '--transport tcpv4 --id 2 --listening-port 18000 --timeout 5'),
('--transport tcpv6 --connection-ds-id 1 --samples 10', '--transport tcpv6 --connection-ds-id 2 --connection-port 18000 --samples 10', '--transport tcpv6 --id 1 --timeout 5 --connection-ds-id 2 --connection-port 18000', '--transport tcpv6 --id 2 --listening-port 18000 --timeout 5')
]

@pytest.mark.parametrize("pub_args, sub_args, server1_args, server2_args", discovery_server_test_cases)
Expand Down

0 comments on commit 7f9022c

Please sign in to comment.