Skip to content

Commit

Permalink
Add PS81 Support for Minitests and Package Testing Triggers
Browse files Browse the repository at this point in the history
Add git diff check for package-testing VERSION file modification for error free re-run of the build job during VERSION file commit (Similar to PXB80 setup)
  • Loading branch information
panchal-yash committed Nov 17, 2023
1 parent be486ae commit d6ae827
Showing 1 changed file with 141 additions and 47 deletions.
188 changes: 141 additions & 47 deletions ps/jenkins/percona-server-for-mysql-8.0.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,31 @@ def installDependencies(def nodeName) {
}

def runPlaybook(def nodeName) {
def PS_MAJOR_RELEASE = sh(returnStdout: true, script: ''' echo ${BRANCH} | sed "s/release-//g" | sed "s/\\.//g" | awk '{print substr($0, 0, 2)}' ''').trim()
echo "MAJOR VERSION IS ${PS_MAJOR_RELEASE}"
def ps80_install_pkg_minitests_playbook = 'ps_80.yml'

def ps80_install_pkg_minitests_playbook

if ("${PS8_RELEASE_VERSION}") { // Checks if PS8_RELEASE_VERSION is not empty
echo "MAJOR VERSION IS ${PS8_RELEASE_VERSION}"

if("${PS8_RELEASE_VERSION}" == "8.0"){
ps80_install_pkg_minitests_playbook = 'ps_80.yml'
PS8_RELEASE_VERSION_PRODUCT_TO_TEST = 'ps80'
}
else if("${PS8_RELEASE_VERSION}" == "8.1" ){
ps80_install_pkg_minitests_playbook = 'ps_81.yml'
PS8_RELEASE_VERSION_PRODUCT_TO_TEST = 'ps81'
}
}
else{
echo "Not Supported Version so NOT SETTING VALUES IN RUN PLAYBOOK !!!!!!! SHOULD FAIL"
}

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}"

