← Back to team overview

sts-sponsors team mailing list archive

[Merge] ~lloydwaltersj/maas-ci/+git/maas-ci-config:add-os-testing into ~maas-committers/maas-ci/+git/maas-ci-config:master

 

Jack Lloyd-Walters has proposed merging ~lloydwaltersj/maas-ci/+git/maas-ci-config:add-os-testing into ~maas-committers/maas-ci/+git/maas-ci-config:master.

Commit message:
Add initial Jenkins job for the automated image tests

Requested reviews:
  MAAS Committers (maas-committers)

For more details, see:
https://code.launchpad.net/~lloydwaltersj/maas-ci/+git/maas-ci-config/+merge/442847
-- 
Your team MAAS Committers is requested to review the proposed merge of ~lloydwaltersj/maas-ci/+git/maas-ci-config:add-os-testing into ~maas-committers/maas-ci/+git/maas-ci-config:master.
diff --git a/jenkins/jobs/ansible_collection.groovy b/jenkins/jobs/ansible_collection.groovy
index a54af91..d9fd448 100644
--- a/jenkins/jobs/ansible_collection.groovy
+++ b/jenkins/jobs/ansible_collection.groovy
@@ -70,7 +70,7 @@ pipeline {
                     env.COMMIT_SHA = sh(script: "git ls-remote ${params.GH_REPO} ${params.GH_BRANCH} | awk \'{print \$1}\'", returnStdout: true).trim()
                     println "commit: ${env.COMMIT_SHA}"
                 }
-                updateCommitStatus(params.TARGET_REPO, env.COMMIT_SHA, "PENDING", "Tests Executing, Awaiting results")
+                updateCommitStatus(env.GH_REPO, env.COMMIT_SHA, "PENDING", "Tests Executing, Awaiting results")
             }
         }
         stage('Install Dependencies') {
@@ -184,7 +184,7 @@ pipeline {
             }    
         }
         success {
-            updateCommitStatus(params.TARGET_REPO, env.COMMIT_SHA, "SUCCESS", "Success")
+            updateCommitStatus(env.GH_REPO, env.COMMIT_SHA, "SUCCESS", "Success")
         }
         failure {
             script {
@@ -192,7 +192,7 @@ pipeline {
                     mattermostSend (color: 'red', message: "[${env.JOB_NAME} #${env.BUILD_NUMBER}](${env.BUILD_URL}) [${params.GH_BRANCH}](${params.GH_REPO}/commit/${env.COMMIT_SHA}) :fire: failed")
                 }
             }
-            updateCommitStatus(params.TARGET_REPO, env.COMMIT_SHA, "FAILURE", "Failed")
+            updateCommitStatus(env.GH_REPO, env.COMMIT_SHA, "FAILURE", "Failed")
         }    
     }
 }
diff --git a/jenkins/jobs/ansible_collection.yaml b/jenkins/jobs/ansible_collection.yaml
index 2487e28..bff14f5 100644
--- a/jenkins/jobs/ansible_collection.yaml
+++ b/jenkins/jobs/ansible_collection.yaml
@@ -14,7 +14,7 @@
     parameters:
       - string:
           name: TARGET_REPO
-          description: Git repo to merge Ansible Collections into
+          description: Git repo url to merge Ansible Collections into
           default: https://github.com/maas/ansible-collection
       - string:
           name: JOB_NAME
@@ -32,17 +32,13 @@
     parameters:
       - string:
           name: GH_REPO
-          description: 'Github repo to clone'
-          default: 'ansible-collection'
+          description: 'Github url of the repo to clone'
+          default: 'https://github.com/maas/ansible-collection'
       - string:
           name: GH_BRANCH
           description: 'Github branch to clone'
           default: 'main'
       - string:
-          name: GH_ORG
-          description: 'Github org that owns the repo to clone'
-          default: 'maas'
-      - string:
           name: SERIES
           description: 'The Ubuntu series to build and with'
           default: '22.04'
