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
This commit is contained in:
Jozef Mikovic 2021-03-23 11:57:45 +01:00 committed by Tom Gundersen
parent af1a2b5cd4
commit 165ecafeb2
7 changed files with 94 additions and 37 deletions

73
schutzbot/Jenkinsfile vendored
View file

@ -277,7 +277,7 @@ pipeline {
agent { label "f32cloudbase && psi && x86_64" } agent { label "f32cloudbase && psi && x86_64" }
environment { environment {
TEST_TYPE = "image" TEST_TYPE = "image"
DISTRO_CODE = "fedora32" DISTRO_CODE = "fedora_32"
AWS_CREDS = credentials('aws-credentials-osbuildci') AWS_CREDS = credentials('aws-credentials-osbuildci')
AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test') AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test')
AZURE_CREDS = credentials('azure') AZURE_CREDS = credentials('azure')
@ -308,7 +308,7 @@ pipeline {
agent { label "f32cloudbase && x86_64 && aws" } agent { label "f32cloudbase && x86_64 && aws" }
environment { environment {
TEST_TYPE = "integration" TEST_TYPE = "integration"
DISTRO_CODE = "fedora32" DISTRO_CODE = "fedora_32"
AWS_CREDS = credentials('aws-credentials-osbuildci') AWS_CREDS = credentials('aws-credentials-osbuildci')
AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test') AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test')
AWS_API_TEST_SHARE_ACCOUNT = credentials('aws-credentials-share-account') AWS_API_TEST_SHARE_ACCOUNT = credentials('aws-credentials-share-account')
@ -372,7 +372,7 @@ pipeline {
agent { label "f33cloudbase && psi && x86_64" } agent { label "f33cloudbase && psi && x86_64" }
environment { environment {
TEST_TYPE = "image" TEST_TYPE = "image"
DISTRO_CODE = "fedora33" DISTRO_CODE = "fedora_33"
AWS_CREDS = credentials('aws-credentials-osbuildci') AWS_CREDS = credentials('aws-credentials-osbuildci')
AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test') AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test')
AZURE_CREDS = credentials('azure') AZURE_CREDS = credentials('azure')
@ -403,7 +403,7 @@ pipeline {
agent { label "f33cloudbase && x86_64 && aws" } agent { label "f33cloudbase && x86_64 && aws" }
environment { environment {
TEST_TYPE = "integration" TEST_TYPE = "integration"
DISTRO_CODE = "fedora33" DISTRO_CODE = "fedora_33"
AWS_CREDS = credentials('aws-credentials-osbuildci') AWS_CREDS = credentials('aws-credentials-osbuildci')
AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test') AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test')
AWS_API_TEST_SHARE_ACCOUNT = credentials('aws-credentials-share-account') AWS_API_TEST_SHARE_ACCOUNT = credentials('aws-credentials-share-account')
@ -467,7 +467,7 @@ pipeline {
agent { label "f33cloudbase && aarch64 && aws" } agent { label "f33cloudbase && aarch64 && aws" }
environment { environment {
TEST_TYPE = "image" TEST_TYPE = "image"
DISTRO_CODE = "fedora33" DISTRO_CODE = "fedora_33"
AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test') AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test')
AZURE_CREDS = credentials('azure') AZURE_CREDS = credentials('azure')
OPENSTACK_CREDS = credentials("psi-openstack-creds") OPENSTACK_CREDS = credentials("psi-openstack-creds")
@ -537,7 +537,7 @@ pipeline {
agent { label "rhel8cloudbase && psi && x86_64" } agent { label "rhel8cloudbase && psi && x86_64" }
environment { environment {
TEST_TYPE = "image" TEST_TYPE = "image"
DISTRO_CODE = "rhel8" DISTRO_CODE = "rhel_8"
AWS_CREDS = credentials('aws-credentials-osbuildci') AWS_CREDS = credentials('aws-credentials-osbuildci')
AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test') AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test')
AZURE_CREDS = credentials('azure') AZURE_CREDS = credentials('azure')
@ -569,7 +569,7 @@ pipeline {
agent { label "rhel8cloudbase && x86_64 && psi" } agent { label "rhel8cloudbase && x86_64 && psi" }
environment { environment {
TEST_TYPE = "integration" TEST_TYPE = "integration"
DISTRO_CODE = "rhel8" DISTRO_CODE = "rhel_8"
AWS_CREDS = credentials('aws-credentials-osbuildci') AWS_CREDS = credentials('aws-credentials-osbuildci')
AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test') AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test')
RHN_REGISTRATION_SCRIPT = credentials('rhn-register-script-production') RHN_REGISTRATION_SCRIPT = credentials('rhn-register-script-production')
@ -669,7 +669,7 @@ pipeline {
agent { label "rhel84cloudbase && psi && x86_64" } agent { label "rhel84cloudbase && psi && x86_64" }
environment { environment {
TEST_TYPE = "image" TEST_TYPE = "image"
DISTRO_CODE = "rhel84" DISTRO_CODE = "rhel_84"
AWS_CREDS = credentials('aws-credentials-osbuildci') AWS_CREDS = credentials('aws-credentials-osbuildci')
AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test') AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test')
AZURE_CREDS = credentials('azure') AZURE_CREDS = credentials('azure')
@ -693,7 +693,7 @@ pipeline {
agent { label "rhel84cloudbase && x86_64 && psi" } agent { label "rhel84cloudbase && x86_64 && psi" }
environment { environment {
TEST_TYPE = "integration" TEST_TYPE = "integration"
DISTRO_CODE = "rhel84" DISTRO_CODE = "rhel_84"
AWS_CREDS = credentials('aws-credentials-osbuildci') AWS_CREDS = credentials('aws-credentials-osbuildci')
AWS_API_TEST_SHARE_ACCOUNT = credentials('aws-credentials-share-account') AWS_API_TEST_SHARE_ACCOUNT = credentials('aws-credentials-share-account')
AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test') 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') { stage('CS8 Base') {
when { when {
beforeAgent true beforeAgent true
@ -770,7 +819,7 @@ pipeline {
agent { label "cs8cloudbase && psi && x86_64" } agent { label "cs8cloudbase && psi && x86_64" }
environment { environment {
TEST_TYPE = "image" TEST_TYPE = "image"
DISTRO_CODE = "centos-stream8" DISTRO_CODE = "centos_8"
AWS_CREDS = credentials('aws-credentials-osbuildci') AWS_CREDS = credentials('aws-credentials-osbuildci')
AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test') AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test')
AZURE_CREDS = credentials('azure') AZURE_CREDS = credentials('azure')
@ -801,7 +850,7 @@ pipeline {
agent { label "cs8cloudbase && x86_64 && aws" } agent { label "cs8cloudbase && x86_64 && aws" }
environment { environment {
TEST_TYPE = "integration" TEST_TYPE = "integration"
DISTRO_CODE = "centos-stream8" DISTRO_CODE = "centos_8"
AWS_CREDS = credentials('aws-credentials-osbuildci') AWS_CREDS = credentials('aws-credentials-osbuildci')
AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test') AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test')
AWS_API_TEST_SHARE_ACCOUNT = credentials('aws-credentials-share-account') AWS_API_TEST_SHARE_ACCOUNT = credentials('aws-credentials-share-account')
@ -860,7 +909,7 @@ pipeline {
AZURE_CREDS = credentials('azure') AZURE_CREDS = credentials('azure')
OPENSTACK_CREDS = credentials("psi-openstack-creds") OPENSTACK_CREDS = credentials("psi-openstack-creds")
VCENTER_CREDS = credentials('vmware-vcenter-credentials') VCENTER_CREDS = credentials('vmware-vcenter-credentials')
DISTRO_CODE = "centos-stream8" DISTRO_CODE = "centos_8"
} }
steps { steps {
run_tests('image') run_tests('image')

View file

@ -14,6 +14,11 @@
set -euxo pipefail 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. # Provision the software under tet.

View file

@ -10,6 +10,12 @@ function greenprint {
echo -e "\033[1;32m${1}\033[0m" 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. # Provision the software under tet.
/usr/libexec/osbuild-composer-test/provision.sh /usr/libexec/osbuild-composer-test/provision.sh

View file

@ -25,13 +25,7 @@ test_divider () {
# Get a list of test cases. # Get a list of test cases.
get_test_cases () { get_test_cases () {
# if the distro is RHEL 8.4 the test case selector needs the minor release number TEST_CASE_SELECTOR="${DISTRO_CODE}-${ARCH}"
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
pushd $IMAGE_TEST_CASES_PATH > /dev/null pushd $IMAGE_TEST_CASES_PATH > /dev/null
ls "$TEST_CASE_SELECTOR"*.json ls "$TEST_CASE_SELECTOR"*.json
popd > /dev/null popd > /dev/null

View file

@ -16,13 +16,7 @@ function greenprint {
/usr/libexec/osbuild-composer-test/provision.sh /usr/libexec/osbuild-composer-test/provision.sh
greenprint "Defining distro selector" greenprint "Defining distro selector"
# if the distro is RHEL 8.4 the distro includes the minor release number DISTRO_SELECTOR="${DISTRO_CODE//_/-}"
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
greenprint "Starting containers" greenprint "Starting containers"
sudo /usr/libexec/osbuild-composer-test/run-koji-container.sh start sudo /usr/libexec/osbuild-composer-test/run-koji-container.sh start

View file

@ -9,8 +9,12 @@ source /etc/os-release
# Test the images # Test the images
/usr/libexec/osbuild-composer-test/libvirt_test.sh qcow2 /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 # 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 if [[ "${ID}-${VERSION_ID}" == "rhel-8.4" || "${ID}-${VERSION_ID}" == "centos-8" ]]; then

View file

@ -26,6 +26,19 @@ def compose_request(distro, koji, arch):
test_repositories = json.load(f) test_repositories = json.load(f)
repositories = [composer_repository_to_koji_repository(repo) for repo in test_repositories[arch]] 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 = { req = {
"name": "name", "name": "name",
@ -36,15 +49,7 @@ def compose_request(distro, koji, arch):
"server": koji, "server": koji,
"task_id": 1 "task_id": 1
}, },
"image_requests": [{ "image_requests": image_requests
"architecture": "x86_64",
"image_type": "qcow2",
"repositories": repositories
},{
"architecture": "x86_64",
"image_type": "ami",
"repositories": repositories
}]
} }
return req return req