Skip to content

Commit

Permalink
Refs #22627: ROS2_EASY_MODE
Browse files Browse the repository at this point in the history
Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>
  • Loading branch information
cferreiragonz committed Jan 22, 2025
1 parent 034e7d5 commit 04b363a
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion include/fastdds/rtps/attributes/BuiltinTransports.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ enum class BuiltinTransports : uint16_t
UDPv6 = 5, //< Instantiate UDPv6 transport only
LARGE_DATA = 6, //< Instantiate SHM, UDPv4 and TCPv4 transports, but UDPv4 is only used for bootstrapping discovery
LARGE_DATAv6 = 7, //< Instantiate SHM, UDPv6 and TCPv6 transports, but UDPv6 is only used for bootstrapping discovery
P2P = 8 //< Instantiate SHM, UDPv4 (unicast) and TCPv4 transports, shall only be used along with EASY_MODE=<ip>
P2P = 8 //< Instantiate SHM, UDPv4 (unicast) and TCPv4 transports, shall only be used along with ROS2_EASY_MODE=<ip>
};

inline std::ostream& operator <<(
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/rtps/RTPSDomain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ RTPSParticipant* RTPSDomainImpl::clientServerEnvironmentCreationOverride(
{
if (res == SystemCommandBuilder::SystemCommandResult::BAD_PARAM)
{
EPROSIMA_LOG_ERROR("DOMAIN", "EASY_MODE IP connection conflicts with a previous one.");
EPROSIMA_LOG_ERROR("DOMAIN", "ROS2_EASY_MODE IP connection conflicts with a previous one.");
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/rtps/attributes/ServerAttributes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ const char* const DEFAULT_ROS2_MASTER_URI = "ROS_DISCOVERY_SERVER";
* - Set the transports to TCP and SHM.
* - Make the participant a SUPER_CLIENT.
*/
const char* const EASY_MODE_URI = "EASY_MODE";
const char* const EASY_MODE_URI = "ROS2_EASY_MODE";

/* Environment variable to transform a SIMPLE participant in a SUPER CLIENT.
* If the participant is not SIMPLE, the variable doesn't have any effects.
Expand Down
10 changes: 5 additions & 5 deletions test/blackbox/common/BlackboxTestsTransportCustom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,8 @@ TEST(ChainingTransportTests, builtin_transports_env_large_data)
*/
TEST(ChainingTransportTests, builtin_transports_env_p2p)
{
#ifndef _WIN32 // EASY_MODE not available on Windows yet
setenv("EASY_MODE", "127.0.0.1", 1);
#ifndef _WIN32 // ROS2_EASY_MODE not available on Windows yet
setenv("ROS2_EASY_MODE", "127.0.0.1", 1);
BuiltinTransportsTest::test_env("P2P");
#endif // _WIN32
}
Expand Down Expand Up @@ -690,7 +690,7 @@ TEST(ChainingTransportTests, builtin_transports_xml_large_data)
}

/**
* DS Auto transport shall always be used along with EASY_MODE=<ip>.
* DS Auto transport shall always be used along with ROS2_EASY_MODE=<ip>.
* This is due to the working principle of the mode. If it is not specified,
* the background discovery server will not be launched and the test will never
* finish since both clients will keep waiting for it.
Expand All @@ -699,8 +699,8 @@ TEST(ChainingTransportTests, builtin_transports_xml_large_data)
*/
TEST(ChainingTransportTests, builtin_transports_xml_p2p)
{
#ifndef _WIN32 // EASY_MODE not available on Windows yet
setenv("EASY_MODE", "127.0.0.1", 1);
#ifndef _WIN32 // ROS2_EASY_MODE not available on Windows yet
setenv("ROS2_EASY_MODE", "127.0.0.1", 1);
BuiltinTransportsTest::test_xml("builtin_transports_profile.xml", "participant_p2p");
#endif // _WIN32
}
Expand Down
14 changes: 7 additions & 7 deletions test/blackbox/common/DDSBlackboxTestsDSEasyMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ void set_easy_discovery_mode_env(
{
/* Set environment variable which will contain the ip of an external point of discovery*/
#ifdef _WIN32
_putenv_s("EASY_MODE", ip.c_str());
_putenv_s("ROS2_EASY_MODE", ip.c_str());
#else
setenv("EASY_MODE", ip.c_str(), 1);
setenv("ROS2_EASY_MODE", ip.c_str(), 1);
#endif // _WIN32

}
Expand All @@ -47,7 +47,7 @@ void stop_background_servers()
/**
* Refers to FASTDDS-EASYMODE-TEST:01 from the test plan.
*
* Launching a participant client with the environment variable EASY_MODE
* Launching a participant client with the environment variable ROS2_EASY_MODE
* correctly spawns and discovers a Discovery Server in the expected
* domain.
*
Expand Down Expand Up @@ -120,7 +120,7 @@ TEST(DSEasyMode, easy_discovery_mode_env_correctly_launches)
/**
* Refers to FASTDDS-EASYMODE-TEST:02 from the test plan.
*
* TCP and SHM are the transports used in EASY_MODE.
* TCP and SHM are the transports used in ROS2_EASY_MODE.
*/
TEST(DSEasyMode, easy_discovery_mode_env_correct_transports_are_used)
{
Expand Down Expand Up @@ -307,7 +307,7 @@ TEST(DSEasyMode, easy_discovery_mode_env_multiple_clients_multiple_domains)

/**
* Launching a second participant in the same domain with different
* EASY_MODE ip value shall log an error.
* ROS2_EASY_MODE ip value shall log an error.
*/
TEST(DSEasyMode, easy_discovery_mode_env_inconsistent_ip)
{
Expand Down Expand Up @@ -344,14 +344,14 @@ TEST(DSEasyMode, easy_discovery_mode_env_inconsistent_ip)
Log::SetVerbosity(Log::Kind::Error);
Log::RegisterConsumer(std::unique_ptr<LogConsumer>(new TestConsumer(n_logs)));

// Set EASY_MODE to localhost
// Set ROS2_EASY_MODE to localhost
set_easy_discovery_mode_env();
PubSubWriter<HelloWorldPubSubType> writer(TEST_TOPIC_NAME);

writer.init();
ASSERT_TRUE(writer.isInitialized());

// Set EASY_MODE to another address in the same domain
// Set ROS2_EASY_MODE to another address in the same domain
set_easy_discovery_mode_env("192.168.1.100");
PubSubWriter<HelloWorldPubSubType> reader(TEST_TOPIC_NAME);

Expand Down
6 changes: 3 additions & 3 deletions test/system/tools/fastdds/test_discovery_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,14 @@ def test_parser_auto_easy_mode_domain_env(self, mock_rpc_stopall, mock_rpc_nbreq
mock_rpc_brequest.return_value = 'Mocked request'
mock_spawn.return_value = True

self.set_env_values('EASY_MODE', '127.0.0.1')
self.set_env_values('ROS2_EASY_MODE', '127.0.0.1')
self.domain = 42
self.third_attr = '127.0.0.1'
self.check_command = [str(command_to_int[Command.AUTO]), '-d', '42', '127.0.0.1:42']
mock_rpc_nbrequest.side_effect = self.side_effect_rpc

# The parser is not responsible of adding the EASY_MODE argument to the command. This is done in Fast DDS.
# The parser only checks if the EASY_MODE variable is set to pass it to the RPC server as third argument
# The parser is not responsible of adding the ROS2_EASY_MODE argument to the command. This is done in Fast DDS.
# The parser only checks if the ROS2_EASY_MODE variable is set to pass it to the RPC server as third argument
argv = ['auto', '-d', '42', '127.0.0.1:42']
parser = Parser(argv)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def _get_signal(self, sig: int):
def run_process_nb(self, domain: int, command: list, easy_mode: str):
"""
Used for starting new servers. Commands 'start' and 'auto'.
If @easy_mode is empty, it means the 'EASY_MODE' variable was not set, that is,
If @easy_mode is empty, it means the 'ROS2_EASY_MODE' variable was not set, that is,
it is a direct call from the CLI.
Note that 'easy_mode' has already been added to the command string in the parser,
it is only used here to avoid using regex to find its value and differentiate
Expand Down
4 changes: 2 additions & 2 deletions tools/fastdds/discovery/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

DOMAIN_ENV_VAR = "ROS_DOMAIN_ID"
REMOTE_SERVERS_ENV_VAR = "ROS_STATIC_PEERS"
EASY_MODE_ENV_VAR = "EASY_MODE"
EASY_MODE_ENV_VAR = "ROS2_EASY_MODE"

class Command(Enum):
SERVER = "server" # Does not need to be specified
Expand Down Expand Up @@ -338,7 +338,7 @@ def __add_remote_servers_to_args(self, args) -> None:

def __get_easy_mode_from_env(self) -> str:
"""
Obtain the value present in 'EASY_MODE' from the environment.
Obtain the value present in 'ROS2_EASY_MODE' from the environment.
"""
value = None
value = os.getenv(EASY_MODE_ENV_VAR)
Expand Down
2 changes: 1 addition & 1 deletion versions.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Forthcoming
* Refactor benchmark example.
* Extended CLI ``shm`` command with ``-f`` param to clean Data Sharing segments.
* New Easy Mode:
* New `EASY_MODE` environment variable
* New `ROS2_EASY_MODE` environment variable
* Extended CLI ``discovery`` command to handle Fast DDS daemon.
* Added P2P builtin transport.

Expand Down

0 comments on commit 04b363a

Please sign in to comment.