OpenStack Heat Orchestration Templates
[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: '{git-url}/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 # This is a single macro to use for all csit jobs who vote on every (relevant) patch set.
124 # Only 'recheck' trigger word is supported, it always triggers the full set of relevant jobs,
125 # in order to prevent Jenkins from starting only a subset and still voting Verified+1.
126 # Contrary to gerrit-trigger-patch-submitted, this votes +1 also on unstable runs.
127 # Arguments:
128 #     server: name of gerrit server to listen to
129 #     project: pattern to match triggering projects
130 #     branch: triggering branch name
131 #     files: pattern to match triggering filepaths
132 - trigger:
133     name: integration-trigger-patch-submitted
134     triggers:
135         - gerrit:
136             server-name: '{server}'
137             trigger-on:
138                 - patchset-created-event:
139                     exclude-drafts: 'true'
140                     exclude-trivial-rebase: 'false'
141                     exclude-no-code-change: 'true'
142                 - draft-published-event
143                 - comment-added-contains-event:
144                     comment-contains-value: 'recheck'
145             override-votes: true
146             gerrit-build-unstable-verified-value: +1
147             gerrit-build-unstable-codereview-value: 0
148             projects:
149                 - project-compare-type: 'ANT'
150                   project-pattern: '{project}'
151                   branches:
152                       - branch-compare-type: 'ANT'
153                         branch-pattern: '**/{branch}'
154                   file-paths:
155                       - compare-type: 'ANT'
156                         pattern: '{files}'
157
158 # Macro: integration-csit-only
159 # Operation: this macro sets a trigger on reverse job list
160 # Used by: csit -only- job templates
161
162 - trigger:
163     name: integration-csit-only
164     triggers:
165         - reverse:
166             jobs: '{jobs}'
167             result: 'success'
168
169 # Macro: integration-csit-all
170 # Operation: this macro sets a periodic trigger
171 # Used by: csit -all- job teamplates
172
173 - trigger:
174     name: integration-csit-all
175     triggers:
176         - timed: 'H H * * *'
177
178 # Macro: integration-jclouds-controller-mininet
179 # Operation: this macro will spin the controller and mininet vms
180 # Used by: {project}-csit-* job templates
181
182 - wrapper:
183     name: integration-jclouds-controller-mininet
184     wrappers:
185       - jclouds:
186           instances:
187             - '{controller-image}':
188                 cloud-name: 'ODLPUB'
189                 count: '{controller-vms}'
190             - '{mininet-image}':
191                 cloud-name: 'ODLPUB'
192                 count: '{mininet-vms}'
193
194 # Macro: integration-openstack-controller-mininet
195 # Operation: this macro will spin the controller and mininet vms
196 # Used by: {project}-csit-* job templates
197
198 - wrapper:
199     name: integration-openstack-controller-mininet
200     wrappers:
201       - openstack:
202           instances:
203             - cloud-name: 'ODLRPC'
204               template-name: '{controller-image}'
205               count: '{controller-vms}'
206             - cloud-name: 'ODLRPC'
207               template-name: '{mininet-image}'
208               count: '{mininet-vms}'
209
210 # Macro: integration-jclouds-controller-devstack
211 # Operation: this macro will spin the controller and devstack vms
212 # Used by: {project}-csit-openstack job templates
213 - wrapper:
214     name: integration-jclouds-controller-devstack
215     wrappers:
216       - jclouds:
217           instances:
218             - '{controller-image}':
219                 cloud-name: 'ODLPUB'
220                 count: '{controller-vms}'
221             - '{openstack-image}':
222                 cloud-name: 'ODLPUB'
223                 count: '{openstack-vms}'
224
225 # Macro: integration-openstack-controller-devstack
226 # Operation: this macro will spin the controller and devstack vms
227 # Used by: {project}-csit-openstack job templates
228 - wrapper:
229     name: integration-openstack-controller-devstack
230     wrappers:
231       - openstack:
232           instances:
233             - cloud-name: 'ODLRPC'
234               template-name: '{controller-image}'
235               count: '{controller-vms}'
236             - cloud-name: 'ODLRPC'
237               template-name: '{openstack-image}'
238               count: '{openstack-vms}'
239
240 # Macro: integration-jclouds-controller-docker
241 # Operation: this macro will sping the controller and docker vms
242 # Used by: {project}-csit-docker job templates
243 - wrapper:
244     name: integration-jclouds-controller-docker
245     wrappers:
246       - jclouds:
247           instances:
248             - '{controller-image}':
249                 cloud-name: 'ODLPUB'
250                 count: '{controller-vms}'
251             - '{docker-image}':
252                 cloud-name: 'ODLPUB'
253                 count: '{docker-vms}'
254
255 #################
256 # Shell Scripts #
257 #################
258
259 # Macro: integration-copy-ssh-keys
260 # Operation: Copy ssh public key used as authentication for robot
261 # Used by: {project}-csit-* job templates
262 #
263 # TODO: Remove this macro. This code is moved into the new macro opendaylight-infra-stack
264
265 - builder:
266     name: integration-copy-ssh-keys
267     builders:
268         - shell: |
269             #!/bin/bash
270             function copy-ssh-keys-to-slave() {
271                 RETRIES=60
272                 for j in $(seq 1 $RETRIES); do
273                     if `ssh-copy-id -i /home/jenkins/.ssh/id_rsa.pub "jenkins@${i}" > /dev/null 2>&1`; then
274                         ssh jenkins@${i} 'echo "$(facter ipaddress_eth0) $(/bin/hostname)" | sudo tee -a /etc/hosts'
275                         echo "Successfully copied public keys to slave ${i}"
276                         break
277                     elif [ $j -eq $RETRIES ]; then
278                         echo "SSH not responding on ${i} after $RETIRES tries. Giving up."
279                         exit 1
280                     else
281                         echo "SSH not responding on ${i}. Retrying in 10 seconds..."
282                         sleep 10
283                     fi
284                 done
285             }
286
287             echo "OpenStack IPS are ${JCLOUDS_IPS}"
288
289             IFS=',' read -ra ADDR <<< "${JCLOUDS_IPS}"
290             pids=""
291             for i in "${ADDR[@]}"; do
292                 ( copy-ssh-keys-to-slave ) &
293                 # Store PID of process
294                 pids+=" $!"
295             done
296
297             # Detect when a process failed to copy ssh keys and fail build
298             for p in $pids; do
299                 if wait $p; then
300                     echo "Process $p successfully copied ssh keys."
301                 else
302                     echo "Process $p failed to copy ssh keys."
303                     exit 1
304                 fi
305             done
306             echo "Copying ssh keys complete."
307
308 # Macro: integration-get-slave-addresses
309 # Operation: this macro gets the IP addresses of the dynamic vms
310 # Used by: {project}-csit-* job templates
311
312 - builder:
313     name: integration-get-slave-addresses
314     builders:
315         - shell:
316             !include-raw:
317                 - include-raw-integration-get-slave-addresses.sh
318
319 # Macro: integration-get-bundle-vars
320 # Operation: this macro gets all bundle related variables
321 # Used by: {project}-csit-3node-* job templates
322
323 - builder:
324     name: integration-get-bundle-vars
325     builders:
326         - shell:
327             !include-raw:
328                 - include-raw-integration-get-bundle-vars.sh
329
330 # Macro: integration-distribution-check
331 # Operation: this macro deploys the controller with all fetures
332 # Used by: {project}-distribution-check-{stream} job template
333
334 - builder:
335     name: integration-distribution-check
336     builders:
337         - shell:
338             !include-raw:
339                 - include-raw-integration-distribution-check.sh
340
341 # Macro: integration-deploy-controller-verify
342 # Operation: this macro deploys the controller with all fetures
343 # Used by: integration-distribution-deploy-{stream} job template
344
345 - builder:
346     name: integration-deploy-controller-verify
347     builders:
348         - shell:
349             !include-raw:
350                 - include-raw-integration-deploy-controller-verify.sh
351
352 # Macro: integration-deploy-controller-offline
353 # Operation: this macro deploys the controller with no external repo configuration
354 # Used by: integration-distrbution-offline-{stream} job template
355
356 - builder:
357     name: integration-deploy-controller-offline
358     builders:
359         - shell:
360             !include-raw:
361                 - include-raw-integration-deploy-controller-offline.sh
362
363 # Macro: integration-deply-controller-run-test
364 # Operation: this macro deploys single contoller and runs test
365 # Used by: {project}-csit-1node-* job templates
366
367 - builder:
368     name: integration-deploy-controller-run-test
369     builders:
370         - shell:
371             !include-raw:
372                 - include-raw-integration-deploy-controller-run-test.sh
373
374 # Macro: integration-configure-clustering
375 # Operation: this macro configures the clustering
376 # Used by: {project}-csit-3node-* job templates
377
378 - builder:
379     name: integration-configure-clustering
380     builders:
381         - shell:
382             !include-raw:
383                 - include-raw-integration-configure-clustering.sh
384
385 # Macro: integration-start-cluster-run-test
386 # Operation: this macro starts the 3-node cluster and runs test
387 # Used by: {project}-csit-3node-* job templates
388
389 - builder:
390     name: integration-start-cluster-run-test
391     builders:
392         - shell:
393             !include-raw:
394                 - include-raw-integration-start-cluster-run-test.sh
395
396 # Macro: integration-get-bundle-url
397 # Operation: this macro gets the job generated distribution URL from distribution pom.xml
398 # Used by: integration-patch-test-{stream} job template
399
400 - builder:
401     name: integration-get-bundle-url
402     builders:
403         - shell:
404             !include-raw:
405                 - include-raw-integration-get-bundle-url.sh
406
407 # Macro: integration-get-bundle-url-root
408 # Operation: this macro gets the job generated distribution URL from root pom.xml
409 # Used by: integration-distribution-verify-{stream} job template
410
411 - builder:
412     name: integration-get-bundle-url-root
413     builders:
414         - shell:
415             !include-raw:
416                 - include-raw-integration-get-bundle-url-root.sh
417
418 # Macro: integration-install-robotframework
419 # Operation: Installs robotframework using pip to a virtualenv
420 # Used by: {project}-csit-* job templates
421
422 - builder:
423     name: integration-install-robotframework
424     builders:
425         - shell:
426             !include-raw:
427                 - include-raw-integration-install-robotframework.sh
428
429 # Macro: integration-cleanup-tmp
430 # Operation: Cleans up temporary files created by build
431 # Used by: {project}-csit-* job templates
432
433 - builder:
434     name: integration-cleanup-tmp
435     builders:
436         - shell:
437             !include-raw:
438                 - include-raw-integration-cleanup-tmp.sh
439
440 # Macro: integration-multipatch-builder
441 # Operation: checks out multiple patches and builds custom distribution
442 # Used by: integration-multipatch-test-* job templates
443
444 - builder:
445     name: integration-multipatch-builder
446     builders:
447         - shell:
448             !include-raw:
449                 - include-raw-integration-multipatch-distribution-test.sh
450
451 # Macro: integration-cleanup-workspace
452 # Operation: Cleans up files possibly left there by the previous build
453 # Used by: {project}-csit-* job templates
454
455 - builder:
456     name: integration-cleanup-workspace
457     builders:
458         - shell:
459             !include-raw:
460                 - include-raw-integration-cleanup-workspace.sh
461
462 # Macro: integration-rebase-patch
463 # Operation: For cloned project, rebase checked-out Gerrit patch onto $BRANCH.
464 # Used by: integration-patch-distribution-* job template
465
466 - builder:
467     name: integration-rebase-gerrit-patch
468     builders:
469         - shell:
470             !include-raw:
471                 - include-raw-integration-rebase-gerrit-patch.sh
472
473 - builder:
474     name: integration-deploy-openstack-run-test
475     builders:
476         - shell:
477             !include-raw:
478                 - include-raw-integration-deploy-openstack-run-test.sh
479 ##############
480 # Publishers #
481 ##############
482
483 # Macro: integration-robot
484 # Operation: this macro publishes robot results
485 # Used by: {project}-csit-* job templates
486
487 - publisher:
488     name: integration-robot
489     publishers:
490         - robot:
491             output-path: ''
492             other-files: ''
493             unstable-threshold: '{unstable-if}'
494             pass-threshold: '{pass-if}'
495             only-critical: false
496
497 - publisher:
498     name: integration-robot-tempest
499     publishers:
500         - robot:
501             output-path: ''
502             other-files:
503                 - tempest_results.html
504             unstable-threshold: '{unstable-if}'
505             pass-threshold: '{pass-if}'
506             only-critical: false
507
508 - publisher:
509     name: integration-csit-archive-build
510     publishers:
511         - postbuildscript:
512             builders:
513                 - shell: |
514                     #!/bin/bash
515                     mkdir -p $WORKSPACE/archives
516                     curl --output robot-plugin.zip "$BUILD_URL/robot/report/*zip*/robot-plugin.zip"
517                     unzip -d $WORKSPACE/archives robot-plugin.zip
518                     mv *log* *.log *.log.gz *.csv *.png $WORKSPACE/archives || true  # Don't fail if file missing
519             script-only-if-succeeded: False
520             script-only-if-failed: False
521             mark-unstable-if-failed: True