Skip to content

Commit

Permalink
Add Minitests for PS 8.0 Build Job (#2335)
Browse files Browse the repository at this point in the history
* Add Minitests for PS 8.0 Build Job

* PS80 Minitests review related changes

* PS80 conditional package-testing job and integration tests triggers based on minitests output
  • Loading branch information
panchal-yash authored Nov 14, 2023
1 parent b35b318 commit bcb8035
Showing 1 changed file with 140 additions and 12 deletions.
152 changes: 140 additions & 12 deletions ps/jenkins/percona-server-for-mysql-8.0.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ library changelog: false, identifier: 'lib@master', retriever: modernSCM([
remote: 'https://github.com/Percona-Lab/jenkins-pipelines.git'
]) _

import groovy.transform.Field

void installCli(String PLATFORM) {
sh """
set -o xtrace
Expand Down Expand Up @@ -63,7 +65,122 @@ void cleanUpWS() {
"""
}

def installDependencies(def nodeName) {
def aptNodes = ['min-buster-x64', 'min-bullseye-x64', 'min-bookworm-x64', 'min-bionic-x64', 'min-focal-x64', 'min-jammy-x64']
def yumNodes = ['min-ol-8-x64', 'min-centos-7-x64', 'min-ol-9-x64', 'min-amazon-2-x64']
try{
if (aptNodes.contains(nodeName)) {
if(nodeName == "min-buster-x64" || nodeName == "min-bullseye-x64" || nodeName == "min-bookworm-x64"){
sh '''
sudo apt-get update
sudo apt-get install -y ansible git wget
'''
}else if(nodeName == "min-bionic-x64" || nodeName == "min-focal-x64" || nodeName == "min-jammy-x64"){
sh '''
sudo apt-get update
sudo apt-get install -y software-properties-common
sudo apt-add-repository --yes --update ppa:ansible/ansible
sudo apt-get install -y ansible git wget
'''
}else {
error "Node Not Listed in APT"
}
} else if (yumNodes.contains(nodeName)) {

if(nodeName == "min-centos-7-x64" || nodeName == "min-ol-9-x64"){
sh '''
sudo yum install -y epel-release
sudo yum -y update
sudo yum install -y ansible git wget tar
'''
}else if(nodeName == "min-ol-8-x64"){
sh '''
sudo yum install -y epel-release
sudo yum -y update
sudo yum install -y ansible-2.9.27 git wget tar
'''
}else if(nodeName == "min-amazon-2-x64"){
sh '''
sudo amazon-linux-extras install epel
sudo yum -y update
sudo yum install -y ansible git wget
'''
}
else {
error "Node Not Listed in YUM"
}
} else {
echo "Unexpected node name: ${nodeName}"
}
} catch (Exception e) {
slackNotify("${SLACKNOTIFY}", "#FF0000", "[${JOB_NAME}]: Server Provision for Mini Package Testing for ${nodeName} at ${BRANCH} FAILED !!")
}

}

def runPlaybook(def nodeName) {

def ps80_install_pkg_minitests_playbook = 'ps_80.yml'
def install_repo = 'testing'
def action_to_test = 'install'
def check_warnings = 'yes'
def install_mysql_shell = 'no'

try {
def playbook = "${ps80_install_pkg_minitests_playbook}"
def playbook_path = "package-testing/playbooks/${playbook}"

sh '''
set -xe
git clone --depth 1 https://github.com/Percona-QA/package-testing
'''
sh """
set -xe
export install_repo="\${install_repo}"
export client_to_test="ps80"
export check_warning="\${check_warnings}"
export install_mysql_shell="\${install_mysql_shell}"
ansible-playbook \
--connection=local \
--inventory 127.0.0.1, \
--limit 127.0.0.1 \
${playbook_path}
"""
} catch (Exception e) {
slackNotify("${SLACKNOTIFY}", "#FF0000", "[${JOB_NAME}]: Mini Package Testing for ${nodeName} at ${BRANCH} FAILED !!!")
mini_test_error="True"
}
}

def minitestNodes = [ "min-buster-x64",
"min-bullseye-x64",
"min-bookworm-x64",
"min-centos-7-x64",
"min-ol-8-x64",
"min-bionic-x64",
"min-focal-x64",
"min-amazon-2-x64",
"min-jammy-x64",
"min-ol-9-x64" ]

def package_tests_ps80(def nodes) {
def stepsForParallel = [:]
for (int i = 0; i < nodes.size(); i++) {
def nodeName = nodes[i]
stepsForParallel[nodeName] = {
stage("Minitest run on ${nodeName}") {
node(nodeName) {
installDependencies(nodeName)
runPlaybook(nodeName)
}
}
}
}
parallel stepsForParallel
}

def AWS_STASH_PATH
@Field def mini_test_error = "False"

pipeline {
agent {
Expand Down Expand Up @@ -102,6 +219,7 @@ parameters {
timestamps ()
}
stages {

stage('Create PS source tarball') {
agent {
label 'min-bionic-x64'
Expand Down Expand Up @@ -638,7 +756,6 @@ parameters {
slackNotify("${SLACKNOTIFY}", "#00FF00", "[${JOB_NAME}]: build has been finished successfully for ${BRANCH} - [${BUILD_URL}]")
slackNotify("${SLACKNOTIFY}", "#00FF00", "[${JOB_NAME}]: Triggering Builds for Package Testing for ${BRANCH} - [${BUILD_URL}]")
unstash 'properties'

script {
currentBuild.description = "Built on ${BRANCH}; path to packages: ${COMPONENT}/${AWS_STASH_PATH}"
REVISION = sh(returnStdout: true, script: "grep REVISION test/percona-server-8.0.properties | awk -F '=' '{ print\$2 }'").trim()
Expand All @@ -663,17 +780,28 @@ parameters {
"""
}
echo "Trigger Package Testing Job for PS"
build job: 'package-testing-ps80', propagate: false, wait: false, parameters: [string(name: 'product_to_test', value: 'ps80'),string(name: 'install_repo', value: "testing"),string(name: 'node_to_test', value: "all"),string(name: 'action_to_test', value: "all"),string(name: 'check_warnings', value: "yes"),string(name: 'install_mysql_shell', value: "no")]
echo "Trigger PMM_PS Github Actions Workflow"
withCredentials([string(credentialsId: 'GITHUB_API_TOKEN', variable: 'GITHUB_API_TOKEN')]) {
sh """
curl -i -v -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${GITHUB_API_TOKEN}" \
"https://api.github.com/repos/Percona-Lab/qa-integration/actions/workflows/PMM_PS.yaml/dispatches" \
-d '{"ref":"main","inputs":{"ps_version":"${PS_RELEASE}"}}'
"""
echo "Start Minitests for PS"

package_tests_ps80(minitestNodes)

if("${mini_test_error}" == "True"){
echo "NOT TRIGGERING PACKAGE TESTS AND INTEGRATION TESTS DUE TO MINITEST FAILURE !!"
}else{
echo "Trigger Package Testing Job for PS"

build job: 'package-testing-ps80', propagate: false, wait: false, parameters: [string(name: 'product_to_test', value: 'ps80'),string(name: 'install_repo', value: "testing"),string(name: 'node_to_test', value: "all"),string(name: 'action_to_test', value: "all"),string(name: 'check_warnings', value: "yes"),string(name: 'install_mysql_shell', value: "no")]

echo "Trigger PMM_PS Github Actions Workflow"

withCredentials([string(credentialsId: 'GITHUB_API_TOKEN', variable: 'GITHUB_API_TOKEN')]) {
sh """
curl -i -v -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${GITHUB_API_TOKEN}" \
"https://api.github.com/repos/Percona-Lab/qa-integration/actions/workflows/PMM_PS.yaml/dispatches" \
-d '{"ref":"main","inputs":{"ps_version":"${PS_RELEASE}"}}'
"""
}
}
}
deleteDir()
Expand Down

0 comments on commit bcb8035

Please sign in to comment.