forked from percona/percona-backup-mongodb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
321 lines (301 loc) · 11.9 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
def skipBranchBulds = true
if ( env.CHANGE_URL ) {
skipBranchBulds = false
}
TestsReport = '| Test name | Logical | Physical |\\r\\n| ------------- | ------------- | ------------- |'
testsReportMap = [:]
void makeReport() {
for ( test in testsReportMap ) {
TestsReport = TestsReport + "\\r\\n| ${test.key} | ${test.value.logical} | ${test.value.physical} |"
}
}
void runTest(String TEST_NAME, String TEST_SCRIPT, String MONGO_VERSION, String BCP_TYPE) {
def mkey = "$TEST_NAME psmdb $MONGO_VERSION"
if (!testsReportMap[mkey]) {
testsReportMap[mkey]=[:]
testsReportMap[mkey]['logical'] = '-'
testsReportMap[mkey]['physical'] = '-'
}
testsReportMap[mkey][BCP_TYPE] = 'failed'
sh """
chmod 777 -R e2e-tests/docker/backups
export MONGODB_VERSION=${MONGO_VERSION}
export TESTS_BCP_TYPE=${BCP_TYPE}
./e2e-tests/${TEST_SCRIPT}
"""
testsReportMap[mkey][BCP_TYPE] = 'passed'
}
void prepareCluster(String CLUSTER_TYPE, String TEST_TYPE, String MONGO_VERSION) {
def compose = 'docker-compose.yaml'
switch(CLUSTER_TYPE) {
case 'rs':
compose = 'docker-compose-rs.yaml'
break
case 'single':
compose = 'docker-compose-single.yaml'
break
default:
compose = 'docker-compose.yaml'
break
}
withCredentials([file(credentialsId: 'PBM-AWS-S3', variable: 'PBM_AWS_S3_YML'), file(credentialsId: 'PBM-GCS-S3', variable: 'PBM_GCS_S3_YML'), file(credentialsId: 'PBM-AZURE', variable: 'PBM_AZURE_YML')]) {
sh """
sudo curl -L "https://github.com/docker/compose/releases/download/1.25.3/docker-compose-\$(uname -s)-\$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
cp $PBM_AWS_S3_YML ./e2e-tests/docker/conf/aws.yaml
cp $PBM_GCS_S3_YML ./e2e-tests/docker/conf/gcs.yaml
cp $PBM_AZURE_YML ./e2e-tests/docker/conf/azure.yaml
sed -i s:pbme2etest:pbme2etest-${TEST_TYPE}:g ./e2e-tests/docker/conf/aws.yaml
sed -i s:pbme2etest:pbme2etest-${TEST_TYPE}:g ./e2e-tests/docker/conf/gcs.yaml
sed -i s:pbme2etest:pbme2etest-${TEST_TYPE}:g ./e2e-tests/docker/conf/azure.yaml
chmod 664 ./e2e-tests/docker/conf/aws.yaml
chmod 664 ./e2e-tests/docker/conf/gcs.yaml
chmod 664 ./e2e-tests/docker/conf/azure.yaml
openssl rand -base64 756 > ./e2e-tests/docker/keyFile
"""
}
}
pipeline {
environment {
AUTHOR_NAME = sh(script: "echo ${CHANGE_AUTHOR_EMAIL} | awk -F'@' '{print \$1}'", , returnStdout: true).trim()
}
agent {
label 'micro-amazon'
}
stages {
stage('Run tests for PBM') {
when {
expression {
!skipBranchBulds
}
}
parallel {
stage('New cluster 4.2 logical') {
agent {
label 'docker'
}
steps {
script {
if ( AUTHOR_NAME == 'null' ) {
AUTHOR_NAME = sh(script: "git show -s --pretty=%ae | awk -F'@' '{print \$1}'", , returnStdout: true).trim()
}
}
prepareCluster('sharded', '42-newc-logic', '4.2')
runTest('New cluster', 'run-new-cluster', '4.2', 'logical')
}
}
stage('New cluster 4.4 logical') {
agent {
label 'docker'
}
steps {
prepareCluster('sharded', '44-newc-logic', '4.4')
runTest('New cluster', 'run-new-cluster', '4.4', 'logical')
}
}
stage('New cluster 5.0 logical') {
agent {
label 'docker'
}
steps {
prepareCluster('sharded', '50-newc-logic', '5.0')
runTest('New cluster', 'run-new-cluster', '5.0', 'logical')
}
}
stage('Sharded 4.2 logical') {
agent {
label 'docker-32gb'
}
steps {
prepareCluster('sharded', '42-shrd-logic', '4.2')
runTest('Sharded', 'run-sharded', '4.2', 'logical')
}
}
stage('Sharded 4.4 logical') {
agent {
label 'docker-32gb'
}
steps {
prepareCluster('sharded', '44-shrd-logic', '4.4')
runTest('Sharded', 'run-sharded', '4.4', 'logical')
}
}
stage('Sharded 5.0 logical') {
agent {
label 'docker-32gb'
}
steps {
prepareCluster('sharded', '50-shrd-logic', '5.0')
runTest('Sharded', 'run-sharded', '5.0', 'logical')
}
}
stage('Non-sharded 4.2 logical') {
agent {
label 'docker'
}
steps {
prepareCluster('rs', '42-rs-logic', '4.2')
runTest('Non-sharded', 'run-rs', '4.2', 'logical')
}
}
stage('Non-sharded 4.4 logical') {
agent {
label 'docker'
}
steps {
prepareCluster('rs', '44-rs-logic', '4.4')
runTest('Non-sharded', 'run-rs', '4.4', 'logical')
}
}
stage('Non-sharded 5.0 logical') {
agent {
label 'docker'
}
steps {
prepareCluster('rs', '50-rs-logic', '5.0')
runTest('Non-sharded', 'run-rs', '5.0', 'logical')
}
}
stage('Single-node 4.2 logical') {
agent {
label 'docker'
}
steps {
prepareCluster('single', '42-single-logic', '4.2')
runTest('Single-node', 'run-single', '4.2', 'logical')
}
}
stage('Single-node 4.4 logical') {
agent {
label 'docker'
}
steps {
prepareCluster('single', '44-single-logic', '4.4')
runTest('Single-node', 'run-single', '4.4', 'logical')
}
}
stage('Single-node 5.0 logical') {
agent {
label 'docker'
}
steps {
prepareCluster('single', '50-single-logic', '5.0')
runTest('Single-node', 'run-single', '5.0', 'logical')
}
}
stage('Sharded 4.2 physical') {
agent {
label 'docker-32gb'
}
steps {
prepareCluster('sharded', '42-shrd-phys', '4.2')
runTest('Sharded', 'run-sharded', '4.2', 'physical')
}
}
stage('Sharded 4.4 physical') {
agent {
label 'docker-32gb'
}
steps {
prepareCluster('sharded', '44-shrd-phys', '4.4')
runTest('Sharded', 'run-sharded', '4.4', 'physical')
}
}
stage('Sharded 5.0 physical') {
agent {
label 'docker-32gb'
}
steps {
prepareCluster('sharded', '50-shrd-phys', '5.0')
runTest('Sharded', 'run-sharded', '5.0', 'physical')
}
}
stage('Non-sharded 4.2 physical') {
agent {
label 'docker'
}
steps {
prepareCluster('rs', '42-rs-phys', '4.2')
runTest('Non-sharded', 'run-rs', '4.2', 'physical')
}
}
stage('Non-sharded 4.4 physical') {
agent {
label 'docker'
}
steps {
prepareCluster('rs', '44-rs-phys', '4.4')
runTest('Non-sharded', 'run-rs', '4.4', 'physical')
}
}
stage('Non-sharded 5.0 physical') {
agent {
label 'docker'
}
steps {
prepareCluster('rs', '50-rs-phys', '5.0')
runTest('Non-sharded', 'run-rs', '5.0', 'physical')
}
}
stage('Single-node 4.2 physical') {
agent {
label 'docker'
}
steps {
prepareCluster('single', '42-single-phys', '4.2')
runTest('Single-node', 'run-single', '4.2', 'physical')
}
}
stage('Single-node 4.4 physical') {
agent {
label 'docker'
}
steps {
prepareCluster('single', '44-single-phys', '4.4')
runTest('Single-node', 'run-single', '4.4', 'physical')
}
}
stage('Single-node 5.0 physical') {
agent {
label 'docker'
}
steps {
prepareCluster('single', '50-single-phys', '5.0')
runTest('Single-node', 'run-single', '5.0', 'physical')
}
}
}
}
}
post {
always {
script {
if (env.CHANGE_URL) {
withCredentials([string(credentialsId: 'GITHUB_API_TOKEN', variable: 'GITHUB_API_TOKEN')]) {
makeReport()
sh """
curl -v -X POST \
-H "Authorization: token ${GITHUB_API_TOKEN}" \
-d "{\\"body\\":\\"${TestsReport}\\"}" \
"https://api.github.com/repos/\$(echo $CHANGE_URL | cut -d '/' -f 4-5)/issues/${CHANGE_ID}/comments"
"""
}
}
}
sh '''
sudo docker rmi -f \$(sudo docker images -q) || true
sudo rm -rf ./*
'''
deleteDir()
}
failure {
script {
try {
slackSend channel: "@${AUTHOR_NAME}", color: '#FF0000', message: "[${JOB_NAME}]: build ${currentBuild.result}, ${BUILD_URL} owner: @${AUTHOR_NAME}"
} catch (exc) {
slackSend channel: '#cloud-dev-ci', color: '#FF0000', message: "[${JOB_NAME}]: build ${currentBuild.result}, ${BUILD_URL} owner: @${AUTHOR_NAME}"
}
}
}
}
}