Expand All @@ -148,7 +163,6 @@ def runPlaybook(def nodeName) {
--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"
Expand Down Expand Up @@ -183,7 +197,9 @@ def package_tests_ps80(def nodes) {
}

def AWS_STASH_PATH
@Field def PS8_RELEASE_VERSION
@Field def mini_test_error = "False"
@Field def PS8_RELEASE_VERSION_PRODUCT_TO_TEST

pipeline {
agent {
Expand Down Expand Up @@ -211,7 +227,7 @@ parameters {
description: 'Repo component to push packages to',
name: 'COMPONENT')
choice(
choices: '#dev-server-qa\n#releases\n#releases-ci',
choices: '#releases\n#releases-ci',
description: 'Channel for notifications',
name: 'SLACKNOTIFY')
}
Expand All @@ -222,7 +238,6 @@ parameters {
timestamps ()
}
stages {
/*
stage('Create PS source tarball') {
agent {
label 'min-bionic-x64'
Expand Down Expand Up @@ -682,26 +697,88 @@ parameters {
}
}
}
*/
stage('Testing') {
steps{
echo "Hello"
stage('Build docker containers') {
agent {
label 'min-bionic-x64'
}
steps {
echo "====> Build docker container"
cleanUpWS()
installCli("deb")
sh '''
sleep 900
'''
unstash 'properties'
sh '''
PS_RELEASE=$(echo ${BRANCH} | sed 's/release-//g')
PS_MAJOR_RELEASE=$(echo ${BRANCH} | sed "s/release-//g" | sed "s/\\.//g" | awk '{print substr($0, 0, 2)}');
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
sudo apt-get install -y docker.io
sudo systemctl status docker
sudo apt-get install -y qemu binfmt-support qemu-user-static
sudo docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
git clone https://github.com/percona/percona-docker
cd percona-docker/percona-server-8.0
sed -i "s/ENV PS_VERSION.*/ENV PS_VERSION ${PS_RELEASE}.${RPM_RELEASE}/g" Dockerfile
sed -i "s/ENV PS_REPO .*/ENV PS_REPO testing/g" Dockerfile
sed -i "s/percona-release enable ps-80/percona-release enable ps-${PS_MAJOR_RELEASE}/g" Dockerfile
sed -i "s/ENV PS_VERSION.*/ENV PS_VERSION ${PS_RELEASE}.${RPM_RELEASE}/g" Dockerfile.aarch64
sed -i "s/ENV PS_REPO .*/ENV PS_REPO testing/g" Dockerfile.aarch64
sed -i "s/percona-release enable ps-80/percona-release enable ps-${PS_MAJOR_RELEASE}/g" Dockerfile.aarch64
sudo docker build -t perconalab/percona-server:${PS_RELEASE}.${RPM_RELEASE} .
sudo docker build -t perconalab/percona-server:${PS_RELEASE}.${RPM_RELEASE}-aarch64 -f Dockerfile.aarch64 .
sudo docker images
'''
withCredentials([
usernamePassword(credentialsId: 'hub.docker.com',
passwordVariable: 'PASS',
usernameVariable: 'USER'
)]) {
sh '''
echo "${PASS}" | sudo docker login -u "${USER}" --password-stdin
PS_RELEASE=$(echo ${BRANCH} | sed 's/release-//g')
sudo docker tag perconalab/percona-server:${PS_RELEASE}.${RPM_RELEASE} perconalab/percona-server:${PS_RELEASE}
sudo docker push perconalab/percona-server:${PS_RELEASE}.${RPM_RELEASE}
sudo docker push perconalab/percona-server:${PS_RELEASE}
sudo docker tag perconalab/percona-server:${PS_RELEASE}.${RPM_RELEASE}-aarch64 perconalab/percona-server:${PS_RELEASE}-aarch64
sudo docker push perconalab/percona-server:${PS_RELEASE}.${RPM_RELEASE}-aarch64
sudo docker push perconalab/percona-server:${PS_RELEASE}-aarch64
'''
}
sh '''
PS_RELEASE=$(echo ${BRANCH} | sed 's/release-//g')
sudo docker manifest create perconalab/percona-server:${PS_RELEASE}.${RPM_RELEASE}-multi \
perconalab/percona-server:${PS_RELEASE}.${RPM_RELEASE} \
perconalab/percona-server:${PS_RELEASE}.${RPM_RELEASE}-aarch64
sudo docker manifest annotate perconalab/percona-server:${PS_RELEASE}.${RPM_RELEASE}-multi perconalab/percona-server:${PS_RELEASE}.${RPM_RELEASE}-aarch64 --os linux --arch arm64 --variant v8
sudo docker manifest annotate perconalab/percona-server:${PS_RELEASE}.${RPM_RELEASE}-multi perconalab/percona-server:${PS_RELEASE}.${RPM_RELEASE} --os linux --arch amd64
sudo docker manifest inspect perconalab/percona-server:${PS_RELEASE}.${RPM_RELEASE}-multi
'''
withCredentials([
usernamePassword(credentialsId: 'hub.docker.com',
passwordVariable: 'PASS',
usernameVariable: 'USER'
)]) {
sh '''
PS_RELEASE=$(echo ${BRANCH} | sed 's/release-//g')
echo "${PASS}" | sudo docker login -u "${USER}" --password-stdin
PS_RELEASE=$(echo ${BRANCH} | sed 's/release-//g')
sudo docker manifest push perconalab/percona-server:${PS_RELEASE}.${RPM_RELEASE}-multi
'''
}
}
}
}
post {
success {
/*
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()
PS_RELEASE = sh(returnStdout: true, script: "echo ${BRANCH} | sed 's/release-//g'").trim()
PS8_RELEASE_VERSION = sh(returnStdout: true, script: """ echo ${BRANCH} | sed -nE '/release-(8\\.0|8\\.1)\\..*/s//\\1/p' """).trim()
withCredentials([string(credentialsId: 'PXC_GITHUB_API_TOKEN', variable: 'TOKEN')]) {
sh """
Expand All @@ -710,41 +787,58 @@ parameters {
cd package-testing
git config user.name "jenkins-pxc-cd"
git config user.email "[email protected]"
OLD_REV=\$(cat VERSIONS | grep PS80_REV | cut -d '=' -f2- )
OLD_VER=\$(cat VERSIONS | grep PS80_VER | cut -d '=' -f2- )
sed -i s/PS80_REV=\$OLD_REV/PS80_REV='"'${REVISION}'"'/g VERSIONS
sed -i s/PS80_VER=\$OLD_VER/PS80_VER='"'${PS_RELEASE}'"'/g VERSIONS
echo "${PS8_RELEASE_VERSION} is the VALUE!!@!"
if [[ "${PS8_RELEASE_VERSION}" == "8.0" ]]; then
OLD_REV=\$(cat VERSIONS | grep PS80_REV | cut -d '=' -f2- )
OLD_VER=\$(cat VERSIONS | grep PS80_VER | cut -d '=' -f2- )
sed -i s/PS80_REV=\$OLD_REV/PS80_REV='"'${REVISION}'"'/g VERSIONS
sed -i s/PS80_VER=\$OLD_VER/PS80_VER='"'${PS_RELEASE}'"'/g VERSIONS
elif [[ "${PS8_RELEASE_VERSION}" == "8.1" ]];then
OLD_REV=\$(cat VERSIONS | grep PS81_REV | cut -d '=' -f2- )
OLD_VER=\$(cat VERSIONS | grep PS81_VER | cut -d '=' -f2- )
sed -i s/PS81_REV=\$OLD_REV/PS81_REV='"'${REVISION}'"'/g VERSIONS
sed -i s/PS81_VER=\$OLD_VER/PS81_VER='"'${PS_RELEASE}'"'/g VERSIONS
else
echo "INVALID PS8_RELEASE_VERSION VALUE: ${PS8_RELEASE_VERSION}"
fi
git diff
git add -A
git commit -m "Autocommit: add ${REVISION} and ${PS_RELEASE} for ps80 package testing VERSIONS file."
git push
if [[ -z \$(git diff) ]]; then
echo "No changes"
else
echo "There are changes"
git add -A
git commit -m "Autocommit: add ${REVISION} and ${PS_RELEASE} for ps80 ${PS8_RELEASE_VERSION} package testing VERSIONS file."
git push
fi
"""
}
*/
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}"}}'
"""
}
}
if("${PS8_RELEASE_VERSION}"){
echo "Executing MINITESTS as VALID VALUES FOR PS8_RELEASE_VERSION:${PS8_RELEASE_VERSION}"
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 PS8 with ${PS8_RELEASE_VERSION_PRODUCT_TO_TEST}"

build job: 'package-testing-ps80', propagate: false, wait: false, parameters: [string(name: 'product_to_test', value: "${PS8_RELEASE_VERSION_PRODUCT_TO_TEST}"),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}"}}'
"""
}
}
}
else{
echo "Skipping MINITESTS and Other Triggers as invalid RELEASE VERSION FOR THIS JOB"
slackNotify("${SLACKNOTIFY}", "#00FF00", "[${JOB_NAME}]: Skipping MINITESTS and Other Triggers as invalid RELEASE VERSION FOR THIS JOB ${BRANCH} - [${BUILD_URL}]")
}
}
deleteDir()
}
Expand Down

0 comments on commit d6ae827

Please sign in to comment.