From 3a416fbf32699a3e6720a2365b45b6c7088c3e46 Mon Sep 17 00:00:00 2001 From: Thilo Fromm Date: Thu, 17 Feb 2022 10:48:49 +0100 Subject: [PATCH] ci-automation testing: address PR review comments - add cleanup script to test.sh - remove wrapper function from qemu test Signed-off-by: Thilo Fromm --- ci-automation/ci_automation_common.sh | 8 +++-- ci-automation/tapfile_helper_lib.sh | 5 +-- ci-automation/test.sh | 17 ++++++---- ci-automation/vendor-testing/qemu.sh | 46 +++++++++++++-------------- 4 files changed, 43 insertions(+), 33 deletions(-) mode change 100644 => 100755 ci-automation/vendor-testing/qemu.sh diff --git a/ci-automation/ci_automation_common.sh b/ci-automation/ci_automation_common.sh index 9818f147f1..871f8cfbfe 100644 --- a/ci-automation/ci_automation_common.sh +++ b/ci-automation/ci_automation_common.sh @@ -10,8 +10,12 @@ source ci-automation/ci-config.env : ${PIGZ:=pigz} # set up author and email so git does not complain when tagging -git -C . config user.name "${CI_GIT_AUTHOR}" -git -C . config user.email "${CI_GIT_EMAIL}" +if ! git config --get user.name ; then + git -C . config user.name "${CI_GIT_AUTHOR}" +fi +if ! git config --get user.email ; then + git -C . config user.email "${CI_GIT_EMAIL}" +fi function init_submodules() { git submodule init diff --git a/ci-automation/tapfile_helper_lib.sh b/ci-automation/tapfile_helper_lib.sh index 7503550cca..bf121937bf 100644 --- a/ci-automation/tapfile_helper_lib.sh +++ b/ci-automation/tapfile_helper_lib.sh @@ -24,8 +24,9 @@ function __sqlite3_wrapper() { while true; do sqlite3 "${dbfile}" "$@" - if [ $? -ne 5 ] ; then - return $? + local ret="$?" + if [ "$ret" -ne 5 ] ; then + return $ret fi local sleep="$((1 + $RANDOM % 5))" echo "Retrying in ${sleep} seconds." >&2 diff --git a/ci-automation/test.sh b/ci-automation/test.sh index 84e06860ba..9fbc760fc8 100644 --- a/ci-automation/test.sh +++ b/ci-automation/test.sh @@ -51,13 +51,15 @@ set -euo pipefail function test_run() { local arch="$1" ; shift - local image="$2"; shift + local image="$1"; shift # default to all tests if [ $# -le 0 ] ; then - set -- * + set -- '*' fi + local retries="${MAX_RETRIES:-999}" + source ci-automation/tapfile_helper_lib.sh source ci-automation/ci_automation_common.sh init_submodules @@ -65,7 +67,7 @@ function test_run() { source sdk_container/.repo/manifests/version.txt local vernum="${FLATCAR_VERSION}" local docker_vernum - docker_vernum="$(vernum_to_docker_image_version "${vernum}")" + docker_vernum="$(vernum_to_docker_image_version "${vernum}")" local packages="flatcar-packages-${arch}" local packages_image="${packages}:${docker_vernum}" @@ -74,6 +76,7 @@ function test_run() { local tests_dir="__TESTS__/${image}" mkdir -p "${tests_dir}" + echo "sudo rm -rf '${tests_dir}'" >> ci-cleanup.sh local container_name="flatcar-tests-${arch}-${docker_vernum}-${image}" @@ -84,8 +87,9 @@ function test_run() { local failfile="failed-run-${retry}." set -o noglob - ./run_sdk_container -n "${container_name}" -C "${packages_image}" -v "${vernum}" \ - ci-automation/vendor/testing/"${image}".sh \ + ./run_sdk_container -x ./ci-cleanup.sh \ + -n "${container_name}" -C "${packages_image}" -v "${vernum}" \ + ci-automation/vendor-testing/"${image}".sh \ "${tests_dir}" \ "${arch}" \ "${vernum}" \ @@ -93,7 +97,8 @@ function test_run() { $@ set +o noglob - ./run_sdk_container -n "${container_name}" -C "${packages_image}" -v "${vernum}" \ + ./run_sdk_container -x ./ci-cleanup.sh \ + -n "${container_name}" -C "${packages_image}" -v "${vernum}" \ ci-automation/test_update_reruns.sh \ "${tests_dir}/${tapfile}" "${image}" "${retry}" \ "${tests_dir}/failed-run-${retry}.txt" diff --git a/ci-automation/vendor-testing/qemu.sh b/ci-automation/vendor-testing/qemu.sh old mode 100644 new mode 100755 index 852e386899..b66daa2064 --- a/ci-automation/vendor-testing/qemu.sh +++ b/ci-automation/vendor-testing/qemu.sh @@ -1,38 +1,38 @@ #!/bin/bash -set -euo pipefail # Copyright (c) 2021 The Flatcar Maintainers. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +set -euo pipefail + # Test execution script for the qemu vendor image. # This script is supposed to run in the SDK container. -function run_testsuite() { - local work_dir="$1"; shift - local arch="$2"; shift - local vernum="$3"; shift - local tapfile="$4"; shift +work_dir="$1"; shift +arch="$1"; shift +vernum="$1"; shift +tapfile="$1"; shift - # $@ now contains tests / test patterns to run +# $@ now contains tests / test patterns to run - source ci-automation/ci_automation_common.sh +source ci-automation/ci_automation_common.sh - mkdir -p "${work_dir}" - cd "${work_dir}" +mkdir -p "${work_dir}" +cd "${work_dir}" - copy_from_buildcache "images/${arch}/${vernum}/${QEMU_IMAGE_NAME}" . +echo "++++ QEMU test: downloading ${QEMU_IMAGE_NAME} for ${vernum} (${arch}) ++++" +copy_from_buildcache "images/${arch}/${vernum}/${QEMU_IMAGE_NAME}" . - set -o noglob +set -o noglob - sudo kola run - --board="${arch}-usr" \ - --parallel="${QEMU_PARALLEL}" \ - --platform=qemu \ - --qemu-bios=/usr/share/qemu/bios-256k.bin \ - --qemu-image="${QEMU_IMAGE_NAME}" \ - --tapfile="${tapfile}" \ - --torcx-manifest="${CONTAINER_TORCX_ROOT}/${arch}-usr/latest/torcx_manifest.json" - $@ +sudo kola run \ + --board="${arch}-usr" \ + --parallel="${QEMU_PARALLEL}" \ + --platform=qemu \ + --qemu-bios=/usr/share/qemu/bios-256k.bin \ + --qemu-image="${QEMU_IMAGE_NAME}" \ + --tapfile="${tapfile}" \ + --torcx-manifest="${CONTAINER_TORCX_ROOT}/${arch}-usr/latest/torcx_manifest.json" \ + $@ - set +o noglob -} +set +o noglob