Browse Source

MEN-2785: Add acceptance tests to GitLab pipeline

Created a new test_acceptance stage that will execute in our private
runners. This stage will execute scripts/run-tests.sh and collect the
now produced xml/html reports for each device type.

Removed the build from the test script, so that we make sure that CI
tests the exact same image build in "build" stage.

Changelog: None

Signed-off-by: Lluis Campos <lluis.campos@northern.tech>
2.0.x
Lluis Campos 5 years ago
parent
commit
5c97d08a0e
  1. 29
      .gitlab-ci.yml
  2. 9
      scripts/run-tests.sh

29
.gitlab-ci.yml

@ -6,6 +6,7 @@ variables:
stages: stages:
- test - test
- build - build
- test_acceptance
test: test:
stage: test stage: test
@ -39,3 +40,31 @@ build:
paths: paths:
- image.tar - image.tar
test_acceptance:
stage: test_acceptance
image: docker:18-dind
tags:
- mender-qa-slave
dependencies:
- build
before_script:
# Start up Docker (DonD)
- /usr/local/bin/dockerd-entrypoint.sh &
- sleep 10
- export DOCKER_HOST="unix:///var/run/docker.sock"
- 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
- pip install "pytest>=3.0" "Fabric>=1.13.0, <2" pytest-html
# Load image under test
- export IMAGE_NAME=$DOCKER_REPOSITORY:pr
- docker load -i image.tar
script:
- ./scripts/run-tests.sh
artifacts:
expire_in: 2w
when: always
paths:
- results_*.xml
- report_*.html

9
scripts/run-tests.sh

@ -75,10 +75,15 @@ convert_and_test() {
--disk-image input/${image_name} \ --disk-image input/${image_name} \
--config ${WORKSPACE}/test_config --config ${WORKSPACE}/test_config
if pip list | grep -q -e pytest-html; then
html_report_args="--html=${MENDER_CONVERT_DIR}/report_${device_type}.html --self-contained-html"
fi
cd ${WORKSPACE}/mender-image-tests cd ${WORKSPACE}/mender-image-tests
python2 -m pytest --verbose \ python2 -m pytest --verbose \
--junit-xml="${WORKSPACE}/results.xml" \ --junit-xml="${MENDER_CONVERT_DIR}/results_${device_type}.xml" \
${html_report_args} \
--test-conversion \ --test-conversion \
--test-variables="${MENDER_CONVERT_DIR}/deploy/${device_type}-${artifact_name}.cfg" \ --test-variables="${MENDER_CONVERT_DIR}/deploy/${device_type}-${artifact_name}.cfg" \
--board-type="${device_type}" \ --board-type="${device_type}" \
@ -107,8 +112,6 @@ mkdir -p ${WORKSPACE}
get_pytest_files get_pytest_files
./docker-build
convert_and_test "qemux86_64" \ convert_and_test "qemux86_64" \
"release-1" \ "release-1" \
"${UBUNTU_IMAGE_URL}" \ "${UBUNTU_IMAGE_URL}" \

Loading…
Cancel
Save