diff --git a/ps/jenkins/percona-server-for-mysql-8.0.groovy b/ps/jenkins/percona-server-for-mysql-8.0.groovy index 808479965b..3379ee6344 100644 --- a/ps/jenkins/percona-server-for-mysql-8.0.groovy +++ b/ps/jenkins/percona-server-for-mysql-8.0.groovy @@ -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 @@ -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 { @@ -102,6 +219,7 @@ parameters { timestamps () } stages { + stage('Create PS source tarball') { agent { label 'min-bionic-x64' @@ -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() @@ -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()