From db1408c88b4706b6ce7a526551a1fdf8d00da9ce Mon Sep 17 00:00:00 2001 From: Scott K Logan Date: Thu, 30 Jul 2020 12:55:51 -0700 Subject: [PATCH] Use reliable QoS for ros2topic tests The TestROS2TopicCLI tests perform feature testing of the ros2topic command line interface. If the system is under stress during these tests, messages may be lost (by design). If that happens, there is a fairly high likelihood that the test_topic_pub_once test will fail because there is only one opportunity for the message to be successfully transported. We're likely dropping other messages in this suite, but the other tests continuously publish until one of the messages is received (or a timeout occurs), making them significantly less likely to fail. Using the 'reliable' setting for QoS reliability seems to make the tests consistently pass, even when the system is placed under additional stress. Signed-off-by: Scott K Logan --- ros2topic/test/fixtures/listener_node.py | 3 ++- ros2topic/test/test_cli.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ros2topic/test/fixtures/listener_node.py b/ros2topic/test/fixtures/listener_node.py index f6355ddff..71fa79b9f 100644 --- a/ros2topic/test/fixtures/listener_node.py +++ b/ros2topic/test/fixtures/listener_node.py @@ -26,7 +26,8 @@ class ListenerNode(Node): def __init__(self): super().__init__('listener') qos_profile = qos_profile_from_short_keys( - 'system_default', durability='transient_local') + 'system_default', durability='transient_local', + reliability='reliable') self.sub = self.create_subscription( String, 'chatter', self.callback, qos_profile ) diff --git a/ros2topic/test/test_cli.py b/ros2topic/test/test_cli.py index 15e278790..0173ff91c 100644 --- a/ros2topic/test/test_cli.py +++ b/ros2topic/test/test_cli.py @@ -563,6 +563,7 @@ def test_topic_pub(self): 'pub', '--keep-alive', '3', # seconds '--qos-durability', 'transient_local', + '--qos-reliability', 'reliable', '/chit_chatter', 'std_msgs/msg/String', '{data: foo}' @@ -588,6 +589,7 @@ def test_topic_pub_once(self): 'pub', '--once', '--keep-alive', '3', # seconds '--qos-durability', 'transient_local', + '--qos-reliability', 'reliable', '/chit_chatter', 'std_msgs/msg/String', '{data: bar}' @@ -615,6 +617,7 @@ def test_topic_pub_print_every_two(self): '-p', '2', '--keep-alive', '3', # seconds '--qos-durability', 'transient_local', + '--qos-reliability', 'reliable', '/chit_chatter', 'std_msgs/msg/String', '{data: fizz}'