From 165ecafeb231ceeab79e080fbf8e70e75330cab9 Mon Sep 17 00:00:00 2001 From: Jozef Mikovic Date: Tue, 23 Mar 2021 11:57:45 +0100 Subject: [PATCH] test: use DISTRO_CODE to select tests case Using DISTRO_CODE simplifies test case selection and allows to test different distro than the one test is running on. This is used to run tests for RHEL 9.0 on F33 or RHEL 8.4 --- schutzbot/Jenkinsfile | 73 ++++++++++++++++++++++++++++++++------- test/cases/api.sh | 5 +++ test/cases/aws.sh | 6 ++++ test/cases/image_tests.sh | 8 +---- test/cases/koji.sh | 8 +---- test/cases/libvirt.sh | 8 +++-- tools/koji-compose.py | 23 +++++++----- 7 files changed, 94 insertions(+), 37 deletions(-) diff --git a/schutzbot/Jenkinsfile b/schutzbot/Jenkinsfile index 78501e588..b329f53e3 100644 --- a/schutzbot/Jenkinsfile +++ b/schutzbot/Jenkinsfile @@ -277,7 +277,7 @@ pipeline { agent { label "f32cloudbase && psi && x86_64" } environment { TEST_TYPE = "image" - DISTRO_CODE = "fedora32" + DISTRO_CODE = "fedora_32" AWS_CREDS = credentials('aws-credentials-osbuildci') AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test') AZURE_CREDS = credentials('azure') @@ -308,7 +308,7 @@ pipeline { agent { label "f32cloudbase && x86_64 && aws" } environment { TEST_TYPE = "integration" - DISTRO_CODE = "fedora32" + DISTRO_CODE = "fedora_32" AWS_CREDS = credentials('aws-credentials-osbuildci') AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test') AWS_API_TEST_SHARE_ACCOUNT = credentials('aws-credentials-share-account') @@ -372,7 +372,7 @@ pipeline { agent { label "f33cloudbase && psi && x86_64" } environment { TEST_TYPE = "image" - DISTRO_CODE = "fedora33" + DISTRO_CODE = "fedora_33" AWS_CREDS = credentials('aws-credentials-osbuildci') AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test') AZURE_CREDS = credentials('azure') @@ -403,7 +403,7 @@ pipeline { agent { label "f33cloudbase && x86_64 && aws" } environment { TEST_TYPE = "integration" - DISTRO_CODE = "fedora33" + DISTRO_CODE = "fedora_33" AWS_CREDS = credentials('aws-credentials-osbuildci') AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test') AWS_API_TEST_SHARE_ACCOUNT = credentials('aws-credentials-share-account') @@ -467,7 +467,7 @@ pipeline { agent { label "f33cloudbase && aarch64 && aws" } environment { TEST_TYPE = "image" - DISTRO_CODE = "fedora33" + DISTRO_CODE = "fedora_33" AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test') AZURE_CREDS = credentials('azure') OPENSTACK_CREDS = credentials("psi-openstack-creds") @@ -537,7 +537,7 @@ pipeline { agent { label "rhel8cloudbase && psi && x86_64" } environment { TEST_TYPE = "image" - DISTRO_CODE = "rhel8" + DISTRO_CODE = "rhel_8" AWS_CREDS = credentials('aws-credentials-osbuildci') AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test') AZURE_CREDS = credentials('azure') @@ -569,7 +569,7 @@ pipeline { agent { label "rhel8cloudbase && x86_64 && psi" } environment { TEST_TYPE = "integration" - DISTRO_CODE = "rhel8" + DISTRO_CODE = "rhel_8" AWS_CREDS = credentials('aws-credentials-osbuildci') AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test') RHN_REGISTRATION_SCRIPT = credentials('rhn-register-script-production') @@ -669,7 +669,7 @@ pipeline { agent { label "rhel84cloudbase && psi && x86_64" } environment { TEST_TYPE = "image" - DISTRO_CODE = "rhel84" + DISTRO_CODE = "rhel_84" AWS_CREDS = credentials('aws-credentials-osbuildci') AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test') AZURE_CREDS = credentials('azure') @@ -693,7 +693,7 @@ pipeline { agent { label "rhel84cloudbase && x86_64 && psi" } environment { TEST_TYPE = "integration" - DISTRO_CODE = "rhel84" + DISTRO_CODE = "rhel_84" AWS_CREDS = credentials('aws-credentials-osbuildci') AWS_API_TEST_SHARE_ACCOUNT = credentials('aws-credentials-share-account') AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test') @@ -738,6 +738,55 @@ pipeline { } } } + stage('EL9.0 Image') { + agent { label "f33cloudbase && psi && x86_64" } + environment { + TEST_TYPE = "image" + DISTRO_CODE = "rhel_90" + AWS_CREDS = credentials('aws-credentials-osbuildci') + AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test') + AZURE_CREDS = credentials('azure') + OPENSTACK_CREDS = credentials("psi-openstack-creds") + VCENTER_CREDS = credentials('vmware-vcenter-credentials') + } + steps { + run_tests('image') + } + post { + always { + preserve_logs('rhel90-image') + sh ( + label: "Run cloud cleaner just in case something failed", + script: "schutzbot/run_cloud_cleaner.sh" + ) + } + } + } + stage('EL9.0 Integration') { + agent { label "rhel84cloudbase && x86_64 && psi" } + environment { + TEST_TYPE = "integration" + DISTRO_CODE = "rhel_90" + AWS_CREDS = credentials('aws-credentials-osbuildci') + AWS_API_TEST_SHARE_ACCOUNT = credentials('aws-credentials-share-account') + AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test') + GCP_API_TEST_SHARE_ACCOUNT = credentials('gcp-credentials-share-account') + AZURE_CLIENT_ID = credentials('azure-client-id') + AZURE_CLIENT_SECRET = credentials('azure-client-secret') + } + steps { + run_tests('integration') + } + post { + always { + preserve_logs('rhel84-integration') + sh ( + label: "Run cloud cleaner just in case something failed", + script: "schutzbot/run_cloud_cleaner.sh" + ) + } + } + } stage('CS8 Base') { when { beforeAgent true @@ -770,7 +819,7 @@ pipeline { agent { label "cs8cloudbase && psi && x86_64" } environment { TEST_TYPE = "image" - DISTRO_CODE = "centos-stream8" + DISTRO_CODE = "centos_8" AWS_CREDS = credentials('aws-credentials-osbuildci') AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test') AZURE_CREDS = credentials('azure') @@ -801,7 +850,7 @@ pipeline { agent { label "cs8cloudbase && x86_64 && aws" } environment { TEST_TYPE = "integration" - DISTRO_CODE = "centos-stream8" + DISTRO_CODE = "centos_8" AWS_CREDS = credentials('aws-credentials-osbuildci') AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test') AWS_API_TEST_SHARE_ACCOUNT = credentials('aws-credentials-share-account') @@ -860,7 +909,7 @@ pipeline { AZURE_CREDS = credentials('azure') OPENSTACK_CREDS = credentials("psi-openstack-creds") VCENTER_CREDS = credentials('vmware-vcenter-credentials') - DISTRO_CODE = "centos-stream8" + DISTRO_CODE = "centos_8" } steps { run_tests('image') diff --git a/test/cases/api.sh b/test/cases/api.sh index 5fb0a2c31..bf5efa1ea 100755 --- a/test/cases/api.sh +++ b/test/cases/api.sh @@ -14,6 +14,11 @@ set -euxo pipefail +#TODO: remove this once there is rhel9 support for necessary image types +if [[ $DISTRO_CODE == rhel_90 ]]; then + echo "Skipped" + exit 0 +fi # # Provision the software under tet. diff --git a/test/cases/aws.sh b/test/cases/aws.sh index d270f0911..e4bed8cd8 100755 --- a/test/cases/aws.sh +++ b/test/cases/aws.sh @@ -10,6 +10,12 @@ function greenprint { echo -e "\033[1;32m${1}\033[0m" } +#TODO: Remove this once there is rhel9 support for AMI image type +if [[ $DISTRO_CODE == rhel_90 ]]; then + greenprint "Skipped" + exit 0 +fi + # Provision the software under tet. /usr/libexec/osbuild-composer-test/provision.sh diff --git a/test/cases/image_tests.sh b/test/cases/image_tests.sh index 09910e908..f530cf667 100755 --- a/test/cases/image_tests.sh +++ b/test/cases/image_tests.sh @@ -25,13 +25,7 @@ test_divider () { # Get a list of test cases. get_test_cases () { - # if the distro is RHEL 8.4 the test case selector needs the minor release number - if [[ "${ID}-${VERSION_ID}" == "rhel-8.4" ]]; then - TEST_CASE_SELECTOR="${ID}_${VERSION_ID//.}-${ARCH}" - # otherwise the minor release number can be dropped - else - TEST_CASE_SELECTOR="${ID}_${VERSION_ID%.*}-${ARCH}" - fi + TEST_CASE_SELECTOR="${DISTRO_CODE}-${ARCH}" pushd $IMAGE_TEST_CASES_PATH > /dev/null ls "$TEST_CASE_SELECTOR"*.json popd > /dev/null diff --git a/test/cases/koji.sh b/test/cases/koji.sh index b326fd6ae..8657e3069 100755 --- a/test/cases/koji.sh +++ b/test/cases/koji.sh @@ -16,13 +16,7 @@ function greenprint { /usr/libexec/osbuild-composer-test/provision.sh greenprint "Defining distro selector" -# if the distro is RHEL 8.4 the distro includes the minor release number -if [[ "${ID}-${VERSION_ID}" == "rhel-8.4" ]]; then - DISTRO_SELECTOR="${ID}-${VERSION_ID//.}" -# otherwise the minor release number can be dropped -else - DISTRO_SELECTOR="${ID}-${VERSION_ID%.*}" -fi +DISTRO_SELECTOR="${DISTRO_CODE//_/-}" greenprint "Starting containers" sudo /usr/libexec/osbuild-composer-test/run-koji-container.sh start diff --git a/test/cases/libvirt.sh b/test/cases/libvirt.sh index 7c6bd3aba..3977f9375 100644 --- a/test/cases/libvirt.sh +++ b/test/cases/libvirt.sh @@ -9,8 +9,12 @@ source /etc/os-release # Test the images /usr/libexec/osbuild-composer-test/libvirt_test.sh qcow2 -/usr/libexec/osbuild-composer-test/libvirt_test.sh openstack -/usr/libexec/osbuild-composer-test/libvirt_test.sh vhd + +#TODO: remove this condition once there is rhel9 support for openstack and vhd image types +if [[ $DISTRO_CODE != rhel_90 ]]; then + /usr/libexec/osbuild-composer-test/libvirt_test.sh openstack + /usr/libexec/osbuild-composer-test/libvirt_test.sh vhd +fi # RHEL 8.4 and Centos Stream 8 images also supports uefi, check that if [[ "${ID}-${VERSION_ID}" == "rhel-8.4" || "${ID}-${VERSION_ID}" == "centos-8" ]]; then diff --git a/tools/koji-compose.py b/tools/koji-compose.py index ff6c21901..0d91a4397 100755 --- a/tools/koji-compose.py +++ b/tools/koji-compose.py @@ -26,6 +26,19 @@ def compose_request(distro, koji, arch): test_repositories = json.load(f) repositories = [composer_repository_to_koji_repository(repo) for repo in test_repositories[arch]] + image_requests = [{ + "architecture": "x86_64", + "image_type": "qcow2", + "repositories": repositories + }] + + #TODO: Remove this condition once there is rhel9 support for AMI image type + if distro != "rhel-90": + image_requests.append({ + "architecture": "x86_64", + "image_type": "ami", + "repositories": repositories + }) req = { "name": "name", @@ -36,15 +49,7 @@ def compose_request(distro, koji, arch): "server": koji, "task_id": 1 }, - "image_requests": [{ - "architecture": "x86_64", - "image_type": "qcow2", - "repositories": repositories - },{ - "architecture": "x86_64", - "image_type": "ami", - "repositories": repositories - }] + "image_requests": image_requests } return req