5ade45a1b1bd49d50fb477a280bb2ceeb46c9452
[releng/builder.git] / jjb / integration / integration-macros.yaml
1 - parameter:
2     name: integration-branch
3     parameters:
4         - string:
5             name: BRANCH
6             default: '{branch}'
7             description: 'Distribution GIT branch'
8
9 - parameter:
10     name: integration-bundleurl
11     parameters:
12         - string:
13             name: BUNDLEURL
14             default: '{bundleurl}'
15             description: 'URL to karaf distribution zip'
16
17 - parameter:
18     name: integration-jdk-version
19     parameters:
20         - string:
21             name: JDKVERSION
22             default: '{jdkversion}'
23             description: 'Parameter to indicate JAVA Version'
24
25 - parameter:
26     name: integration-controller-scope
27     parameters:
28         - string:
29             name: CONTROLLERSCOPE
30             default: '{controller-scope}'
31             description: 'Feature Only or Feature All test'
32
33 - parameter:
34     name: integration-controller-features
35     parameters:
36         - string:
37             name: CONTROLLERFEATURES
38             default: '{controller-features}'
39             description: 'Features to install in the controller separated by comma'
40
41 - parameter:
42     name: integration-distribution-stream
43     parameters:
44         - string:
45             name: DISTROSTREAM
46             default: '{stream}'
47             description: 'Distribution stream string, for suites to know which behavior to expect'
48
49 - parameter:
50     name: integration-stream-test-plan
51     parameters:
52         - string:
53             name: STREAMTESTPLAN
54             default: '{stream-test-plan}'
55             description: 'Stream-specific test plan we will run'
56
57 - parameter:
58     name: integration-test-plan
59     parameters:
60         - string:
61             name: TESTPLAN
62             default: '{test-plan}'
63             description: 'General test plan we will run unless stream-specific one is found'
64
65 - parameter:
66     name: integration-test-options
67     parameters:
68         - string:
69             name: TESTOPTIONS
70             default: '{test-options}'
71             description: 'Robot command options'
72
73 - parameter:
74     name: integration-distribution-git-url
75     parameters:
76         - string:
77             name: DISTROGITURL
78             default: 'ssh://jenkins-$SILO@git.opendaylight.org:29418/integration/distribution'
79             description: 'Distribution GIT URL (do not modify)'
80
81 - parameter:
82     name: integration-patch-refspec
83     parameters:
84         - string:
85             name: PATCHREFSPEC
86             default: '{branch}'
87             description: 'Integration Patch Refspec'
88
89 # Macro: integration-gerrit-scm
90 # Operation: this macro downloads a project gerrit
91 # Used by: all csit jobs
92
93 - scm:
94     name: integration-gerrit-scm
95     scm:
96         - git:
97             credentials-id: 'opendaylight-jenkins-ssh'
98             url: '$GIT_BASE'
99             basedir: '{basedir}'
100             refspec: '{refspec}'
101             branches:
102                 - 'origin/{branch}'
103             skip-tag: true
104             choosing-strategy: 'gerrit'
105
106 # Macro: integration-distribution-scm
107 # Operation: this macro downloads the integration/distribution repo using distribution as basedir
108 # Used by: integration-patch-test-{stream} job template
109
110 - scm:
111     name: integration-distribution-scm
112     scm:
113         - git:
114             credentials-id: 'opendaylight-jenkins-ssh'
115             basedir: 'distribution'
116             url: '$DISTROGITURL'
117             refspec: ''
118             branches:
119                 - 'origin/{branch}'
120             skip-tag: true
121
122 # Macro: integration-trigger-patch-submitted
123 # Operation: this macro sets a trigger for patch submitted on a path pattern
124 # Used by: {project}-verify-csit-* job templates
125
126 - trigger:
127     name: integration-trigger-patch-submitted
128     triggers:
129         - gerrit:
130             server-name: '{server-name}'
131             trigger-on:
132                 - patchset-created-event:
133                     exclude-drafts: 'true'
134                     exclude-trivial-rebase: 'false'
135                     exclude-no-code-change: 'true'
136                 - draft-published-event
137                 - comment-added-contains-event:
138                     comment-contains-value: 'recheck'
139                 - comment-added-contains-event:
140                     comment-contains-value: 'reverify'
141             override-votes: true
142             gerrit-build-unstable-verified-value: +1
143             gerrit-build-unstable-codereview-value: 0
144             projects:
145               - project-compare-type: 'ANT'
146                 project-pattern: '{name}'
147                 branches:
148                   - branch-compare-type: 'ANT'
149                     branch-pattern: '**/{branch}'
150                 file-paths:
151                   - compare-type: 'ANT'
152                     pattern: '{pattern}'
153
154 # Macro: integration-csit-only
155 # Operation: this macro sets a trigger on reverse job list
156 # Used by: csit -only- job templates
157
158 - trigger:
159     name: integration-csit-only
160     triggers:
161         - reverse:
162             jobs: '{jobs}'
163             result: 'success'
164
165 # Macro: integration-csit-all
166 # Operation: this macro sets a periodic trigger
167 # Used by: csit -all- job teamplates
168
169 - trigger:
170     name: integration-csit-all
171     triggers:
172         - timed: 'H H * * *'
173
174 # Macro: integration-jclouds-controller-mininet
175 # Operation: this macro will spin the controller and mininet vms
176 # Used by: {project}-csit-* job templates
177
178 - wrapper:
179     name: integration-jclouds-controller-mininet
180     wrappers:
181       - jclouds:
182           instances:
183             - '{controller-image}':
184                 cloud-name: 'ODLPUB'
185                 count: '{controller-vms}'
186             - '{mininet-image}':
187                 cloud-name: 'ODLPUB'
188                 count: '{mininet-vms}'
189
190 # Macro: integration-openstack-controller-mininet
191 # Operation: this macro will spin the controller and mininet vms
192 # Used by: {project}-csit-* job templates
193
194 - wrapper:
195     name: integration-openstack-controller-mininet
196     wrappers:
197       - openstack:
198           instances:
199             - cloud-name: 'ODLRPC'
200               template-name: '{controller-image}'
201               count: '{controller-vms}'
202             - cloud-name: 'ODLRPC'
203               template-name: '{mininet-image}'
204               count: '{mininet-vms}'
205
206 # Macro: integration-jclouds-controller-devstack
207 # Operation: this macro will spin the controller and devstack vms
208 # Used by: {project}-csit-openstack job templates
209 - wrapper:
210     name: integration-jclouds-controller-devstack
211     wrappers:
212       - jclouds:
213           instances:
214             - '{controller-image}':
215                 cloud-name: 'ODLPUB'
216                 count: '{controller-vms}'
217             - '{openstack-image}':
218                 cloud-name: 'ODLPUB'
219                 count: '{openstack-vms}'
220
221 # Macro: integration-openstack-controller-devstack
222 # Operation: this macro will spin the controller and devstack vms
223 # Used by: {project}-csit-openstack job templates
224 - wrapper:
225     name: integration-openstack-controller-devstack
226     wrappers:
227       - openstack:
228           instances:
229             - cloud-name: 'ODLRPC'
230               template-name: '{controller-image}'
231               count: '{controller-vms}'
232             - cloud-name: 'ODLRPC'
233               template-name: '{openstack-image}'
234               count: '{openstack-vms}'
235
236 # Macro: integration-jclouds-controller-docker
237 # Operation: this macro will sping the controller and docker vms
238 # Used by: {project}-csit-docker job templates
239 - wrapper:
240     name: integration-jclouds-controller-docker
241     wrappers:
242       - jclouds:
243           instances:
244             - '{controller-image}':
245                 cloud-name: 'ODLPUB'
246                 count: '{controller-vms}'
247             - '{docker-image}':
248                 cloud-name: 'ODLPUB'
249                 count: '{docker-vms}'
250
251 #################
252 # Shell Scripts #
253 #################
254
255 # Macro: integration-copy-ssh-keys
256 # Operation: Copy ssh public key used as authentication for robot
257 # Used by: {project}-csit-* job templates
258
259 - builder:
260     name: integration-copy-ssh-keys
261     builders:
262         - shell: |
263             #!/bin/bash
264             function copy-ssh-keys-to-slave() {
265                 RETRIES=60
266                 for j in $(seq 1 $RETRIES); do
267                     if `ssh-copy-id -i /home/jenkins/.ssh/id_rsa.pub "jenkins@${i}" > /dev/null 2>&1`; then
268                         ssh jenkins@${i} 'echo "$(facter ipaddress_eth0) $(/bin/hostname)" | sudo tee -a /etc/hosts'
269                         echo "Successfully copied public keys to slave ${i}"
270                         break
271                     elif [ $j -eq $RETRIES ]; then
272                         echo "SSH not responding on ${i} after $RETIRES tries. Giving up."
273                         exit 1
274                     else
275                         echo "SSH not responding on ${i}. Retrying in 10 seconds..."
276                         sleep 10
277                     fi
278                 done
279             }
280
281             echo "OpenStack IPS are ${JCLOUDS_IPS}"
282
283             IFS=',' read -ra ADDR <<< "${JCLOUDS_IPS}"
284             pids=""
285             for i in "${ADDR[@]}"; do
286                 ( copy-ssh-keys-to-slave ) &
287                 # Store PID of process
288                 pids+=" $!"
289             done
290
291             # Detect when a process failed to copy ssh keys and fail build
292             for p in $pids; do
293                 if wait $p; then
294                     echo "Process $p successfully copied ssh keys."
295                 else
296                     echo "Process $p failed to copy ssh keys."
297                     exit 1
298                 fi
299             done
300             echo "Copying ssh keys complete."
301
302 # Macro: integration-get-slave-addresses
303 # Operation: this macro gets the IP addresses of the dynamic vms
304 # Used by: {project}-csit-* job templates
305
306 - builder:
307     name: integration-get-slave-addresses
308     builders:
309         - shell:
310             !include-raw:
311                 - include-raw-integration-get-slave-addresses.sh
312
313 # Macro: integration-get-bundle-vars
314 # Operation: this macro gets all bundle related variables
315 # Used by: {project}-csit-3node-* job templates
316
317 - builder:
318     name: integration-get-bundle-vars
319     builders:
320         - shell:
321             !include-raw:
322                 - include-raw-integration-get-bundle-vars.sh
323
324 # Macro: integration-distribution-check
325 # Operation: this macro deploys the controller with all fetures
326 # Used by: {project}-distribution-check-{stream} job template
327
328 - builder:
329     name: integration-distribution-check
330     builders:
331         - shell:
332             !include-raw:
333                 - include-raw-integration-distribution-check.sh
334
335 # Macro: integration-deploy-controller-verify
336 # Operation: this macro deploys the controller with all fetures
337 # Used by: integration-distribution-deploy-{stream} job template
338
339 - builder:
340     name: integration-deploy-controller-verify
341     builders:
342         - shell:
343             !include-raw:
344                 - include-raw-integration-deploy-controller-verify.sh
345
346 # Macro: integration-deploy-controller-offline
347 # Operation: this macro deploys the controller with no external repo configuration
348 # Used by: integration-distrbution-offline-{stream} job template
349
350 - builder:
351     name: integration-deploy-controller-offline
352     builders:
353         - shell:
354             !include-raw:
355                 - include-raw-integration-deploy-controller-offline.sh
356
357 # Macro: integration-deply-controller-run-test
358 # Operation: this macro deploys single contoller and runs test
359 # Used by: {project}-csit-1node-* job templates
360
361 - builder:
362     name: integration-deploy-controller-run-test
363     builders:
364         - shell:
365             !include-raw:
366                 - include-raw-integration-deploy-controller-run-test.sh
367
368 # Macro: integration-configure-clustering
369 # Operation: this macro configures the clustering
370 # Used by: {project}-csit-3node-* job templates
371
372 - builder:
373     name: integration-configure-clustering
374     builders:
375         - shell:
376             !include-raw:
377                 - include-raw-integration-configure-clustering.sh
378
379 # Macro: integration-start-cluster-run-test
380 # Operation: this macro starts the 3-node cluster and runs test
381 # Used by: {project}-csit-3node-* job templates
382
383 - builder:
384     name: integration-start-cluster-run-test
385     builders:
386         - shell:
387             !include-raw:
388                 - include-raw-integration-start-cluster-run-test.sh
389
390 # Macro: integration-get-bundle-url
391 # Operation: this macro gets the job generated distribution URL from distribution pom.xml
392 # Used by: integration-patch-test-{stream} job template
393
394 - builder:
395     name: integration-get-bundle-url
396     builders:
397         - shell:
398             !include-raw:
399                 - include-raw-integration-get-bundle-url.sh
400
401 # Macro: integration-get-bundle-url-root
402 # Operation: this macro gets the job generated distribution URL from root pom.xml
403 # Used by: integration-distribution-verify-{stream} job template
404
405 - builder:
406     name: integration-get-bundle-url-root
407     builders:
408         - shell:
409             !include-raw:
410                 - include-raw-integration-get-bundle-url-root.sh
411
412 # Macro: integration-install-robotframework
413 # Operation: Installs robotframework using pip to a virtualenv
414 # Used by: {project}-csit-* job templates
415
416 - builder:
417     name: integration-install-robotframework
418     builders:
419         - shell:
420             !include-raw:
421                 - include-raw-integration-install-robotframework.sh
422
423 # Macro: integration-cleanup-tmp
424 # Operation: Cleans up temporary files created by build
425 # Used by: {project}-csit-* job templates
426
427 - builder:
428     name: integration-cleanup-tmp
429     builders:
430         - shell:
431             !include-raw:
432                 - include-raw-integration-cleanup-tmp.sh
433
434 # Macro: integration-multipatch-builder
435 # Operation: checks out multiple patches and builds custom distribution
436 # Used by: integration-multipatch-test-* job templates
437
438 - builder:
439     name: integration-multipatch-builder
440     builders:
441         - shell:
442             !include-raw:
443                 - include-raw-integration-multipatch-distribution-test.sh
444
445 # Macro: integration-cleanup-worspace
446 # Operation: Cleans up files possibly left there by the previous build
447 # Used by: {project}-csit-* job templates
448
449 - builder:
450     name: integration-cleanup-workspace
451     builders:
452         - shell:
453             !include-raw:
454                 - include-raw-integration-cleanup-workspace.sh
455
456 # Macro: integration-rebase-patch
457 # Operation: For cloned project, rebase checked-out Gerrit patch onto $BRANCH.
458 # Used by: integration-patch-distribution-* job template
459
460 - builder:
461     name: integration-rebase-gerrit-patch
462     builders:
463         - shell:
464             !include-raw:
465                 - include-raw-integration-rebase-gerrit-patch.sh
466
467 - builder:
468     name: integration-deploy-openstack-run-test
469     builders:
470         - shell:
471             !include-raw:
472                 - include-raw-integration-deploy-openstack-run-test.sh
473 ##############
474 # Publishers #
475 ##############
476
477 # Macro: integration-robot
478 # Operation: this macro publishes robot results
479 # Used by: {project}-csit-* job templates
480
481 - publisher:
482     name: integration-robot
483     publishers:
484         - robot:
485             output-path: ''
486             other-files: ''
487             unstable-threshold: '{unstable-if}'
488             pass-threshold: '{pass-if}'
489             only-critical: false
490
491 - publisher:
492     name: integration-robot-tempest
493     publishers:
494         - robot:
495             output-path: ''
496             other-files:
497                 - tempest_results.html
498             unstable-threshold: '{unstable-if}'
499             pass-threshold: '{pass-if}'
500             only-critical: false
501
502 - publisher:
503     name: integration-csit-archive-build
504     publishers:
505         - postbuildscript:
506             builders:
507                 - shell: |
508                     #!/bin/bash
509                     mkdir $WORKSPACE/archives
510                     curl --output robot-plugin.zip "$BUILD_URL/robot/report/*zip*/robot-plugin.zip"
511                     unzip -d $WORKSPACE/archives robot-plugin.zip
512                     mv *log* *.log *.log.gz *.csv *.png $WORKSPACE/archives || true  # Don't fail if file missing
513             script-only-if-succeeded: False
514             script-only-if-failed: False
515             mark-unstable-if-failed: True