test/api.sh: Drop distro aliases and dot-notation

This reverts commit 2fe5e01d4d with the
exception of the changes in tools/provision.sh.
This functionality is covered by unit tests in osbuild/images:
aaa53adc3c/pkg/distrofactory/distrofactory_test.go (L9)
This commit is contained in:
Simon Steinbeiss 2024-03-05 15:17:55 +01:00 committed by Simon Steinbeiß
parent f02fe86366
commit bdc973d085
9 changed files with 36 additions and 162 deletions

View file

@ -22,9 +22,7 @@ CLOUD_PROVIDER_OCI="oci"
# Supported Image type names
#
export IMAGE_TYPE_AWS="aws"
export IMAGE_TYPE_AWS_SAP_RHUI="aws-sap-rhui"
export IMAGE_TYPE_AZURE="azure"
export IMAGE_TYPE_AZURE_SAP_RHUI="azure-sap-rhui"
export IMAGE_TYPE_EDGE_COMMIT="edge-commit"
export IMAGE_TYPE_EDGE_CONTAINER="edge-container"
export IMAGE_TYPE_EDGE_INSTALLER="edge-installer"
@ -53,50 +51,14 @@ IMAGE_TYPE="$1"
# set TEST_MODULE_HOTFIXES to 1 to enable module hotfixes for the test
TEST_MODULE_HOTFIXES="${TEST_MODULE_HOTFIXES:-0}"
# set TEST_NO_DOT_NOTATION to 1 to disable dot notation in the test
# Not using the dot notation means that the dot separating the major and minor
# version in the distro name will be removed.
#
# This test variant is mutually exclusive with TEST_DISTRO_ALIAS.
TEST_NO_DOT_NOTATION="${TEST_NO_DOT_NOTATION:-0}"
# set TEST_DISTRO_ALIAS to 1 to test configuring and using a distro alias
# when submitting composer request.
#
# This test variant deliberately uses the SAP image to test that the alias
# works as expected. The reason is that the SAP image will always have DNF
# configuration pinned down to a specific OS version and the version is the
# same as the distro definition used to generate the manifest.
# Specifically, the `/etc/dnf/vars/releasever` file will contain `X.Y`.
#
# This test variant is mutually exclusive with TEST_NO_DOT_NOTATION.
export TEST_DISTRO_ALIAS="${TEST_DISTRO_ALIAS:-0}"
# TEST_NO_DOT_NOTATION and TEST_DISTRO_ALIAS are mutually exclusive
if [[ "$TEST_NO_DOT_NOTATION" == "1" && "$TEST_DISTRO_ALIAS" == "1" ]]; then
echo "TEST_NO_DOT_NOTATION and TEST_DISTRO_ALIAS are mutually exclusive"
exit 1
fi
# TEST_DISTRO_ALIAS requires that the IMAGE_TYPE is a SAP image
if [[ "$TEST_DISTRO_ALIAS" == "1" ]]; then
case "${IMAGE_TYPE}" in
"$IMAGE_TYPE_AWS_SAP_RHUI"|"IMAGE_TYPE_AZURE_SAP_RHUI")
;;
*)
echo "TEST_DISTRO_ALIAS can only be used with SAP images"
exit 1
esac
fi
# select cloud provider based on image type
#
# the supported image types are listed in the api spec (internal/cloudapi/v2/openapi.v2.yml)
case ${IMAGE_TYPE} in
"$IMAGE_TYPE_AWS"|"$IMAGE_TYPE_AWS_SAP_RHUI")
"$IMAGE_TYPE_AWS")
CLOUD_PROVIDER="${CLOUD_PROVIDER_AWS}"
;;
"$IMAGE_TYPE_AZURE"|"IMAGE_TYPE_AZURE_SAP_RHUI")
"$IMAGE_TYPE_AZURE")
CLOUD_PROVIDER="${CLOUD_PROVIDER_AZURE}"
;;
"$IMAGE_TYPE_GCP")
@ -127,54 +89,14 @@ ARTIFACTS="${ARTIFACTS:-/tmp/artifacts}"
source /usr/libexec/osbuild-composer-test/set-env-variables.sh
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
export DISTRO="${DISTRO_CODE}"
# Container image used for cloud provider CLI tools
export CONTAINER_IMAGE_CLOUD_TOOLS="quay.io/osbuild/cloud-tools:latest"
WORKDIR=$(mktemp -d)
KILL_PIDS=()
function cleanups() {
greenprint "Cleaning up"
set +eu
cleanup
# dump the DB here to ensure that it gets dumped even if the test fails
dump_db
sudo "${CONTAINER_RUNTIME}" kill "${DB_CONTAINER_NAME}"
sudo "${CONTAINER_RUNTIME}" rm "${DB_CONTAINER_NAME}"
sudo rm -rf "$WORKDIR"
for P in "${KILL_PIDS[@]}"; do
sudo pkill -P "$P"
done
set -eu
}
trap cleanups EXIT
#
# Provision the software under test.
#
# Path to a file with extra composer configuration
EXTRA_COMPOSER_CONF=""
# Configure distro alias for the host distro in composer without the minor
# version.
if [[ "${TEST_DISTRO_ALIAS}" == "1" ]]; then
DISTRO_ALIAS="${ID}-${VERSION_ID%.*}"
EXTRA_COMPOSER_CONF="$(mktemp -p "${WORKDIR}")"
cat <<EOF | tee "${EXTRA_COMPOSER_CONF}" >/dev/null
[distro_aliases]
${DISTRO_ALIAS} = "${DISTRO}"
EOF
fi
/usr/libexec/osbuild-composer-test/provision.sh tls "${EXTRA_COMPOSER_CONF}"
/usr/libexec/osbuild-composer-test/provision.sh
#
# Set up the database queue
@ -212,9 +134,7 @@ PGUSER=postgres PGPASSWORD=foobar PGDATABASE=osbuildcomposer PGHOST=localhost PG
"$(go env GOPATH)"/bin/tern migrate -m /usr/share/tests/osbuild-composer/schemas
popd
# TODO: move this to the tools/provision.sh and don't override composer config
COMPOSER_CONFIG="/etc/osbuild-composer/osbuild-composer.toml"
cat <<EOF | sudo tee "${COMPOSER_CONFIG}"
cat <<EOF | sudo tee "/etc/osbuild-composer/osbuild-composer.toml"
log_level = "debug"
[koji]
allowed_domains = [ "localhost", "client.osbuild.org" ]
@ -231,10 +151,6 @@ pg_ssl_mode = "disable"
pg_max_conns = 10
EOF
if [[ "${TEST_DISTRO_ALIAS}" == "1" ]]; then
cat "${EXTRA_COMPOSER_CONF}" | sudo tee -a "${COMPOSER_CONFIG}"
fi
sudo systemctl restart osbuild-composer
greenprint "Using Cloud Provider / Target ${CLOUD_PROVIDER} for Image Type ${IMAGE_TYPE}"
@ -286,6 +202,29 @@ function dump_db() {
| sudo tee "${ARTIFACTS}/build-result.txt"
}
WORKDIR=$(mktemp -d)
KILL_PIDS=()
function cleanups() {
greenprint "Cleaning up"
set +eu
cleanup
# dump the DB here to ensure that it gets dumped even if the test fails
dump_db
sudo "${CONTAINER_RUNTIME}" kill "${DB_CONTAINER_NAME}"
sudo "${CONTAINER_RUNTIME}" rm "${DB_CONTAINER_NAME}"
sudo rm -rf "$WORKDIR"
for P in "${KILL_PIDS[@]}"; do
sudo pkill -P "$P"
done
set -eu
}
trap cleanups EXIT
# make a dummy rpm and repo to test payload_repositories
greenprint "Setting up dummy rpm and repo"
sudo dnf install -y rpm-build createrepo
@ -374,19 +313,7 @@ else
fi
export SSH_USER
if [[ "$TEST_NO_DOT_NOTATION" == "1" ]]; then
# This removes dot from VERSION_ID.
# ID == rhel && VERSION_ID == 8.6 => DISTRO == rhel-86
# ID == centos && VERSION_ID == 8 => DISTRO == centos-8
# ID == fedora && VERSION_ID == 35 => DISTRO == fedora-35
DISTRO_NAME="$ID-${VERSION_ID//./}"
elif [[ "$TEST_DISTRO_ALIAS" == "1" ]]; then
DISTRO_NAME="$DISTRO_ALIAS"
else
DISTRO_NAME="$DISTRO"
fi
export DISTRO_NAME
export DISTRO="$ID-${VERSION_ID}"
SUBSCRIPTION_BLOCK=
# Only RHEL need subscription block.
@ -564,9 +491,6 @@ function collectMetrics(){
}
function sendCompose() {
echo "Compose request:"
cat "$1"
OUTPUT=$(mktemp)
HTTPSTATUS=$(curl \
--silent \

View file

@ -36,7 +36,7 @@ function createReqFile() {
cat > "$REQUEST_FILE" << EOF
{
"distribution": "$DISTRO_NAME",
"distribution": "$DISTRO",
"customizations": {
"filesystem": [
{

View file

@ -68,7 +68,7 @@ function createReqFile() {
cat > "$REQUEST_FILE" << EOF
{
"distribution": "$DISTRO_NAME",
"distribution": "$DISTRO",
"customizations": {
"filesystem": [
{

View file

@ -75,16 +75,6 @@ function _instanceCheck() {
else
echo "firewalld not available on host, that's fine"
fi
if [[ "${TEST_DISTRO_ALIAS}" == "1" ]]; then
echo "✔️ Checking DNF config of an image built using distro alias"
DNF_VARS_RELEASEVER=$($_ssh cat /etc/dnf/vars/releasever)
if [[ "$DNF_VARS_RELEASEVER" != "$VERSION_ID" ]]; then
echo "DNF config of an image built using distro alias has wrong releasever: $DNF_VARS_RELEASEVER"
echo "Expected: $VERSION_ID"
exit 1
fi
fi
}
WORKER_REFRESH_TOKEN_PATH="/etc/osbuild-worker/token"

View file

@ -16,7 +16,7 @@ function createReqFileEdge() {
cat > "$REQUEST_FILE" << EOF
{
"distribution": "$DISTRO_NAME",
"distribution": "$DISTRO",
"customizations": {
"payload_repositories": [
{
@ -62,7 +62,7 @@ EOF
function createReqFileGuest() {
cat > "$REQUEST_FILE" << EOF
{
"distribution": "$DISTRO_NAME",
"distribution": "$DISTRO",
"customizations": {
"payload_repositories": [
{
@ -103,7 +103,7 @@ EOF
function createReqFileVSphere() {
cat > "$REQUEST_FILE" << EOF
{
"distribution": "$DISTRO_NAME",
"distribution": "$DISTRO",
"customizations": {
"payload_repositories": [
{

View file

@ -42,7 +42,7 @@ EOF
function createReqFile() {
cat > "$REQUEST_FILE" << EOF
{
"distribution": "$DISTRO_NAME",
"distribution": "$DISTRO",
"customizations": {
"payload_repositories": [
{

View file

@ -55,7 +55,7 @@ function createReqFile() {
cat > "$REQUEST_FILE" << EOF
{
"distribution": "$DISTRO_NAME",
"distribution": "$DISTRO",
"customizations": {
"filesystem": [
{

View file

@ -60,7 +60,7 @@ function installClient() {
function createReqFile() {
cat > "$REQUEST_FILE" << EOF
{
"distribution": "$DISTRO_NAME",
"distribution": "$DISTRO",
"customizations": {
"filesystem": [
{