Skip to content

Commit

Permalink
Add new pipeline to test triggering basic e2e from prow
Browse files Browse the repository at this point in the history
Signed-off-by: Mohammed Boukhalfa <mohammed.boukhalfa@est.tech>
  • Loading branch information
mboukhalfa committed Feb 28, 2024
1 parent 9373c6e commit 566e17d
Show file tree
Hide file tree
Showing 2 changed files with 177 additions and 0 deletions.
167 changes: 167 additions & 0 deletions jenkins/jobs/prow_integration_tests.pipeline
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
import java.text.SimpleDateFormat

// 10 minutes
def CLEAN_TIMEOUT = 600
// 2 hours
def TIMEOUT = 7200
KEEP_TEST_ENV=(env.KEEP_TEST_ENV)
KUBECTL_SHA256=(env.KUBECTL_SHA256)

script {
def UPDATED_REPO = "https://github.com/${env.REPO_OWNER}/${env.REPO_NAME}.git"
echo "Checkout ${UPDATED_REPO} main"
// Set defaults for non-PR jobs
def pullSha = (env.PULL_PULL_SHA) ?: "main"
def ci_git_url = "https://github.com/metal3-io/project-infra.git"
def ci_git_branch = "main"
// Fetch the main branch and the pullSha, nothing else
def refspec = '+refs/heads/main:refs/remotes/origin/main ' + pullSha
def date = new Date()
def dateFormat = new SimpleDateFormat("yyyyMMddHHmmss")
def rand = new Random()
VM_KEY = (1..4).collect { ('a'..'z').join("")[ rand.nextInt( 26 ) ] }.join("")

if ("${KEEP_TEST_ENV}" == "true") {
VM_NAME = "ci-test-keep-vm-" + dateFormat.format(date) + "-" + VM_KEY
} else {
VM_NAME = "ci-test-vm-" + dateFormat.format(date) + "-" + VM_KEY
}
}

