ros2 / launch

Tools for launching multiple processes and for writing tests involving multiple processes.
Apache License 2.0
124 stars 139 forks source link

Deadlock / missed messages in launch test. #648

Open rshanor opened 2 years ago

rshanor commented 2 years ago

Bug report

Required Info:

Steps to reproduce issue

Below is the test I am tying to run. I also have a generate_test_description section which spins up 4 other nodes. When I run my test with colcon test and pytest, the test runs for a while but eventually fails when a future does not finish (using executor.spin_until_future_complete). However, if I bring up all the other nodes manually and then run the below test as a script, everything always works as expected. As far as I can tell, the conductor.collect_calibration_data function below, which makes a bunch of service calls, sends a request that is never received by the server, or never receives a response from the server that appear to have been sent.

class TestRobotConductor(unittest.TestCase):
    def setUp(self):
        rclpy.init()
        self.node = rclpy.create_node("test_robot_conductor")
        self.executor = rclpy.executors.MultiThreadedExecutor()
        self.executor.add_node(self.node)
        self.executor_thread = threading.Thread(target=self.executor.spin, daemon=True)
        self.executor_thread.start()
        self.cam_cal_client = CamCalClient(self.node, self.executor)

    def tearDown(self):
        self.node.destroy_node()
        self.executor.shutdown()
        rclpy.shutdown()

    def test_robot_conductor(self):
        self.cam_cal_client.wait_for_services(timeout_sec=5.0)
        conductor = RobotConductor(self.cam_cal_client)
        conductor.collect_calibration_data()
        response = conductor.execute_cal()