Skip to content

Commit 674791c

Browse files
authored
Use reliable QoS for ros2topic tests (#555)
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 <[email protected]>
1 parent f03938e commit 674791c

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

ros2topic/test/fixtures/listener_node.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ class ListenerNode(Node):
2626
def __init__(self):
2727
super().__init__('listener')
2828
qos_profile = qos_profile_from_short_keys(
29-
'system_default', durability='transient_local')
29+
'system_default', durability='transient_local',
30+
reliability='reliable')
3031
self.sub = self.create_subscription(
3132
String, 'chatter', self.callback, qos_profile
3233
)

ros2topic/test/test_cli.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ def test_topic_pub(self):
563563
'pub',
564564
'--keep-alive', '3', # seconds
565565
'--qos-durability', 'transient_local',
566+
'--qos-reliability', 'reliable',
566567
'/chit_chatter',
567568
'std_msgs/msg/String',
568569
'{data: foo}'
@@ -588,6 +589,7 @@ def test_topic_pub_once(self):
588589
'pub', '--once',
589590
'--keep-alive', '3', # seconds
590591
'--qos-durability', 'transient_local',
592+
'--qos-reliability', 'reliable',
591593
'/chit_chatter',
592594
'std_msgs/msg/String',
593595
'{data: bar}'
@@ -615,6 +617,7 @@ def test_topic_pub_print_every_two(self):
615617
'-p', '2',
616618
'--keep-alive', '3', # seconds
617619
'--qos-durability', 'transient_local',
620+
'--qos-reliability', 'reliable',
618621
'/chit_chatter',
619622
'std_msgs/msg/String',
620623
'{data: fizz}'

0 commit comments

Comments
 (0)