pipeline {
agent { label 'metal3-static-workers' }
environment {
METAL3_CI_USER="metal3ci"
// these defined in the job project
REPO_ORG = "${PROJECT_REPO_ORG}"
REPO_NAME = "${PROJECT_REPO_NAME}"
// these coming from the prow env vars
UPDATED_REPO = "${env.REPO_NAME}"
REPO_BRANCH = "${env.PULL_BASE_REF}"
UPDATED_BRANCH = "${env.PULL_PULL_SHA}"
OS_USERNAME="metal3ci"
OS_AUTH_URL="https://kna1.citycloud.com:5000"
OS_USER_DOMAIN_NAME="CCP_Domain_37137"
OS_PROJECT_DOMAIN_NAME="CCP_Domain_37137"
OS_REGION_NAME="Kna1"
OS_PROJECT_NAME="Default Project 37137"
OS_TENANT_NAME="Default Project 37137"
OS_AUTH_VERSION=3
OS_IDENTITY_API_VERSION=3
TEST_EXECUTER_VM_NAME = "${VM_NAME}"
BUILD_TAG = "${env.BUILD_TAG}"
PR_ID = "${env.PULL_NUMBER}"
IMAGE_OS = "${IMAGE_OS}"
CAPI_VERSION = "${CAPI_VERSION}"
CAPIRELEASE = "${CAPIRELEASE}"
CAPM3_VERSION = "${CAPM3_VERSION}"
CAPM3RELEASEBRANCH = "${capm3_release_branch}"
CAPM3RELEASE = "${CAPM3RELEASE}"
BMORELEASEBRANCH = "${bmo_release_branch}"
TARGET_NODE_MEMORY = "${TARGET_NODE_MEMORY}"
NUM_NODES="${NUM_NODES}"
TESTS_FOR="${TESTS_FOR}"
KEEP_TEST_ENV="${KEEP_TEST_ENV}"
GINKGO_FOCUS="${GINKGO_FOCUS}"
GINKGO_SKIP="${GINKGO_SKIP}"
EPHEMERAL_TEST="${EPHEMERAL_TEST}"
IRONIC_INSTALL_TYPE="${params.IRONIC_INSTALL_TYPE}"
IRONIC_USE_MARIADB="${params.IRONIC_USE_MARIADB}"
BUILD_MARIADB_IMAGE_LOCALLY="${params.BUILD_MARIADB_IMAGE_LOCALLY}"
UPGRADE_FROM_RELEASE="${UPGRADE_FROM_RELEASE}"
KUBERNETES_VERSION_UPGRADE_FROM="${KUBERNETES_VERSION_UPGRADE_FROM}"
KUBERNETES_VERSION_UPGRADE_TO="${KUBERNETES_VERSION_UPGRADE_TO}"
KUBECTL_SHA256="${KUBECTL_SHA256}"
}
stages {
stage('SCM') {
options {
timeout(time: 5, unit: 'MINUTES')
}
steps {
/* Checkout CI Repo */
checkout([$class: 'GitSCM',
branches: [[name: ci_git_branch]],
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'WipeWorkspace'],
[$class: 'CleanCheckout'],
[$class: 'CleanBeforeCheckout']],
submoduleCfg: [],
userRemoteConfigs: [[credentialsId: ci_git_credential_id,
url: ci_git_url]]])
script {
CURRENT_START_TIME = System.currentTimeMillis()
}
}
}
stage('Run integration test') {
options {
timeout(time: TIMEOUT, unit: 'SECONDS')
}
steps {
withCredentials([usernamePassword(credentialsId: 'metal3ci_city_cloud_openstack_credentials', usernameVariable: 'OS_USERNAME', passwordVariable: 'OS_PASSWORD')]) {
withCredentials([sshUserPrivateKey(credentialsId: 'metal3ci_city_cloud_ssh_keypair', keyFileVariable: 'METAL3_CI_USER_KEY')]) {
withCredentials([string(credentialsId: 'metal3-clusterctl-github-token', variable: 'GITHUB_TOKEN')]) {
ansiColor('xterm') {
timestamps {
sh "./jenkins/scripts/integration_test.sh"
}
}
}
}
}
}
post {
always {
script {
CURRENT_END_TIME = System.currentTimeMillis()
if ((((CURRENT_END_TIME - CURRENT_START_TIME)/1000) - TIMEOUT) > 0) {
echo "Failed due to timeout"
currentBuild.result = 'FAILURE'
}
}
withCredentials([usernamePassword(credentialsId: 'metal3ci_city_cloud_openstack_credentials', usernameVariable: 'OS_USERNAME', passwordVariable: 'OS_PASSWORD')]) {
withCredentials([sshUserPrivateKey(credentialsId: 'metal3ci_city_cloud_ssh_keypair', keyFileVariable: 'METAL3_CI_USER_KEY')]){
timestamps {
sh "./jenkins/scripts/fetch_logs.sh"
}
}
}
archiveArtifacts "logs-${env.BUILD_TAG}.tgz"
}
}
}
}
post {
success {
withCredentials([usernamePassword(credentialsId: 'metal3ci_city_cloud_openstack_credentials', usernameVariable: 'OS_USERNAME', passwordVariable: 'OS_PASSWORD')]) {
withCredentials([sshUserPrivateKey(credentialsId: 'metal3ci_city_cloud_ssh_keypair', keyFileVariable: 'METAL3_CI_USER_KEY')]){
script {
if ("${KEEP_TEST_ENV}" == "true") {
echo "Skipping environment clean up"
} else {
timestamps {
sh "./jenkins/scripts/integration_test_clean.sh"
}
}
}
}
}
}
cleanup {
withCredentials([usernamePassword(credentialsId: 'metal3ci_city_cloud_openstack_credentials', usernameVariable: 'OS_USERNAME', passwordVariable: 'OS_PASSWORD')]) {
withCredentials([sshUserPrivateKey(credentialsId: 'metal3ci_city_cloud_ssh_keypair', keyFileVariable: 'METAL3_CI_USER_KEY')]){
script {
if ("${KEEP_TEST_ENV}" == "true") {
echo "Skipping VM deletion"
} else {
timestamps {
sh "./jenkins/scripts/integration_delete.sh"
}
}
}
}
}
}
}
}
10 changes: 10 additions & 0 deletions prow/manifests/overlays/metal3/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1138,6 +1138,16 @@ presubmits:
value: "TRUE"
image: docker.io/golang:1.19
imagePullPolicy: Always
# name: {job_prefix}_{proj}_{capm3_target_branch}_e2e_basic_test_{image_os}
- name: metal3-capm3-main-e2e-basic-test-centos
branches:
- main
- release-1.6
agent: jenkins
# Don't run unless triggered to avoid wasting resources
always_run: false
# Until we have checked that it works, keep it optional
optional: true

metal3-io/community:
- name: markdownlint
Expand Down

0 comments on commit 566e17d

Please sign in to comment.