ci-automation: Further refactor

This commit is contained in:
Krzesimir Nowak 2023-01-11 16:14:06 +01:00
parent fdb08f17cc
commit 22ce97471f
10 changed files with 39 additions and 43 deletions

View File

@ -60,8 +60,7 @@ run_kola_tests() {
--aws-ami="${AWS_AMI_ID}" \
--aws-region="${AWS_REGION}" \
--aws-type="${instance_type}" \
--aws-iam-profile="${AWS_IAM_PROFILE}" \
"${@}"
--aws-iam-profile="${AWS_IAM_PROFILE}"
}
# these are set in ci-config.env

View File

@ -59,8 +59,7 @@ run_kola_tests() {
--do-config-file="${config_file}" \
--do-image="${image_name}" \
--parallel="${DIGITALOCEAN_PARALLEL}" \
--platform=do \
"${@}"
--platform=do
}
run_default_kola_tests

View File

@ -49,8 +49,7 @@ run_kola_tests() {
--equinixmetal-project="${EQUINIXMETAL_PROJECT}" \
--equinixmetal-storage-url="${EQUINIXMETAL_STORAGE_URL}" \
--gce-json-key=<(echo "${GCP_JSON_KEY}" | base64 --decode) \
--equinixmetal-api-key="${EQUINIXMETAL_KEY}" \
"${@}"
--equinixmetal-api-key="${EQUINIXMETAL_KEY}"
}
run_default_kola_tests

View File

@ -68,8 +68,7 @@ run_kola_tests() {
--gce-machinetype="${GCE_MACHINE_TYPE}" \
"${extra_arg[@]}" \
--parallel="${GCE_PARALLEL}" \
--platform=gce \
"${@}"
--platform=gce
}
run_default_kola_tests

View File

@ -67,8 +67,7 @@ run_kola_tests() {
--openstack-host="${OPENSTACK_HOST}" \
--openstack-keyfile="${openstack_keyfile}" \
--openstack-image="${IMAGE_ID}" \
--openstack-config-file="${config_file}" \
"${@}"
--openstack-config-file="${config_file}"
}
run_default_kola_tests

View File

@ -60,8 +60,7 @@ run_kola_tests() {
--platform=qemu \
--qemu-bios="${bios}" \
--qemu-image="${QEMU_IMAGE_NAME}" \
--qemu-skip-mangle \
"${@}"
--qemu-skip-mangle
}
run_default_kola_tests

View File

@ -107,8 +107,7 @@ run_kola_tests() {
--qemu-bios="${bios}" \
--qemu-image="${image}" \
--update-payload=tmp/flatcar_test_update.gz \
--qemu-skip-mangle \
cl.update.payload
--qemu-skip-mangle
}
run_default_kola_tests

View File

@ -48,8 +48,7 @@ run_kola_tests() {
kola_run \
--parallel=42 \
--platform=test \
"${@}"
--platform=test
}
run_default_kola_tests

View File

@ -70,8 +70,7 @@ run_kola_tests() {
--platform=esx \
--parallel="${VMWARE_ESX_PARALLEL}" \
--esx-config-file "${config_file}" \
--esx-ova-path "${VMWARE_ESX_IMAGE_NAME}" \
"${@}"
--esx-ova-path "${VMWARE_ESX_IMAGE_NAME}"
}
run_default_kola_tests

View File

