ROS tests move to test/ and new Jenkins

This commit is contained in:
Daniel Agar 2017-12-10 20:19:03 -05:00 committed by Lorenz Meier
parent f46db40b10
commit 63deb40a76
11 changed files with 250 additions and 199 deletions

184
Jenkinsfile vendored
View File

@ -346,6 +346,190 @@ pipeline {
}
}
stage('ROS mission 1') {
agent {
docker {
image 'px4io/px4-dev-ros:2017-12-30'
args '-e CCACHE_DIR=/tmp/ccache -v /tmp/ccache:/tmp/ccache:rw -e HOME=$WORKSPACE'
}
}
steps {
sh 'make clean; rm -rf .ros; rm -rf .gazebo'
sh 'make posix_sitl_default'
sh 'make posix_sitl_default sitl_gazebo'
sh './test/rostest_px4_run.sh mavros_posix_test_mission.test mission:=vtol_new_1.txt vehicle:=vtol_standard'
}
post {
always {
archiveArtifacts '**/*.ulg'
archiveArtifacts '.ros/log/*.log'
archiveArtifacts '.ros/test_results/px4/**.xml'
//sh './Tools/upload_log.py -q --description "${ghprbPullDescription}" --source CI .ros/rootfs/fs/microsd/log/*/*.ulg'
}
}
}
stage('ROS mission 2') {
agent {
docker {
image 'px4io/px4-dev-ros:2017-12-30'
args '-e CCACHE_DIR=/tmp/ccache -v /tmp/ccache:/tmp/ccache:rw -e HOME=$WORKSPACE'
}
}
steps {
sh 'make clean; rm -rf .ros; rm -rf .gazebo'
sh 'make posix_sitl_default'
sh 'make posix_sitl_default sitl_gazebo'
sh './test/rostest_px4_run.sh mavros_posix_test_mission.test mission:=vtol_new_2.txt vehicle:=vtol_standard'
}
post {
always {
archiveArtifacts '**/*.ulg'
archiveArtifacts '.ros/log/*.log'
archiveArtifacts '.ros/test_results/px4/**.xml'
//sh './Tools/upload_log.py -q --description "${ghprbPullDescription}" --source CI .ros/rootfs/fs/microsd/log/*/*.ulg'
}
}
}
stage('ROS mission 3') {
agent {
docker {
image 'px4io/px4-dev-ros:2017-12-30'
args '-e CCACHE_DIR=/tmp/ccache -v /tmp/ccache:/tmp/ccache:rw -e HOME=$WORKSPACE'
}
}
steps {
sh 'make clean; rm -rf .ros; rm -rf .gazebo'
sh 'make posix_sitl_default'
sh 'make posix_sitl_default sitl_gazebo'
sh './test/rostest_px4_run.sh mavros_posix_test_mission.test mission:=vtol_old_1.txt vehicle:=vtol_standard'
}
post {
always {
archiveArtifacts '**/*.ulg'
archiveArtifacts '.ros/log/*.log'
archiveArtifacts '.ros/test_results/px4/**.xml'
//sh './Tools/upload_log.py -q --description "${ghprbPullDescription}" --source CI .ros/rootfs/fs/microsd/log/*/*.ulg'
}
}
}
stage('ROS mission 4') {
agent {
docker {
image 'px4io/px4-dev-ros:2017-12-30'
args '-e CCACHE_DIR=/tmp/ccache -v /tmp/ccache:/tmp/ccache:rw -e HOME=$WORKSPACE'
}
}
steps {
sh 'make clean; rm -rf .ros; rm -rf .gazebo'
sh 'make posix_sitl_default'
sh 'make posix_sitl_default sitl_gazebo'
sh './test/rostest_px4_run.sh mavros_posix_test_mission.test mission:=vtol_old_2.txt vehicle:=vtol_standard'
}
post {
always {
archiveArtifacts '**/*.ulg'
archiveArtifacts '.ros/log/*.log'
archiveArtifacts '.ros/test_results/px4/**.xml'
//sh './Tools/upload_log.py -q --description "${ghprbPullDescription}" --source CI .ros/rootfs/fs/microsd/log/*/*.ulg'
}
}
}
stage('ROS mission 5') {
agent {
docker {
image 'px4io/px4-dev-ros:2017-12-30'
args '-e CCACHE_DIR=/tmp/ccache -v /tmp/ccache:/tmp/ccache:rw -e HOME=$WORKSPACE'
}
}
steps {
sh 'make clean; rm -rf .ros; rm -rf .gazebo'
sh 'make posix_sitl_default'
sh 'make posix_sitl_default sitl_gazebo'
sh './test/rostest_px4_run.sh mavros_posix_test_mission.test mission:=vtol_old_3.txt vehicle:=vtol_standard'
}
post {
always {
archiveArtifacts '**/*.ulg'
archiveArtifacts '.ros/log/*.log'
archiveArtifacts '.ros/test_results/px4/**.xml'
//sh './Tools/upload_log.py -q --description "${ghprbPullDescription}" --source CI .ros/rootfs/fs/microsd/log/*/*.ulg'
}
}
}
stage('ROS mission 6') {
agent {
docker {
image 'px4io/px4-dev-ros:2017-12-30'
args '-e CCACHE_DIR=/tmp/ccache -v /tmp/ccache:/tmp/ccache:rw -e HOME=$WORKSPACE'
}
}
steps {
sh 'make clean; rm -rf .ros; rm -rf .gazebo'
sh 'make posix_sitl_default'
sh 'make posix_sitl_default sitl_gazebo'
sh './test/rostest_px4_run.sh mavros_posix_test_mission.test mission:=multirotor_box.mission vehicle:=iris'
}
post {
always {
archiveArtifacts '**/*.ulg'
archiveArtifacts '.ros/log/*.log'
archiveArtifacts '.ros/test_results/px4/**.xml'
//sh './Tools/upload_log.py -q --description "${ghprbPullDescription}" --source CI .ros/rootfs/fs/microsd/log/*/*.ulg'
}
}
}
stage('ROS offboard att') {
agent {
docker {
image 'px4io/px4-dev-ros:2017-12-30'
args '-e CCACHE_DIR=/tmp/ccache -v /tmp/ccache:/tmp/ccache:rw -e HOME=$WORKSPACE'
}
}
steps {
sh 'make clean; rm -rf .ros; rm -rf .gazebo'
sh 'make posix_sitl_default'
sh 'make posix_sitl_default sitl_gazebo'
sh './test/rostest_px4_run.sh mavros_posix_tests_offboard_attctl.test'
}
post {
always {
archiveArtifacts '**/*.ulg'
archiveArtifacts '.ros/log/*.log'
archiveArtifacts '.ros/test_results/px4/**.xml'
//sh './Tools/upload_log.py -q --description "${ghprbPullDescription}" --source CI .ros/rootfs/fs/microsd/log/*/*.ulg'
}
}
}
stage('ROS offboard pos') {
agent {
docker {
image 'px4io/px4-dev-ros:2017-12-30'
args '-e CCACHE_DIR=/tmp/ccache -v /tmp/ccache:/tmp/ccache:rw -e HOME=$WORKSPACE'
}
}
steps {
sh 'make clean; rm -rf .ros; rm -rf .gazebo'
sh 'make posix_sitl_default'
sh 'make posix_sitl_default sitl_gazebo'
sh './test/rostest_px4_run.sh mavros_posix_tests_offboard_posctl.test'
}
post {
always {
archiveArtifacts '**/*.ulg'
archiveArtifacts '.ros/log/*.log'
archiveArtifacts '.ros/test_results/px4/**.xml'
//sh './Tools/upload_log.py -q --description "${ghprbPullDescription}" --source CI .ros/rootfs/fs/microsd/log/*/*.ulg'
}
}
}
// temporarily disabled until stable
//stage('tests coverage') {
// agent {

