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

Wait for server in test_rmw_implementation service tests #191

Merged
merged 4 commits into from
May 6, 2021

Conversation

hidmic
Copy link
Contributor

@hidmic hidmic commented May 4, 2021

Current tests assume service server and client in the same process discover each other immediately. That doesn't seem to be true for rmw_connextdds and thus the flakes in amd64 Linux repeated CI, which can be reproduced locally (FYI @asorbini).

This patch amends this.

Repeated CI up to test_rmw_implementation:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
hidmic added 2 commits May 4, 2021 18:05
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Comment on lines 388 to 390
rmw_ret_t ret = rmw_service_server_is_available(node, client, &is_available);
EXPECT_EQ(RMW_RET_OK, ret) << rmw_get_error_string().str;
ASSERT_FALSE(is_available);
Copy link
Contributor

Choose a reason for hiding this comment

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

Just so I understand properly; we don't need to wait here because we never created a server at all, right?

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's my recollection, yes.

Comment on lines 399 to 401
EXPECT_EQ(RMW_RET_OK, ret) << rmw_get_error_string().str;
rmw_reset_error();
if (is_available) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure that this is the right logic here (I also don't think the previous logic is correct either).

What we are doing here is looping for a specified amount of time, waiting to see if the service server has become available. From what I understand from the documentation, rmw_service_server_is_available should always return RMW_RET_OK, unless the typesupport didn't match or an unexpected error occurred. But in those latter 2 cases, that is clearly a failure of this test, and so further waiting doesn't seem warranted. Thus, I would think this logic would be:

if (ret != RMW_RET_OK) {
    break;
}
if (is_available) {
    break;
}

And then we keep both expectations below. What do you think?

(this same comment applies to both loops below)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd be fine with it. We could also just ASSERT_EQ(RMW_RET_OK, ret) << rmw_get_error_string().str; right after calling rmw_service_is_available. Which one would you prefer?

Copy link
Member

@ivanpauno ivanpauno May 5, 2021

Choose a reason for hiding this comment

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

Both alternatives sound fine to me

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd be fine with it. We could also just ASSERT_EQ(RMW_RET_OK, ret) << rmw_get_error_string().str; right after calling rmw_service_is_available. Which one would you prefer?

The downside to doing an ASSERT is that we'd never hit the cleanup. While that doesn't matter too much in a test, it has the side-effect of making clang static analysis complain, which I'd rather avoid.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, but that's because the test is not doing clean-up properly ! See 2da26ad.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
@hidmic
Copy link
Contributor Author

hidmic commented May 5, 2021

Regular CI up to test_rmw_implementation:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@hidmic hidmic requested a review from clalancette May 5, 2021 19:52
@hidmic hidmic merged commit 6454f91 into master May 6, 2021
@delete-merged-branch delete-merged-branch bot deleted the hidmic/wait-for-service-server-in-tests branch May 6, 2021 12:41
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