Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PMM-13337 refactor repo enabling for jobs #2844

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 8 additions & 35 deletions pmm/aws-staging-start.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,9 @@ pipeline {
description: 'Which Version of PMM-Server',
name: 'PMM_VERSION')
choice(
choices: ['no', 'yes'],
description: 'Enable Testing Repo, for RC testing',
name: 'ENABLE_TESTING_REPO')
choice(
choices: ['yes', 'no'],
description: 'Enable Experimental Repo, for dev-latest',
name: 'ENABLE_EXPERIMENTAL_REPO')
choices: ['experimental', 'testing', 'release'],
description: 'Repo to enable (experimental - dev-latest, testing - rc, release - stable)',
name: 'REPO_TO_ENABLE')
choice(
choices: ['no', 'yes'],
description: 'Enable Pull Mode, if you are using this instance as Client Node',
Expand Down Expand Up @@ -328,9 +324,9 @@ pipeline {
}
}
}
stage('Enable Testing Repo') {
stage("Enable ${env.REPO_TO_ENABLE} Repo") {
when {
expression { env.ENABLE_TESTING_REPO == "yes" && env.PMM_VERSION == "pmm2" && env.CLIENT_INSTANCE == "no" }
expression { env.PMM_VERSION == "pmm2" && env.CLIENT_INSTANCE == "no" }
}
steps {
script {
Expand All @@ -343,31 +339,8 @@ pipeline {
# exclude unavailable mirrors
docker exec ${VM_NAME}-server bash -c "echo exclude=mirror.es.its.nyu.edu | tee -a /etc/yum/pluginconf.d/fastestmirror.conf"
docker exec ${VM_NAME}-server yum update -y percona-release
docker exec ${VM_NAME}-server sed -i'' -e 's^/release/^/testing/^' /etc/yum.repos.d/pmm2-server.repo
docker exec ${VM_NAME}-server percona-release enable pmm2-client testing
docker exec ${VM_NAME}-server yum clean all
docker exec ${VM_NAME}-server yum clean metadata
"""
}
}
}
}
}
stage('Enable Experimental Repo') {
when {
expression { env.PMM_VERSION == "pmm2" && env.CLIENT_INSTANCE == "no" && env.ENABLE_EXPERIMENTAL_REPO == "yes" && env.ENABLE_TESTING_REPO == "no" }
}
steps {
script {
withEnv(['JENKINS_NODE_COOKIE=dontKillMe']) {
node(env.VM_NAME){
sh """
set -o errexit
set -o xtrace
docker exec ${VM_NAME}-server bash -c "echo exclude=mirror.es.its.nyu.edu | tee -a /etc/yum/pluginconf.d/fastestmirror.conf"
docker exec ${VM_NAME}-server yum update -y percona-release
docker exec ${VM_NAME}-server sed -i'' -e 's^/release/^/experimental/^' /etc/yum.repos.d/pmm2-server.repo
docker exec ${VM_NAME}-server percona-release enable pmm2-client experimental
docker exec ${VM_NAME}-server sed -i'' -e 's^/release/^/${REPO_TO_ENABLE}/^' /etc/yum.repos.d/pmm2-server.repo
docker exec ${VM_NAME}-server percona-release enable pmm2-client ${REPO_TO_ENABLE}
docker exec ${VM_NAME}-server yum clean all
docker exec ${VM_NAME}-server yum clean metadata
"""
Expand All @@ -379,7 +352,7 @@ pipeline {
stage('Run Clients') {
steps {
node(env.VM_NAME){
setupPMMClient(SERVER_IP, CLIENT_VERSION.trim(), PMM_VERSION, ENABLE_PULL_MODE, ENABLE_TESTING_REPO, CLIENT_INSTANCE, 'aws-staging', ADMIN_PASSWORD)
setupPMMClient(SERVER_IP, CLIENT_VERSION.trim(), PMM_VERSION, ENABLE_PULL_MODE, REPO_TO_ENABLE, CLIENT_INSTANCE, 'aws-staging', ADMIN_PASSWORD)
script {
env.PMM_REPO="experimental"
if(env.CLIENT_VERSION == "pmm2-rc") {
Expand Down
36 changes: 6 additions & 30 deletions pmm/pmm2-ami-staging-start.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,9 @@ pipeline {
description: 'Stop the instance after, days ("0" value disables autostop and recreates instance in case of AWS failure)',
name: 'DAYS')
choice(
choices: ['no', 'yes'],
description: 'Enable Testing Repo, for RC testing',
name: 'ENABLE_TESTING_REPO')
choice(
choices: ['yes', 'no'],
description: 'Enable Experimental Repo, for dev-latest',
name: 'ENABLE_EXPERIMENTAL_REPO')
choices: ['experimental', 'testing', 'release'],
description: 'Repo to enable (experimental - dev-latest, testing - rc, release - stable)',
name: 'REPO_TO_ENABLE')
choice(
choices: ['false', 'true'],
description: 'Enable to setup Docker-compose for remote instances',
Expand Down Expand Up @@ -221,34 +217,14 @@ pipeline {
archiveArtifacts 'INSTANCE_ID'
}
}
stage('Enable Testing Repo') {
when {
expression { env.ENABLE_TESTING_REPO == "yes" }
}
steps {
withCredentials([sshUserPrivateKey(credentialsId: 'aws-jenkins-admin', keyFileVariable: 'KEY_PATH', passphraseVariable: '', usernameVariable: 'USER')]) {
sh '''
ssh -i "${KEY_PATH}" -o ConnectTimeout=1 -o StrictHostKeyChecking=no admin@${PUBLIC_IP} '
sudo yum update -y percona-release
sudo sed -i'' -e 's^/release/^/testing/^' /etc/yum.repos.d/pmm2-server.repo
sudo percona-release enable pmm2-client testing
sudo yum clean all
'
'''
}
}
}
stage('Enable Experimental Repo') {
when {
expression { env.ENABLE_EXPERIMENTAL_REPO == "yes" && env.ENABLE_TESTING_REPO == "no" }
}
stage("Enable ${env.REPO_TO_ENABLE} Repo") {
steps {
withCredentials([sshUserPrivateKey(credentialsId: 'aws-jenkins-admin', keyFileVariable: 'KEY_PATH', passphraseVariable: '', usernameVariable: 'USER')]) {
sh '''
ssh -i "${KEY_PATH}" -o ConnectTimeout=1 -o StrictHostKeyChecking=no admin@${PUBLIC_IP} '
sudo yum update -y percona-release
sudo sed -i'' -e 's^/release/^/experimental/^' /etc/yum.repos.d/pmm2-server.repo
sudo percona-release enable pmm2-client experimental
sudo sed -i'' -e 's^/release/^/${REPO_TO_ENABLE}/^' /etc/yum.repos.d/pmm2-server.repo
sudo percona-release enable pmm2-client ${REPO_TO_ENABLE}
sudo yum clean all
sudo yum clean metadata
'
Expand Down
27 changes: 12 additions & 15 deletions pmm/pmm2-ami-upgrade-tests-matrix.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ library changelog: false, identifier: 'lib@master', retriever: modernSCM([
remote: 'https://github.com/Percona-Lab/jenkins-pipelines.git'
]) _

void runAMIUpgradeJob(String PMM_UI_TESTS_BRANCH, String PMM_VERSION, String PMM_SERVER_LATEST, String ENABLE_TESTING_REPO, PMM_QA_BRANCH) {
void runAMIUpgradeJob(String PMM_UI_TESTS_BRANCH, String PMM_VERSION, String PMM_SERVER_LATEST, String REPO_TO_ENABLE, PMM_QA_BRANCH) {
upgradeJob = build job: 'pmm2-ami-upgrade-tests', parameters: [
string(name: 'GIT_BRANCH', value: PMM_UI_TESTS_BRANCH),
string(name: 'CLIENT_VERSION', value: PMM_VERSION),
string(name: 'SERVER_VERSION', value: PMM_VERSION),
string(name: 'PMM_SERVER_LATEST', value: PMM_SERVER_LATEST),
string(name: 'ENABLE_TESTING_REPO', value: ENABLE_TESTING_REPO),
string(name: 'REPO_TO_ENABLE', value: REPO_TO_ENABLE),
string(name: 'PMM_QA_GIT_BRANCH', value: PMM_QA_BRANCH)
]
}
Expand All @@ -19,20 +19,13 @@ String pmmServerLatestVersion
List amiVersions = pmmVersion('ami').keySet() as List
List versions = amiVersions[-5..-1]
def parallelStagesMatrix = versions.collectEntries {String it ->
if ("${params.UPGRADE_TO}" == "dev-latest") {
enableTestingRepo = 'no'
pmmServerLatestVersion = pmmVersion()
} else {
enableTestingRepo = 'yes'
pmmServerLatestVersion = pmmVersion('rc')
}
["${it} -> ${pmmServerLatestVersion}" : generateStage(it, pmmServerLatestVersion, enableTestingRepo)]
["${it} -> ${pmmServerLatestVersion}" : generateStage(it, PMM_SERVER_LATEST, REPO_TO_ENABLE)]
}

def generateStage(String version, String latest, String enableRepo) {
def generateStage(String version, String latest, String repoToEnable) {
return {
stage("${version}") {
runAMIUpgradeJob(PMM_UI_TESTS_BRANCH, version, latest, enableRepo, PMM_QA_BRANCH)
runAMIUpgradeJob(PMM_UI_TESTS_BRANCH, version, latest, repoToEnable, PMM_QA_BRANCH)
}
}
}
Expand All @@ -50,10 +43,14 @@ pipeline {
defaultValue: 'main',
description: 'Tag/Branch for pmm-qa repository',
name: 'PMM_QA_BRANCH')
string(
defaultValue: latestVersion,
description: 'latest PMM Server Version',
name: 'PMM_SERVER_LATEST')
choice(
choices: ['dev-latest', 'release candidate'],
description: 'Upgrade to:',
name: 'UPGRADE_TO')
choices: ['experimental', 'testing', 'release'],
description: 'Repo to enable (experimental - dev-latest, testing - rc, release - stable)',
name: 'REPO_TO_ENABLE')
}
options {
skipDefaultCheckout()
Expand Down
20 changes: 10 additions & 10 deletions pmm/pmm2-ami-upgrade-tests.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ library changelog: false, identifier: 'lib@master', retriever: modernSCM([
remote: 'https://github.com/Percona-Lab/jenkins-pipelines.git'
]) _

void runAMIStagingStart(AMI_ID, PMM_QA_GIT_BRANCH, ENABLE_TESTING_REPO, AMI_UPGRADE_TESTING_INSTANCE) {
void runAMIStagingStart(AMI_ID, PMM_QA_GIT_BRANCH, REPO_TO_ENABLE, AMI_UPGRADE_TESTING_INSTANCE) {
amiStagingJob = build job: 'pmm2-ami-staging-start', parameters: [
string(name: 'AMI_ID', value: AMI_ID),
string(name: 'ENABLE_TESTING_REPO', value: ENABLE_TESTING_REPO),
string(name: 'REPO_TO_ENABLE', value: REPO_TO_ENABLE),
string(name: 'PMM_QA_GIT_BRANCH', value: PMM_QA_GIT_BRANCH),
string(name: 'AMI_UPGRADE_TESTING_INSTANCE', value: AMI_UPGRADE_TESTING_INSTANCE)
]
Expand Down Expand Up @@ -34,13 +34,13 @@ void customSetupAMIInstance(INSTANCE_IP) {
}
}

void runStagingClient(CLIENT_VERSION, CLIENTS, CLIENT_INSTANCE, SERVER_IP, PMM_QA_GIT_BRANCH, ENABLE_TESTING_REPO, NODE_TYPE) {
void runStagingClient(CLIENT_VERSION, CLIENTS, CLIENT_INSTANCE, SERVER_IP, PMM_QA_GIT_BRANCH, REPO_TO_ENABLE, NODE_TYPE) {
stagingJob = build job: 'aws-staging-start', parameters: [
string(name: 'CLIENT_VERSION', value: CLIENT_VERSION),
string(name: 'CLIENTS', value: CLIENTS),
string(name: 'CLIENT_INSTANCE', value: CLIENT_INSTANCE),
string(name: 'PMM_QA_GIT_BRANCH', value: PMM_QA_GIT_BRANCH),
string(name: 'ENABLE_TESTING_REPO', value: ENABLE_TESTING_REPO),
string(name: 'REPO_TO_ENABLE', value: REPO_TO_ENABLE),
string(name: 'SERVER_IP', value: SERVER_IP),
string(name: 'NOTIFY', value: 'false'),
string(name: 'DAYS', value: '1'),
Expand Down Expand Up @@ -195,9 +195,9 @@ pipeline {
description: 'Tag/Branch for pmm-qa repository',
name: 'PMM_QA_GIT_BRANCH')
choice(
choices: ['no', 'yes'],
description: 'Enable Testing Repo, for RC testing',
name: 'ENABLE_TESTING_REPO')
choices: ['experimental', 'testing', 'release'],
description: 'Repo to enable (experimental - dev-latest, testing - rc, release - stable)',
name: 'REPO_TO_ENABLE')
choice(
choices: ['true', 'false'],
description: 'Enable to setup Docker-compose for remote instances',
Expand Down Expand Up @@ -232,7 +232,7 @@ pipeline {
}
stage('Start AMI Server') {
steps {
runAMIStagingStart(amiID, PMM_QA_GIT_BRANCH, ENABLE_TESTING_REPO, AMI_UPGRADE_TESTING_INSTANCE)
runAMIStagingStart(amiID, PMM_QA_GIT_BRANCH, REPO_TO_ENABLE, AMI_UPGRADE_TESTING_INSTANCE)
customSetupAMIInstance(AMI_INSTANCE_IP)
}
}
Expand All @@ -250,12 +250,12 @@ pipeline {
parallel {
stage('Start Client Instance Remote Instance') {
steps {
runStagingClient(CLIENT_VERSION, '--setup-remote-db', 'yes', AMI_INSTANCE_IP, PMM_QA_GIT_BRANCH, ENABLE_TESTING_REPO, 'remote-node')
runStagingClient(CLIENT_VERSION, '--setup-remote-db', 'yes', AMI_INSTANCE_IP, PMM_QA_GIT_BRANCH, REPO_TO_ENABLE, 'remote-node')
}
}
stage('Start Client Instance DB connect Instance') {
steps {
runStagingClient(CLIENT_VERSION, '--addclient=modb,1 --addclient=pgsql,1 --addclient=ps,1 --setup-with-custom-queries', 'yes', AMI_INSTANCE_IP, PMM_QA_GIT_BRANCH, ENABLE_TESTING_REPO, 'db-node')
runStagingClient(CLIENT_VERSION, '--addclient=modb,1 --addclient=pgsql,1 --addclient=ps,1 --setup-with-custom-queries', 'yes', AMI_INSTANCE_IP, PMM_QA_GIT_BRANCH, REPO_TO_ENABLE, 'db-node')
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pmm/pmm2-ovf-image-test.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ pipeline {
currentBuild.description = "VM_NAME: ${VM_NAME}, IP: ${PUBLIC_IP}, OWNER: ${OWNER}"
}

setupPMMClient(env.PUBLIC_IP, params.CLIENT_VERSION, 'pmm2', 'yes', 'no', 'yes', 'ovf_setup', env.ADMIN_PASSWORD)
setupPMMClient(env.PUBLIC_IP, params.CLIENT_VERSION, 'pmm2', 'yes', 'experimental', 'yes', 'ovf_setup', env.ADMIN_PASSWORD)

sh """
set -o errexit
Expand Down
44 changes: 5 additions & 39 deletions pmm/pmm2-ovf-staging-start.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,9 @@ pipeline {
description: 'OVA Image version, for installing already released version, pass 2.x.y ex. 2.28.0',
name: 'OVA_VERSION')
choice(
choices: ['no', 'yes'],
description: 'Enable Testing Repo, for RC testing',
name: 'ENABLE_TESTING_REPO')
choice(
choices: ['yes', 'no'],
description: 'Enable Experimental, for Dev Latest testing',
name: 'ENABLE_EXPERIMENTAL_REPO')
choices: ['experimental', 'testing', 'release'],
description: 'Repo to enable (experimental - dev-latest, testing - rc, release - stable)',
name: 'REPO_TO_ENABLE')
string(
defaultValue: 'main',
description: 'Tag/Branch for pmm-qa repository',
Expand Down Expand Up @@ -147,40 +143,10 @@ pipeline {
}
}
}
stage('Enable Testing Repo') {
when {
expression { env.ENABLE_TESTING_REPO == "yes" && env.ENABLE_EXPERIMENTAL_REPO == "no" }
}
stage("Enable ${env.REPO_TO_ENABLE} Repo") {
steps {
node(env.VM_NAME){
enableRepo('testing', env.IP)
}
}
}
stage('Enable Experimental Repo') {
when {
expression { env.ENABLE_EXPERIMENTAL_REPO == "yes" && env.ENABLE_TESTING_REPO == "no" }
}
steps {
node(env.VM_NAME){
enableRepo('experimental', env.IP)
}
}
}
stage('Enable Release Repo') {
when {
expression { env.ENABLE_EXPERIMENTAL_REPO == "no" && env.ENABLE_TESTING_REPO == "no" }
}
steps {
node(env.VM_NAME) {
withCredentials([sshUserPrivateKey(credentialsId: 'OVF_VM_TESTQA', keyFileVariable: 'KEY_PATH', passphraseVariable: '', usernameVariable: 'USER')]) {
sh '''
ssh -i "${KEY_PATH}" -p 3022 -o ConnectTimeout=1 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null admin@${IP} '
sudo yum update -y percona-release || true
sudo yum clean all
'
'''
}
enableRepo(env.REPO_TO_ENABLE, env.IP)
}
}
}
Expand Down
11 changes: 5 additions & 6 deletions pmm/pmm2-ovf-upgrade-tests-matrix.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ void runOVFUpgradeJob(String GIT_BRANCH, PMM_VERSION, PMM_SERVER_LATEST, ENABLE_
string(name: 'SERVER_VERSION', value: PMM_VERSION),
string(name: 'CLIENT_VERSION', value: PMM_VERSION),
string(name: 'PMM_SERVER_LATEST', value: PMM_SERVER_LATEST),
string(name: 'ENABLE_TESTING_REPO', value: ENABLE_TESTING_REPO),
string(name: 'ENABLE_EXPERIMENTAL_REPO', value: 'no'),
string(name: 'REPO_TO_ENABLE', value: REPO_TO_ENABLE),
string(name: 'PMM_QA_GIT_BRANCH', value: PMM_QA_GIT_BRANCH)
]
}
Expand All @@ -29,7 +28,7 @@ def generateStage(VERSION) {
GIT_BRANCH,
VERSION,
PMM_SERVER_LATEST,
ENABLE_TESTING_REPO,
REPO_TO_ENABLE,
PMM_QA_GIT_BRANCH
)
}
Expand All @@ -54,9 +53,9 @@ pipeline {
description: 'dev-latest PMM Server Version',
name: 'PMM_SERVER_LATEST')
choice(
choices: ['no', 'yes'],
description: 'Enable Testing Repo for RC',
name: 'ENABLE_TESTING_REPO')
choices: ['experimental', 'testing', 'release'],
description: 'Repo to enable (experimental - dev-latest, testing - rc, release - stable)',
name: 'REPO_TO_ENABLE')
}
options {
skipDefaultCheckout()
Expand Down
Loading