View File

@ -279,7 +279,7 @@ format:
# Testing
# --------------------------------------------------------------------
.PHONY: tests tests_coverage
.PHONY: tests tests_coverage tests_mission tests_offboard rostest
tests:
@$(MAKE) --no-print-directory posix_sitl_default test_results \
@ -290,6 +290,18 @@ tests_coverage:
@$(MAKE) --no-print-directory posix_sitl_default test_coverage_genhtml PX4_CMAKE_BUILD_TYPE=Coverage
@echo "Open $(SRC_DIR)/build/posix_sitl_default/coverage-html/index.html to see coverage"
rostest: posix_sitl_default
@$(MAKE) --no-print-directory posix_sitl_default sitl_gazebo
tests_mission: rostest
@test/rostest_px4_run.sh mavros_posix_tests_missions.test
tests_offboard: rostest
@$(SRC_DIR)/test/rostest_px4_run.sh mavros_posix_tests_offboard_attctl.test
@$(SRC_DIR)/test/rostest_px4_run.sh mavros_posix_tests_offboard_posctl.test
# static analyzers (scan-build, clang-tidy, cppcheck)
# --------------------------------------------------------------------
.PHONY: scan-build posix_sitl_default-clang clang-tidy clang-tidy-fix clang-tidy-quiet cppcheck check_stack

