mirror of
https://github.com/flatcar/scripts.git
synced 2025-11-28 14:01:43 +01:00
run_local_tests.sh: script for running tests on local builds
This change adds run_local_tests.sh, a script to run tests on local builds. It's a comfort wrapper around ci-automation scripts and uses the latest local build. Signed-off-by: Thilo Fromm <thilofromm@microsoft.com>
This commit is contained in:
parent
6f651a298c
commit
35779f1ca3
108
run_local_tests.sh
Executable file
108
run_local_tests.sh
Executable file
@ -0,0 +1,108 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2023 The Flatcar Maintainers.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# QoL wrapper around ci-automation test.sh for running local tests of qemu_uefi image.
|
||||
# The devcontainer tests will be skipped since these require a valid commit ref in
|
||||
# the upstream scripts repo.
|
||||
#
|
||||
# Requirements:
|
||||
# - Docker (for running the Mantle container).
|
||||
#
|
||||
# Prerequisites:
|
||||
# - Flatcar OS image and qemu uefi code to be tested in
|
||||
# __build__/images/images/amd64-usr/latest/
|
||||
#
|
||||
# This script is intended to be run after building a qemu_uefi image with the SDK container:
|
||||
# ./build_packages
|
||||
# ./build_image
|
||||
# ./image_to_vm.sh --from=../build/images/amd64-usr/latest/ --format=qemu_uefi --image_compression_formats none
|
||||
# Then, EXIT the SDK container (or run this on a different terminal):
|
||||
# ./run_local_tests.sh
|
||||
#
|
||||
# Optional prerequisites:
|
||||
# - Custom Mantle container image / version in sdk_container/.repo/manifests/mantle-container.
|
||||
# This comes in handy if you've built a local mantle/kola which you want to test.
|
||||
# Just edit the file and put in the whole containerr image name and version.
|
||||
#
|
||||
# Output:
|
||||
# results reports:
|
||||
# - results-qemu_uefi-detailed.md
|
||||
# - results-qemu_uefi-detailed.tap
|
||||
# - results-qemu_uefi.md
|
||||
# - results-qemu_uefi.tap
|
||||
# - results-qemu_update-detailed.md
|
||||
# - results-qemu_update-detailed.tap
|
||||
# - results-qemu_update.md
|
||||
# - results-qemu_update.tap
|
||||
#
|
||||
#
|
||||
# - Detailed test run output will reside below __TESTS__/qemu-uefi
|
||||
|
||||
function set_vars() {
|
||||
local arch="${1}"
|
||||
local parallel="${2}"
|
||||
|
||||
# Read by the mantle container.
|
||||
# The local directory ("pwd") will be mounted to /work/ in the container.
|
||||
cat > sdk_container/.env <<EOF
|
||||
export export QEMU_IMAGE_NAME="/work/__build__/images/images/${arch}-usr/latest/flatcar_production_image.bin"
|
||||
export QEMU_UEFI_BIOS="/work/__build__/images/images/${arch}-usr/latest/flatcar_production_qemu_uefi_efi_code.fd"
|
||||
export QEMU_UPDATE_PAYLOAD="/work/__build__/images/images/${arch}-usr/latest/flatcar_test_update.gz"
|
||||
export PARALLEL_TESTS=${parallel}
|
||||
EOF
|
||||
|
||||
export MAX_RETRIES=5
|
||||
export SKIP_COPY_TO_BINCACHE=1
|
||||
}
|
||||
#--
|
||||
|
||||
function run_local_tests() {
|
||||
local arch="${1:-amd64}"
|
||||
if [[ $# -gt 0 ]] ; then shift; fi
|
||||
local parallel="${1:-2}"
|
||||
if [[ $# -gt 0 ]] ; then shift; fi
|
||||
|
||||
rm -f results.*
|
||||
|
||||
local mantle_container="$(cat "sdk_container/.repo/manifests/mantle-container")"
|
||||
local custom_test_list=false
|
||||
|
||||
# Generate list of all tests for qemu w/o the devcontainer tests.
|
||||
# This will generate globs for top-level test modules, e.g. "cl.update.oem" will become cl.*.
|
||||
# Globs are necessary because tests ignore OS min/max version specification if a test was specified with its full name.
|
||||
# Using globs will prevent tests to be run which aren't meant for the OS version we're testing.
|
||||
if [[ $# -eq 0 ]] ; then
|
||||
tests="$(docker run "${mantle_container}" \
|
||||
kola list --platform qemu \
|
||||
| awk '!/^(devcontainer|Test)/ {if ($1 != "") print gensub(/^([^.]+).*/,"\\1",1,$1) ".*"}' | uniq)"
|
||||
set -- ${tests}
|
||||
else
|
||||
custom_test_list=true
|
||||
fi
|
||||
|
||||
source ci-automation/test.sh || exit 1
|
||||
set_vars "${arch}" "${parallel}"
|
||||
|
||||
echo "================================="
|
||||
echo "Using Mantle docker image '${mantle_container}'"
|
||||
|
||||
rm -f results.sqlite
|
||||
test_run "${arch}" qemu_uefi "${@}"
|
||||
if [[ "${custom_test_list}" = "false" ]] ; then
|
||||
test_run "${arch}" qemu_update
|
||||
fi
|
||||
|
||||
}
|
||||
# --
|
||||
|
||||
|
||||
if [[ "$(basename "${0}")" = "run_local_tests.sh" ]] ; then
|
||||
set -euo pipefail
|
||||
run_local_tests "${@}"
|
||||
fi
|
||||
Loading…
x
Reference in New Issue
Block a user