Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove 'addresses' tag from Discovery Server connection-addresses #473

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ddsrouter_core/src/cpp/testing/random_values.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ std::shared_ptr<ParticipantConfiguration> random_participant_configuration(
c->id = id;
c->domain = random_domain(seed);
c->discovery_server_guid_prefix = random_guid_prefix(seed);
c->connection_addresses = {random_connection_address(seed)};
c->connection_addresses = {random_address(seed)};
return c;
}

Expand Down
16 changes: 6 additions & 10 deletions ddsrouter_core/test/blackbox/ddsrouter_core/dds/WAN/DDSTestWAN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,12 @@ discovery_server_participant_configuration(
if (is_client(wan_kind))
{
conf.connection_addresses.insert(
participants::types::DiscoveryServerConnectionAddress(
{
participants::types::Address(
(ip_version == participants::types::IpVersion::v4 ? "127.0.0.1" : "::1"),
11666 + (this_server_id_is_1 ? 0u : 1u),
11666 + (this_server_id_is_1 ? 0u : 1u),
ip_version,
transport_protocol)
}
)
participants::types::Address(
(ip_version == participants::types::IpVersion::v4 ? "127.0.0.1" : "::1"),
11666 + (this_server_id_is_1 ? 0u : 1u),
11666 + (this_server_id_is_1 ? 0u : 1u),
ip_version,
transport_protocol)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ participants:
- name: Edge_1_DS_Participant
kind: wan-ds
connection-addresses:
- addresses:
- domain: ddsrouter_cloud
port: 11666
transport: udp
- domain: ddsrouter_cloud
port: 11666
transport: udp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ participants:
- name: Edge_2_DS_Participant
kind: wan-ds
connection-addresses:
- addresses:
- domain: ddsrouter_cloud
port: 21666
transport: udp
- domain: ddsrouter_cloud
port: 21666
transport: udp
Original file line number Diff line number Diff line change
Expand Up @@ -37,46 +37,32 @@ using namespace eprosima;
*
* POSITIVE CASES:
* - 1 address
* - 1 connection N addresses
* - N connections 1 addresses
* - N addresses
*
* NEGATIVE CASES:
* - not list format
* - incorrect guid format
* - not list of addresses
* - incorrect address format
*/
TEST(YamlGetDiscoveryServerParticipantConfigurationTest, get_participant_connection_addresses)
{
ddsrouter::core::types::ParticipantKind kind = ddsrouter::core::types::ParticipantKind::discovery_server;
ddspipe::core::types::ParticipantId id = ddspipe::core::testing::random_participant_id();
ddspipe::core::types::GuidPrefix guid_prefix = ddspipe::core::testing::random_guid_prefix();

// 1 address
{
Yaml yml;
Yaml yml_participant;
Yaml yml_connection_addresses;
Yaml yml_connection_address;
Yaml yml_addresses;
Yaml yml_address;

// Add required fields
ddspipe::yaml::testing::participantid_to_yaml(yml_participant, id);
ddsrouter::yaml::testing::participantkind_to_yaml(yml_participant, kind);
ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml(yml_participant, guid_prefix);

// Add address
ddspipe::participants::types::Address address = ddspipe::participants::testing::random_address();
ddspipe::yaml::testing::address_to_yaml(yml_address, address);
yml_addresses.push_back(yml_address);
yml_connection_address[ddspipe::yaml::COLLECTION_ADDRESSES_TAG] = yml_addresses;

// Add server guid
ddspipe::core::types::GuidPrefix connection_guid = ddspipe::core::testing::random_guid_prefix();
ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml(yml_connection_address, connection_guid);

yml_connection_addresses.push_back(yml_connection_address);
yml_connection_addresses.push_back(yml_address);

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

// Check result
ASSERT_EQ(result.connection_addresses.size(), 1u);
ASSERT_EQ(result.connection_addresses.begin()->addresses().size(), 1u);
ASSERT_EQ(address, *result.connection_addresses.begin()->addresses().begin());
ASSERT_EQ(address, *result.connection_addresses.begin());
}

// 1 connection N addresses
// N addresses
{
Yaml yml;
Yaml yml_participant;
Yaml yml_connection_addresses;
Yaml yml_connection_address;
Yaml yml_addresses;

// Add required fields
ddspipe::yaml::testing::participantid_to_yaml(yml_participant, id);
ddsrouter::yaml::testing::participantkind_to_yaml(yml_participant, kind);
ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml(yml_participant, guid_prefix);

// Add addresses
std::vector<ddspipe::participants::types::Address> addresses;
Expand All @@ -117,15 +99,8 @@ TEST(YamlGetDiscoveryServerParticipantConfigurationTest, get_participant_connect
// Add it to yaml
Yaml yml_address;
ddspipe::yaml::testing::address_to_yaml(yml_address, address);
yml_addresses.push_back(yml_address);
yml_connection_addresses.push_back(yml_address);
}
yml_connection_address[ddspipe::yaml::COLLECTION_ADDRESSES_TAG] = yml_addresses;

// Add server guid
ddspipe::core::types::GuidPrefix connection_guid = ddspipe::core::testing::random_guid_prefix();
ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml(yml_connection_address, connection_guid);

yml_connection_addresses.push_back(yml_connection_address);

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

// Check result
ASSERT_EQ(result.connection_addresses.size(), 1u);
ASSERT_EQ(addresses.size(), result.connection_addresses.begin()->addresses().size());
ASSERT_EQ(addresses.size(), result.connection_addresses.size()) << yml;
// Check every address is inside connection addresses of the configuration
for (ddspipe::participants::types::Address address : addresses)
{
// ATTENTION: this previous declaration is needed as listening_addresses() does not return a reference
// ATTENTION: this previous declaration is needed as connection_addresses() does not return a reference
std::set<ddspipe::participants::types::Address> addresses_result =
result.connection_addresses.begin()->addresses();
result.connection_addresses;
ASSERT_NE(
addresses_result.find(address),
addresses_result.end());
}
}

// N connections 1 address
{
Yaml yml;
Yaml yml_participant;
Yaml yml_connection_addresses;

// Add required fields
ddspipe::yaml::testing::participantid_to_yaml(yml_participant, id);
ddsrouter::yaml::testing::participantkind_to_yaml(yml_participant, kind);
ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml(yml_participant, guid_prefix);

std::vector<ddspipe::core::types::GuidPrefix> connection_guids;

// Add connections
for (uint32_t i = 0; i < ddsrouter::yaml::testing::TEST_ITERATIONS; i++)
{
Yaml yml_connection_address;
Yaml yml_addresses;

// Add address
ddspipe::participants::types::Address address = ddspipe::participants::testing::random_address(i);

// Add it to yaml
Yaml yml_address;
ddspipe::yaml::testing::address_to_yaml(yml_address, address);
yml_addresses.push_back(yml_address);
yml_connection_address[ddspipe::yaml::COLLECTION_ADDRESSES_TAG] = yml_addresses;

// Add server guid
ddspipe::core::types::GuidPrefix connection_guid = ddspipe::core::testing::random_guid_prefix(i);
connection_guids.push_back(connection_guid);
ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml(yml_connection_address, connection_guid);

yml_connection_addresses.push_back(yml_connection_address);
}


yml_participant[ddspipe::yaml::CONNECTION_ADDRESSES_TAG] = yml_connection_addresses;
yml["participant"] = yml_participant;

// Get configuration object from yaml
ddspipe::participants::DiscoveryServerParticipantConfiguration result =
ddspipe::yaml::YamlReader::get<ddspipe::participants::DiscoveryServerParticipantConfiguration>(yml,
"participant",
ddspipe::yaml::YamlReaderVersion::LATEST);

// Check result
ASSERT_EQ(connection_guids.size(), result.connection_addresses.size());
// Check that every connection has a correct number of addresses and a guid given
for (ddspipe::participants::types::DiscoveryServerConnectionAddress connection : result.connection_addresses)
{
ASSERT_EQ(connection.addresses().size(), 1u);
}
}

// not list format
{
Yaml yml;
Yaml yml_participant;
Yaml yml_connection_addresses;
Yaml yml_connection_address;
Yaml yml_addresses;
Yaml yml_address;

// Add required fields
ddspipe::yaml::testing::participantid_to_yaml(yml_participant, id);
ddsrouter::yaml::testing::participantkind_to_yaml(yml_participant, kind);
ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml(yml_participant, guid_prefix);

// Add address
ddspipe::participants::types::Address address = ddspipe::participants::testing::random_address();
ddspipe::yaml::testing::address_to_yaml(yml_address, address);
yml_addresses.push_back(yml_address);
yml_connection_address[ddspipe::yaml::COLLECTION_ADDRESSES_TAG] = yml_addresses;

// Add server guid
ddspipe::core::types::GuidPrefix connection_guid = ddspipe::core::testing::random_guid_prefix();
ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml(yml_connection_address, connection_guid);

// Add connection wrongly
yml_connection_addresses["address1"] = yml_connection_address;

yml_participant[ddspipe::yaml::CONNECTION_ADDRESSES_TAG] = yml_connection_addresses;
yml["participant"] = yml_participant;

// Get configuration object from yaml
ASSERT_THROW(
ddspipe::participants::DiscoveryServerParticipantConfiguration result =
ddspipe::yaml::YamlReader::get<ddspipe::participants::DiscoveryServerParticipantConfiguration>(yml,
"participant", ddspipe::yaml::YamlReaderVersion::LATEST),
eprosima::utils::ConfigurationException);
}

// not list of addresses
{
Yaml yml;
Yaml yml_participant;
Yaml yml_connection_addresses;
Yaml yml_connection_address;
Yaml yml_addresses;
Yaml yml_address;

// Add required fields
ddspipe::yaml::testing::participantid_to_yaml(yml_participant, id);
ddsrouter::yaml::testing::participantkind_to_yaml(yml_participant, kind);
ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml(yml_participant, guid_prefix);

// Add address
ddspipe::participants::types::Address address = ddspipe::participants::testing::random_address();
ddspipe::yaml::testing::address_to_yaml(yml_address, address);
// Add address wrongly
yml_addresses["address1"] = yml_address;

yml_connection_address[ddspipe::yaml::COLLECTION_ADDRESSES_TAG] = yml_addresses;

// Add server guid
ddspipe::core::types::GuidPrefix connection_guid = ddspipe::core::testing::random_guid_prefix();
ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml(yml_connection_address, connection_guid);

// Add connection
yml_connection_addresses.push_back(yml_connection_address);
yml_connection_addresses["address1"] = yml_address;

yml_participant[ddspipe::yaml::CONNECTION_ADDRESSES_TAG] = yml_connection_addresses;
yml["participant"] = yml_participant;
Expand All @@ -289,26 +159,14 @@ TEST(YamlGetDiscoveryServerParticipantConfigurationTest, get_participant_connect
Yaml yml;
Yaml yml_participant;
Yaml yml_connection_addresses;
Yaml yml_connection_address;
Yaml yml_addresses;
Yaml yml_address;

// Add required fields
ddspipe::yaml::testing::participantid_to_yaml(yml_participant, id);
ddsrouter::yaml::testing::participantkind_to_yaml(yml_participant, kind);
ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml(yml_participant, guid_prefix);

// Add empty address
yml_addresses.push_back(yml_address);
yml_connection_address[ddspipe::yaml::COLLECTION_ADDRESSES_TAG] = yml_addresses;

// Add server guid
ddspipe::core::types::GuidPrefix connection_guid = ddspipe::core::testing::random_guid_prefix();
ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml(yml_connection_address, connection_guid);

// Add connection wrongly
yml_connection_addresses.push_back(yml_connection_address);

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ TEST(YamlGetDiscoveryServerParticipantConfigurationTest, get_participant_listeni
{
ddsrouter::core::types::ParticipantKind kind = ddsrouter::core::types::ParticipantKind::discovery_server;
ddspipe::core::types::ParticipantId id = ddspipe::core::testing::random_participant_id();
ddspipe::core::types::GuidPrefix guid_prefix = ddspipe::core::testing::random_guid_prefix();

// 1 address
{
Expand All @@ -53,7 +52,6 @@ TEST(YamlGetDiscoveryServerParticipantConfigurationTest, get_participant_listeni
// Add required fields
ddspipe::yaml::testing::participantid_to_yaml(yml_participant, id);
ddsrouter::yaml::testing::participantkind_to_yaml(yml_participant, kind);
ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml(yml_participant, guid_prefix);

// Add address
ddspipe::participants::types::Address address = ddspipe::participants::testing::random_address();
Expand Down Expand Up @@ -83,7 +81,6 @@ TEST(YamlGetDiscoveryServerParticipantConfigurationTest, get_participant_listeni
// Add required fields
ddspipe::yaml::testing::participantid_to_yaml(yml_participant, id);
ddsrouter::yaml::testing::participantkind_to_yaml(yml_participant, kind);
ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml(yml_participant, guid_prefix);

// Add addresses
std::vector<ddspipe::participants::types::Address> addresses;
Expand Down Expand Up @@ -129,7 +126,6 @@ TEST(YamlGetDiscoveryServerParticipantConfigurationTest, get_participant_listeni
// Add required fields
ddspipe::yaml::testing::participantid_to_yaml(yml_participant, id);
ddsrouter::yaml::testing::participantkind_to_yaml(yml_participant, kind);
ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml(yml_participant, guid_prefix);

// Add address badly
Yaml yml_listening_addresses;
Expand Down Expand Up @@ -158,7 +154,6 @@ TEST(YamlGetDiscoveryServerParticipantConfigurationTest, get_participant_listeni
// Add required fields
ddspipe::yaml::testing::participantid_to_yaml(yml_participant, id);
ddsrouter::yaml::testing::participantkind_to_yaml(yml_participant, kind);
ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml(yml_participant, guid_prefix);

// Add incorrect address
Yaml yml_listening_addresses;
Expand Down
5 changes: 2 additions & 3 deletions docs/resources/examples/ros_discovery_client.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ participants:
ros-discovery-server: true # 7
id: 2 # 8
connection-addresses: # 9
- addresses:
- domain: localhost # 10
port: 11888 # 11
- domain: localhost # 10
port: 11888 # 11
# 12

##################################
Expand Down
5 changes: 2 additions & 3 deletions docs/resources/examples/wan_ds_client.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ participants:
- name: WANClient # 6
kind: wan-ds # 7
connection-addresses: # 8
- addresses: # 9
- ip: 1.1.1.1
port: 11666
- ip: 1.1.1.1 # 9
port: 11666
listening-addresses: # 10
- ip: 2.2.2.2 # 11
port: 11670 # 12
Expand Down
Loading
Loading