Browse Source

Split run-tests.sh to export common shell functions in a utility script

changelog: none

Modified-by: Kristian Amlie <kristian.amlie@northern.tech>

Signed-off-by: Alf-Rune Siqveland <alf.rune@northern.tech>
Signed-off-by: Kristian Amlie <kristian.amlie@northern.tech>
2.0.x
Alf-Rune Siqveland 5 years ago
committed by Kristian Amlie
parent
commit
f52fdfa8cf
No known key found for this signature in database GPG Key ID: F464407C996AF03F
  1. 8
      .gitlab-ci.yml
  2. 83
      scripts/test/run-tests.sh
  3. 94
      scripts/test/test-utils.sh

8
.gitlab-ci.yml

@ -55,7 +55,7 @@ test_acceptance:
- export IMAGE_NAME=$DOCKER_REPOSITORY:pr
- docker load -i image.tar
script:
- ./scripts/run-tests.sh
- ./scripts/test/run-tests.sh
artifacts:
expire_in: 2w
when: always
@ -90,7 +90,11 @@ convert_raspbian:
-c configs/raspberrypi3_config
-c configs/images/raspberrypi3_raspbian_config
-c mender_client_version_config
- mv deploy/*-mender-raspbian.sdimg.xz deploy/${RASPBIAN_NAME}-mender-${MENDER_CLIENT_VERSION}.img.xz
- cp deploy/raspberrypi-mender-raspbian.sdimg.xz deploy/${RASPBIAN_NAME}-mender-${MENDER_CLIENT_VERSION}.img.xz
- unxz deploy/raspberrypi-mender-raspbian.sdimg.xz
# Verify converted image
- . ./scripts/test/test-utils.sh
- run_tests raspbian mender-raspbian "-k TestMenderInstalled"
after_script:
- mkdir -p output

83
scripts/test/run-tests.sh

@ -0,0 +1,83 @@
#!/bin/bash
set -e
root_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )/../../" && pwd )
if [ "${root_dir}" != "${PWD}" ]; then
echo "You must execute $(basename $0) from the root directory: ${root_dir}"
exit 1
fi
WORKSPACE=./tests
BBB_DEBIAN_IMAGE="bone-debian-9.5-iot-armhf-2018-10-07-4gb.img"
BBB_DEBIAN_IMAGE_URL="http://debian.beagleboard.org/images/${BBB_DEBIAN_IMAGE}.xz"
RASPBIAN_IMAGE="2019-04-08-raspbian-stretch-lite"
RASPBIAN_IMAGE_URL="https://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2019-04-09/${RASPBIAN_IMAGE}.zip"
TINKER_IMAGE="20170417-tinker-board-linaro-stretch-alip-v1.8"
TINKER_IMAGE_URL="http://dlcdnet.asus.com/pub/ASUS/mb/Linux/Tinker_Board_2GB/${TINKER_IMAGE}.zip"
UBUNTU_IMAGE="Ubuntu-Bionic-x86-64.img"
UBUNTU_IMAGE_URL="https://d1b0l86ne08fsf.cloudfront.net/mender-convert/images/${UBUNTU_IMAGE}.gz"
UBUNTU_SERVER_RPI_IMAGE="ubuntu-18.04.3-preinstalled-server-armhf+raspi3.img"
UBUNTU_SERVER_RPI_IMAGE_URL="http://cdimage.ubuntu.com/ubuntu/releases/bionic/release/${UBUNTU_SERVER_RPI_IMAGE}.xz"
# Keep common function declarations in separate utils script
UTILS_PATH=${0/$(basename $0)/test-utils.sh}
source $UTILS_PATH
# Some distros do not have /sbin in path for "normal users"
export PATH="${PATH}:/sbin"
if [ ! -d ${WORKSPACE}/mender-image-tests ]; then
git clone https://github.com/mendersoftware/mender-image-tests ${WORKSPACE}/mender-image-tests
else
cd ${WORKSPACE}/mender-image-tests
git pull
cd -
fi
mkdir -p ${WORKSPACE}
get_pytest_files
test_result=0
convert_and_test "qemux86_64" \
"release-1" \
"${UBUNTU_IMAGE_URL}" \
"${UBUNTU_IMAGE}" \
"${UBUNTU_IMAGE}.gz" \
"configs/qemux86-64_config" || test_result=$?
convert_and_test "raspberrypi" \
"release-1" \
"${RASPBIAN_IMAGE_URL}" \
"${RASPBIAN_IMAGE}.img" \
"${RASPBIAN_IMAGE}.zip" \
"configs/raspberrypi3_config" || test_result=$?
# MEN-2809: Disabled due broken download link
#convert_and_test "linaro-alip" \
# "release-1" \
# "${TINKER_IMAGE_URL}" \
# "${TINKER_IMAGE}.img" \
# "${TINKER_IMAGE}.zip" || test_result=$?
convert_and_test "beaglebone" \
"release-1" \
"${BBB_DEBIAN_IMAGE_URL}" \
"${BBB_DEBIAN_IMAGE}" \
"${BBB_DEBIAN_IMAGE}.xz" || test_result=$?
convert_and_test "ubuntu" \
"release-1" \
"${UBUNTU_SERVER_RPI_IMAGE_URL}" \
"${UBUNTU_SERVER_RPI_IMAGE}" \
"${UBUNTU_SERVER_RPI_IMAGE}.xz" \
"configs/raspberrypi3_config" || test_result=$?
exit $test_result

94
scripts/run-tests.sh → scripts/test/test-utils.sh

@ -1,38 +1,10 @@
#!/bin/bash
set -e
root_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd )
if [ "${root_dir}" != "${PWD}" ]; then
echo "You must execute $(basename $0) from the root directory: ${root_dir}"
exit 1
fi
MENDER_ACCEPTANCE_URL="https://raw.githubusercontent.com/mendersoftware/meta-mender/master/tests/acceptance"
WORKSPACE=./tests
WORKSPACE=${WORKSPACE:-./tests}
# Relative to where scripts are executed (${WORKSPACE}/mender-image-tests)
MENDER_CONVERT_DIR=../../
BBB_DEBIAN_IMAGE="bone-debian-9.5-iot-armhf-2018-10-07-4gb.img"
BBB_DEBIAN_IMAGE_URL="http://debian.beagleboard.org/images/${BBB_DEBIAN_IMAGE}.xz"
RASPBIAN_IMAGE="2019-04-08-raspbian-stretch-lite"
RASPBIAN_IMAGE_URL="https://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2019-04-09/${RASPBIAN_IMAGE}.zip"
TINKER_IMAGE="20170417-tinker-board-linaro-stretch-alip-v1.8"
TINKER_IMAGE_URL="http://dlcdnet.asus.com/pub/ASUS/mb/Linux/Tinker_Board_2GB/${TINKER_IMAGE}.zip"
UBUNTU_IMAGE="Ubuntu-Bionic-x86-64.img"
UBUNTU_IMAGE_URL="https://d1b0l86ne08fsf.cloudfront.net/mender-convert/images/${UBUNTU_IMAGE}.gz"
UBUNTU_SERVER_RPI_IMAGE="ubuntu-18.04.3-preinstalled-server-armhf+raspi3.img"
UBUNTU_SERVER_RPI_IMAGE_URL="http://cdimage.ubuntu.com/ubuntu/releases/bionic/release/${UBUNTU_SERVER_RPI_IMAGE}.xz"
MENDER_ACCEPTANCE_URL="https://raw.githubusercontent.com/mendersoftware/meta-mender/master/tests/acceptance"
# Some distros do not have /sbin in path for "normal users"
export PATH="${PATH}:/sbin"
convert_and_test() {
device_type=$1
artifact_name=$2
@ -85,6 +57,16 @@ convert_and_test() {
--disk-image input/${image_name} \
${MENDER_CONVERT_EXTRA_ARGS}
run_tests "${device_type}" "${artifact_name}"
return $?
}
run_tests() {
device_type=$1
artifact_name=$2
shift 2
pytest_args_extra=$@
if pip3 list | grep -q -e pytest-html; then
html_report_args="--html=${MENDER_CONVERT_DIR}/report_${device_type}.html --self-contained-html"
fi
@ -111,7 +93,8 @@ convert_and_test() {
--board-type="${device_type}" \
--mender-image=${device_type}-${artifact_name}.sdimg \
--sdimg-location="${MENDER_CONVERT_DIR}/deploy" \
tests_${device_type}
tests_${device_type} \
${pytest_args_extra}
exitcode=$?
cd -
@ -126,52 +109,3 @@ get_pytest_files() {
wget -N ${MENDER_ACCEPTANCE_URL}/fixtures.py -P $WORKSPACE/mender-image-tests
}
if [ ! -d ${WORKSPACE}/mender-image-tests ]; then
git clone https://github.com/mendersoftware/mender-image-tests ${WORKSPACE}/mender-image-tests
else
cd ${WORKSPACE}/mender-image-tests
git pull
cd -
fi
mkdir -p ${WORKSPACE}
get_pytest_files
test_result=0
convert_and_test "qemux86_64" \
"release-1" \
"${UBUNTU_IMAGE_URL}" \
"${UBUNTU_IMAGE}" \
"${UBUNTU_IMAGE}.gz" \
"configs/qemux86-64_config" || test_result=$?
convert_and_test "raspberrypi" \
"release-1" \
"${RASPBIAN_IMAGE_URL}" \
"${RASPBIAN_IMAGE}.img" \
"${RASPBIAN_IMAGE}.zip" \
"configs/raspberrypi3_config" || test_result=$?
# MEN-2809: Disabled due broken download link
#convert_and_test "linaro-alip" \
# "release-1" \
# "${TINKER_IMAGE_URL}" \
# "${TINKER_IMAGE}.img" \
# "${TINKER_IMAGE}.zip" || test_result=$?
convert_and_test "beaglebone" \
"release-1" \
"${BBB_DEBIAN_IMAGE_URL}" \
"${BBB_DEBIAN_IMAGE}" \
"${BBB_DEBIAN_IMAGE}.xz" || test_result=$?
convert_and_test "ubuntu" \
"release-1" \
"${UBUNTU_SERVER_RPI_IMAGE_URL}" \
"${UBUNTU_SERVER_RPI_IMAGE}" \
"${UBUNTU_SERVER_RPI_IMAGE}.xz" \
"configs/raspberrypi3_config" || test_result=$?
exit $test_result
Loading…
Cancel
Save