Skip to content

Commit

Permalink
Add app_id and app_metadata attributes (#59)
Browse files Browse the repository at this point in the history
* Add app_id and app_metadata to config

Signed-off-by: Jesus Perez <[email protected]>

* Forthcoming version updated

Signed-off-by: Jesus Perez <[email protected]>

* Apply suggestions

Signed-off-by: Jesus Perez <[email protected]>

* Added spy configuration test

Signed-off-by: Jesus Perez <[email protected]>

* Apply suggestions

Signed-off-by: Jesus Perez <[email protected]>

---------

Signed-off-by: Jesus Perez <[email protected]>
  • Loading branch information
jepemi authored Nov 17, 2023
1 parent ca02f5c commit 26f4bb2
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/rst/notes/forthcoming_version.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ This release will include the following **Configuration features**:
* :ref:`Max Reception Rate <user_manual_configuration_dds__max_rx_rate>`.
* :ref:`Downsampling <user_manual_configuration_dds__downsampling>`.
* Remove the support for Built-in Topics.
* Set `app_id` and `app_metadata` attributes in *eProsima Fast DDS Spy* participants.
1 change: 1 addition & 0 deletions docs/rst/notes/notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

.. _notes:

.. TODO uncomment when there are forthcoming notes
.. include:: forthcoming_version.rst

##############
Expand Down
4 changes: 4 additions & 0 deletions fastddsspy_yaml/src/cpp/YamlReaderConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,12 @@ Configuration::Configuration()
, spy_configuration(std::make_shared<participants::SpyParticipantConfiguration>())
{
simple_configuration->id = "SimpleParticipant";
simple_configuration->app_id = "FASTDDS_SPY";
simple_configuration->app_metadata = "";
simple_configuration->is_repeater = false;
spy_configuration->id = "Fast-Spy-007";
spy_configuration->app_id = "FASTDDS_SPY";
spy_configuration->app_metadata = "";
spy_configuration->is_repeater = false;
}

Expand Down
1 change: 1 addition & 0 deletions fastddsspy_yaml/test/unittest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
##############

add_subdirectory(yaml_writer)
add_subdirectory(yaml_reader)
38 changes: 38 additions & 0 deletions fastddsspy_yaml/test/unittest/yaml_reader/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima).
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

############################
# Yaml Reader Test #
############################

set(TEST_NAME YamlReaderTest)

set(TEST_SOURCES
${PROJECT_SOURCE_DIR}/src/cpp/YamlReaderConfiguration.cpp
YamlReaderTest.cpp
)

set(TEST_LIST
get_spy_configuration_trivial
)

set(TEST_EXTRA_LIBRARIES
${MODULE_DEPENDENCIES}
)

add_unittest_executable(
"${TEST_NAME}"
"${TEST_SOURCES}"
"${TEST_LIST}"
"${TEST_EXTRA_LIBRARIES}")
66 changes: 66 additions & 0 deletions fastddsspy_yaml/test/unittest/yaml_reader/YamlReaderTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include <cpp_utils/testing/gtest_aux.hpp>
#include <gtest/gtest.h>

#include <fastddsspy_yaml/YamlReaderConfiguration.hpp>

using namespace eprosima;
using namespace eprosima::ddspipe::yaml;
using namespace eprosima::spy::participants;

/**
* Test load a whole Spy Configuration from yaml node.
*/
TEST(YamlReaderTest, get_spy_configuration_trivial)
{
const char* yml_str =
R"(
version: v4.0
dds:
ros2-types: true
)";

Yaml yml = YAML::Load(yml_str);

// Load configuration
eprosima::spy::yaml::Configuration configuration(yml);

// Check is valid
utils::Formatter error_msg;
ASSERT_TRUE(configuration.is_valid(error_msg));

// Check yaml specified data
ASSERT_EQ(configuration.ros2_types, true);

// Check app data
ASSERT_EQ(configuration.simple_configuration->id, "SimpleParticipant");
ASSERT_EQ(configuration.simple_configuration->app_id, "FASTDDS_SPY");
ASSERT_EQ(configuration.simple_configuration->app_metadata, "");
ASSERT_FALSE(configuration.simple_configuration->is_repeater);

ASSERT_EQ(configuration.spy_configuration->id, "Fast-Spy-007");
ASSERT_EQ(configuration.spy_configuration->app_id, "FASTDDS_SPY");
ASSERT_EQ(configuration.spy_configuration->app_metadata, "");
ASSERT_FALSE(configuration.spy_configuration->is_repeater);
}

int main(
int argc,
char** argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

0 comments on commit 26f4bb2

Please sign in to comment.