@ -117,6 +117,13 @@ CIA_VENDOR_SCRIPTS_DIR="${ciavts_vendor_scripts_dir}"
# Unset all variables with ciavts_ prefix now.
unset -v "${!ciavts_@}"
function generate_fail_tapfile() {
local tapfile="${1}"; shift
# rest of the args are test names
echo "1..${#@}" >"${tapfile}"
printf 'not ok - %s\n' "${@}" >>"${tapfile}"
}
trap handle_flaky_setup ERR
function handle_flaky_setup() {
if [[ -e "${CIA_TAPFILE}" ]]; then
@ -161,8 +168,7 @@ function handle_flaky_setup() {
all_tests=( "${CIA_OUTPUT_ALL_TESTS[@]}" )
fi
echo "1..${#all_tests[@]}" >"${CIA_TAPFILE}"
printf 'not ok - %s\n' "${all_tests[@]}" >>"${CIA_TAPFILE}"
generate_fail_tapfile "${CIA_TAPFILE}" "${all_tests[@]}"
return 0
}
@ -306,8 +312,6 @@ function merge_tap_files() {
#
# run_kola_tests that takes the following parameters:
# 1 - instance type
# 2 - tap file
# @ - tests to run
#
# query_kola_tests that takes the following parameters:
# 1 - instance type
@ -317,28 +321,26 @@ function merge_tap_files() {
# the line will be ignored.
#
# Typical use:
#
# CIA_OUTPUT_MAIN_INSTANCE=…
# CIA_OUTPUT_ALL_TESTS=( … )
# CIA_OUTPUT_EXTRA_INSTANCES=( … )
# CIA_OUTPUT_EXTRA_INSTANCE_TESTS=( … )
# CIA_OUTPUT_TIMEOUT=…
#
# function run_kola_tests() {
# local instance_type="${1}"; shift
# local tap_file="${1}"; shift
# kola run … "${@}"
# kola_run …
# }
#
# # Setup (download and prepare images for kola)
#
# function query_kola_tests() {
# local instance_type="${1}"; shift
# kola list … "${@}"
# }
#
# args=(
# "${main_instance}"
# "${CIA_TAPFILE}"
# "${CIA_FIRST_RUN}"
# "${other_instance_types[@]}"
# '--'
# 'cl.internet'
# '--'
# "${tests_to_run[@]}"
# )
# run_kola_tests_on_instances "${args[@]}"
# run_default_kola_tests
#
# Parameters:
# 1 - main instance type - there all the tests are being run
@ -430,6 +432,7 @@ function run_kola_tests_on_instances() {
function run_kola_tests_internal() {
local instance_type="${1}"; shift
local CIA_INTERNAL_TAPFILE="${1}"; shift
local CIA_INTERNAL_TESTS=( "${@}" )
run_kola_tests "${instance_type}" "${@}"
}
@ -473,7 +476,7 @@ function run_default_kola_tests() {
# run_kola_tests callback used by run_default_kola_tests or
# run_kola_tests_on_instances.
function kola_run() {
local common_opts
local -a common_opts kola_cmd
common_opts=(
--board="${CIA_ARCH}-usr"
@ -481,19 +484,21 @@ function kola_run() {
--torcx-manifest="${CIA_TORCX_MANIFEST}"
--channel="${CIA_CHANNEL}"
)
kola_cmd=()
if [[ -n "${CIA_OUTPUT_TIMEOUT:-}" ]]; then
unsafe_code_section \
timeout --signal=SIGQUIT "${CIA_OUTPUT_TIMEOUT}" \
kola run "${common_opts[@]}" "${@}"
else
unsafe_code_section \
kola run "${common_opts[@]}" "${@}"
kola_cmd+=( timeout --signal=SIGQUIT "${CIA_OUTPUT_TIMEOUT}" )
fi
kola_cmd+=( kola run "${common_opts[@]}" "${@}" "${CIA_INTERNAL_TESTS[@]}" )
# Run in a subshell to avoid executing the err handler.
(
printf "%q" "${kola_cmd[@]}"; printf '\n'
"${kola_cmd[@]}" || :
)
# In case of timeout, the tapfile might be still missing. But
# since we were ignoring the error at the time, handle_flaky_setup
# didn't run, so do it now.
if [[ ! -e "${CIA_INTERNAL_TAPFILE}" ]]; then
handle_flaky_setup
generate_fail_tapfile "${CIA_INTERNAL_TAPFILE}" "${CIA_INTERNAL_TESTS[@]}"
fi
}