diff --git a/.gitignore b/.gitignore index 8b2889a..77a99bc 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ work rootfs_overlay_demo/* tests mender_local_config +*.xml +*.html diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5c6a5e1..46863d6 100644 --- a/.gitlab-ci.yml +++ b/.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 diff --git a/mender-convert-extract b/mender-convert-extract index 7713b41..d50f8a4 100755 --- a/mender-convert-extract +++ b/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 diff --git a/mender-convert-modify b/mender-convert-modify index b352e81..48b5250 100755 --- a/mender-convert-modify +++ b/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 diff --git a/mender-convert-package b/mender-convert-package index 9d3489f..14214bf 100755 --- a/mender-convert-package +++ b/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 diff --git a/modules/config.sh b/modules/config.sh index ea653cb..e2dafea 100644 --- a/modules/config.sh +++ b/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}" diff --git a/scripts/README-run-tests.md b/scripts/README-run-tests.md index f6b5219..541080e 100644 --- a/scripts/README-run-tests.md +++ b/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 +``` diff --git a/scripts/run-tests.sh b/scripts/run-tests.sh index 4864e27..452725f 100755 --- a/scripts/run-tests.sh +++ b/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 \