Browse Source

Merge pull request #120 from mirzak/update-test-to-cover-multi-config

scripts: run-tests: ensure that multi-config code path is executed
2.0.x
Mirza Krak 5 years ago
committed by GitHub
parent
commit
8d8c11bfc0
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .gitignore
  2. 2
      .gitlab-ci.yml
  3. 3
      mender-convert-extract
  4. 3
      mender-convert-modify
  5. 3
      mender-convert-package
  6. 1
      modules/config.sh
  7. 17
      scripts/README-run-tests.md
  8. 33
      scripts/run-tests.sh

2
.gitignore

@ -4,3 +4,5 @@ work
rootfs_overlay_demo/*
tests
mender_local_config
*.xml
*.html

2
.gitlab-ci.yml

@ -55,7 +55,7 @@ test_acceptance:
- docker version
# Install dependencies
- apk --update --no-cache add bash wget git util-linux mtools python
py-pip gcc python2-dev libffi-dev libc-dev openssl-dev make
py-pip gcc python2-dev libffi-dev libc-dev openssl-dev make sudo
- pip install "pytest>=3.0" "Fabric>=1.13.0, <2" pytest-html
# Load image under test
- export IMAGE_NAME=$DOCKER_REPOSITORY:pr

3
mender-convert-extract

@ -19,7 +19,8 @@ echo "Running $(basename $0): $@"
source modules/bootstrap.sh
source modules/disk.sh
declare -a configs
# The mender_convert_config is always used and provides all the defaults
declare -a configs=("configs/mender_convert_config")
disk_image=""
while (( "$#" )); do

3
mender-convert-modify

@ -39,7 +39,8 @@ source modules/bootstrap.sh
source modules/disk.sh
source modules/probe.sh
declare -a configs
# The mender_convert_config is always used and provides all the defaults
declare -a configs=("configs/mender_convert_config")
while (( "$#" )); do
case "$1" in

3
mender-convert-package

@ -38,7 +38,8 @@ echo "Running $(basename $0): $@"
source modules/bootstrap.sh
source modules/disk.sh
declare -a configs
# The mender_convert_config is always used and provides all the defaults
declare -a configs=("configs/mender_convert_config")
while (( "$#" )); do
case "$1" in

1
modules/config.sh

@ -16,7 +16,6 @@
# Read in the array of config files to process
read -a configs <<< "${@}"
configs=( "configs/mender_convert_config" "${configs[@]}" )
for config in "${configs[@]}"; do
log_info "Using configuration file: ${config}"
source "${config}"

17
scripts/README-run-tests.md

@ -1,13 +1,16 @@
# Run tests
Run the following commands to install test dependencies (assumes that all mender-convert dependencies are already installed):
The tests utilize the provided Docker container in this repository and conversion
is done using the `docker-mender-convert` command. For this reason we first need
to build the container (commands must be run from the root directory of
`mender-convert`):
sudo apt-get update e2fsprogs=1.44.1-1
sudo apt-get -qy --force-yes install python-pip
sudo pip2 install pytest --upgrade
sudo pip2 install pytest-xdist --upgrade
sudo pip2 install pytest-html --upgrade
```bash
./docker-build
```
Run tests:
./scripts/run-tests.sh
```bash
./scripts/run-tests.sh
```

33
scripts/run-tests.sh

@ -60,25 +60,40 @@ convert_and_test() {
rm -f ${WORKSPACE}/test_config
# Two motives for the following statement
#
# - speed up tests by avoiding decompression on all images (majority of images
# we test have a platform specific configuration)
#
# - test providing multiple '--config' options
#
# - (when no platform configuration is provided) test conversion without
# '--config' and with MENDER_COMPRESS_DISK_IMAGE=y. Compressed disk
# images is the default user facing option and we need to ensure that we
# cover this in the tests.
if [ -n "${config}" ]; then
cp ${config} ${WORKSPACE}/test_config
echo "Will disable MENDER_COMPRESS_DISK_IMAGE for this image"
echo "MENDER_COMPRESS_DISK_IMAGE=n" > ${WORKSPACE}/test_config
local MENDER_CONVERT_EXTRA_ARGS="--config ${config} --config ${WORKSPACE}/test_config"
fi
# Disable compression of disk image when testing, otherwise we need to
# unpack each image we test which is time consuming
echo "MENDER_COMPRESS_DISK_IMAGE=n" >> ${WORKSPACE}/test_config
echo "Configuration used:"
cat ${WORKSPACE}/test_config
MENDER_ARTIFACT_NAME=${artifact_name} ./docker-mender-convert \
--disk-image input/${image_name} \
--config ${WORKSPACE}/test_config
${MENDER_CONVERT_EXTRA_ARGS}
if pip list | grep -q -e pytest-html; then
html_report_args="--html=${MENDER_CONVERT_DIR}/report_${device_type}.html --self-contained-html"
fi
# Need to decompress images built with MENDER_COMPRESS_DISK_IMAGE=y before
# running tests.
if [ -f deploy/${device_type}-${artifact_name}.sdimg.gz ]; then
# sudo is needed because the image is created using docker-mender-convert
# which sets root permissions on the image
sudo gunzip --force deploy/${device_type}-${artifact_name}.sdimg.gz
fi
cd ${WORKSPACE}/mender-image-tests
python2 -m pytest --verbose \

Loading…
Cancel
Save