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

[12529] Fix file watch initialization #2280

Merged
merged 7 commits into from
Nov 11, 2021

Conversation

JLBuenoLopez
Copy link
Contributor

If the FASTDDS_ENVIRONMENT_FILE environment variable is set but the file does not exist, Fast DDS breaks. This PR fixes this issue and adds also a test to check different Discovery Server configurations.

…e file does not exist

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>
Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>
Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>
Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>
@JLBuenoLopez
Copy link
Contributor Author

File watch is a feature not implemented yet for MacOS. I have fixed the new test so it also works in MacOS not running the checks related with the addition of dynamic servers.

@MiguelCompany MiguelCompany added this to the v2.4.1 milestone Nov 2, 2021
Copy link
Contributor

@jsan-rt jsan-rt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just two little nitpicks.

As a side note, maybe this new test could have been split into a few smaller tests.

@@ -36,16 +44,23 @@
#include <fastdds/dds/subscriber/Subscriber.hpp>
#include <fastdds/dds/topic/qos/TopicQos.hpp>
#include <fastdds/rtps/attributes/RTPSParticipantAttributes.h>
#include <fastdds/rtps/attributes/ServerAttributes.h>
#include <fastdds/rtps/common/Locator.h>
#include <fastdds/rtps/participant/RTPSParticipant.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this include really needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not being used. Good catch!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is necessary because RTPSParticipant::getRTPSParticipantAttributes is defined within that header file. Without this include, the project does not build.

Copy link
Contributor

@jsan-rt jsan-rt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A last minute comment that was not included in the previous review

Comment on lines 583 to 585
* FASTDDS_ENVIRONMENT_FILE_ENV_VAR should be defined from the start because it is only loaded once (when the XML
* profiles are loaded). The file is not going to exist until a later case. However, the filewatch is initialized
* even though the file does not exist ()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to comments later in this test and this check:

if (!filename.empty() && SystemInfo::file_exists(filename))

It looks like the filewatch is in fact NOT initialized if the file does not exist. If that is so please correct this comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment does not apply any longer as the test has been split into smaller tests

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>
Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>
#ifndef __APPLE__
std::this_thread::sleep_for(std::chrono::milliseconds(1100));
file.open(filename);
file << "{\"ROS_DISCOVERY_SERVER\": \"84.22.253.128:8888;192.168.1.133:64863;localhost:1234\"}";
file.close();
std::this_thread::sleep_for(std::chrono::milliseconds(1100));
get_rtps_attributes(participant, attributes);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add an EXPECT_NE here so it is tested that modifying the file does in fact not modify the RTPS attributes, hence the next lines.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The attributes have indeed been modified. The variable output used to validate the expected attributes output is the one we need to update so the check is correct.

Comment on lines 746 to 747
* SERVER Participant without initial remote server list set by QoS.
* The environment variable applies and adds those remote servers to the list.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are not calling set_environment_variable() and you are checking truth against the vector being empty. Either the test is wrong or else the explanation is. Please check it.

@@ -799,30 +894,44 @@ TEST(ParticipantTests, RemoteServersListConfiguration)
file << "{\"ROS_DISCOVERY_SERVER\": \"172.17.0.5:4321;192.168.1.133:64863\"}";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this fail since we already defined a Discovery Server via environment variable earlier and it is not included here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is just the issue this test intends to check: what happens when two servers with the same guidPrefix are being added, one through the environment variable and another through QoS. It seems that both are included though only one of them is pinged (as the test comment explains). Also, the attributes only holds the one set by QoS (which is not the one being pinged as far as I know checking with a wireshark capture) and it is against this server that the feature checks that no server has been removed. That is the reason why this test is called inconsistent. The main goal was checking that Fast DDS does not have a core and that any mishandle of the API is safe (even though the behavior can be undefined). That is the reason why in our documentation we have included a note stating that it is advised to use either the API or the environment variable but not both at the same time.

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>
Copy link
Contributor

@jsan-rt jsan-rt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@MiguelCompany
Copy link
Member

MiguelCompany commented Nov 10, 2021

Just one more CI run.

@MiguelCompany
Copy link
Member

@richiprosima Please test this

@MiguelCompany MiguelCompany merged commit 53333fe into master Nov 11, 2021
@MiguelCompany MiguelCompany deleted the feature/consistent-qos-dds-rtps branch November 11, 2021 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants