From 36fae8ebac5037d9d6a278d5e432af878b136cf2 Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Mon, 22 Jul 2024 11:07:06 +0000 Subject: [PATCH 01/11] Add a pytest launch file to test ros2_control_node --- controller_manager/CMakeLists.txt | 5 + controller_manager/test/cm.launch.py | 45 +++++++++ .../test/test_ros2_control_node.yaml | 11 +++ .../test/test_ros2_control_node_launch.py | 91 +++++++++++++++++++ 4 files changed, 152 insertions(+) create mode 100644 controller_manager/test/cm.launch.py create mode 100644 controller_manager/test/test_ros2_control_node.yaml create mode 100644 controller_manager/test/test_ros2_control_node_launch.py diff --git a/controller_manager/CMakeLists.txt b/controller_manager/CMakeLists.txt index 7c437d35e0..3f54baf732 100644 --- a/controller_manager/CMakeLists.txt +++ b/controller_manager/CMakeLists.txt @@ -209,6 +209,11 @@ if(BUILD_TESTING) ament_target_dependencies(test_hardware_management_srvs controller_manager_msgs ) + + find_package(ament_cmake_pytest REQUIRED) + install(FILES test/test_ros2_control_node.yaml test/cm.launch.py + DESTINATION test) + ament_add_pytest_test(test_ros2_control_node test/test_ros2_control_node_launch.py) endif() install( diff --git a/controller_manager/test/cm.launch.py b/controller_manager/test/cm.launch.py new file mode 100644 index 0000000000..92910c12b3 --- /dev/null +++ b/controller_manager/test/cm.launch.py @@ -0,0 +1,45 @@ +# Copyright 2021 Stogl Robotics Consulting UG (haftungsbeschränkt) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +from launch import LaunchDescription +from launch.substitutions import PathJoinSubstitution + +from launch_ros.actions import Node +from launch_ros.substitutions import FindPackageShare + + +def generate_launch_description(): + # Declare arguments + declared_arguments = [] + + robot_controllers = PathJoinSubstitution( + [ + FindPackageShare("controller_manager"), + "test", + "test_ros2_control_node.yaml", + ] + ) + + control_node = Node( + package="controller_manager", + executable="ros2_control_node", + parameters=[robot_controllers], + output="both", + ) + nodes = [ + control_node, + ] + + return LaunchDescription(declared_arguments + nodes) diff --git a/controller_manager/test/test_ros2_control_node.yaml b/controller_manager/test/test_ros2_control_node.yaml new file mode 100644 index 0000000000..ce0602d6b3 --- /dev/null +++ b/controller_manager/test/test_ros2_control_node.yaml @@ -0,0 +1,11 @@ +controller_manager: + ros__parameters: + update_rate: 100 # Hz + +ctrl_with_parameters_and_type: + ros__parameters: + type: "controller_manager/test_controller" + joint_names: ["joint0"] + +joint_state_broadcaster: + type: joint_state_broadcaster/JointStateBroadcaster diff --git a/controller_manager/test/test_ros2_control_node_launch.py b/controller_manager/test/test_ros2_control_node_launch.py new file mode 100644 index 0000000000..a63cf9bb39 --- /dev/null +++ b/controller_manager/test/test_ros2_control_node_launch.py @@ -0,0 +1,91 @@ +# Copyright (c) 2024 AIT - Austrian Institute of Technology GmbH +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# * Neither the name of the {copyright_holder} nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# Author: Christoph Froehlich + +import os +import pytest +import unittest +import time + +from ament_index_python.packages import get_package_share_directory +from launch import LaunchDescription +from launch.actions import IncludeLaunchDescription +from launch.launch_description_sources import PythonLaunchDescriptionSource +from launch_testing.actions import ReadyToTest + +import launch_testing.markers +import rclpy +from rclpy.node import Node + + +# Executes the given launch file and checks if all nodes can be started +@pytest.mark.rostest +def generate_test_description(): + + launch_include = IncludeLaunchDescription( + PythonLaunchDescriptionSource( + os.path.join( + get_package_share_directory("controller_manager"), + "../../test/cm.launch.py", + ) + ), + ) + + return LaunchDescription([launch_include, ReadyToTest()]) + + +# This is our test fixture. Each method is a test case. +# These run alongside the processes specified in generate_test_description() +class TestFixture(unittest.TestCase): + + def setUp(self): + rclpy.init() + self.node = Node("test_node") + + def tearDown(self): + self.node.destroy_node() + rclpy.shutdown() + + def test_node_start(self, proc_output): + start = time.time() + found = False + while time.time() - start < 2.0 and not found: + found = "controller_manager" in self.node.get_node_names() + time.sleep(0.1) + assert found, "controller_manager not found!" + + +# TODO(anyone): enable this if shutdown of ros2_control_node does not fail anymore +@launch_testing.post_shutdown_test() +# These tests are run after the processes in generate_test_description() have shutdown. +class TestDescriptionCraneShutdown(unittest.TestCase): + + def test_exit_codes(self, proc_info): + """Check if the processes exited normally.""" + launch_testing.asserts.assertExitCodes(proc_info) From 7fa25badfc6e43a781fe926e263acf65a4ed6ad7 Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Mon, 22 Jul 2024 11:09:36 +0000 Subject: [PATCH 02/11] Add ament_cmake_pytest dependency --- controller_manager/package.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/controller_manager/package.xml b/controller_manager/package.xml index c8da38364a..6121331c92 100644 --- a/controller_manager/package.xml +++ b/controller_manager/package.xml @@ -30,6 +30,7 @@ std_msgs ament_cmake_gmock + ament_cmake_pytest hardware_interface_testing ros2_control_test_assets From 3bb714b16fb041d10d957058ea46f97ec8388b8d Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Mon, 22 Jul 2024 11:29:25 +0000 Subject: [PATCH 03/11] Deactivate post_shutdown_test --- .../test/test_ros2_control_node_launch.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/controller_manager/test/test_ros2_control_node_launch.py b/controller_manager/test/test_ros2_control_node_launch.py index a63cf9bb39..c83de69af9 100644 --- a/controller_manager/test/test_ros2_control_node_launch.py +++ b/controller_manager/test/test_ros2_control_node_launch.py @@ -39,7 +39,7 @@ from launch.launch_description_sources import PythonLaunchDescriptionSource from launch_testing.actions import ReadyToTest -import launch_testing.markers +# import launch_testing.markers import rclpy from rclpy.node import Node @@ -82,10 +82,10 @@ def test_node_start(self, proc_output): # TODO(anyone): enable this if shutdown of ros2_control_node does not fail anymore -@launch_testing.post_shutdown_test() -# These tests are run after the processes in generate_test_description() have shutdown. -class TestDescriptionCraneShutdown(unittest.TestCase): +# @launch_testing.post_shutdown_test() +# # These tests are run after the processes in generate_test_description() have shutdown. +# class TestDescriptionCraneShutdown(unittest.TestCase): - def test_exit_codes(self, proc_info): - """Check if the processes exited normally.""" - launch_testing.asserts.assertExitCodes(proc_info) +# def test_exit_codes(self, proc_info): +# """Check if the processes exited normally.""" +# launch_testing.asserts.assertExitCodes(proc_info) From a556e512e9f2b8562c8fdce3ad10fd7960550026 Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Mon, 22 Jul 2024 11:29:44 +0000 Subject: [PATCH 04/11] Try to make test fail --- controller_manager/src/ros2_control_node.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controller_manager/src/ros2_control_node.cpp b/controller_manager/src/ros2_control_node.cpp index 7addaf6cee..5ed9eb0640 100644 --- a/controller_manager/src/ros2_control_node.cpp +++ b/controller_manager/src/ros2_control_node.cpp @@ -37,7 +37,7 @@ int main(int argc, char ** argv) std::shared_ptr executor = std::make_shared(); - std::string manager_node_name = "controller_manager"; + std::string manager_node_name = "controller_test_manager"; auto cm = std::make_shared(executor, manager_node_name); From 9ff0f0f6c7eb83c0280c818b8f35759aab41bde0 Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Mon, 22 Jul 2024 11:49:37 +0000 Subject: [PATCH 05/11] Revert "Try to make test fail" This reverts commit a556e512e9f2b8562c8fdce3ad10fd7960550026. --- controller_manager/src/ros2_control_node.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controller_manager/src/ros2_control_node.cpp b/controller_manager/src/ros2_control_node.cpp index 5ed9eb0640..7addaf6cee 100644 --- a/controller_manager/src/ros2_control_node.cpp +++ b/controller_manager/src/ros2_control_node.cpp @@ -37,7 +37,7 @@ int main(int argc, char ** argv) std::shared_ptr executor = std::make_shared(); - std::string manager_node_name = "controller_test_manager"; + std::string manager_node_name = "controller_manager"; auto cm = std::make_shared(executor, manager_node_name); From 98961e112d0f6981814b161343d69f0d453cd74b Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Mon, 22 Jul 2024 11:50:59 +0000 Subject: [PATCH 06/11] Update pytest marker --- controller_manager/test/test_ros2_control_node_launch.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/controller_manager/test/test_ros2_control_node_launch.py b/controller_manager/test/test_ros2_control_node_launch.py index c83de69af9..3f88c47624 100644 --- a/controller_manager/test/test_ros2_control_node_launch.py +++ b/controller_manager/test/test_ros2_control_node_launch.py @@ -39,13 +39,12 @@ from launch.launch_description_sources import PythonLaunchDescriptionSource from launch_testing.actions import ReadyToTest -# import launch_testing.markers import rclpy from rclpy.node import Node # Executes the given launch file and checks if all nodes can be started -@pytest.mark.rostest +@pytest.mark.launch_test def generate_test_description(): launch_include = IncludeLaunchDescription( @@ -72,7 +71,7 @@ def tearDown(self): self.node.destroy_node() rclpy.shutdown() - def test_node_start(self, proc_output): + def test_node_start(self): start = time.time() found = False while time.time() - start < 2.0 and not found: From 38ee32fe9fca956bee62919c9d5a5b6864b3f8b3 Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Mon, 22 Jul 2024 11:52:52 +0000 Subject: [PATCH 07/11] Deactivate tests temporarily --- .github/workflows/jazzy-binary-build.yml | 24 +++++++++---------- .github/workflows/jazzy-debian-build.yml | 24 +++++++++---------- .github/workflows/jazzy-rhel-binary-build.yml | 24 +++++++++---------- .github/workflows/jazzy-semi-binary-build.yml | 24 +++++++++---------- .github/workflows/rolling-binary-build.yml | 24 +++++++++---------- .github/workflows/rolling-debian-build.yml | 24 +++++++++---------- .../workflows/rolling-rhel-binary-build.yml | 24 +++++++++---------- 7 files changed, 84 insertions(+), 84 deletions(-) diff --git a/.github/workflows/jazzy-binary-build.yml b/.github/workflows/jazzy-binary-build.yml index 5be853ebfc..38f9d5c924 100644 --- a/.github/workflows/jazzy-binary-build.yml +++ b/.github/workflows/jazzy-binary-build.yml @@ -4,18 +4,18 @@ name: Jazzy Binary Build on: workflow_dispatch: - pull_request: - branches: - - master - paths: - - '**.hpp' - - '**.h' - - '**.cpp' - - '**.py' - - '.github/workflows/jazzy-binary-build.yml' - - '**/package.xml' - - '**/CMakeLists.txt' - - 'ros2_control-not-released.jazzy.repos' + # pull_request: + # branches: + # - master + # paths: + # - '**.hpp' + # - '**.h' + # - '**.cpp' + # - '**.py' + # - '.github/workflows/jazzy-binary-build.yml' + # - '**/package.xml' + # - '**/CMakeLists.txt' + # - 'ros2_control-not-released.jazzy.repos' push: branches: - master diff --git a/.github/workflows/jazzy-debian-build.yml b/.github/workflows/jazzy-debian-build.yml index 4ec6a29fff..b9023727b7 100644 --- a/.github/workflows/jazzy-debian-build.yml +++ b/.github/workflows/jazzy-debian-build.yml @@ -1,18 +1,18 @@ name: Debian Jazzy Source Build on: workflow_dispatch: - pull_request: - branches: - - master - paths: - - '**.hpp' - - '**.h' - - '**.cpp' - - '**.py' - - '.github/workflows/jazzy-debian-build.yml' - - '**/package.xml' - - '**/CMakeLists.txt' - - 'ros2_control.jazzy.repos' + # pull_request: + # branches: + # - master + # paths: + # - '**.hpp' + # - '**.h' + # - '**.cpp' + # - '**.py' + # - '.github/workflows/jazzy-debian-build.yml' + # - '**/package.xml' + # - '**/CMakeLists.txt' + # - 'ros2_control.jazzy.repos' schedule: # Run every day to detect flakiness and broken dependencies - cron: '03 1 * * *' diff --git a/.github/workflows/jazzy-rhel-binary-build.yml b/.github/workflows/jazzy-rhel-binary-build.yml index 0dcc912dab..18820cf41c 100644 --- a/.github/workflows/jazzy-rhel-binary-build.yml +++ b/.github/workflows/jazzy-rhel-binary-build.yml @@ -1,18 +1,18 @@ name: RHEL Jazzy Semi-Binary Build on: workflow_dispatch: - pull_request: - branches: - - master - paths: - - '**.hpp' - - '**.h' - - '**.cpp' - - '**.py' - - '.github/workflows/jazzy-rhel-binary-build.yml' - - '**/package.xml' - - '**/CMakeLists.txt' - - 'ros2_control.jazzy.repos' + # pull_request: + # branches: + # - master + # paths: + # - '**.hpp' + # - '**.h' + # - '**.cpp' + # - '**.py' + # - '.github/workflows/jazzy-rhel-binary-build.yml' + # - '**/package.xml' + # - '**/CMakeLists.txt' + # - 'ros2_control.jazzy.repos' schedule: # Run every day to detect flakiness and broken dependencies - cron: '03 1 * * *' diff --git a/.github/workflows/jazzy-semi-binary-build.yml b/.github/workflows/jazzy-semi-binary-build.yml index 9634732cf9..f3c9ef4547 100644 --- a/.github/workflows/jazzy-semi-binary-build.yml +++ b/.github/workflows/jazzy-semi-binary-build.yml @@ -4,18 +4,18 @@ name: Jazzy Semi-Binary Build on: workflow_dispatch: - pull_request: - branches: - - master - paths: - - '**.hpp' - - '**.h' - - '**.cpp' - - '**.py' - - '.github/workflows/jazzy-semi-binary-build.yml' - - '**/package.xml' - - '**/CMakeLists.txt' - - 'ros2_control.jazzy.repos' + # pull_request: + # branches: + # - master + # paths: + # - '**.hpp' + # - '**.h' + # - '**.cpp' + # - '**.py' + # - '.github/workflows/jazzy-semi-binary-build.yml' + # - '**/package.xml' + # - '**/CMakeLists.txt' + # - 'ros2_control.jazzy.repos' push: branches: - master diff --git a/.github/workflows/rolling-binary-build.yml b/.github/workflows/rolling-binary-build.yml index 24a28f16ae..bc0fd5d6ae 100644 --- a/.github/workflows/rolling-binary-build.yml +++ b/.github/workflows/rolling-binary-build.yml @@ -4,18 +4,18 @@ name: Rolling Binary Build on: workflow_dispatch: - pull_request: - branches: - - master - paths: - - '**.hpp' - - '**.h' - - '**.cpp' - - '**.py' - - '.github/workflows/rolling-binary-build.yml' - - '**/package.xml' - - '**/CMakeLists.txt' - - 'ros2_control-not-released.rolling.repos' + # pull_request: + # branches: + # - master + # paths: + # - '**.hpp' + # - '**.h' + # - '**.cpp' + # - '**.py' + # - '.github/workflows/rolling-binary-build.yml' + # - '**/package.xml' + # - '**/CMakeLists.txt' + # - 'ros2_control-not-released.rolling.repos' push: branches: - master diff --git a/.github/workflows/rolling-debian-build.yml b/.github/workflows/rolling-debian-build.yml index 00d4ad844b..ce1ca9a64c 100644 --- a/.github/workflows/rolling-debian-build.yml +++ b/.github/workflows/rolling-debian-build.yml @@ -1,18 +1,18 @@ name: Debian Rolling Source Build on: workflow_dispatch: - pull_request: - branches: - - master - paths: - - '**.hpp' - - '**.h' - - '**.cpp' - - '**.py' - - '.github/workflows/rolling-debian-build.yml' - - '**/package.xml' - - '**/CMakeLists.txt' - - 'ros2_control.rolling.repos' + # pull_request: + # branches: + # - master + # paths: + # - '**.hpp' + # - '**.h' + # - '**.cpp' + # - '**.py' + # - '.github/workflows/rolling-debian-build.yml' + # - '**/package.xml' + # - '**/CMakeLists.txt' + # - 'ros2_control.rolling.repos' schedule: # Run every day to detect flakiness and broken dependencies - cron: '03 1 * * *' diff --git a/.github/workflows/rolling-rhel-binary-build.yml b/.github/workflows/rolling-rhel-binary-build.yml index c8939d6015..7ede10eef8 100644 --- a/.github/workflows/rolling-rhel-binary-build.yml +++ b/.github/workflows/rolling-rhel-binary-build.yml @@ -1,18 +1,18 @@ name: RHEL Rolling Semi-Binary Build on: workflow_dispatch: - pull_request: - branches: - - master - paths: - - '**.hpp' - - '**.h' - - '**.cpp' - - '**.py' - - '.github/workflows/rolling-rhel-binary-build.yml' - - '**/package.xml' - - '**/CMakeLists.txt' - - 'ros2_control.jazzy.repos' + # pull_request: + # branches: + # - master + # paths: + # - '**.hpp' + # - '**.h' + # - '**.cpp' + # - '**.py' + # - '.github/workflows/rolling-rhel-binary-build.yml' + # - '**/package.xml' + # - '**/CMakeLists.txt' + # - 'ros2_control.jazzy.repos' schedule: # Run every day to detect flakiness and broken dependencies - cron: '03 1 * * *' From 4ae55fabbb8e17ea7b8ccb352850051f34741563 Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Mon, 22 Jul 2024 12:08:58 +0000 Subject: [PATCH 08/11] Test test_exit_codes once again --- .../test/test_ros2_control_node_launch.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/controller_manager/test/test_ros2_control_node_launch.py b/controller_manager/test/test_ros2_control_node_launch.py index 3f88c47624..1795f4a0cd 100644 --- a/controller_manager/test/test_ros2_control_node_launch.py +++ b/controller_manager/test/test_ros2_control_node_launch.py @@ -39,6 +39,7 @@ from launch.launch_description_sources import PythonLaunchDescriptionSource from launch_testing.actions import ReadyToTest +import launch_testing.markers import rclpy from rclpy.node import Node @@ -80,11 +81,10 @@ def test_node_start(self): assert found, "controller_manager not found!" -# TODO(anyone): enable this if shutdown of ros2_control_node does not fail anymore -# @launch_testing.post_shutdown_test() -# # These tests are run after the processes in generate_test_description() have shutdown. -# class TestDescriptionCraneShutdown(unittest.TestCase): +@launch_testing.post_shutdown_test() +# These tests are run after the processes in generate_test_description() have shutdown. +class TestDescriptionCraneShutdown(unittest.TestCase): -# def test_exit_codes(self, proc_info): -# """Check if the processes exited normally.""" -# launch_testing.asserts.assertExitCodes(proc_info) + def test_exit_codes(self, proc_info): + """Check if the processes exited normally.""" + launch_testing.asserts.assertExitCodes(proc_info) From 334a295f323f77962f9b88a6633b96290e3ec4af Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Mon, 22 Jul 2024 12:34:20 +0000 Subject: [PATCH 09/11] Revert "Deactivate tests temporarily" This reverts commit 38ee32fe9fca956bee62919c9d5a5b6864b3f8b3. --- .github/workflows/jazzy-binary-build.yml | 24 +++++++++---------- .github/workflows/jazzy-debian-build.yml | 24 +++++++++---------- .github/workflows/jazzy-rhel-binary-build.yml | 24 +++++++++---------- .github/workflows/jazzy-semi-binary-build.yml | 24 +++++++++---------- .github/workflows/rolling-binary-build.yml | 24 +++++++++---------- .github/workflows/rolling-debian-build.yml | 24 +++++++++---------- .../workflows/rolling-rhel-binary-build.yml | 24 +++++++++---------- 7 files changed, 84 insertions(+), 84 deletions(-) diff --git a/.github/workflows/jazzy-binary-build.yml b/.github/workflows/jazzy-binary-build.yml index 38f9d5c924..5be853ebfc 100644 --- a/.github/workflows/jazzy-binary-build.yml +++ b/.github/workflows/jazzy-binary-build.yml @@ -4,18 +4,18 @@ name: Jazzy Binary Build on: workflow_dispatch: - # pull_request: - # branches: - # - master - # paths: - # - '**.hpp' - # - '**.h' - # - '**.cpp' - # - '**.py' - # - '.github/workflows/jazzy-binary-build.yml' - # - '**/package.xml' - # - '**/CMakeLists.txt' - # - 'ros2_control-not-released.jazzy.repos' + pull_request: + branches: + - master + paths: + - '**.hpp' + - '**.h' + - '**.cpp' + - '**.py' + - '.github/workflows/jazzy-binary-build.yml' + - '**/package.xml' + - '**/CMakeLists.txt' + - 'ros2_control-not-released.jazzy.repos' push: branches: - master diff --git a/.github/workflows/jazzy-debian-build.yml b/.github/workflows/jazzy-debian-build.yml index b9023727b7..4ec6a29fff 100644 --- a/.github/workflows/jazzy-debian-build.yml +++ b/.github/workflows/jazzy-debian-build.yml @@ -1,18 +1,18 @@ name: Debian Jazzy Source Build on: workflow_dispatch: - # pull_request: - # branches: - # - master - # paths: - # - '**.hpp' - # - '**.h' - # - '**.cpp' - # - '**.py' - # - '.github/workflows/jazzy-debian-build.yml' - # - '**/package.xml' - # - '**/CMakeLists.txt' - # - 'ros2_control.jazzy.repos' + pull_request: + branches: + - master + paths: + - '**.hpp' + - '**.h' + - '**.cpp' + - '**.py' + - '.github/workflows/jazzy-debian-build.yml' + - '**/package.xml' + - '**/CMakeLists.txt' + - 'ros2_control.jazzy.repos' schedule: # Run every day to detect flakiness and broken dependencies - cron: '03 1 * * *' diff --git a/.github/workflows/jazzy-rhel-binary-build.yml b/.github/workflows/jazzy-rhel-binary-build.yml index 18820cf41c..0dcc912dab 100644 --- a/.github/workflows/jazzy-rhel-binary-build.yml +++ b/.github/workflows/jazzy-rhel-binary-build.yml @@ -1,18 +1,18 @@ name: RHEL Jazzy Semi-Binary Build on: workflow_dispatch: - # pull_request: - # branches: - # - master - # paths: - # - '**.hpp' - # - '**.h' - # - '**.cpp' - # - '**.py' - # - '.github/workflows/jazzy-rhel-binary-build.yml' - # - '**/package.xml' - # - '**/CMakeLists.txt' - # - 'ros2_control.jazzy.repos' + pull_request: + branches: + - master + paths: + - '**.hpp' + - '**.h' + - '**.cpp' + - '**.py' + - '.github/workflows/jazzy-rhel-binary-build.yml' + - '**/package.xml' + - '**/CMakeLists.txt' + - 'ros2_control.jazzy.repos' schedule: # Run every day to detect flakiness and broken dependencies - cron: '03 1 * * *' diff --git a/.github/workflows/jazzy-semi-binary-build.yml b/.github/workflows/jazzy-semi-binary-build.yml index f3c9ef4547..9634732cf9 100644 --- a/.github/workflows/jazzy-semi-binary-build.yml +++ b/.github/workflows/jazzy-semi-binary-build.yml @@ -4,18 +4,18 @@ name: Jazzy Semi-Binary Build on: workflow_dispatch: - # pull_request: - # branches: - # - master - # paths: - # - '**.hpp' - # - '**.h' - # - '**.cpp' - # - '**.py' - # - '.github/workflows/jazzy-semi-binary-build.yml' - # - '**/package.xml' - # - '**/CMakeLists.txt' - # - 'ros2_control.jazzy.repos' + pull_request: + branches: + - master + paths: + - '**.hpp' + - '**.h' + - '**.cpp' + - '**.py' + - '.github/workflows/jazzy-semi-binary-build.yml' + - '**/package.xml' + - '**/CMakeLists.txt' + - 'ros2_control.jazzy.repos' push: branches: - master diff --git a/.github/workflows/rolling-binary-build.yml b/.github/workflows/rolling-binary-build.yml index bc0fd5d6ae..24a28f16ae 100644 --- a/.github/workflows/rolling-binary-build.yml +++ b/.github/workflows/rolling-binary-build.yml @@ -4,18 +4,18 @@ name: Rolling Binary Build on: workflow_dispatch: - # pull_request: - # branches: - # - master - # paths: - # - '**.hpp' - # - '**.h' - # - '**.cpp' - # - '**.py' - # - '.github/workflows/rolling-binary-build.yml' - # - '**/package.xml' - # - '**/CMakeLists.txt' - # - 'ros2_control-not-released.rolling.repos' + pull_request: + branches: + - master + paths: + - '**.hpp' + - '**.h' + - '**.cpp' + - '**.py' + - '.github/workflows/rolling-binary-build.yml' + - '**/package.xml' + - '**/CMakeLists.txt' + - 'ros2_control-not-released.rolling.repos' push: branches: - master diff --git a/.github/workflows/rolling-debian-build.yml b/.github/workflows/rolling-debian-build.yml index ce1ca9a64c..00d4ad844b 100644 --- a/.github/workflows/rolling-debian-build.yml +++ b/.github/workflows/rolling-debian-build.yml @@ -1,18 +1,18 @@ name: Debian Rolling Source Build on: workflow_dispatch: - # pull_request: - # branches: - # - master - # paths: - # - '**.hpp' - # - '**.h' - # - '**.cpp' - # - '**.py' - # - '.github/workflows/rolling-debian-build.yml' - # - '**/package.xml' - # - '**/CMakeLists.txt' - # - 'ros2_control.rolling.repos' + pull_request: + branches: + - master + paths: + - '**.hpp' + - '**.h' + - '**.cpp' + - '**.py' + - '.github/workflows/rolling-debian-build.yml' + - '**/package.xml' + - '**/CMakeLists.txt' + - 'ros2_control.rolling.repos' schedule: # Run every day to detect flakiness and broken dependencies - cron: '03 1 * * *' diff --git a/.github/workflows/rolling-rhel-binary-build.yml b/.github/workflows/rolling-rhel-binary-build.yml index 7ede10eef8..c8939d6015 100644 --- a/.github/workflows/rolling-rhel-binary-build.yml +++ b/.github/workflows/rolling-rhel-binary-build.yml @@ -1,18 +1,18 @@ name: RHEL Rolling Semi-Binary Build on: workflow_dispatch: - # pull_request: - # branches: - # - master - # paths: - # - '**.hpp' - # - '**.h' - # - '**.cpp' - # - '**.py' - # - '.github/workflows/rolling-rhel-binary-build.yml' - # - '**/package.xml' - # - '**/CMakeLists.txt' - # - 'ros2_control.jazzy.repos' + pull_request: + branches: + - master + paths: + - '**.hpp' + - '**.h' + - '**.cpp' + - '**.py' + - '.github/workflows/rolling-rhel-binary-build.yml' + - '**/package.xml' + - '**/CMakeLists.txt' + - 'ros2_control.jazzy.repos' schedule: # Run every day to detect flakiness and broken dependencies - cron: '03 1 * * *' From d4540d16d619e010e7aeddcdd1dbf0d1d37f1d6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Fr=C3=B6hlich?= Date: Mon, 22 Jul 2024 15:11:44 +0200 Subject: [PATCH 10/11] Update controller_manager/test/cm.launch.py --- controller_manager/test/cm.launch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controller_manager/test/cm.launch.py b/controller_manager/test/cm.launch.py index 92910c12b3..24364a859f 100644 --- a/controller_manager/test/cm.launch.py +++ b/controller_manager/test/cm.launch.py @@ -1,4 +1,4 @@ -# Copyright 2021 Stogl Robotics Consulting UG (haftungsbeschränkt) +# Copyright (c) 2024 AIT - Austrian Institute of Technology GmbH # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. From f3d69c85409fdcfee714a140de63321896da1d5f Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Mon, 22 Jul 2024 15:54:35 +0000 Subject: [PATCH 11/11] Remove separate test launch file --- controller_manager/CMakeLists.txt | 2 +- controller_manager/test/cm.launch.py | 45 ------------------- .../test/test_ros2_control_node_launch.py | 29 +++++++----- 3 files changed, 18 insertions(+), 58 deletions(-) delete mode 100644 controller_manager/test/cm.launch.py diff --git a/controller_manager/CMakeLists.txt b/controller_manager/CMakeLists.txt index 3f54baf732..c4ef0e7df0 100644 --- a/controller_manager/CMakeLists.txt +++ b/controller_manager/CMakeLists.txt @@ -211,7 +211,7 @@ if(BUILD_TESTING) ) find_package(ament_cmake_pytest REQUIRED) - install(FILES test/test_ros2_control_node.yaml test/cm.launch.py + install(FILES test/test_ros2_control_node.yaml DESTINATION test) ament_add_pytest_test(test_ros2_control_node test/test_ros2_control_node_launch.py) endif() diff --git a/controller_manager/test/cm.launch.py b/controller_manager/test/cm.launch.py deleted file mode 100644 index 24364a859f..0000000000 --- a/controller_manager/test/cm.launch.py +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright (c) 2024 AIT - Austrian Institute of Technology GmbH -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -from launch import LaunchDescription -from launch.substitutions import PathJoinSubstitution - -from launch_ros.actions import Node -from launch_ros.substitutions import FindPackageShare - - -def generate_launch_description(): - # Declare arguments - declared_arguments = [] - - robot_controllers = PathJoinSubstitution( - [ - FindPackageShare("controller_manager"), - "test", - "test_ros2_control_node.yaml", - ] - ) - - control_node = Node( - package="controller_manager", - executable="ros2_control_node", - parameters=[robot_controllers], - output="both", - ) - nodes = [ - control_node, - ] - - return LaunchDescription(declared_arguments + nodes) diff --git a/controller_manager/test/test_ros2_control_node_launch.py b/controller_manager/test/test_ros2_control_node_launch.py index 1795f4a0cd..c8c1136849 100644 --- a/controller_manager/test/test_ros2_control_node_launch.py +++ b/controller_manager/test/test_ros2_control_node_launch.py @@ -28,19 +28,18 @@ # # Author: Christoph Froehlich -import os import pytest import unittest import time -from ament_index_python.packages import get_package_share_directory from launch import LaunchDescription -from launch.actions import IncludeLaunchDescription -from launch.launch_description_sources import PythonLaunchDescriptionSource +from launch.substitutions import PathJoinSubstitution +from launch_ros.substitutions import FindPackageShare from launch_testing.actions import ReadyToTest import launch_testing.markers import rclpy +import launch_ros.actions from rclpy.node import Node @@ -48,16 +47,22 @@ @pytest.mark.launch_test def generate_test_description(): - launch_include = IncludeLaunchDescription( - PythonLaunchDescriptionSource( - os.path.join( - get_package_share_directory("controller_manager"), - "../../test/cm.launch.py", - ) - ), + robot_controllers = PathJoinSubstitution( + [ + FindPackageShare("controller_manager"), + "test", + "test_ros2_control_node.yaml", + ] ) - return LaunchDescription([launch_include, ReadyToTest()]) + control_node = launch_ros.actions.Node( + package="controller_manager", + executable="ros2_control_node", + parameters=[robot_controllers], + output="both", + ) + + return LaunchDescription([control_node, ReadyToTest()]) # This is our test fixture. Each method is a test case.