From 1292ba54b02b510c6629a8c5a5bf96c585a8b2e7 Mon Sep 17 00:00:00 2001 From: Felix Exner Date: Tue, 15 Apr 2025 15:31:49 +0200 Subject: [PATCH] tool_contact_test: Check result status directly Re-using the goal handle seems to be flaky. --- .../test/integration_test_tool_contact.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/ur_robot_driver/test/integration_test_tool_contact.py b/ur_robot_driver/test/integration_test_tool_contact.py index 383d362b0..db6c60817 100644 --- a/ur_robot_driver/test/integration_test_tool_contact.py +++ b/ur_robot_driver/test/integration_test_tool_contact.py @@ -31,6 +31,7 @@ import sys import time import unittest +import logging import pytest @@ -131,10 +132,20 @@ def test_deactivate_controller_aborts_action(self): deactivate_controllers=["tool_contact_controller"], ).ok ) - # Wait for action to finish - self._tool_contact_interface.get_result(goal_handle, 5) - # Check status of goal handle, as result does not contain information about the status of the action. Only the empty result definition. - self.assertEqual(goal_handle._status, GoalStatus.STATUS_ABORTED) + future_res = goal_handle.get_result_async() + + timeout = 5.0 + logging.info("Waiting for action result from controller with timeout %fs", timeout) + rclpy.spin_until_future_complete(self.node, future_res, timeout_sec=timeout) + + if future_res.result() is not None: + logging.info(" Received result: %s", future_res.result().result) + # Check status of goal handle, as result does not contain information about the status of the action. Only the empty result definition. + self.assertEqual(future_res.result().status, GoalStatus.STATUS_ABORTED) + else: + raise Exception( + f"Exception while calling action '{self.__action_name}': {future_res.exception()}" + ) def test_inactive_controller_rejects_actions(self): self.assertTrue(