Skip to content

Commit

Permalink
Add Docker tests
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Lopez Fernandez <[email protected]>
  • Loading branch information
juanlofer-eprosima committed Sep 26, 2024
1 parent fd2ba0d commit f76a07e
Show file tree
Hide file tree
Showing 14 changed files with 755 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM ubuntu:22.04
LABEL [email protected]

# Avoid interactuation with installation of some package that needs the locale.
ENV TZ=Europe/Madrid
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

# Avoids using interactions during building
ENV DEBIAN_FRONTEND=noninteractive

# Use a bash shell so it is possigle to run things like `source` (required for colcon builds)
SHELL ["/bin/bash", "-c"]

COPY linux_bisource_installation.bash /tmp/linux_bisource_installation.bash
RUN chmod +x /tmp/linux_bisource_installation.bash
RUN /tmp/linux_bisource_installation.bash
RUN rm /tmp/linux_bisource_installation.bash

COPY run.bash /root/run.bash
RUN chmod +x /root/run.bash

ENTRYPOINT ["/root/run.bash" ]
7 changes: 7 additions & 0 deletions .github/docker/run.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# Setup environment
source "/opt/ros/iron/setup.bash"
source "/root/vulcanexus_iron/install/setup.bash"

exec "$@"
67 changes: 67 additions & 0 deletions .github/workflows/test_docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: test-docker-workflow
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
- humble
- iron
- jazzy

schedule:
- cron: '0 0 * * *'

jobs:
docker-tests:
runs-on: ubuntu-22.04

env:
VULCANEXUS_COMPOSE_TEST_DOCKER_IMAGE: "vulcanexus:ci"

steps:

- name: Sync repository
uses: eProsima/eProsima-CI/external/checkout@v0
with:
path: src
# ref: main
ref: feature/fastdds-cli-package

- name: Build Vulcanexus Docker image
run: |
cd ./src/.github/docker/vulcanexus
docker build \
--no-cache \
-t ${{ env.VULCANEXUS_COMPOSE_TEST_DOCKER_IMAGE }} \
-f Dockerfile .
- name: Check if Docker images exist
run: |
[ -n "$(docker images -q ${{ env.VULCANEXUS_COMPOSE_TEST_DOCKER_IMAGE }})" ] || echo "Vulcanexus Docker image does not exist"
- name: Compile docker tests
run: |
colcon build \
--packages-select vulcanexus_test \
--cmake-args \
-DBUILD_COMPOSE_TESTS=ON
- name: Compile docker tests
uses: eProsima/eProsima-CI/multiplatform/colcon_build@v0
with:
workspace: ${{ github.workspace }}
colcon_build_args: --packages-up-to vulcanexus_test
cmake_args: -DBUILD_COMPOSE_TESTS=ON
workspace_dependencies: install

- name: Run tests
run: |
export VULCANEXUS_COMPOSE_TEST_DOCKER_IMAGE=${{ env.VULCANEXUS_COMPOSE_TEST_DOCKER_IMAGE }}
source install/setup.bash
colcon test \
--packages-select vulcanexus_test \
--event-handlers console_direct+ \
--return-code-on-test-failure \
--ctest-args \
--timeout 120
142 changes: 142 additions & 0 deletions docs/resources/scripts/linux_bisource_installation.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
#!/bin/bash

set -e

if (( $EUID == 0 )); then
shopt -s expand_aliases
alias sudo=''
fi

if !(locale | grep -e 'utf8' -e 'UTF-8') >/dev/null 2>&1; then

##LINUX_BINARY_LOCALE
locale # check for UTF-8

sudo apt update && sudo apt install -y locales
# Any UTF-8 locale will work. Using en_US as an example
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8
##!

locale

fi

##LINUX_BINARY_UBUNTU_UNIVERSE
apt-cache policy | grep universe

# This should print something similar to:
#
# 500 http://us.archive.ubuntu.com/ubuntu jammy/universe amd64 Packages
# release v=22.04,o=Ubuntu,a=jammy,n=jammy,l=Ubuntu,c=universe,b=amd64
#
# Otherwise run

sudo apt install -y software-properties-common
sudo add-apt-repository universe -y
##!

##LINUX_BINARY_KEYSTORE
sudo apt update && sudo apt install -y curl gnupg lsb-release
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
##!

