Skip to content

Commit db5a4ca

Browse files
yurkovychvpeterSirotnakademidoff
authored
PMM-14125 helm tests job (#3508)
* PMM-14125-helm-tests job * PMM-14125-helm-tests job * PMM-14125-helm-tests job * PMM-14125-helm-tests job * PMM-14125-helm-tests job * PMM-14125 increase tests stage timeout * PMM-14125 update permissions * PMM-14125 PMM_CHART_BRANCH usage * PMM-14125 add helm to nightly * PMM-14125 add helm to nightly * PMM-14125 add helm to nightly * PMM-14125 destroy helm on nightly * PMM-14125 destroy helm on nightly * PMM-14125 destroy helm on nightly * PMM-7: slowlog for ps * PMM-14125 destroy helm on nightly * Update pmm/v3/pmm3-openshift-helm-tests.groovy Co-authored-by: Alex Demidoff <[email protected]> * PMM-14125 review changes on nightly --------- Co-authored-by: Peter Sirotnak <[email protected]> Co-authored-by: Alex Demidoff <[email protected]>
1 parent b70ffce commit db5a4ca

File tree

2 files changed

+224
-18
lines changed

2 files changed

+224
-18
lines changed
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
library changelog: false, identifier: 'lib@master', retriever: modernSCM([
2+
$class: 'GitSCMSource',
3+
remote: 'https://github.com/Percona-Lab/jenkins-pipelines.git'
4+
]) _
5+
6+
def runOpenshiftClusterCreate(String OPENSHIFT_VERSION) {
7+
def clusterName = "helm-test-${env.BUILD_NUMBER}"
8+
9+
clusterCreateJob = build job: 'openshift-cluster-create', parameters: [
10+
string(name: 'CLUSTER_NAME', value: clusterName),
11+
string(name: 'OPENSHIFT_VERSION', value: OPENSHIFT_VERSION),
12+
booleanParam(name: 'DEPLOY_PMM', value: false),
13+
string(name: 'TEAM_NAME', value: 'pmm'),
14+
string(name: 'PRODUCT_TAG', value: 'pmm'),
15+
]
16+
17+
env.VM_IP = clusterCreateJob.buildVariables.IP
18+
env.VM_NAME = clusterCreateJob.buildVariables.VM_NAME
19+
env.WORK_DIR = clusterCreateJob.buildVariables.WORK_DIR
20+
env.FINAL_CLUSTER_NAME = clusterCreateJob.buildVariables.FINAL_CLUSTER_NAME
21+
}
22+
23+
24+
def destroyOpenshift(CLUSTER_NAME) {
25+
build job: 'openshift-cluster-destroy', parameters: [
26+
string(name: 'CLUSTER_NAME', value: CLUSTER_NAME),
27+
string(name: 'DESTROY_REASON', value: 'testing-complete'),
28+
]
29+
}
30+
31+
pipeline {
32+
agent {
33+
label 'min-noble-x64'
34+
}
35+
parameters {
36+
string(
37+
defaultValue: 'v3',
38+
description: 'Tag/Branch for pmm-qa repository',
39+
name: 'PMM_QA_GIT_BRANCH')
40+
string(
41+
defaultValue: 'latest',
42+
description: 'Helm chart branch to use. Leave "latest" to use latest released chart',
43+
name: 'PMM_CHART_BRANCH')
44+
string(
45+
defaultValue: 'perconalab/pmm-server',
46+
description: 'PMM Server image repository',
47+
name: 'IMAGE_REPO')
48+
string(
49+
defaultValue: '3-dev-latest',
50+
description: 'PMM Server image tag',
51+
name: 'IMAGE_TAG')
52+
choice(
53+
choices: ['latest', '4.19.6', '4.19.5', '4.19.4', '4.19.3', '4.19.2', '4.18.9', '4.18.8', '4.18.7', '4.18.6', '4.18.5', '4.17.9', '4.17.8', '4.17.7', '4.17.6', '4.17.5', '4.16.9', '4.16.8', '4.16.7', '4.16.6', '4.16.5'],
54+
description: 'OpenShift version to install (specific version or channel)',
55+
name: 'OPENSHIFT_VERSION')
56+
}
57+
options {
58+
skipDefaultCheckout()
59+
}
60+
stages {
61+
stage('Prepare') {
62+
steps {
63+
script {
64+
currentBuild.description = "OpenShift version ${env.OPENSHIFT_VERSION}. Image repo ${env.IMAGE_REPO}. Image tag ${env.IMAGE_TAG}"
65+
}
66+
// clean up workspace and fetch pmm-qa repository
67+
deleteDir()
68+
git poll: false, branch: PMM_QA_GIT_BRANCH, url: 'https://github.com/percona/pmm-qa.git'
69+
70+
sh '''
71+
sudo mkdir -p /srv/pmm-qa || :
72+
sudo git clone --single-branch --branch \${PMM_QA_GIT_BRANCH} https://github.com/percona/pmm-qa.git /srv/pmm-qa
73+
sudo chmod -R 755 /srv/pmm-qa
74+
75+
sudo mkdir -p /opt/bats || :
76+
sudo git clone https://github.com/bats-core/bats-core.git /opt/bats
77+
sudo chmod -R 755 /opt/bats
78+
sudo /opt/bats/install.sh /usr/local
79+
80+
cd /srv/pmm-qa/k8s
81+
sudo ./setup_bats_libs.sh
82+
83+
sudo chown -R "$(id -un)":"$(id -gn)" /srv/pmm-qa
84+
85+
# Install kubectl
86+
bash -x ./install_k8s_tools.sh --kubectl --helm --sudo
87+
sleep 5
88+
kubectl version --client
89+
'''
90+
}
91+
}
92+
stage('Create OpenShift Cluster') {
93+
steps {
94+
runOpenshiftClusterCreate(OPENSHIFT_VERSION)
95+
}
96+
}
97+
stage('Copy Artifacts') {
98+
steps {
99+
script {
100+
101+
copyArtifacts filter: "openshift-clusters/${env.FINAL_CLUSTER_NAME}/auth/kubeconfig", projectName: 'openshift-cluster-create', target: 'cluster-artifacts'
102+
sh "ls -la cluster-artifacts/openshift-clusters/${env.FINAL_CLUSTER_NAME}/auth"
103+
// Validate cluster access
104+
def kubeconfig = "${WORKSPACE}/cluster-artifacts/openshift-clusters/${env.FINAL_CLUSTER_NAME}/auth/kubeconfig"
105+
env.KUBECONFIG = kubeconfig
106+
107+
if (!fileExists(kubeconfig)) {
108+
error "Failed to copy kubeconfig file from cluster creation job"
109+
}
110+
111+
withEnv(["KUBECONFIG=${kubeconfig}"]) {
112+
sh """
113+
# Wait for up to 1 minute for the cluster to be accessible
114+
for i in {1..6}; do
115+
if kubectl get nodes &>/dev/null; then
116+
echo "Successfully connected to OpenShift cluster"
117+
kubectl get nodes -o wide
118+
exit 0
119+
fi
120+
echo "Waiting for cluster to be accessible... (attempt \$i/6)"
121+
sleep 10
122+
done
123+
echo "Failed to connect to OpenShift cluster after 1 minute"
124+
exit 1
125+
"""
126+
}
127+
}
128+
}
129+
}
130+
stage('Run Helm Tests') {
131+
options {
132+
timeout(time: 40, unit: "MINUTES")
133+
}
134+
steps {
135+
sh """
136+
cd /srv/pmm-qa/k8s
137+
export BATS_LIB_PATH="/srv/pmm-qa/k8s/lib"
138+
export IMAGE_REPO=${IMAGE_REPO}
139+
export IMAGE_TAG=${IMAGE_TAG}
140+
export PMM_CHART_BRANCH=${PMM_CHART_BRANCH}
141+
bats --tap helm-test.bats
142+
"""
143+
}
144+
}
145+
}
146+
post {
147+
always {
148+
// destroy cluster
149+
script {
150+
if (env.FINAL_CLUSTER_NAME) {
151+
destroyOpenshift(env.FINAL_CLUSTER_NAME)
152+
}
153+
}
154+
}
155+
}
156+
}

pmm/v3/pmm3-ui-tests-nightly.groovy

Lines changed: 68 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,33 @@ void runOVFStagingStart(String SERVER_VERSION, PMM_QA_GIT_BRANCH) {
4444
env.ADMIN_PASSWORD = "admin"
4545
}
4646

47+
def runOpenshiftClusterCreate(String OPENSHIFT_VERSION, DOCKER_VERSION, ADMIN_PASSWORD) {
48+
def clusterName = "nightly-test-${env.BUILD_NUMBER}"
49+
def pmmImageRepo = DOCKER_VERSION.split(":")[0]
50+
def pmmImageTag = DOCKER_VERSION.split(":")[1]
51+
52+
clusterCreateJob = build job: 'openshift-cluster-create', parameters: [
53+
string(name: 'CLUSTER_NAME', value: clusterName),
54+
string(name: 'OPENSHIFT_VERSION', value: OPENSHIFT_VERSION),
55+
booleanParam(name: 'DEPLOY_PMM', value: true),
56+
string(name: 'TEAM_NAME', value: 'pmm'),
57+
string(name: 'PRODUCT_TAG', value: 'pmm'),
58+
string(name: 'PMM_ADMIN_PASSWORD', value: ADMIN_PASSWORD),
59+
string(name: 'PMM_IMAGE_REPOSITORY', value: pmmImageRepo),
60+
string(name: 'PMM_IMAGE_TAG', value: pmmImageTag),
61+
]
62+
63+
def pmmAddress = clusterCreateJob.buildVariables.PMM_URL
64+
def pmmHostname = pmmAddress.split("//")[1]
65+
66+
env.VM_IP = pmmHostname
67+
env.VM_NAME = clusterCreateJob.buildVariables.VM_NAME
68+
env.WORK_DIR = clusterCreateJob.buildVariables.WORK_DIR
69+
env.FINAL_CLUSTER_NAME = clusterCreateJob.buildVariables.FINAL_CLUSTER_NAME
70+
env.PMM_URL = "https://admin:${ADMIN_PASSWORD}@${pmmHostname}"
71+
env.PMM_UI_URL = "${pmmAddress}/"
72+
}
73+
4774
void runAMIStagingStart(String AMI_ID) {
4875
amiStagingJob = build job: 'pmm3-ami-staging-start', parameters: [
4976
string(name: 'AMI_ID', value: AMI_ID)
@@ -191,7 +218,7 @@ pipeline {
191218
description: 'Tag/Branch for pmm-ui-tests repository',
192219
name: 'GIT_BRANCH')
193220
choice(
194-
choices: ['docker', 'ovf', 'ami'],
221+
choices: ['docker', 'ovf', 'ami', 'helm'],
195222
description: "PMM Server installation type.",
196223
name: 'SERVER_TYPE')
197224
string(
@@ -218,6 +245,10 @@ pipeline {
218245
defaultValue: 'v3',
219246
description: 'Tag/Branch for pmm-qa repository',
220247
name: 'PMM_QA_GIT_BRANCH')
248+
choice(
249+
choices: ['latest', '4.19.6', '4.19.5', '4.19.4', '4.19.3', '4.19.2', '4.18.9', '4.18.8', '4.18.7', '4.18.6', '4.18.5', '4.17.9', '4.17.8', '4.17.7', '4.17.6', '4.17.5', '4.16.9', '4.16.8', '4.16.7', '4.16.6', '4.16.5'],
250+
description: 'OpenShift version to install (specific version or channel)',
251+
name: 'OPENSHIFT_VERSION')
221252
choice(
222253
choices: ['8.0', '8.4', '5.7'],
223254
description: 'Percona XtraDB Cluster version',
@@ -262,6 +293,9 @@ pipeline {
262293
stages {
263294
stage('Prepare') {
264295
steps {
296+
script {
297+
currentBuild.description = "${env.SERVER_TYPE} Server: ${env.DOCKER_VERSION}. Client: ${env.CLIENT_VERSION}"
298+
}
265299
// clean up workspace and fetch pmm-ui-tests repository
266300
deleteDir()
267301
git poll: false, branch: GIT_BRANCH, url: 'https://github.com/percona/pmm-ui-tests.git'
@@ -301,6 +335,14 @@ pipeline {
301335
runAMIStagingStart(DOCKER_VERSION)
302336
}
303337
}
338+
stage('Setup Helm Server Instance') {
339+
when {
340+
expression { env.SERVER_TYPE == "helm" }
341+
}
342+
steps {
343+
runOpenshiftClusterCreate(OPENSHIFT_VERSION, DOCKER_VERSION, ADMIN_PASSWORD)
344+
}
345+
}
304346
}
305347
}
306348
stage('Sanity check') {
@@ -329,7 +371,7 @@ pipeline {
329371
}
330372
stage('ps single and mongo pss client') {
331373
steps {
332-
runStagingClient(DOCKER_VERSION, CLIENT_VERSION, '--database ps --database psmdb,SETUP_TYPE=pss', 'yes', env.VM_IP, 'mysql-node', ENABLE_PULL_MODE, PXC_VERSION, PS_VERSION, MS_VERSION, PGSQL_VERSION, PDPGSQL_VERSION, MD_VERSION, PSMDB_VERSION, MODB_VERSION, QUERY_SOURCE, QA_INTEGRATION_GIT_BRANCH, ADMIN_PASSWORD)
374+
runStagingClient(DOCKER_VERSION, CLIENT_VERSION, '--database ps,QUERY_SOURCE=slowlog --database psmdb,SETUP_TYPE=pss', 'yes', env.VM_IP, 'mysql-node', ENABLE_PULL_MODE, PXC_VERSION, PS_VERSION, MS_VERSION, PGSQL_VERSION, PDPGSQL_VERSION, MD_VERSION, PSMDB_VERSION, MODB_VERSION, QUERY_SOURCE, QA_INTEGRATION_GIT_BRANCH, ADMIN_PASSWORD)
333375
}
334376
}
335377
stage('pdpgsql, pgsql and pdpgsql patroni client') {
@@ -436,21 +478,6 @@ pipeline {
436478
post {
437479
always {
438480
// stop staging
439-
sh '''
440-
curl --insecure ${PMM_URL}/logs.zip --output logs.zip || true
441-
'''
442-
script {
443-
if (currentBuild.result == null || currentBuild.result == 'SUCCESS') {
444-
junit 'tests/output/*.xml'
445-
slackSend botUser: true, channel: '#pmm-notifications', color: '#00FF00', message: "[${JOB_NAME}]: build finished - ${BUILD_URL}"
446-
archiveArtifacts artifacts: 'logs.zip'
447-
} else {
448-
junit 'tests/output/*.xml'
449-
slackSend botUser: true, channel: '#pmm-notifications', color: '#FF0000', message: "[${JOB_NAME}]: build ${currentBuild.result} - ${BUILD_URL}"
450-
archiveArtifacts artifacts: 'logs.zip'
451-
archiveArtifacts artifacts: 'tests/output/*.png'
452-
}
453-
}
454481
script {
455482
if (env.SERVER_TYPE == "ovf") {
456483
ovfStagingStopJob = build job: 'pmm-ovf-staging-stop', parameters: [
@@ -462,6 +489,12 @@ pipeline {
462489
string(name: 'AMI_ID', value: env.AMI_INSTANCE_ID),
463490
]
464491
}
492+
if (env.SERVER_TYPE == "helm") {
493+
build job: 'openshift-cluster-destroy', parameters: [
494+
string(name: 'CLUSTER_NAME', value: env.FINAL_CLUSTER_NAME),
495+
string(name: 'DESTROY_REASON', value: 'testing-complete'),
496+
]
497+
}
465498
if(env.VM_NAME && env.SERVER_TYPE == "docker")
466499
{
467500
destroyStaging(VM_NAME)
@@ -487,7 +520,24 @@ pipeline {
487520
destroyStaging(VM_CLIENT_NAME_PS_GR)
488521
}
489522
}
490-
deleteDir()
523+
sh '''
524+
curl --insecure ${PMM_URL}/logs.zip --output logs.zip || true
525+
'''
526+
}
527+
success {
528+
script {
529+
junit 'tests/output/*.xml'
530+
slackSend botUser: true, channel: '#pmm-notifications', color: '#00FF00', message: "[${JOB_NAME}]: build finished - ${BUILD_URL}"
531+
archiveArtifacts artifacts: 'logs.zip'
532+
}
533+
}
534+
failure {
535+
script {
536+
junit 'tests/output/*.xml'
537+
slackSend botUser: true, channel: '#pmm-notifications', color: '#FF0000', message: "[${JOB_NAME}]: build ${currentBuild.result} - ${BUILD_URL}"
538+
archiveArtifacts artifacts: 'logs.zip'
539+
archiveArtifacts artifacts: 'tests/output/*.png'
540+
}
491541
}
492542
}
493543
}

0 commit comments

Comments
 (0)