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

Qos system tests #1

Closed
wants to merge 4 commits into from
Closed

Qos system tests #1

wants to merge 4 commits into from

Conversation

dabonnie
Copy link

Added basic system tests for the rclcpp QoS features

  • liveliness
  • deadline
  • lifespan

Added simple test for liveliness

Signed-off-by: Devin Bonnie <[email protected]>
Added lifespan system test

Signed-off-by: Devin Bonnie <[email protected]>
Signed-off-by: Devin Bonnie <[email protected]>
Added minor liveliness test cleanup

Signed-off-by: Devin Bonnie <[email protected]>
@dabonnie
Copy link
Author

Closing this PR and opening against ros2/system_tests per standup today.

@dabonnie dabonnie closed this Apr 22, 2019
* @param milliseconds
* @return tuple of milliseconds converted to <seconds, nanoseconds>
*/
std::tuple<size_t, size_t> chrono_milliseconds_to_size_t(

Choose a reason for hiding this comment

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

We should use a time type of some sort rather than generic tuple. e.g. rmw_time_t or rcl_duration, something.

Copy link
Author

Choose a reason for hiding this comment

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

That could work. Might be nice to add in rcutils or in rclcpp for others to use and really be useful :-)

const std::chrono::milliseconds & milliseconds);

/// Simple publishing node used for system tests
class Publisher : public rclcpp::Node

Choose a reason for hiding this comment

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

A namespace or prefixed naming would be nice for these - so that there's no possible confusion with the rclcpp types. I'd recommend something along the lines of QoSTestPublisherNode

Copy link
Author

Choose a reason for hiding this comment

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

Will rename.

/// number of messages published
int sent_message_count_;
/// if true then currently has an active publishing timer
bool is_publishing = false;

Choose a reason for hiding this comment

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

May want to go private and public instead of using separate naming conventions (with or without the suffix _). Wouldn't hurt to go all-private and provide accessors for the ones you want to be externally used.

Copy link
Author

Choose a reason for hiding this comment

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

This PR is stale, here's the most recent: ros2#347

std::recursive_mutex toggle_publish_mutex;
};

class Subscriber : public rclcpp::Node

Choose a reason for hiding this comment

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

All comments from Publisher apply

using namespace std::chrono_literals;

/// Liveliness setup
class LivelinessSetup : public ::testing::Test

Choose a reason for hiding this comment

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

Utilities TestSetup? Quick eyeball looks identical

ASSERT_EQ(0, event.not_alive_count);
ASSERT_EQ(-1, event.alive_count_change);
ASSERT_EQ(0, event.not_alive_count_change);
}

Choose a reason for hiding this comment

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

else { fail } maybe?

Copy link
Author

Choose a reason for hiding this comment

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

Assert should fast fail.

RCLCPP_DEBUG(rclcpp::get_logger("rclcpp"), "QOSDeadlineOfferedInfo callback");
total_number_of_publisher_deadline_events++;
// assert the correct value on a change
ASSERT_EQ(1, event.total_count_change);

Choose a reason for hiding this comment

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

Assert total_count against our locally-tracked counter total_number_of_publisher_deadline_events?

Copy link
Author

Choose a reason for hiding this comment

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

This is a simple check to ensure the callback is working (to fail fast). The total count is checked at the end.

RCLCPP_DEBUG(rclcpp::get_logger("rclcpp"), "QOSDeadlineRequestedInfo callback");
total_number_of_subscriber_deadline_events++;
// assert the correct value on a change
ASSERT_EQ(1, event.total_count_change);

Choose a reason for hiding this comment

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

Assert total_count against our locally-tracked counter total_number_of_subscriber_deadline_events?

max_test_length / expected_number_of_pub_events,
[&publisher]() -> void {
// start / stop publishing to trigger deadline
publisher->toggle_publishing();

Choose a reason for hiding this comment

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

Would it be a good idea to remove this step of complexity and just have the publisher never publish at all, since we're only trying to trigger the deadline events?

Copy link
Author

Choose a reason for hiding this comment

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

Yeah great point, I think I'll add another test which does exactly that (it's a valid permutation that should be stressed).

EXPECT_GT(subscriber->received_message_count_, 0); // check if we received anything
}

// todo multiple publisher test?

Choose a reason for hiding this comment

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

Don't leave the todo. I don't think this is necessary for this pass

Copy link
Author

Choose a reason for hiding this comment

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

This is stale.

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.

2 participants