Skip to content

Commit

Permalink
Configure the domain through the command-line (#82)
Browse files Browse the repository at this point in the history
* Replace FOXGLOVEWS with FASTDDSSPY as the logging tag

Signed-off-by: tempate <[email protected]>

* Configure the domain through the terminal

Signed-off-by: tempate <[email protected]>

* Update the latest help in tests

Signed-off-by: tempate <[email protected]>

* Documentation

Signed-off-by: tempate <[email protected]>

* Apply suggestions

Signed-off-by: tempate <[email protected]>

* Tests

Signed-off-by: tempate <[email protected]>

* Fix valid_output to accept several guids and rates

Signed-off-by: tempate <[email protected]>

* Fix python linter

Signed-off-by: tempate <[email protected]>

---------

Signed-off-by: tempate <[email protected]>
  • Loading branch information
Tempate authored Apr 9, 2024
1 parent 06e9e5e commit 653eeda
Show file tree
Hide file tree
Showing 18 changed files with 267 additions and 22 deletions.
6 changes: 5 additions & 1 deletion docs/rst/notes/forthcoming_version.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@

.. add orphan tag when new info added to this file
:orphan:
.. :orphan:
###################
Forthcoming Version
###################

This release includes the following **Configuration Features**:

* New :ref:`domain argument <user_manual_user_interface_domain_argument>` to configure the ``domain`` through the command-line.
2 changes: 1 addition & 1 deletion docs/rst/notes/notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

.. _notes:

.. .. include:: forthcoming_version.rst
.. include:: forthcoming_version.rst

##############
Version v0.4.0
Expand Down
84 changes: 84 additions & 0 deletions docs/rst/user_manual/tool.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,38 @@ The |espy| application supports several input arguments:
- Readable File Path
- ``./FASTDDSSPY_CONFIGURATION.yaml``

* - :ref:`user_manual_user_interface_reload_time_argument`
- ``-r``
- ``--reload-time``
- Period (in seconds) to reload |br|
configuration file
- 0

* - :ref:`user_manual_user_interface_domain_argument`
-
- ``--domain``
- Domain to spy on
- 0

* - :ref:`user_manual_user_interface_debug_argument`
- ``-d``
- ``--debug``
- Debug mode
- ``false``

* - :ref:`user_manual_user_interface_log_filter_argument`
-
- ``--log-filter``
- Filter the logs displayed
- ``FASTDDSSPY``

* - :ref:`user_manual_user_interface_log_verbosity_argument`
-
- ``--log-verbosity``
- Maximum category of the |br|
logs displayed
- ``error``

.. _user_manual_user_interface_help_argument:

Help Argument
Expand All @@ -87,6 +119,13 @@ It shows the usage information of the application.
Application parameters
-c --config-path Path to the Configuration File (yaml format) [Default: ./FASTDDSSPY_CONFIGURATION.yaml].
-r --reload-time Time period in seconds to reload configuration file. This is needed when FileWatcher functionality is not available (e.g. config file is a symbolic link). Value 0 does not reload file. [Default: 0].
--domain Set the domain (0-255) to spy on. [Default = 0].
Debug parameters
-d --debug Set log verbosity to Info (Using this option with --log-filter and/or --log-verbosity will head to undefined behaviour).
--log-filter Set a Regex Filter to filter by category the info and warning log entries. [Default = "FASTDDSSPY"].
--log-verbosity Set a Log Verbosity Level higher or equal the one given. (Values accepted: "info","warning","error" no Case Sensitive) [Default = "error"].
.. _user_manual_user_interface_version_argument:

Expand Down Expand Up @@ -114,6 +153,51 @@ Reload Topics
This configuration file allows to allow and block DDS :term:`Topics <Topic>`.
A modification in this file will modify the running application.

.. _user_manual_user_interface_reload_time_argument:

Reload Time Argument
--------------------

This argument sets the time period in seconds to reload the configuration file.

.. _user_manual_user_interface_domain_argument:

Domain Argument
---------------

This argument sets the domain id of the |spy|.

.. warning::

If set, it will override the domain id set in the configuration file.

.. _user_manual_user_interface_debug_argument:

Debug Argument
--------------

This argument sets the log verbosity to Info.

.. warning::

Using this option with :ref:`log filter <user_manual_user_interface_log_filter_argument>` and/or :ref:`log verbosity <user_manual_user_interface_log_verbosity_argument>` will head to undefined behaviour.

.. _user_manual_user_interface_log_filter_argument:

Log Filter Argument
-------------------

Configure the |spy| to print the logs that match the given filter.
By default the filter is set to ``FASTDDSSPY`` for ``warning`` and ``info`` logs.

.. _user_manual_user_interface_log_verbosity_argument:

Log Verbosity Argument
----------------------

Configure the |spy| to print the logs up to a certain verbosity level.
The verbosity levels are (from more to less restrictive): ``error``, ``warning``, and ``info``.

.. _user_manual_user_interface_interactive_app:

Interactive application
Expand Down
2 changes: 1 addition & 1 deletion fastddsspy_tool/src/cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ int main(
// in non debug or with LOG_NO_INFO=ON.
// This is the easiest way to allow to see Warnings and Errors from Fast DDS.
// Change it when Log Module is independent and with more extensive API.
// eprosima::utils::Log::SetCategoryFilter(std::regex("(ddspipe|FOXGLOVEWS)"));
// eprosima::utils::Log::SetCategoryFilter(std::regex("(ddspipe|FASTDDSSPY)"));
}
// Create the Spy
eprosima::spy::Controller spy(configuration);
Expand Down
33 changes: 24 additions & 9 deletions fastddsspy_tool/src/cpp/user_interface/arguments_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,17 @@ const option::Descriptor usage[] = {

},

{
optionIndex::DOMAIN,
0,
"",
"domain",
Arg::Numeric,
" \t--domain\t \t" \
"Set the domain (0-255) to spy on. " \
"[Default = 0]."
},

////////////////////
// Debug options
{
Expand Down Expand Up @@ -248,8 +259,12 @@ ProcessReturnCode parse_arguments(
utils::VerbosityKind(static_cast<int>(from_string_LogKind(opt.arg)));
break;

case optionIndex::DOMAIN:
commandline_args.domain.set_value(std::stoi(opt.arg));
break;

case optionIndex::UNKNOWN_OPT:
logError(FOXGLOVEWS_ARGS, opt << " is not a valid argument.");
logError(FASTDDSSPY_ARGS, opt << " is not a valid argument.");
option::printUsage(fwrite, stdout, usage, columns);
return ProcessReturnCode::incorrect_argument;
break;
Expand All @@ -269,7 +284,7 @@ option::ArgStatus Arg::Unknown(
if (msg)
{
logError(
FOXGLOVEWS_ARGS,
FASTDDSSPY_ARGS,
"Unknown option '" << option << "'. Use -h to see this executable possible arguments.");
}
return option::ARG_ILLEGAL;
Expand All @@ -286,7 +301,7 @@ option::ArgStatus Arg::Required(

if (msg)
{
logError(FOXGLOVEWS_ARGS, "Option '" << option << "' required.");
logError(FASTDDSSPY_ARGS, "Option '" << option << "' required.");
}
return option::ARG_ILLEGAL;
}
Expand All @@ -306,7 +321,7 @@ option::ArgStatus Arg::Numeric(

if (msg)
{
logError(FOXGLOVEWS_ARGS, "Option '" << option << "' requires a numeric argument.");
logError(FASTDDSSPY_ARGS, "Option '" << option << "' requires a numeric argument.");
}
return option::ARG_ILLEGAL;
}
Expand All @@ -326,7 +341,7 @@ option::ArgStatus Arg::Float(

if (msg)
{
logError(FOXGLOVEWS_ARGS, "Option '" << option << "' requires a float argument.");
logError(FASTDDSSPY_ARGS, "Option '" << option << "' requires a float argument.");
}
return option::ARG_ILLEGAL;
}
Expand All @@ -341,7 +356,7 @@ option::ArgStatus Arg::String(
}
if (msg)
{
logError(FOXGLOVEWS_ARGS, "Option '" << option << "' requires a text argument.");
logError(FASTDDSSPY_ARGS, "Option '" << option << "' requires a text argument.");
}
return option::ARG_ILLEGAL;
}
Expand All @@ -360,7 +375,7 @@ option::ArgStatus Arg::Readable_File(
}
if (msg)
{
logError(FOXGLOVEWS_ARGS, "Option '" << option << "' requires an existing readable file as argument.");
logError(FASTDDSSPY_ARGS, "Option '" << option << "' requires an existing readable file as argument.");
}
return option::ARG_ILLEGAL;
}
Expand All @@ -381,7 +396,7 @@ option::ArgStatus Arg::Valid_Options(
{
if (msg)
{
logError(FOXGLOVEWS_ARGS, "Option '" << option.name << "' requires a text argument.");
logError(FASTDDSSPY_ARGS, "Option '" << option.name << "' requires a text argument.");
}
return option::ARG_ILLEGAL;
}
Expand All @@ -400,7 +415,7 @@ option::ArgStatus Arg::Valid_Options(
}
error_msg << "}.";

logError(FOXGLOVEWS_ARGS, error_msg);
logError(FASTDDSSPY_ARGS, error_msg);
}

return option::ARG_ILLEGAL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ enum optionIndex
VERSION,
LOG_FILTER,
LOG_VERBOSITY,
DOMAIN,
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __init__(self):
--log-verbosity Set a Log Verbosity Level higher or equal the one given. \
(Values accepted: "info","warning","error" no Case Sensitive) [Default = "warning"]. \n\
\n\
\x1b[37;1m2023-04-12 14:29:23.337 \x1b[31;1m[\x1b[37;1mFOXGLOVEWS_ARGS\x1b[31;1m Error] \
\x1b[37;1m2023-04-12 14:29:23.337 \x1b[31;1m[\x1b[37;1mFASTDDSSPY_ARGS\x1b[31;1m Error] \
\x1b[37mOption '--config-path' requires an existing readable file as argument.\
\x1b[34;1m -> Function \x1b[36mReadable_File\x1b[m\n"""
)
Expand Down
40 changes: 40 additions & 0 deletions fastddsspy_tool/test/application/test_cases/one_shot__domain.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright 2024 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.

"""Tests for the fastddsspy executable."""

import test_class


class TestCase_instance (test_class.TestCase):
"""@brief A subclass of `test_class.TestCase` representing a specific test case."""

def __init__(self):
"""
@brief Initialize the TestCase_instance object.
This test launches:
fastddsspy --domain 84
"""
super().__init__(
name='--DomainCommand',
one_shot=True,
command=[],
dds=False,
config='',
arguments_dds=[],
arguments_spy=['--domain', '84', 'exit'],
commands_spy=[],
output=''
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Copyright 2024 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.

"""Tests for the fastddsspy executable."""

import test_class


class TestCase_instance (test_class.TestCase):
"""@brief A subclass of `test_class.TestCase` representing a specific test case."""

def __init__(self):
"""
@brief Initialize the TestCase_instance object.
This test launches:
fastddsspy --domain
"""
super().__init__(
name='--DomainFailCommand',
one_shot=True,
command=[],
dds=False,
config='',
arguments_dds=[],
arguments_spy=['--domain'],
commands_spy=[],
output="""\x1b[37;1m%%time%% \x1b[31;1m[\x1b[37;1mFASTDDSSPY_ARGS\x1b[31;1m Error] \
\x1b[37mOption \'--domain\' requires a numeric argument.\x1b[34;1m -> Function \
\x1b[36mString\x1b[m\n\
Usage: Fast DDS Spy \n\
Start an interactive CLI to introspect a DDS network.\n\
General options:\n\
Application help and information.\n\
-h --help Print this help message.\n\
-v --version Print version, branch and commit hash.\n\
\n\
Application parameters\n\
-c --config-path Path to the Configuration File (yaml format) \
[Default: ./FASTDDSSPY_CONFIGURATION.yaml].\n\
-r --reload-time Time period in seconds to reload configuration file. \
This is needed when FileWatcher functionality is not available \
(e.g. config file is a symbolic link). Value 0 does not reload file. [Default: 0].\n\
--domain Set the domain (0-255) to spy on. [Default = 0].\n\
\n\
Debug parameters\n\
-d --debug Set log verbosity to Info \
\n\
(Using this option with \
--log-filter and/or --log-verbosity will head to undefined behaviour).\n\
--log-filter Set a Regex Filter to filter by category the info and warning \
log entries. [Default = "FASTDDSSPY"]. \n\
--log-verbosity Set a Log Verbosity Level higher or equal the one given. \
(Values accepted: "info","warning","error" no Case Sensitive) [Default = "warning"]. \n\n"""
)

def valid_output(self, output):
"""
@brief Validate the output.
@param output: The actual output obtained from executing a command.
@return Always returns True.
"""
return True
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def __init__(self):
-r --reload-time Time period in seconds to reload configuration file. \
This is needed when FileWatcher functionality is not available \
(e.g. config file is a symbolic link). Value 0 does not reload file. [Default: 0].\n\
--domain Set the domain (0-255) to spy on. [Default = 0].\n\
\n\
Debug parameters\n\
-d --debug Set log verbosity to Info \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __init__(self):
--log-verbosity Set a Log Verbosity Level higher or equal the one given. \
(Values accepted: "info","warning","error" no Case Sensitive) [Default = "warning"]. \n\
\n\
\x1b[37;1m2023-04-13 12:08:51.556 \x1b[31;1m[\x1b[37;1mFOXGLOVEWS_ARGS\x1b[31;1m Error] \
\x1b[37;1m2023-04-13 12:08:51.556 \x1b[31;1m[\x1b[37;1mFASTDDSSPY_ARGS\x1b[31;1m Error] \
\x1b[37mOption \'--log-filter\' requires a text argument.\x1b[34;1m -> Function \
\x1b[36mString\x1b[m\n"""
)
Expand Down
Loading

0 comments on commit 653eeda

Please sign in to comment.