##LINUX_BINARY_REPO_SOURCELIST
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(source /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
##!

##LINUX_BINARY_ROS_UPDATE
sudo apt update -y
##!

##LINUX_BINARY_ROS_INSTALL
sudo apt install -y ros-iron-desktop
##!

##SETUP_ROS_ENV
source "/opt/ros/iron/setup.bash"
##!

##CREATE_WORKSPACE
mkdir -p ~/vulcanexus_iron/src
cd ~/vulcanexus_iron
##!

##LINUX_SOURCE_ROS2_DEPS
sudo apt update && sudo apt install -y \
build-essential \
cmake \
git \
python3-colcon-common-extensions \
python3-flake8 \
python3-flake8-blind-except \
python3-flake8-builtins \
python3-flake8-class-newline \
python3-flake8-comprehensions \
python3-flake8-deprecated \
python3-flake8-docstrings \
python3-flake8-import-order \
python3-flake8-quotes \
python3-pip \
python3-pytest \
python3-pytest-cov \
python3-pytest-repeat \
python3-pytest-rerunfailures \
python3-rosdep \
python3-setuptools \
python3-vcstool \
wget
##!

##LINUX_SOURCE_VULCA_DEPS
sudo apt update && sudo apt install -y \
libasio-dev \
libdocopt-dev \
libengine-pkcs11-openssl \
liblog4cxx-dev \
liblz4-dev \
libp11-dev \
libqt5charts5-dev \
libssl-dev \
libtinyxml2-dev \
libxerces-c-dev \
libyaml-cpp-dev \
libzstd-dev \
openjdk-8-jdk \
python3-sphinx \
python3-sphinx-rtd-theme \
qtbase5-dev \
qtdeclarative5-dev \
qtquickcontrols2-5-dev \
swig
##!

# Get Vulcanexus sources
wget https://raw.githubusercontent.com/eProsima/vulcanexus/iron/vulcanexus.repos
wget https://raw.githubusercontent.com/eProsima/vulcanexus/iron/colcon.meta
vcs import --force src < vulcanexus.repos

# Avoid compilation of some documentation and demo packages
touch src/eProsima/Fast-DDS-QoS-Profiles-Manager/docs/COLCON_IGNORE
touch src/eProsima/Vulcanexus-Base/docs/COLCON_IGNORE
touch src/eProsima/Vulcanexus-Base/code/COLCON_IGNORE
##!

#################################################################################################
#################################################################################################
#################################################################################################
###### TEMP ######
cd /tmp
git clone https://github.com/eProsima/vulcanexus.git
cd vulcanexus
git checkout feature/fastdds-cli-package
mv fastdds_cli ~/vulcanexus_iron/src/eProsima/Vulcanexus-Base
#################################################################################################
#################################################################################################
#################################################################################################

##LINUX_SOURCE_VULCA_COMPILE
cd ~/vulcanexus_iron
colcon build --cmake-args -DBUILD_TESTING=OFF
##!
36 changes: 36 additions & 0 deletions vulcanexus_test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima).
#
# 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.

cmake_minimum_required(VERSION 3.8)
project(vulcanexus_test)

# find dependencies
find_package(ament_cmake REQUIRED)

###############################################################################
# Test
###############################################################################
# Compile tests if CMake options requires it
option(BUILD_COMPOSE_TESTS "Compile compose tests" OFF)

if(BUILD_COMPOSE_TESTS)
message(STATUS "Compiling Compose Tests of ${PROJECT_NAME}")
add_subdirectory(compose)
endif()

###############################################################################
# Packaging
###############################################################################
# Install package
ament_package()
51 changes: 51 additions & 0 deletions vulcanexus_test/compose/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima).
#
# 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.

# Name of files to test
set(TESTS
fastdds_cli/discovery_server
fastdds_cli/shm
fastdds_cli/xml
)

file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/test_cases DESTINATION ${CMAKE_CURRENT_BINARY_DIR})

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docker-compose.sh
${CMAKE_CURRENT_BINARY_DIR}/docker-compose.sh
COPYONLY)

file(
COPY
${CMAKE_CURRENT_SOURCE_DIR}/scripts
DESTINATION
${CMAKE_CURRENT_BINARY_DIR}
)

find_program (BASH_PROGRAM bash)

# Populate the tests
foreach(TEST IN LISTS TESTS)

set(TEST_NAME "vulcanexus.compose.${TEST}")
string(REPLACE "/" "_" TEST_NAME ${TEST_NAME})

message(STATUS "Building test ${TEST_NAME}")

add_test(
NAME ${TEST_NAME}
COMMAND ${BASH_PROGRAM} ${CMAKE_CURRENT_BINARY_DIR}/docker-compose.sh
-t ${TEST_NAME}
-f ${CMAKE_CURRENT_BINARY_DIR}/test_cases/${TEST}/compose.yml)

endforeach()
Loading

0 comments on commit f76a07e

Please sign in to comment.