Skip to content

Commit 36e17ef

Browse files
Fix duplicated transport when using specific XML with CLI (#5988) (#6009)
* Refs #23610: Test with XML file * Refs #23610: Fix bug when passing XML --------- (cherry picked from commit bfa10bc) Signed-off-by: cferreiragonz <[email protected]> Co-authored-by: Carlos Ferreira González <[email protected]>
1 parent a488f8f commit 36e17ef

File tree

4 files changed

+60
-1
lines changed

4 files changed

+60
-1
lines changed

test/system/tools/fds/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ if(Python3_Interpreter_FOUND)
3737
test_fast_discovery_several_server_ids
3838
test_fast_discovery_invalid_locator
3939
test_fast_discovery_non_existent_profile
40+
test_fast_discovery_tcp_via_XML
4041
)
4142

4243
if(SECURITY)
@@ -124,6 +125,7 @@ if(Python3_Interpreter_FOUND)
124125

125126
configure_file("test_xml_discovery_server_profile.xml" "test_xml_discovery_server_profile.xml" COPYONLY)
126127
configure_file("test_wrong_xml_discovery_server_profile.xml" "test_wrong_xml_discovery_server_profile.xml" COPYONLY)
128+
configure_file("test_xml_discovery_server_tcp.xml" "test_xml_discovery_server_tcp.xml" COPYONLY)
127129
unset(TEST_ENVIRONMENT)
128130

129131
endif()
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<dds>
3+
<profiles>
4+
<transport_descriptors>
5+
<transport_descriptor>
6+
<transport_id>tcp_transport</transport_id>
7+
<type>TCPv4</type>
8+
<listening_ports>
9+
<port>12345</port>
10+
</listening_ports>
11+
</transport_descriptor>
12+
</transport_descriptors>
13+
<participant profile_name="tcp_ds" is_default_profile="true">
14+
<rtps>
15+
<useBuiltinTransports>false</useBuiltinTransports>
16+
<userTransports>
17+
<transport_id>tcp_transport</transport_id>
18+
</userTransports>
19+
<builtin>
20+
<discovery_config>
21+
<discoveryProtocol>SERVER</discoveryProtocol>
22+
</discovery_config>
23+
<metatrafficUnicastLocatorList>
24+
<locator>
25+
<tcpv4>
26+
<address>127.0.0.1</address>
27+
<port>12345</port>
28+
<physical_port>12345</physical_port>
29+
</tcpv4>
30+
</locator>
31+
</metatrafficUnicastLocatorList>
32+
</builtin>
33+
</rtps>
34+
</participant>
35+
</profiles>
36+
</dds>

test/system/tools/fds/tests.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
test_fast_discovery_several_server_ids,
4242
test_fast_discovery_invalid_locator,
4343
test_fast_discovery_non_existent_profile,
44+
test_fast_discovery_tcp_via_XML,
4445
4546
"""
4647

@@ -639,6 +640,19 @@ def test_fast_discovery_security_enabled_cli_prefix(fast_discovery_tool):
639640
exit_code = check_output(output, err, EXPECTED_OUTPUT, False, False)
640641
sys.exit(exit_code)
641642

643+
def test_fast_discovery_tcp_via_XML(fast_discovery_tool):
644+
"""Test TCP transport loaded via XML configuration"""
645+
646+
XML_file_path = "test_xml_discovery_server_tcp.xml"
647+
command = [fast_discovery_tool, str(command_to_int_test[Command_test.SERVER]), '-x', XML_file_path]
648+
output, err, exit_code = send_command(command)
649+
if exit_code != 0:
650+
print(output)
651+
sys.exit(exit_code)
652+
EXPECTED_OUTPUT = "TCPv4:[127.0.0.1]:12345-12345"
653+
exit_code = check_output(output, err, EXPECTED_OUTPUT, False, False)
654+
sys.exit(exit_code)
655+
642656
if __name__ == '__main__':
643657

644658
parser = argparse.ArgumentParser(
@@ -693,7 +707,9 @@ def test_fast_discovery_security_enabled_cli_prefix(fast_discovery_tool):
693707
'test_fast_discovery_security_enabled_xml_prefix': lambda:
694708
test_fast_discovery_security_enabled_xml_prefix(args.binary_path),
695709
'test_fast_discovery_security_enabled_cli_prefix': lambda:
696-
test_fast_discovery_security_enabled_cli_prefix(args.binary_path)
710+
test_fast_discovery_security_enabled_cli_prefix(args.binary_path),
711+
'test_fast_discovery_tcp_via_XML': lambda:
712+
test_fast_discovery_tcp_via_XML(args.binary_path)
697713
}
698714

699715
tests[args.test_name]()

tools/fds/CliDiscoveryManager.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,11 @@ bool CliDiscoveryManager::add_tcp_servers()
566566

567567
void CliDiscoveryManager::configure_transports()
568568
{
569+
if (serverQos.transport().user_transports.size() > 0)
570+
{
571+
// User transports already configured in XML file
572+
return;
573+
}
569574
if (!serverQos.wire_protocol().builtin.metatrafficUnicastLocatorList.has_kind<LOCATOR_KIND_UDPv4>())
570575
{
571576
serverQos.transport().use_builtin_transports = false;

0 commit comments

Comments
 (0)