View File

@ -1,31 +0,0 @@
#!/bin/bash
#
# Run container and start test execution
#
# License: according to LICENSE.md in the root directory of the PX4 Firmware repository
set -e
if [ -z "$WORKSPACE" ]; then
echo "\$WORKSPACE not set"
exit 1
fi
IMAGE=px4io/px4-dev-ros:v1.0
# Pulling latest image
echo "===> pull latest Docker image"
docker pull $IMAGE
# removing some images might fail
set +e
docker rmi $(docker images --filter "dangling=true" -q --no-trunc)
set -e
echo "<==="
#
# Running SITL testing container
# Assuming that necessary source projects, including this one, are cloned in the build server workspace of this job.
#
echo "===> run container"
docker run --rm -v "$WORKSPACE:/job:rw" $IMAGE bash "/job/Firmware/integrationtests/run_tests.bash" /job/Firmware
echo "<==="

View File

@ -1,140 +0,0 @@
#!/bin/bash
#
# Starts tests from within the container
#
# License: according to LICENSE.md in the root directory of the PX4 Firmware repository
set -e
# TODO move to docker image
pip install --upgrade numpy -q
pip install px4tools pymavlink toml -q
# A POSIX variable
OPTIND=1 # Reset in case getopts has been used previously in the shell.
# Initialize our own variables:
do_clean=true
gui=false
while getopts "h?og" opt; do
case "$opt" in
h|\?)
echo """
$0 [-h] [-o] [-g]
-h show help
-o don't clean before building (to save time)
-g run gazebo gui
"""
exit 0
;;
o) do_clean=false
echo "not cleaning"
;;
g) gui=true
;;
esac
done
# determine the directory of the source given the directory of this script
pushd `dirname $0` > /dev/null
SCRIPTPATH=`pwd`
popd > /dev/null
ORIG_SRC=$(dirname $SCRIPTPATH)
# set paths
JOB_DIR=$(dirname $ORIG_SRC)
CATKIN_DIR=$JOB_DIR/catkin
BUILD_DIR=$CATKIN_DIR/build/px4
SRC_DIR=${CATKIN_DIR}/src/px4
echo setting up ROS paths
if [ -f /opt/ros/indigo/setup.bash ]
then
source /opt/ros/indigo/setup.bash
elif [ -f /opt/ros/kinetic/setup.bash ]
then
source /opt/ros/kinetic/setup.bash
else
echo "could not find /opt/ros/{ros-distro}/setup.bash"
exit 1
fi
export ROS_HOME=$JOB_DIR/.ros
export ROS_LOG_DIR=$ROS_HOME/log
export ROS_TEST_RESULT_DIR=$ROS_HOME/test_results/px4
export PX4_LOG_DIR=$ROS_HOME/rootfs/fs/microsd/log
TEST_RESULT_TARGET_DIR=$JOB_DIR/test_results
# TODO
# BAGS=$ROS_HOME
# CHARTS=$ROS_HOME/charts
# EXPORT_CHARTS=/sitl/testing/export_charts.py
if $do_clean
then
echo cleaning
rm -rf $CATKIN_DIR
rm -rf $ROS_HOME
rm -rf $TEST_RESULT_TARGET_DIR
else
echo skipping clean step
fi
echo "=====> compile ($SRC_DIR)"
mkdir -p $ROS_HOME
mkdir -p $CATKIN_DIR/src
mkdir -p $TEST_RESULT_TARGET_DIR
if ! [ -d $SRC_DIR ]
then
ln -s $ORIG_SRC $SRC_DIR
ln -s $ORIG_SRC/Tools/sitl_gazebo ${CATKIN_DIR}/src/mavlink_sitl_gazebo
fi
cd $CATKIN_DIR
catkin_make
. ./devel/setup.bash
echo "<====="
# print paths to user
echo -e "JOB_DIR\t\t: $JOB_DIR"
echo -e "ROS_HOME\t: $ROS_HOME"
echo -e "CATKIN_DIR\t: $CATKIN_DIR"
echo -e "BUILD_DIR\t: $BUILD_DIR"
echo -e "SRC_DIR\t\t: $SRC_DIR"
echo -e "ROS_TEST_RESULT_DIR\t: $ROS_TEST_RESULT_DIR"
echo -e "ROS_LOG_DIR\t\t: $ROS_LOG_DIR"
echo -e "PX4_LOG_DIR\t\t: $PX4_LOG_DIR"
echo -e "TEST_RESULT_TARGET_DIR\t: $TEST_RESULT_TARGET_DIR"
# don't exit on error anymore (because single tests or exports might fail)
# however, stop executing tests after the first failure
set +e
echo "=====> run tests"
test $? -eq 0 && rostest px4 mavros_posix_tests_iris.launch gui:=$gui
# commented out optical flow test for now since ci server has
# an issue producing the simulated flow camera currently
#test $? -eq 0 && rostest px4 mavros_posix_tests_iris_opt_flow.launch gui:=$gui
test $? -eq 0 && rostest px4 mavros_posix_tests_standard_vtol.launch gui:=$gui
TEST_RESULT=$?
echo "<====="
# TODO
echo "=====> process test results"
# cd $BAGS
# for bag in `ls *.bag`
# do
# echo "processing bag: $bag"
# python $EXPORT_CHARTS $CHARTS $bag
# done
echo "copy build test results to job directory"
cp -r $ROS_TEST_RESULT_DIR/* ${TEST_RESULT_TARGET_DIR}
cp -r $ROS_LOG_DIR/* ${TEST_RESULT_TARGET_DIR}
cp -r $PX4_LOG_DIR/* ${TEST_RESULT_TARGET_DIR}
# cp $BAGS/*.bag ${TEST_RESULT_TARGET_DIR}/
# cp -r $CHARTS ${TEST_RESULT_TARGET_DIR}/
echo "<====="
# need to return error if tests failed, else Jenkins won't notice the failure
exit $TEST_RESULT

View File

@ -1,19 +0,0 @@
#!/bin/bash
#
# Upload SITL CI logs to Flight Review
#
# License: according to LICENSE.md in the root directory of the PX4 Firmware repository
if [ -z "$WORKSPACE" ] || [ -z "${ghprbActualCommitAuthorEmail}" ] || [ -z "${ghprbPullDescription}" ]; then
echo "Environment not set. Needs to be called from within Jenkins."
exit 1
fi
echo "Uploading test logs to Flight Review"
CMD="$WORKSPACE/Firmware/Tools/upload_log.py"
find "$WORKSPACE/test_results" -name \*.ulg -exec "$CMD" -q \
--description "${ghprbPullDescription}" --source CI "{}" \;
# XXX: move up if we want email notifications
# --email "${ghprbActualCommitAuthorEmail}" \

View File

@ -0,0 +1,21 @@
<launch>
<!-- Posix SITL MAVROS integration tests -->
<arg name="ns" default="/"/>
<arg name="headless" default="true"/>
<arg name="gui" default="false"/>
<arg name="est" default="ekf2"/>
<arg name="mission"/>
<include file="$(find px4)/launch/mavros_posix_sitl.launch">
<arg name="ns" value="$(arg ns)"/>
<arg name="headless" value="$(arg headless)"/>
<arg name="gui" value="$(arg gui)"/>
<arg name="vehicle" value="standard_vtol"/>
<arg name="est" value="$(arg est)"/>
</include>
<group ns="$(arg ns)">
<test test-name="mission_test" pkg="px4" type="mission_test.py" time-limit="300.0" args="$(arg mission)" />
</group>
</launch>

View File

@ -19,5 +19,3 @@
<test test-name="mavros_flow_offboard_attctl_test" pkg="px4" type="mavros_offboard_attctl_test.py" />
</group>
</launch>
<!-- vim: set ft=xml et fenc=utf-8 ff=unix sts=0 sw=4 ts=4 : -->

View File

@ -15,6 +15,7 @@
</include>
<group ns="$(arg ns)">
<test test-name="multicopter_box" pkg="px4" type="mission_test.py" vehicle="iris" time-limit="120.0" args="multirotor_box.mission"/>
<test test-name="mission_test_new_1" pkg="px4" type="mission_test.py" time-limit="300.0" args="vtol_new_1.txt" />
<test test-name="mission_test_new_2" pkg="px4" type="mission_test.py" time-limit="300.0" args="vtol_new_2.txt" />
<test test-name="mission_test_old_1" pkg="px4" type="mission_test.py" time-limit="300.0" args="vtol_old_1.txt" />
@ -22,5 +23,3 @@
<test test-name="mission_test_old_3" pkg="px4" type="mission_test.py" time-limit="300.0" args="vtol_old_3.txt" />
</group>
</launch>
<!-- vim: set et ft=xml fenc=utf-8 ff=unix sts=0 sw=4 ts=4 : -->

View File

@ -15,10 +15,6 @@
</include>
<group ns="$(arg ns)">
<test test-name="box" pkg="px4" type="mission_test.py" time-limit="120.0" args="multirotor_box.mission"/>
<test test-name="mavros_offboard_posctl_test" pkg="px4" type="mavros_offboard_posctl_test.py" time-limit="120.0"/>
<test test-name="mavros_offboard_attctl_test" pkg="px4" type="mavros_offboard_attctl_test.py" time-limit="120.0"/>
</group>
</launch>
<!-- vim: set et ft=xml fenc=utf-8 ff=unix sts=0 sw=4 ts=4 : -->

View File

@ -0,0 +1,20 @@
<launch>
<!-- Posix SITL MAVROS integration tests -->
<arg name="ns" default="/"/>
<arg name="headless" default="true"/>
<arg name="gui" default="false"/>
<arg name="est" default="lpe"/>
<include file="$(find px4)/launch/mavros_posix_sitl.launch">
<arg name="ns" value="$(arg ns)"/>
<arg name="headless" value="$(arg headless)"/>
<arg name="gui" value="$(arg gui)"/>
<arg name="vehicle" value="iris"/>
<arg name="est" value="$(arg est)"/>
</include>
<group ns="$(arg ns)">
<test test-name="mavros_offboard_posctl_test" pkg="px4" type="mavros_offboard_posctl_test.py" time-limit="120.0"/>
</group>
</launch>

11
test/rostest_px4_run.sh Executable file
View File

@ -0,0 +1,11 @@
#! /bin/bash
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
PX4_SRC_DIR=${DIR}/..
source /opt/ros/kinetic/setup.bash
source ${PX4_SRC_DIR}/Tools/setup_gazebo.bash ${PX4_SRC_DIR} ${PX4_SRC_DIR}/build/posix_sitl_default
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:${PX4_SRC_DIR}:${PX4_SRC_DIR}/Tools/sitl_gazebo
rostest px4 "$@"