diff --git a/jenkins/jobs/automated_image_tests.groovy b/jenkins/jobs/automated_image_tests.groovy
new file mode 100644
index 0000000..da33ffa
--- /dev/null
+++ b/jenkins/jobs/automated_image_tests.groovy
@@ -0,0 +1,61 @@
+pipeline {
+    agent {
+        label 'ci-lab'
+    }
+    options {
+        timeout(time: 6, unit: "HOURS")
+    }
+    stages {
+        stage('Checkout') {
+            steps {
+                sh """
+                rm -rf system-tests
+                git clone ${params.SYSTEMTEST_REPO} --branch ${params.SYSTEMTEST_BRANCH} --depth 1 system-tests
+                env -C system-tests git show --no-patch
+                """
+            }
+        }
+        stage('Setup') {
+            steps {
+                sh """
+                sudo apt-get install -y tox
+                """
+            }
+        }
+        stage('System Tests') {
+            steps {
+                writeFile file: 'system-tests/config.yaml', text: """
+                proxy:
+                    http: http://squid.internal:3128
+                containers-image: ${params.CONTAINERS_IMAGE}
+                image-tests:
+                    temporal-namespace: ${params.TEMPORAL_NAMESPACE}
+                    temporal-ip: ${params.TEMPORAL_IP}
+                    to-test: ${params.TEST_IMAGES}
+                """
+                dir("system-tests") {
+                    sh """
+                    cat config.yaml
+                    export http_proxy=http://squid.internal:3128/
+                    export https_proxy=http://squid.internal:3128/
+                    tox r -e cog
+                    tox r -e image_tests -- ${params.PYTEST_ARGS}
+                    """
+                }
+            }
+        }
+    }
+    post {
+        always {
+            archiveArtifacts artifacts:'system-tests/*.log,system-tests/config.yaml,system-tests/junit*.xml', fingerprint: true
+            junit allowEmptyResults: true, testResults: 'system-tests/junit*.xml'
+        }
+        failure {
+            script {
+                if (params.GITHUB_BRANCH == "main" && currentBuild.getBuildCauses("hudson.triggers.TimerTrigger$TimerTriggerCause")) {
+                    // mattermostSend (color: 'red', message: "[${env.JOB_NAME} #${env.BUILD_NUMBER}](${env.BUILD_URL}) :fire: failed")
+                }
+            }
+        }
+    }
+}
diff --git a/jenkins/jobs/automated_image_tests.yaml b/jenkins/jobs/automated_image_tests.yaml
new file mode 100644
index 0000000..4b46f4e
--- /dev/null
+++ b/jenkins/jobs/automated_image_tests.yaml
@@ -0,0 +1,42 @@
+- project:
+    name: automated-os-image-tests
+    jobs:
+      - automated-image-tests
+
+- job-template:
+    name: automated-image-tests
+    description: |
+      Automatically test MAAS Images and send the results to an external useful location
+    project-type: pipeline
+    parameters:
+      - string:
+          name: SYSTEMTEST_REPO
+          description: Git repo to pull system tests from
+          default: https://git.launchpad.net/~maas-committers/maas-ci/+git/system-tests
+      - string:
+          name: SYSTEMTEST_BRANCH
+          description: Branch in the repo to use
+          default: master
+      - string:
+          name: PYTEST_ARGS
+          description: Additional args to pytest
+          default: --log-cli-level info
+      - string:
+          name: CONTAINERS_IMAGE
+          description: LXD image for containers used in tests
+          default: ubuntu:22.04
+      - string:
+          name: TEMPORAL_NAMESPACE
+          description: The namespace temporal is using to segregate these tests.
+          default: default
+      - string:
+          name: TEMPORAL_IP
+          description: The IP address of our temporal server to run the workflows on.
+          default: 10.245.136.157
+      - string:
+          name: TEST_IMAGES
+          description: Comma-seperated list of images to test
+          default: ubuntu:22.10,ubuntu:22.04
+    triggers:
+      - timed: '@midnight'
+    dsl: !include-jinja2: automated_image_tests.groovy

Follow ups