debian-forge-composer/schutzbot/Jenkinsfile
Tom Gundersen 805ae59151 tests: ship all tests in the -tests sub-package
No tests should be run directly from git, but should rather be installed
onto the test system using rpm and run from there. This moves towards
unifying our two types of test cases.

The new structure of is now:

`test/cmd`:   the executors, one for each test-case. This is installed
              into `/usr/libexec/test/osbuild-composer`.
`test/data`:  data and config used by the tests. This is installed into
              `/usr/share/tests/osbuild-composer`.
`schutzbot`:  configuration of the actual test run. In particular, this
              is where the distros and repositories to test against are
              configured.

This is very much still work-in-progress, and is only the first step
towards simplifying schutzbot. Apart from moving files around, this
should be a noop.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-10-06 13:08:26 +02:00

618 lines
22 KiB
Groovy

pipeline {
agent none
environment {
AWS_REGION = "us-east-2"
AWS_BUCKET = "imagebuilder-jenkins-testing-use2"
}
options {
timestamps()
ansiColor('xterm')
// Cancel the pipeline if it runs for more than three hours.
timeout(
time: 3,
unit: "HOURS"
)
}
stages {
stage("Prepare 🤔") {
agent { label "schutzbot" }
options {
// Don't checkout the git repository here. It just clogs
// up the Jenkins disk space and does nothing for us.
skipDefaultCheckout()
}
steps {
sh (
label: "Get environment variables",
script: "env | sort"
)
}
}
stage("Mock build 👷🏻") {
// Halt the pipeline immediately if a single mock build fails.
// A failure to build an RPM is serious and must be
// investigated.
failFast true
parallel {
stage('F31') {
agent { label "f31cloudbase && x86_64 && aws" }
environment {
AWS_CREDS = credentials('aws-credentials-osbuildci')
AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test')
}
steps {
sh "schutzbot/ci_details.sh"
retry(3) {
sh "schutzbot/mockbuild.sh"
}
stash (
includes: 'osbuild-mock.repo',
name: 'fedora31'
)
}
}
stage('F32') {
agent { label "f32cloudbase && x86_64 && aws" }
environment {
AWS_CREDS = credentials('aws-credentials-osbuildci')
AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test')
}
steps {
sh "schutzbot/ci_details.sh"
retry(3) {
sh "schutzbot/mockbuild.sh"
}
stash (
includes: 'osbuild-mock.repo',
name: 'fedora32'
)
}
}
stage('EL8') {
agent { label "rhel8cloudbase && x86_64 && aws" }
environment {
AWS_CREDS = credentials('aws-credentials-osbuildci')
AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test')
RHN_REGISTRATION_SCRIPT = credentials('rhn-register-script-production')
}
steps {
sh "schutzbot/ci_details.sh"
retry(3) {
sh "schutzbot/mockbuild.sh"
}
stash (
includes: 'osbuild-mock.repo',
name: 'rhel8cdn'
)
}
}
stage('EL8.3') {
agent { label "rhel83cloudbase && x86_64 && aws" }
environment {
AWS_CREDS = credentials('aws-credentials-osbuildci')
AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test')
RHN_REGISTRATION_SCRIPT = credentials('rhn-register-script-production-beta')
}
steps {
sh "schutzbot/ci_details.sh"
retry(3) {
sh "schutzbot/mockbuild.sh"
}
stash (
includes: 'osbuild-mock.repo',
name: 'rhel83'
)
}
}
}
}
stage("Testing 🍌") {
parallel {
stage('F31 Base') {
agent { label "f31cloudbase && x86_64 && aws" }
environment { TEST_TYPE = "base" }
steps {
unstash 'fedora31'
run_tests('base')
}
post {
always {
preserve_logs('fedora31-base')
}
}
}
stage('F31 Image') {
agent { label "f31cloudbase && psi && x86_64" }
environment {
TEST_TYPE = "image"
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')
DISTRO_CODE = "fedora31"
}
steps {
unstash 'fedora31'
run_tests('image')
}
post {
always {
preserve_logs('fedora31-image')
}
}
}
stage('F31 Integration') {
agent { label "f31cloudbase && x86_64 && aws" }
environment {
TEST_TYPE = "integration"
AWS_CREDS = credentials('aws-credentials-osbuildci')
AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test')
}
steps {
unstash 'fedora31'
run_tests('integration')
}
post {
always {
preserve_logs('fedora31-integration')
}
}
}
stage('F32 Base') {
agent { label "f32cloudbase && x86_64 && aws" }
environment { TEST_TYPE = "base" }
steps {
unstash 'fedora32'
run_tests('base')
}
post {
always {
preserve_logs('fedora32-base')
}
}
}
stage('F32 Image') {
agent { label "f32cloudbase && psi && x86_64" }
environment {
TEST_TYPE = "image"
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')
DISTRO_CODE = "fedora32"
}
steps {
unstash 'fedora32'
run_tests('image')
}
post {
always {
preserve_logs('fedora32-image')
}
}
}
stage('F32 Integration') {
agent { label "f32cloudbase && x86_64 && aws" }
environment {
TEST_TYPE = "integration"
AWS_CREDS = credentials('aws-credentials-osbuildci')
AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test')
}
steps {
unstash 'fedora32'
run_tests('integration')
}
post {
always {
preserve_logs('fedora32-integration')
}
}
}
stage('F32 OSTree') {
agent { label "f32cloudbase && psi && x86_64" }
steps {
unstash 'fedora32'
run_tests('ostree')
}
post {
always {
preserve_logs('fedora32-ostree')
}
}
}
stage('EL8 Base') {
agent { label "rhel8cloudbase && x86_64 && aws" }
environment {
TEST_TYPE = "base"
RHN_REGISTRATION_SCRIPT = credentials('rhn-register-script-production')
}
steps {
unstash 'rhel8cdn'
run_tests('base')
}
post {
always {
preserve_logs('rhel8-base')
}
}
}
stage('EL8 Image') {
agent { label "rhel8cloudbase && psi && x86_64" }
environment {
TEST_TYPE = "image"
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")
RHN_REGISTRATION_SCRIPT = credentials('rhn-register-script-production')
VCENTER_CREDS = credentials('vmware-vcenter-credentials')
DISTRO_CODE = "rhel8"
}
steps {
unstash 'rhel8cdn'
run_tests('image')
}
post {
always {
preserve_logs('rhel8-image')
}
}
}
stage('EL8 Integration') {
agent { label "rhel8cloudbase && x86_64 && psi" }
environment {
TEST_TYPE = "integration"
AWS_CREDS = credentials('aws-credentials-osbuildci')
AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test')
RHN_REGISTRATION_SCRIPT = credentials('rhn-register-script-production')
}
steps {
unstash 'rhel8cdn'
run_tests('integration')
}
post {
always {
preserve_logs('rhel8-integration')
}
}
}
stage('EL8.3 Base') {
agent { label "rhel83cloudbase && x86_64 && aws" }
environment {
TEST_TYPE = "base"
RHN_REGISTRATION_SCRIPT = credentials('rhn-register-script-production-beta')
}
steps {
unstash 'rhel83'
run_tests('base')
}
post {
always {
preserve_logs('rhel83-base')
}
}
}
stage('EL8.3 Image') {
agent { label "rhel83cloudbase && psi && x86_64" }
environment {
TEST_TYPE = "image"
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")
RHN_REGISTRATION_SCRIPT = credentials('rhn-register-script-production-beta')
VCENTER_CREDS = credentials('vmware-vcenter-credentials')
DISTRO_CODE = "rhel83"
}
steps {
unstash 'rhel83'
run_tests('image')
}
post {
always {
preserve_logs('rhel83-image')
}
}
}
stage('EL8.3 Integration') {
agent { label "rhel83cloudbase && x86_64 && psi" }
environment {
TEST_TYPE = "integration"
AWS_CREDS = credentials('aws-credentials-osbuildci')
AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test')
RHN_REGISTRATION_SCRIPT = credentials('rhn-register-script-production-beta')
}
steps {
unstash 'rhel83'
run_tests('integration')
}
post {
always {
preserve_logs('rhel83-integration')
}
}
}
stage('EL8.3 OSTree') {
agent { label "rhel83cloudbase && psi && x86_64" }
steps {
unstash 'rhel83'
run_tests('ostree')
}
post {
always {
preserve_logs('rhel83-ostree')
}
}
}
}
}
}
post {
success {
node('schutzbot') {
script {
if (env.BRANCH_NAME == 'master') {
telegramSend "💚 CI passed for osbuild-composer master branch ${env.BUILD_URL}"
}
}
}
}
unsuccessful {
node('schutzbot') {
script {
if (env.BRANCH_NAME == 'master') {
telegramSend "💣 CI failed for osbuild-composer master branch ${env.BUILD_URL}"
}
}
}
}
}
}
pipeline {
// test against RHEL nightly builds
agent none
// TODO: do we need to disable triggering via GitHub pull requests ???
triggers {
cron('@daily')
}
environment {
AWS_REGION = "us-east-2"
AWS_BUCKET = "imagebuilder-jenkins-testing-use2"
}
options {
timestamps()
ansiColor('xterm')
// Cancel the pipeline if it runs for more than three hours.
timeout(
time: 3,
unit: "HOURS"
)
}
stages {
stage("Prepare 🤔") {
agent { label "schutzbot" }
options {
// Don't checkout the git repository here. It just clogs
// up the Jenkins disk space and does nothing for us.
skipDefaultCheckout()
}
steps {
sh (
label: "Get environment variables",
script: "env | sort"
)
// don't build, use RPMs from the nightly trees
sh "schutzbot/prepare-rhel-nightly.sh"
stash (
includes: 'osbuild-mock.repo',
name: 'rhel8nightly'
)
stash (
includes: 'rhel-8.json',
name: 'rhel8json'
)
stash (
includes: 'rhel-8-beta.json',
name: 'rhel8betajson'
)
stash (
includes: 'COMPOSE_ID',
name: 'compose_id'
)
}
}
stage("Testing 🍌") {
parallel {
stage('EL8 Base') {
agent { label "rhel8cloudbase && psi && x86_64" }
environment {
TEST_TYPE = "base"
}
steps {
unstash 'rhel8nightly'
unstash 'rhel8json'
unstash 'rhel8betajson'
run_tests('dummy-base')
}
post {
always {
preserve_logs('rhel8-base')
}
}
}
stage('EL8 Image') {
agent { label "rhel8cloudbase && psi && x86_64" }
environment {
TEST_TYPE = "image"
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 {
unstash 'rhel8nightly'
unstash 'rhel8json'
unstash 'rhel8betajson'
run_tests('dummy-image')
}
post {
always {
preserve_logs('rhel8-image')
}
}
}
stage('EL8 Integration') {
agent { label "rhel8cloudbase && psi && x86_64" }
environment {
TEST_TYPE = "integration"
AWS_CREDS = credentials('aws-credentials-osbuildci')
AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test')
}
steps {
unstash 'rhel8nightly'
unstash 'rhel8json'
unstash 'rhel8betajson'
run_tests('dummy-integration')
}
post {
always {
preserve_logs('rhel8-integration')
}
}
}
}
}
}
//TODO: send messages via Email too
// TODO: how do we make the contents of COMPOSE_ID available as env.COMPOSE_ID
post {
success {
node('schutzbot') {
script {
telegramSend "💚 CI passed for ${env.COMPOSE_ID} see ${env.BUILD_URL}"
}
}
}
unsuccessful {
node('schutzbot') {
script {
telegramSend "💣 CI failed for ${env.COMPOSE_ID} see ${env.BUILD_URL}"
}
}
}
}
}
// Set up a function to hold the steps needed to run the tests so we don't
// need to copy/paste the same lines over and over above.
void run_tests(test_type) {
// Get CI machine details.
sh (
label: "Get CI machine details",
script: "schutzbot/ci_details.sh"
)
// Deploy the Image Builder packages and services.
sh (
label: "Deploy",
script: "schutzbot/deploy.sh"
)
// Run the base tests.
if (test_type == 'base') {
sh (
label: "Base tests",
script: "schutzbot/run_base_tests.sh"
)
}
if (test_type == 'image') {
sh (
label: "Image tests",
script: "schutzbot/run_image_tests.sh"
)
}
if (test_type == 'ostree') {
sh (
label: "OSTree tests",
script: "/usr/libexec/tests/osbuild-composer/ostree.sh"
)
}
if (test_type == 'integration') {
// Run Koji tests.
sh (
label: "Koji tests",
script: "/usr/libexec/tests/osbuild-composer/koji.sh"
)
// Run the qcow2 test.
sh (
label: "Integration test: QCOW2",
script: "/usr/libexec/tests/osbuild-composer/qemu.sh qcow2"
)
// Run the openstack test.
sh (
label: "Integration test: OpenStack",
script: "/usr/libexec/tests/osbuild-composer/qemu.sh openstack"
)
// Run the VHD/Azure test.
sh (
label: "Integration test: VHD",
script: "/usr/libexec/tests/osbuild-composer/qemu.sh vhd"
)
// Run the AWS test.
sh (
label: "Integration test: AWS",
script: "/usr/libexec/tests/osbuild-composer/aws.sh"
)
}
}
// Move logs to a unique location and tell Jenkins to capture them on success
// or failure.
void preserve_logs(test_slug) {
// Save the systemd journal.
sh "journalctl --boot > systemd-journald.log"
// Make a directory for the log files and move the logs there.
sh "mkdir ${test_slug} && mv *.log *.jpg ${test_slug}/ || true"
// Artifact the logs.
archiveArtifacts (
allowEmptyArchive: true,
artifacts: "${test_slug}/*.log,${test_slug}/*.jpg"
)
}