Skip to content

Commit de9ddaa

Browse files
Remove 'addresses' tag from Discovery Server connection-addresses (#473)
Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>
1 parent 2d8ae69 commit de9ddaa

16 files changed

Lines changed: 64 additions & 249 deletions

File tree

ddsrouter_core/src/cpp/testing/random_values.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ std::shared_ptr<ParticipantConfiguration> random_participant_configuration(
6161
c->id = id;
6262
c->domain = random_domain(seed);
6363
c->discovery_server_guid_prefix = random_guid_prefix(seed);
64-
c->connection_addresses = {random_connection_address(seed)};
64+
c->connection_addresses = {random_address(seed)};
6565
return c;
6666
}
6767

ddsrouter_core/test/blackbox/ddsrouter_core/dds/WAN/DDSTestWAN.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,12 @@ discovery_server_participant_configuration(
102102
if (is_client(wan_kind))
103103
{
104104
conf.connection_addresses.insert(
105-
participants::types::DiscoveryServerConnectionAddress(
106-
{
107-
participants::types::Address(
108-
(ip_version == participants::types::IpVersion::v4 ? "127.0.0.1" : "::1"),
109-
11666 + (this_server_id_is_1 ? 0u : 1u),
110-
11666 + (this_server_id_is_1 ? 0u : 1u),
111-
ip_version,
112-
transport_protocol)
113-
}
114-
)
105+
participants::types::Address(
106+
(ip_version == participants::types::IpVersion::v4 ? "127.0.0.1" : "::1"),
107+
11666 + (this_server_id_is_1 ? 0u : 1u),
108+
11666 + (this_server_id_is_1 ? 0u : 1u),
109+
ip_version,
110+
transport_protocol)
115111
);
116112
}
117113

ddsrouter_test/compose/test_cases/discovery_server/ddsrouter_edge_1.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ participants:
99
- name: Edge_1_DS_Participant
1010
kind: wan-ds
1111
connection-addresses:
12-
- addresses:
13-
- domain: ddsrouter_cloud
14-
port: 11666
15-
transport: udp
12+
- domain: ddsrouter_cloud
13+
port: 11666
14+
transport: udp

ddsrouter_test/compose/test_cases/discovery_server/ddsrouter_edge_2.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ participants:
99
- name: Edge_2_DS_Participant
1010
kind: wan-ds
1111
connection-addresses:
12-
- addresses:
13-
- domain: ddsrouter_cloud
14-
port: 21666
15-
transport: udp
12+
- domain: ddsrouter_cloud
13+
port: 21666
14+
transport: udp

ddsrouter_yaml/test/unittest/participants/test_units/YamlGetDiscoveryServerParticipantConfigurationTest_get_participant_connection_addresses.ipp

Lines changed: 11 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -37,46 +37,32 @@ using namespace eprosima;
3737
*
3838
* POSITIVE CASES:
3939
* - 1 address
40-
* - 1 connection N addresses
41-
* - N connections 1 addresses
40+
* - N addresses
4241
*
4342
* NEGATIVE CASES:
4443
* - not list format
45-
* - incorrect guid format
46-
* - not list of addresses
4744
* - incorrect address format
4845
*/
4946
TEST(YamlGetDiscoveryServerParticipantConfigurationTest, get_participant_connection_addresses)
5047
{
5148
ddsrouter::core::types::ParticipantKind kind = ddsrouter::core::types::ParticipantKind::discovery_server;
5249
ddspipe::core::types::ParticipantId id = ddspipe::core::testing::random_participant_id();
53-
ddspipe::core::types::GuidPrefix guid_prefix = ddspipe::core::testing::random_guid_prefix();
5450

5551
// 1 address
5652
{
5753
Yaml yml;
5854
Yaml yml_participant;
5955
Yaml yml_connection_addresses;
60-
Yaml yml_connection_address;
61-
Yaml yml_addresses;
6256
Yaml yml_address;
6357

6458
// Add required fields
6559
ddspipe::yaml::testing::participantid_to_yaml(yml_participant, id);
6660
ddsrouter::yaml::testing::participantkind_to_yaml(yml_participant, kind);
67-
ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml(yml_participant, guid_prefix);
6861

6962
// Add address
7063
ddspipe::participants::types::Address address = ddspipe::participants::testing::random_address();
7164
ddspipe::yaml::testing::address_to_yaml(yml_address, address);
72-
yml_addresses.push_back(yml_address);
73-
yml_connection_address[ddspipe::yaml::COLLECTION_ADDRESSES_TAG] = yml_addresses;
74-
75-
// Add server guid
76-
ddspipe::core::types::GuidPrefix connection_guid = ddspipe::core::testing::random_guid_prefix();
77-
ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml(yml_connection_address, connection_guid);
78-
79-
yml_connection_addresses.push_back(yml_connection_address);
65+
yml_connection_addresses.push_back(yml_address);
8066

8167
yml_participant[ddspipe::yaml::CONNECTION_ADDRESSES_TAG] = yml_connection_addresses;
8268
yml["participant"] = yml_participant;
@@ -89,22 +75,18 @@ TEST(YamlGetDiscoveryServerParticipantConfigurationTest, get_participant_connect
8975

9076
// Check result
9177
ASSERT_EQ(result.connection_addresses.size(), 1u);
92-
ASSERT_EQ(result.connection_addresses.begin()->addresses().size(), 1u);
93-
ASSERT_EQ(address, *result.connection_addresses.begin()->addresses().begin());
78+
ASSERT_EQ(address, *result.connection_addresses.begin());
9479
}
9580

96-
// 1 connection N addresses
81+
// N addresses
9782
{
9883
Yaml yml;
9984
Yaml yml_participant;
10085
Yaml yml_connection_addresses;
101-
Yaml yml_connection_address;
102-
Yaml yml_addresses;
10386

10487
// Add required fields
10588
ddspipe::yaml::testing::participantid_to_yaml(yml_participant, id);
10689
ddsrouter::yaml::testing::participantkind_to_yaml(yml_participant, kind);
107-
ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml(yml_participant, guid_prefix);
10890

10991
// Add addresses
11092
std::vector<ddspipe::participants::types::Address> addresses;
@@ -117,15 +99,8 @@ TEST(YamlGetDiscoveryServerParticipantConfigurationTest, get_participant_connect
11799
// Add it to yaml
118100
Yaml yml_address;
119101
ddspipe::yaml::testing::address_to_yaml(yml_address, address);
120-
yml_addresses.push_back(yml_address);
102+
yml_connection_addresses.push_back(yml_address);
121103
}
122-
yml_connection_address[ddspipe::yaml::COLLECTION_ADDRESSES_TAG] = yml_addresses;
123-
124-
// Add server guid
125-
ddspipe::core::types::GuidPrefix connection_guid = ddspipe::core::testing::random_guid_prefix();
126-
ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml(yml_connection_address, connection_guid);
127-
128-
yml_connection_addresses.push_back(yml_connection_address);
129104

130105
yml_participant[ddspipe::yaml::CONNECTION_ADDRESSES_TAG] = yml_connection_addresses;
131106
yml["participant"] = yml_participant;
@@ -137,141 +112,36 @@ TEST(YamlGetDiscoveryServerParticipantConfigurationTest, get_participant_connect
137112
ddspipe::yaml::YamlReaderVersion::LATEST);
138113

139114
// Check result
140-
ASSERT_EQ(result.connection_addresses.size(), 1u);
141-
ASSERT_EQ(addresses.size(), result.connection_addresses.begin()->addresses().size());
115+
ASSERT_EQ(addresses.size(), result.connection_addresses.size()) << yml;
142116
// Check every address is inside connection addresses of the configuration
143117
for (ddspipe::participants::types::Address address : addresses)
144118
{
145-
// ATTENTION: this previous declaration is needed as listening_addresses() does not return a reference
119+
// ATTENTION: this previous declaration is needed as connection_addresses() does not return a reference
146120
std::set<ddspipe::participants::types::Address> addresses_result =
147-
result.connection_addresses.begin()->addresses();
121+
result.connection_addresses;
148122
ASSERT_NE(
149123
addresses_result.find(address),
150124
addresses_result.end());
151125
}
152126
}
153127

154-
// N connections 1 address
155-
{
156-
Yaml yml;
157-
Yaml yml_participant;
158-
Yaml yml_connection_addresses;
159-
160-
// Add required fields
161-
ddspipe::yaml::testing::participantid_to_yaml(yml_participant, id);
162-
ddsrouter::yaml::testing::participantkind_to_yaml(yml_participant, kind);
163-
ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml(yml_participant, guid_prefix);
164-
165-
std::vector<ddspipe::core::types::GuidPrefix> connection_guids;
166-
167-
// Add connections
168-
for (uint32_t i = 0; i < ddsrouter::yaml::testing::TEST_ITERATIONS; i++)
169-
{
170-
Yaml yml_connection_address;
171-
Yaml yml_addresses;
172-
173-
// Add address
174-
ddspipe::participants::types::Address address = ddspipe::participants::testing::random_address(i);
175-
176-
// Add it to yaml
177-
Yaml yml_address;
178-
ddspipe::yaml::testing::address_to_yaml(yml_address, address);
179-
yml_addresses.push_back(yml_address);
180-
yml_connection_address[ddspipe::yaml::COLLECTION_ADDRESSES_TAG] = yml_addresses;
181-
182-
// Add server guid
183-
ddspipe::core::types::GuidPrefix connection_guid = ddspipe::core::testing::random_guid_prefix(i);
184-
connection_guids.push_back(connection_guid);
185-
ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml(yml_connection_address, connection_guid);
186-
187-
yml_connection_addresses.push_back(yml_connection_address);
188-
}
189-
190-
191-
yml_participant[ddspipe::yaml::CONNECTION_ADDRESSES_TAG] = yml_connection_addresses;
192-
yml["participant"] = yml_participant;
193-
194-
// Get configuration object from yaml
195-
ddspipe::participants::DiscoveryServerParticipantConfiguration result =
196-
ddspipe::yaml::YamlReader::get<ddspipe::participants::DiscoveryServerParticipantConfiguration>(yml,
197-
"participant",
198-
ddspipe::yaml::YamlReaderVersion::LATEST);
199-
200-
// Check result
201-
ASSERT_EQ(connection_guids.size(), result.connection_addresses.size());
202-
// Check that every connection has a correct number of addresses and a guid given
203-
for (ddspipe::participants::types::DiscoveryServerConnectionAddress connection : result.connection_addresses)
204-
{
205-
ASSERT_EQ(connection.addresses().size(), 1u);
206-
}
207-
}
208-
209128
// not list format
210129
{
211130
Yaml yml;
212131
Yaml yml_participant;
213132
Yaml yml_connection_addresses;
214-
Yaml yml_connection_address;
215-
Yaml yml_addresses;
216133
Yaml yml_address;
217134

218135
// Add required fields
219136
ddspipe::yaml::testing::participantid_to_yaml(yml_participant, id);
220137
ddsrouter::yaml::testing::participantkind_to_yaml(yml_participant, kind);
221-
ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml(yml_participant, guid_prefix);
222138

223139
// Add address
224140
ddspipe::participants::types::Address address = ddspipe::participants::testing::random_address();
225141
ddspipe::yaml::testing::address_to_yaml(yml_address, address);
226-
yml_addresses.push_back(yml_address);
227-
yml_connection_address[ddspipe::yaml::COLLECTION_ADDRESSES_TAG] = yml_addresses;
228-
229-
// Add server guid
230-
ddspipe::core::types::GuidPrefix connection_guid = ddspipe::core::testing::random_guid_prefix();
231-
ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml(yml_connection_address, connection_guid);
232142

233143
// Add connection wrongly
234-
yml_connection_addresses["address1"] = yml_connection_address;
235-
236-
yml_participant[ddspipe::yaml::CONNECTION_ADDRESSES_TAG] = yml_connection_addresses;
237-
yml["participant"] = yml_participant;
238-
239-
// Get configuration object from yaml
240-
ASSERT_THROW(
241-
ddspipe::participants::DiscoveryServerParticipantConfiguration result =
242-
ddspipe::yaml::YamlReader::get<ddspipe::participants::DiscoveryServerParticipantConfiguration>(yml,
243-
"participant", ddspipe::yaml::YamlReaderVersion::LATEST),
244-
eprosima::utils::ConfigurationException);
245-
}
246-
247-
// not list of addresses
248-
{
249-
Yaml yml;
250-
Yaml yml_participant;
251-
Yaml yml_connection_addresses;
252-
Yaml yml_connection_address;
253-
Yaml yml_addresses;
254-
Yaml yml_address;
255-
256-
// Add required fields
257-
ddspipe::yaml::testing::participantid_to_yaml(yml_participant, id);
258-
ddsrouter::yaml::testing::participantkind_to_yaml(yml_participant, kind);
259-
ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml(yml_participant, guid_prefix);
260-
261-
// Add address
262-
ddspipe::participants::types::Address address = ddspipe::participants::testing::random_address();
263-
ddspipe::yaml::testing::address_to_yaml(yml_address, address);
264-
// Add address wrongly
265-
yml_addresses["address1"] = yml_address;
266-
267-
yml_connection_address[ddspipe::yaml::COLLECTION_ADDRESSES_TAG] = yml_addresses;
268-
269-
// Add server guid
270-
ddspipe::core::types::GuidPrefix connection_guid = ddspipe::core::testing::random_guid_prefix();
271-
ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml(yml_connection_address, connection_guid);
272-
273-
// Add connection
274-
yml_connection_addresses.push_back(yml_connection_address);
144+
yml_connection_addresses["address1"] = yml_address;
275145

276146
yml_participant[ddspipe::yaml::CONNECTION_ADDRESSES_TAG] = yml_connection_addresses;
277147
yml["participant"] = yml_participant;
@@ -289,26 +159,14 @@ TEST(YamlGetDiscoveryServerParticipantConfigurationTest, get_participant_connect
289159
Yaml yml;
290160
Yaml yml_participant;
291161
Yaml yml_connection_addresses;
292-
Yaml yml_connection_address;
293-
Yaml yml_addresses;
294162
Yaml yml_address;
295163

296164
// Add required fields
297165
ddspipe::yaml::testing::participantid_to_yaml(yml_participant, id);
298166
ddsrouter::yaml::testing::participantkind_to_yaml(yml_participant, kind);
299-
ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml(yml_participant, guid_prefix);
300-
301-
// Add empty address
302-
yml_addresses.push_back(yml_address);
303-
yml_connection_address[ddspipe::yaml::COLLECTION_ADDRESSES_TAG] = yml_addresses;
304-
305-
// Add server guid
306-
ddspipe::core::types::GuidPrefix connection_guid = ddspipe::core::testing::random_guid_prefix();
307-
ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml(yml_connection_address, connection_guid);
308-
309-
// Add connection wrongly
310-
yml_connection_addresses.push_back(yml_connection_address);
311167

168+
// Add connection wrongly (empty yaml = incorrect address)
169+
yml_connection_addresses.push_back(yml_address);
312170
yml_participant[ddspipe::yaml::CONNECTION_ADDRESSES_TAG] = yml_connection_addresses;
313171
yml["participant"] = yml_participant;
314172

ddsrouter_yaml/test/unittest/participants/test_units/YamlGetDiscoveryServerParticipantConfigurationTest_get_participant_listening_addresses.ipp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ TEST(YamlGetDiscoveryServerParticipantConfigurationTest, get_participant_listeni
4141
{
4242
ddsrouter::core::types::ParticipantKind kind = ddsrouter::core::types::ParticipantKind::discovery_server;
4343
ddspipe::core::types::ParticipantId id = ddspipe::core::testing::random_participant_id();
44-
ddspipe::core::types::GuidPrefix guid_prefix = ddspipe::core::testing::random_guid_prefix();
4544

4645
// 1 address
4746
{
@@ -53,7 +52,6 @@ TEST(YamlGetDiscoveryServerParticipantConfigurationTest, get_participant_listeni
5352
// Add required fields
5453
ddspipe::yaml::testing::participantid_to_yaml(yml_participant, id);
5554
ddsrouter::yaml::testing::participantkind_to_yaml(yml_participant, kind);
56-
ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml(yml_participant, guid_prefix);
5755

5856
// Add address
5957
ddspipe::participants::types::Address address = ddspipe::participants::testing::random_address();
@@ -83,7 +81,6 @@ TEST(YamlGetDiscoveryServerParticipantConfigurationTest, get_participant_listeni
8381
// Add required fields
8482
ddspipe::yaml::testing::participantid_to_yaml(yml_participant, id);
8583
ddsrouter::yaml::testing::participantkind_to_yaml(yml_participant, kind);
86-
ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml(yml_participant, guid_prefix);
8784

8885
// Add addresses
8986
std::vector<ddspipe::participants::types::Address> addresses;
@@ -129,7 +126,6 @@ TEST(YamlGetDiscoveryServerParticipantConfigurationTest, get_participant_listeni
129126
// Add required fields
130127
ddspipe::yaml::testing::participantid_to_yaml(yml_participant, id);
131128
ddsrouter::yaml::testing::participantkind_to_yaml(yml_participant, kind);
132-
ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml(yml_participant, guid_prefix);
133129

134130
// Add address badly
135131
Yaml yml_listening_addresses;
@@ -158,7 +154,6 @@ TEST(YamlGetDiscoveryServerParticipantConfigurationTest, get_participant_listeni
158154
// Add required fields
159155
ddspipe::yaml::testing::participantid_to_yaml(yml_participant, id);
160156
ddsrouter::yaml::testing::participantkind_to_yaml(yml_participant, kind);
161-
ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml(yml_participant, guid_prefix);
162157

163158
// Add incorrect address
164159
Yaml yml_listening_addresses;

docs/resources/examples/ros_discovery_client.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ participants:
3636
ros-discovery-server: true # 7
3737
id: 2 # 8
3838
connection-addresses: # 9
39-
- addresses:
40-
- domain: localhost # 10
41-
port: 11888 # 11
39+
- domain: localhost # 10
40+
port: 11888 # 11
4241
# 12
4342

4443
##################################

docs/resources/examples/wan_ds_client.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ participants:
3535
- name: WANClient # 6
3636
kind: wan-ds # 7
3737
connection-addresses: # 8
38-
- addresses: # 9
39-
- ip: 1.1.1.1
40-
port: 11666
38+
- ip: 1.1.1.1 # 9
39+
port: 11666
4140
listening-addresses: # 10
4241
- ip: 2.2.2.2 # 11
4342
port: 11670 # 12

0 commit comments

Comments
 (0)