diff --git a/Jenkinsfile b/Jenkinsfile index d25eb15014..43e2a2a25a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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 { diff --git a/Makefile b/Makefile index 790d73f5f0..1ae9ec2ce4 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/integrationtests/run_container.bash b/integrationtests/run_container.bash deleted file mode 100755 index b8a969af95..0000000000 --- a/integrationtests/run_container.bash +++ /dev/null @@ -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 "<===" diff --git a/integrationtests/run_tests.bash b/integrationtests/run_tests.bash deleted file mode 100755 index 5e26acd7f0..0000000000 --- a/integrationtests/run_tests.bash +++ /dev/null @@ -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 diff --git a/integrationtests/upload_test_logs.bash b/integrationtests/upload_test_logs.bash deleted file mode 100755 index ad76461ede..0000000000 --- a/integrationtests/upload_test_logs.bash +++ /dev/null @@ -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}" \ diff --git a/test/mavros_posix_test_mission.test b/test/mavros_posix_test_mission.test new file mode 100644 index 0000000000..cc11c52759 --- /dev/null +++ b/test/mavros_posix_test_mission.test @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/launch/mavros_posix_tests_iris_opt_flow.launch b/test/mavros_posix_tests_iris_opt_flow.test similarity index 92% rename from launch/mavros_posix_tests_iris_opt_flow.launch rename to test/mavros_posix_tests_iris_opt_flow.test index 68ecf90ebe..305d64d4a0 100644 --- a/launch/mavros_posix_tests_iris_opt_flow.launch +++ b/test/mavros_posix_tests_iris_opt_flow.test @@ -19,5 +19,3 @@ - - diff --git a/launch/mavros_posix_tests_standard_vtol.launch b/test/mavros_posix_tests_missions.test similarity index 89% rename from launch/mavros_posix_tests_standard_vtol.launch rename to test/mavros_posix_tests_missions.test index 4ce051cb40..3fdc207319 100644 --- a/launch/mavros_posix_tests_standard_vtol.launch +++ b/test/mavros_posix_tests_missions.test @@ -15,6 +15,7 @@ + @@ -22,5 +23,3 @@ - - diff --git a/launch/mavros_posix_tests_iris.launch b/test/mavros_posix_tests_offboard_attctl.test similarity index 69% rename from launch/mavros_posix_tests_iris.launch rename to test/mavros_posix_tests_offboard_attctl.test index 7fae242b7e..49aa92d918 100644 --- a/launch/mavros_posix_tests_iris.launch +++ b/test/mavros_posix_tests_offboard_attctl.test @@ -15,10 +15,6 @@ - - - - diff --git a/test/mavros_posix_tests_offboard_posctl.test b/test/mavros_posix_tests_offboard_posctl.test new file mode 100644 index 0000000000..87d2ccfe60 --- /dev/null +++ b/test/mavros_posix_tests_offboard_posctl.test @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/test/rostest_px4_run.sh b/test/rostest_px4_run.sh new file mode 100755 index 0000000000..6af134a164 --- /dev/null +++ b/test/rostest_px4_run.sh @@ -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 "$@"