flatcar-scripts/ci-automation/vendor-testing/openstack.sh
Mathieu Tortuyaux d7f8e23345
testing/openstack: clean everything before testing
It happens that we have some leftovers instances running in an "error"
state (the error comes from the OpenStack scheduled deletion). This
leads to instance creation error during the test because quota limits
are hit.

Let's clean-up everything before running the new tests.

This won't impact tests from other channels as OpenStack is limited to
one CI job at a time.

Signed-off-by: Mathieu Tortuyaux <mtortuyaux@microsoft.com>
2025-02-27 13:01:54 +01:00

68 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
# Copyright (c) 2022 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 Openstack vendor image.
# This script is supposed to run in the mantle container.
source ci-automation/vendor_test.sh
# ARM64 does not seem to be supported yet with devstack, so for now fail it as an
# unsupported option.
if [[ "${CIA_ARCH}" == "arm64" ]]; then
echo "1..1" > "${CIA_TAPFILE}"
echo "not ok - all qemu tests" >> "${CIA_TAPFILE}"
echo " ---" >> "${CIA_TAPFILE}"
echo " ERROR: ARM64 tests not supported on Openstack (devstack)." | tee -a "${CIA_TAPFILE}"
echo " ..." >> "${CIA_TAPFILE}"
break_retest_cycle
exit 1
fi
# OPENSTACK_CREDS, OPENSTACK_USER, OPENSTACK_HOST, OPENSTACK_KEYFILE should be provided by sdk_container/.env
config_file=''
secret_to_file config_file "${OPENSTACK_CREDS}"
openstack_keyfile=''
secret_to_file openstack_keyfile "${OPENSTACK_KEYFILE}"
# Make sure that everything is cleaned up before starting.
ore --config-file "${config_file}" openstack gc --duration 1s
# Upload the image on OpenStack dev instance.
IMAGE_ID=$(ore openstack create-image \
--name=flatcar-"${CIA_VERNUM}" \
--file="https://${BUILDCACHE_SERVER}/images/${CIA_ARCH}/${CIA_VERNUM}/${OPENSTACK_IMAGE_NAME}" \
--config-file="${config_file}"
)
# Delete the image once we exit.
trap 'ore --config-file "${config_file}" openstack delete-image --id "${IMAGE_ID}" || true' EXIT
kola_test_basename="ci-${CIA_VERNUM//+/-}"
kola_test_basename="${kola_test_basename//[+.]/-}"
set -x
timeout --signal=SIGQUIT 2h kola run \
--board="${CIA_ARCH}-usr" \
--parallel="${OPENSTACK_PARALLEL}" \
--tapfile="${CIA_TAPFILE}" \
--channel="${CIA_CHANNEL}" \
--basename="${kola_test_basename}" \
--platform=openstack \
--openstack-network=public \
--openstack-domain=default \
--openstack-flavor=flatcar-flavor \
--openstack-user="${OPENSTACK_USER}" \
--openstack-host="${OPENSTACK_HOST}" \
--openstack-keyfile="${openstack_keyfile}" \
--openstack-image="${IMAGE_ID}" \
--openstack-config-file="${config_file}" \
"${@}"
set +x