Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add system tests into CI #271

Open
wants to merge 14 commits into
base: rolling
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 28 additions & 10 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,21 @@ jobs:
strategy:
fail-fast: false
matrix:
include:
# Rolling (source)
- ROS_DISTRO: rolling
BUILD_TYPE: source
# Jazzy (binary)
- ROS_DISTRO: jazzy
BUILD_TYPE: binary
# Iron (binary)
- ROS_DISTRO: iron
BUILD_TYPE: binary
ROS_DISTRO: [rolling, jazzy, iron]
BUILD_TYPE: [source, binary]
exclude:
- BUILD_TYPE: ${{ github.event_name != 'schedule' && 'source' || '' }}
env:
ROS2_REPOS_FILE_URL: 'https://raw.githubusercontent.com/ros2/ros2/${{ matrix.ROS_DISTRO }}/ros2.repos'
RMW_MIDDLEWARE_TEST_PACKAGES: 'test_rclcpp test_communication rcl'
runs-on: ubuntu-latest
container:
image: ${{ matrix.BUILD_TYPE == 'binary' && format('ros:{0}-ros-base', matrix.ROS_DISTRO) || 'ubuntu:noble' }}
steps:
- uses: ros-tooling/[email protected]
if: ${{ matrix.BUILD_TYPE == 'source' }}
with:
use-ros2-testing: true
- name: Install Coverage Tools
if: ${{ matrix.BUILD_TYPE == 'binary' }}
run: sudo apt update && sudo apt install -y python3-colcon-coveragepy-result python3-colcon-lcov-result lcov
Expand All @@ -42,7 +39,28 @@ jobs:
uses: ros-tooling/[email protected]
with:
package-name: |
${{ matrix.BUILD_TYPE == 'source' && env.RMW_MIDDLEWARE_TEST_PACKAGES || '' }}
rmw_zenoh_cpp
zenoh_c_vendor
colcon-defaults: |
{
"build": {
"cmake-args": [
"-DSKIP_MULTI_RMW_TESTS=ON"
]
}
}
target-ros2-distro: ${{ matrix.ROS_DISTRO }}
vcs-repo-file-url: ${{ matrix.BUILD_TYPE == 'source' && env.ROS2_REPOS_FILE_URL || '' }}
skip-tests: true
- name: Run system_tests
if: ${{ matrix.BUILD_TYPE == 'source' }}
run: |
cd ${{ steps.action-ros-ci.outputs.ros-workspace-directory-name }}
. install/setup.sh
launch_test install/rmw_zenoh_cpp/test/rmw_zenoh_integration.test.py 'selected_system_tests:=${{ env.RMW_MIDDLEWARE_TEST_PACKAGES }}'
- uses: actions/upload-artifact@v3
if: ${{ matrix.BUILD_TYPE == 'source' }}
with:
name: colcon-logs-${{ matrix.ROS_DISTRO }}-latest
path: ${{ steps.action-ros-ci.outputs.ros-workspace-directory-name }}/log
3 changes: 3 additions & 0 deletions rmw_zenoh_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ if(BUILD_TESTING)
ament_lint_cmake()
ament_uncrustify(EXCLUDE ${_linter_excludes})
ament_xmllint()

install(FILES test/rmw_zenoh_integration.test.py
DESTINATION test)
endif()

install(
Expand Down
1 change: 1 addition & 0 deletions rmw_zenoh_cpp/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<depend>rosidl_typesupport_fastrtps_cpp</depend>
<depend>rmw</depend>

<test_depend>ament_index_python</test_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>

Expand Down
84 changes: 84 additions & 0 deletions rmw_zenoh_cpp/test/rmw_zenoh_integration.test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Copyright 2024 Open Source Robotics Foundation, Inc.
#
# 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.

import os
import sys
import signal
import subprocess
import time
import unittest

import launch
import launch.actions
import launch.substitutions
import launch_ros.actions
import launch_testing.actions
import launch_testing.markers
import pytest


proc_env = os.environ.copy()
proc_env['RMW_IMPLEMENTATION'] = 'rmw_zenoh_cpp'

@pytest.mark.launch_test
@launch_testing.markers.keep_alive
def generate_test_description():

selected_system_tests = launch.substitutions.LaunchConfiguration('selected_system_tests')
selected_system_tests_arg = launch.actions.DeclareLaunchArgument(
'selected_system_tests',
default_value="test_rclcpp test_communication")

zenoh_router = launch_ros.actions.Node(
package="rmw_zenoh_cpp",
executable="rmw_zenohd",
output="both",
env=proc_env
)

dut_process = launch.actions.ExecuteProcess(
cmd=[
'colcon',
'test',
'--packages-select',
selected_system_tests,
'--retest-until-pass',
'2',
],
shell=True,
env=proc_env,
)

return launch.LaunchDescription([
selected_system_tests_arg,
zenoh_router,
dut_process,
# In tests where all of the procs under tests terminate themselves, it's necessary
# to add a dummy process not under test to keep the launch alive. launch_test
# provides a simple launch action that does this:
launch_testing.util.KeepAliveProc(),
launch_testing.actions.ReadyToTest()
]) , {'dut_process': dut_process}

class TestTerminatingProcessStops(unittest.TestCase):
def test_proc_terminates(self, proc_info, dut_process):
proc_info.assertWaitForShutdown(process=dut_process, timeout=400000)

# These tests are run after the processes in generate_test_description() have shutdown.
@launch_testing.post_shutdown_test()
class TestShutdown(unittest.TestCase):

def test_exit_codes(self, proc_info):
"""Check if the processes exited normally."""
launch_testing.asserts.assertExitCodes(proc_info)