mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-22 14:11:07 +02:00
ci-automation: Make AWS test script to work
This commit is contained in:
parent
6278762fa8
commit
d60d514482
@ -105,8 +105,17 @@ VMWARE_ESX_PARALLEL="${PARALLEL_TESTS:-4}"
|
|||||||
|
|
||||||
# -- AWS --
|
# -- AWS --
|
||||||
|
|
||||||
AWS_INSTANCE_TYPE="${AWS_INSTANCE_TYPE:-t3.small}"
|
: ${AWS_amd64_INSTANCE_TYPE:="t3.small"}
|
||||||
AWS_OFFER="${AWS_OFFER:-basic}"
|
# Space separated list of instance types. On those instances the
|
||||||
AWS_OEM_SUFFIX="_${AWS_OFFER}"
|
# cl.internet kola test will be run if this test is selected to run.
|
||||||
AWS_IAM_PROFILE="${AWS_IAM_PROFILE:-ciauto-test}"
|
: ${AWS_amd64_MORE_INSTANCE_TYPES:="m4.2xlarge"}
|
||||||
AWS_REGION="${AWS_REGION:-us-east-1}"
|
: ${AWS_arm64_INSTANCE_TYPE:="a1.large"}
|
||||||
|
# Space separated list of instance types. On those instances the
|
||||||
|
# cl.internet kola test will be run if this test is selected to run.
|
||||||
|
: ${AWS_arm64_MORE_INSTANCE_TYPES:=""}
|
||||||
|
: ${AWS_IAM_PROFILE:="ciauto-test"}
|
||||||
|
: ${AWS_REGION:="us-east-1"}
|
||||||
|
: ${AWS_AMI_ID:=""}
|
||||||
|
AWS_PARALLEL="${PARALLEL_TESTS:-8}"
|
||||||
|
# AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY should come from
|
||||||
|
# sdk_container/.env
|
||||||
|
116
ci-automation/vendor-testing/aws.sh
Normal file → Executable file
116
ci-automation/vendor-testing/aws.sh
Normal file → Executable file
@ -5,68 +5,78 @@
|
|||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# Test execution script for the qemu vendor image.
|
# Test execution script for the AWS vendor image.
|
||||||
# This script is supposed to run in the SDK container.
|
# This script is supposed to run in the mantle container.
|
||||||
|
|
||||||
work_dir="$1"; shift
|
source ci-automation/vendor_test.sh
|
||||||
arch="$1"; shift
|
|
||||||
vernum="$1"; shift
|
|
||||||
tapfile="$1"; shift
|
|
||||||
|
|
||||||
AWS_BOARD="${arch}-usr"
|
board="${CIA_ARCH}-usr"
|
||||||
AWS_CHANNEL="$(get_git_channel)"
|
escaped_vernum="${CIA_VERNUM//+/-}"
|
||||||
AWS_IMAGE_NAME="ci-${vernum}"
|
image_name="ci-${escaped_vernum}-${CIA_ARCH}"
|
||||||
|
aws_instance_type_var="AWS_${CIA_ARCH}_INSTANCE_TYPE"
|
||||||
|
aws_instance_type="${!aws_instance_type_var}"
|
||||||
|
more_aws_instance_types_var="AWS_${CIA_ARCH}_MORE_INSTANCE_TYPES"
|
||||||
|
set -o noglob # there shouldn't be any instance types with asterisks
|
||||||
|
# in it, but…
|
||||||
|
more_aws_instance_types=( ${!more_aws_instance_types_var} )
|
||||||
|
set +o noglob
|
||||||
|
|
||||||
if [[ "${arch}" == "arm64-usr" ]]; then
|
vmdk='flatcar_production_ami_vmdk_image.vmdk'
|
||||||
AWS_INSTANCE_TYPE="a1.large"
|
tarball="${vmdk}.bz2"
|
||||||
fi
|
|
||||||
|
|
||||||
# $@ now contains tests / test patterns to run
|
|
||||||
|
|
||||||
source ci-automation/ci_automation_common.sh
|
|
||||||
|
|
||||||
mkdir -p "${work_dir}"
|
|
||||||
cd "${work_dir}"
|
|
||||||
|
|
||||||
testscript="$(basename "$0")"
|
|
||||||
|
|
||||||
if [[ "${AWS_AMI_ID}" == "" ]]; then
|
if [[ "${AWS_AMI_ID}" == "" ]]; then
|
||||||
[ -s verify.asc ] && verify_key=--verify-key=verify.asc || verify_key=
|
if [[ -f "${vmdk}" ]]; then
|
||||||
|
echo "++++ ${CIA_TESTSCRIPT}: using existing ${vmdk} for ${CIA_VERNUM} (${CIA_ARCH}) ++++"
|
||||||
|
else
|
||||||
|
echo "++++ ${CIA_TESTSCRIPT}: downloading ${tarball} for ${CIA_VERNUM} (${CIA_ARCH}) ++++"
|
||||||
|
copy_from_buildcache "images/${CIA_ARCH}/${CIA_VERNUM}/${tarball}" .
|
||||||
|
lbunzip2 "${tarball}"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "++++ ${testscript}: downloading flatcar_production_ami_vmdk${AWS_OEM_SUFFIX}_image.vmdk.bz2 for ${vernum} (${arch}) ++++"
|
aws_bucket="flatcar-kola-ami-import-${AWS_REGION}"
|
||||||
copy_from_buildcache "images/${arch}/${vernum}/flatcar_production_ami_vmdk${AWS_OEM_SUFFIX}_image.vmdk.bz2" .
|
aws_s3_path="s3://${aws_bucket}/${escaped_vernum}/${board}/"
|
||||||
|
trap 'ore -d aws delete --region="${AWS_REGION}" --board="${board}" --name="${image_name}" --ami-name="${image_name}" --file="${vmdk}" --bucket "${aws_s3_path}"' EXIT
|
||||||
bunzip2 "${work_dir}/flatcar_production_ami_vmdk${AWS_OEM_SUFFIX}_image.vmdk.bz2"
|
ore aws initialize --region="${AWS_REGION}" --bucket "${aws_bucket}"
|
||||||
|
AWS_AMI_ID=$(ore aws upload --force --region="${AWS_REGION}" --board="${board}" --name="${image_name}" --ami-name="${image_name}" --ami-description="Flatcar Test ${image_name}" --file="${vmdk}" --bucket "${aws_s3_path}" | jq -r .HVM)
|
||||||
# FIXME: need to check if it is ok to run ore
|
echo "++++ ${CIA_TESTSCRIPT}: created new AMI ${AWS_AMI_ID} (will be removed after testing) ++++"
|
||||||
AWS_BUCKET="flatcar-kola-ami-import-${AWS_REGION}"
|
|
||||||
trap 'bin/ore -d aws delete --region="${AWS_REGION}" --name="${AWS_IMAGE_NAME}" --ami-name="${AWS_IMAGE_NAME}" --file="${work_dir}/flatcar_production_ami_vmdk${AWS_OEM_SUFFIX}_image.vmdk" --bucket "s3://${AWS_BUCKET}/${AWS_BOARD}/"; rm -r ${work_dir}/' EXIT
|
|
||||||
bin/ore aws initialize --region="${AWS_REGION}" --bucket "${AWS_BUCKET}"
|
|
||||||
AWS_AMI_ID=$(bin/ore aws upload --force --region="${AWS_REGION}" --name=${AWS_IMAGE_NAME} --ami-name="${AWS_IMAGE_NAME}" --ami- description="Flatcar Test ${AWS_IMAGE_NAME}" --file="${work_dir}/flatcar_production_ami_vmdk${AWS_OEM_SUFFIX}_image.vmdk" --bucket "s3://${AWS_BUCKET}/${AWS_BOARD}/" | jq -r .HVM)
|
|
||||||
echo "Created new AMI ${AWS_AMI_ID} (will be removed after testing)"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
run_kola_tests() {
|
||||||
|
local instance_type="${1}"; shift
|
||||||
|
local instance_tapfile="${1}"; shift
|
||||||
|
|
||||||
# AWS timeout
|
timeout --signal=SIGQUIT 6h \
|
||||||
timeout=6h
|
kola run \
|
||||||
|
--board="${board}" \
|
||||||
|
--basename="${image_name}" \
|
||||||
|
--channel="${CIA_CHANNEL}" \
|
||||||
|
--offering='basic' \
|
||||||
|
--parallel="${AWS_PARALLEL}" \
|
||||||
|
--platform=aws \
|
||||||
|
--aws-ami="${AWS_AMI_ID}" \
|
||||||
|
--aws-region="${AWS_REGION}" \
|
||||||
|
--aws-type="${instance_type}" \
|
||||||
|
--aws-iam-profile="${AWS_IAM_PROFILE}" \
|
||||||
|
--tapfile="${instance_tapfile}" \
|
||||||
|
--torcx-manifest="${CIA_TORCX_MANIFEST}" \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
set -x
|
query_kola_tests() {
|
||||||
set -o noglob
|
shift; # ignore the instance type
|
||||||
|
kola list --platform=aws --filter "${@}"
|
||||||
|
}
|
||||||
|
|
||||||
sudo timeout --signal=SIGQUIT ${timeout} bin/kola run \
|
# these are set in ci-config.env
|
||||||
--board="${AWS_BOARD}" \
|
export AWS_ACCESS_KEY_ID
|
||||||
--basename="${AWS_IMAGE_NAME}" \
|
export AWS_SECRET_ACCESS_KEY
|
||||||
--channel="${AWS_CHANNEL}" \
|
|
||||||
--offering="${AWS_OFFER}" \
|
|
||||||
--parallel=${PARALLEL_TESTS} \
|
|
||||||
--platform=aws \
|
|
||||||
--aws-ami="${AWS_AMI_ID}" \
|
|
||||||
--aws-region="${AWS_REGION}" \
|
|
||||||
--aws-type="${AWS_INSTANCE_TYPE}" \
|
|
||||||
--aws-iam-profile="${AWS_IAM_PROFILE}" \
|
|
||||||
--tapfile="${tapfile}" \
|
|
||||||
--torcx-manifest=torcx_manifest.json \
|
|
||||||
$@
|
|
||||||
|
|
||||||
set +o noglob
|
run_kola_tests_on_instances \
|
||||||
set +x
|
"${aws_instance_type}" \
|
||||||
|
"${CIA_TAPFILE}" \
|
||||||
|
"${CIA_FIRST_RUN}" \
|
||||||
|
"${more_aws_instance_types[@]}" \
|
||||||
|
'--' \
|
||||||
|
'cl.internet' \
|
||||||
|
'--' \
|
||||||
|
"${@}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user