Merge "Fail if image delete does not succeed"
[releng/builder.git] / jjb / integration / integration-macros.yaml
1 ---
2 # TODO: Make all bash constants more readable.
3 # e.g.: DISTRIBUTION_BRANCH instead of DISTROBRANCH.
4 - parameter:
5     name: integration-distribution-branch
6     parameters:
7       - string:
8           name: DISTROBRANCH
9           default: '{branch}'
10           description: 'Distribution GIT branch'
11
12 - parameter:
13     name: distribution-karaf-version
14     # Arguments:
15     #   karaf-version: Provide, otherwise defaults.yaml value is used.
16     parameters:
17       - string:
18           name: KARAF_VERSION
19           default: '{karaf-version}'
20           description: 'karaf3, karaf4, odl, affects ODL deploy scripts'
21
22 - parameter:
23     name: integration-bundle-url
24     parameters:
25       - string:
26           name: BUNDLE_URL
27           default: '{bundle-url}'
28           description: 'URL to karaf distribution zip'
29
30 - parameter:
31     name: integration-repo-url
32     parameters:
33       - string:
34           name: REPO_URL
35           default: '{repo-url}'
36           description: 'URL to feature repo artifact'
37
38 - parameter:
39     name: integration-jdk-version
40     parameters:
41       - string:
42           name: JDKVERSION
43           default: '{jdkversion}'
44           description: 'Parameter to indicate JAVA Version'
45
46 - parameter:
47     name: integration-controller-scope
48     parameters:
49       - string:
50           name: CONTROLLERSCOPE
51           default: '{controller-scope}'
52           description: 'Feature Only or Feature All test'
53
54 - parameter:
55     name: integration-controller-features
56     parameters:
57       - string:
58           name: CONTROLLERFEATURES
59           default: '{controller-features}'
60           description: 'Features to install in the controller separated by comma'
61
62 - parameter:
63     name: integration-controller-debug-map
64     parameters:
65       - string:
66           name: CONTROLLERDEBUGMAP
67           default: '{controller-debug-map}'
68           description: |
69               Key:Value map of debugs to enable on the controller separated by spaces.
70               The module should not include org.opendaylight.
71               The levels must be one of: ERROR, WARN, INFO, DEBUG, TRACE.
72               (ex. ovsdb.lib:ERROR netvirt.vpnservice:INFO)
73
74 - parameter:
75     name: integration-distribution-stream
76     parameters:
77       - string:
78           name: DISTROSTREAM
79           default: '{stream}'
80           description: 'Distribution stream string, for suites to know which behavior to expect'
81
82 - parameter:
83     name: integration-script-plan
84     parameters:
85       - string:
86           name: SCRIPTPLAN
87           default: '{script-plan}'
88           description: 'Script plan we will run before downloading and un-archiving am ODL distribution'
89
90 - parameter:
91     name: integration-config-plan
92     parameters:
93       - string:
94           name: CONFIGPLAN
95           default: '{config-plan}'
96           description: 'Config plan we will run after un-archiving and starting an ODL distribution'
97
98 - parameter:
99     name: integration-stream-test-plan
100     parameters:
101       - string:
102           name: STREAMTESTPLAN
103           default: '{stream-test-plan}'
104           description: 'Stream-specific test plan we will run'
105
106 - parameter:
107     name: integration-test-plan
108     parameters:
109       - string:
110           name: TESTPLAN
111           default: '{test-plan}'
112           description: 'General test plan we will run unless stream-specific one is found'
113
114 - parameter:
115     name: integration-test-suites
116     parameters:
117       - string:
118           name: SUITES
119           default: '{test-suites}'
120           description: |
121               List of space-separated suites. Useful when running specific suites within a testplan.
122               Do not include ${{WORKSPACE}}/test/csit/suites/ in the values:
123               (ex. openstack/connectivity/l2.robot openstack/clustering/ha_l2.robot
124                openstack/tempest/tempest.robot netvirt/elan/elan.robot).
125
126 - parameter:
127     name: integration-test-options
128     parameters:
129       - string:
130           name: TESTOPTIONS
131           default: '{test-options}'
132           description: 'Robot command options'
133
134 - parameter:
135     name: gate-job
136     parameters:
137       - string:
138           name: GATE_JOB
139           default: '{gate-job}'
140           description: 'Flag to indicate if job is for gating or not'
141
142 - parameter:
143     name: integration-distribution-git-url
144     parameters:
145       - string:
146           name: DISTROGITURL
147           default: '{git-url}/integration/distribution'
148           description: 'Distribution GIT URL (do not modify)'
149
150 - parameter:
151     name: integration-patch-refspec
152     parameters:
153       - string:
154           name: PATCHREFSPEC
155           default: '{branch}'
156           description: 'Integration Patch Refspec'
157
158 - parameter:
159     name: integration-use-features-boot
160     parameters:
161       - string:
162           name: USEFEATURESBOOT
163           default: '{use-features-boot}'
164           description: 'Boolean to toggle whether featuresBoot is appended or ignored'
165
166 # Macro: integration-gerrit-scm
167 # Operation: this macro downloads a project gerrit
168 # Used by: all csit jobs
169
170 - scm:
171     name: integration-gerrit-scm
172     scm:
173       - git:
174           credentials-id: 'opendaylight-jenkins-ssh'
175           url: '$GIT_BASE'
176           basedir: '{basedir}'
177           refspec: '{refspec}'
178           branches:
179             - 'origin/{branch}'
180           skip-tag: true
181           choosing-strategy: 'gerrit'
182
183 # Macro: integration-distribution-scm
184 # Operation: this macro downloads the integration/distribution repo using distribution as basedir
185 # Used by: integration-patch-test-{stream} job template
186
187 - scm:
188     name: integration-distribution-scm
189     scm:
190       - git:
191           credentials-id: 'opendaylight-jenkins-ssh'
192           basedir: 'distribution'
193           url: '$DISTROGITURL'
194           refspec: ''
195           branches:
196             - 'origin/{branch}'
197           skip-tag: true
198
199 # Macro: integration-trigger-patch-submitted
200 # This is a single macro to use for all csit jobs who vote on every (relevant) patch set.
201 # Only 'recheck' trigger word is supported, it always triggers the full set of relevant jobs,
202 # in order to prevent Jenkins from starting only a subset and still voting Verified+1.
203 # Contrary to gerrit-trigger-patch-submitted, this votes +1 also on unstable runs.
204 # Arguments:
205 #     gerrit-server-name: name of gerrit server to listen to
206 #     project: pattern to match triggering projects
207 #     branch: triggering branch name
208 #     files: pattern to match triggering filepaths
209 - trigger:
210     name: integration-trigger-patch-submitted
211     triggers:
212       - gerrit:
213           server-name: '{gerrit-server-name}'
214           trigger-on:
215             - patchset-created-event:
216                 exclude-drafts: true
217                 exclude-trivial-rebase: false
218                 exclude-no-code-change: false
219             - draft-published-event
220             - comment-added-contains-event:
221                 comment-contains-value: '^Patch Set[ ]+[0-9]+:([ ]+|[\n]+)(recheck|reverify)$'
222           override-votes: true
223           gerrit-build-unstable-verified-value: +1
224           gerrit-build-unstable-codereview-value: 0
225           projects:
226             - project-compare-type: ANT
227               project-pattern: '{project}'
228               branches:
229                 - branch-compare-type: ANT
230                   branch-pattern: '**/{branch}'
231               file-paths:
232                 - compare-type: ANT
233                   pattern: '{files}'
234
235 # Macro: integration-csit-only
236 # Operation: this macro sets a trigger on reverse job list
237 # Used by: csit -only- job templates
238
239 - trigger:
240     name: integration-csit-trigger
241     triggers:
242       - reverse:
243           jobs: '{jobs}'
244           result: 'success'
245
246 # Macro: integration-openstack-controller-mininet
247 # Operation: this macro will spin the controller and mininet vms
248 # Used by: {project}-csit-* job templates
249
250 - wrapper:
251     name: integration-openstack-controller-mininet
252     wrappers:
253       - openstack:
254           instances:
255             - cloud-name: 'ODLRPC'
256               template-name: '{controller-image}'
257               count: '{controller-vms}'
258             - cloud-name: 'ODLRPC'
259               template-name: '{mininet-image}'
260               count: '{mininet-vms}'
261
262 # Macro: integration-openstack-controller-devstack
263 # Operation: this macro will spin the controller and devstack vms
264 # Used by: {project}-csit-openstack job templates
265 - wrapper:
266     name: integration-openstack-controller-devstack
267     wrappers:
268       - openstack:
269           instances:
270             - cloud-name: 'ODLRPC'
271               template-name: '{controller-image}'
272               count: '{controller-vms}'
273             - cloud-name: 'ODLRPC'
274               template-name: '{openstack-image}'
275               count: '{openstack-vms}'
276
277 #################
278 # Shell Scripts #
279 #################
280
281 # Macro: integration-infra-stack
282 # Operation: Sets environment and then calls opendaylight-infra-stack to spin
283 #            up csit lab using openstack-heat.
284 # Used by: {project}-csit-* job templates
285
286 - builder:
287     name: integration-infra-stack
288     builders:
289       - integration-cleanup-workspace
290       - shell: |
291           #!/bin/bash
292           # Setup openstack envirnoment file for use by
293           # the opendaylight-infra-stack macro
294           cat > $WORKSPACE/opendaylight-infra-environment.yaml << EOF
295           parameters:
296               vm_0_count: {vm_0_count}
297               vm_0_flavor: {vm_0_flavor}
298               vm_0_image: {vm_0_image}
299               vm_1_count: {vm_1_count}
300               vm_1_flavor: {vm_1_flavor}
301               vm_1_image: {vm_1_image}
302           EOF
303           echo "Contents of opendaylight-infra-environment.yaml ..."
304           cat $WORKSPACE/opendaylight-infra-environment.yaml
305       - opendaylight-infra-stack:
306           stack-template: '{stack-template}'
307
308 # Macro: integration-infra-stack-3-type
309 # Operation: Sets environment and then calls opendaylight-infra-stack to spin
310 #            up csit lab using openstack-heat.
311 # Used by: {project}-csit-* job templates
312
313 - builder:
314     name: integration-infra-stack-3-type
315     builders:
316       - integration-cleanup-workspace
317       - shell: |
318           #!/bin/bash
319           # Setup openstack envirnoment file for use by
320           # the opendaylight-infra-stack macro
321           cat > $WORKSPACE/opendaylight-infra-environment.yaml << EOF
322           parameters:
323               vm_0_count: {vm_0_count}
324               vm_0_flavor: {vm_0_flavor}
325               vm_0_image: {vm_0_image}
326               vm_1_count: {vm_1_count}
327               vm_1_flavor: {vm_1_flavor}
328               vm_1_image: {vm_1_image}
329               vm_2_count: {vm_2_count}
330               vm_2_flavor: {vm_2_flavor}
331               vm_2_image: {vm_2_image}
332           EOF
333           echo "Contents of opendaylight-infra-environment.yaml ..."
334           cat $WORKSPACE/opendaylight-infra-environment.yaml
335       - opendaylight-infra-stack:
336           stack-template: 'csit-3-instance-type.yaml'
337
338 # Macro: integration-apex-stack-3-type
339 # Operation: Sets environment and then calls opendaylight-apex-stack to spin
340 #            up csit lab using openstack-heat.
341 # Used by: {project}-csit-* apex related job templates
342
343 - builder:
344     name: integration-apex-stack-3-type
345     builders:
346       - integration-cleanup-workspace
347       - shell: |
348           #!/bin/bash
349           # Setup openstack envirnoment file for use by
350           # the opendaylight-infra-stack macro
351           cat > $WORKSPACE/opendaylight-infra-environment.yaml << EOF
352           parameters:
353               vm_0_count: {vm_0_count}
354               vm_0_flavor: {vm_0_flavor}
355               vm_0_image: {vm_0_image}
356               vm_1_count: {vm_1_count}
357               vm_1_flavor: {vm_1_flavor}
358               vm_1_image: {vm_1_image}
359               vm_2_count: {vm_2_count}
360               vm_2_flavor: {vm_2_flavor}
361               vm_2_image: {vm_2_image}
362           EOF
363           echo "Contents of opendaylight-infra-environment.yaml ..."
364           cat $WORKSPACE/opendaylight-infra-environment.yaml
365       - opendaylight-apex-stack:
366           stack-template: 'csit-apex-3-instance-type.yaml'
367
368 # Macro: integration-infra-stack-4-type
369 # Operation: Sets environment and then calls opendaylight-infra-stack to spin
370 #            up csit lab using openstack-heat.
371 # Used by: {project}-csit-* job templates
372
373 - builder:
374     name: integration-infra-stack-4-type
375     builders:
376       - integration-cleanup-workspace
377       - shell: |
378           #!/bin/bash
379           # Setup openstack envirnoment file for use by
380           # the opendaylight-infra-stack macro
381           cat > $WORKSPACE/opendaylight-infra-environment.yaml << EOF
382           parameters:
383               vm_0_count: {vm_0_count}
384               vm_0_flavor: {vm_0_flavor}
385               vm_0_image: {vm_0_image}
386               vm_1_count: {vm_1_count}
387               vm_1_flavor: {vm_1_flavor}
388               vm_1_image: {vm_1_image}
389               vm_2_count: {vm_2_count}
390               vm_2_flavor: {vm_2_flavor}
391               vm_2_image: {vm_2_image}
392               vm_3_count: {vm_3_count}
393               vm_3_flavor: {vm_3_flavor}
394               vm_3_image: {vm_3_image}
395           EOF
396           echo "Contents of opendaylight-infra-environment.yaml ..."
397           cat $WORKSPACE/opendaylight-infra-environment.yaml
398       - opendaylight-infra-stack:
399           stack-template: 'csit-4-instance-type.yaml'
400
401 # Macro: integration-get-apex-addresses
402 # Operation: this macro gets the IP addresses of the dynamic vms from apex snapshots
403 # Used by: {project}-csit-* apex related job templates
404
405 - builder:
406     name: integration-get-apex-addresses
407     builders:
408       - shell: !include-raw: integration-get-apex-addresses.sh
409
410 # Macro: integration-apex-run-tests
411 # Operation: this macro just runs the robot suites
412 # Used by: {project}-csit-* apex related job templates
413
414 - builder:
415     name: integration-apex-run-tests
416     builders:
417       - shell: !include-raw: integration-apex-run-tests.sh
418
419 # Macro: integration-get-slave-addresses
420 # Operation: this macro gets the IP addresses of the dynamic vms
421 # Used by: {project}-csit-* job templates
422
423 - builder:
424     name: integration-get-slave-addresses
425     builders:
426       - shell: !include-raw: integration-get-slave-addresses.sh
427
428 - builder:
429     name: integration-set-variables
430     # Operation: Construct variables not requiring online detection and export using set_variables.env
431     # Required bash variables:
432     #   KARAF_VERSION: 'karaf4' or 'karaf3'. Use distribution-karaf-version macro to set.
433     builders:
434       - shell: !include-raw: integration-set-variables.sh
435       - inject:
436           properties-file: set_variables.env
437
438 - builder:
439     name: integration-detect-variables
440     # Operation: Construct variables including online detection and export using detect_variables.env
441     #   This calls integration-set-variables internally.
442     # Required bash variables:
443     #   KARAF_VERSION: 'karaf4' or 'karaf3'. Use distribution-karaf-version macro to set.
444     builders:
445       - integration-set-variables
446       - shell: !include-raw: integration-detect-variables.sh
447       - inject:
448           properties-file: detect_variables.env
449
450 # Macro: integration-deply-controller-run-test
451 # Operation: this macro deploys single contoller and runs test
452 # Used by: {project}-csit-1node-* job templates
453
454 - builder:
455     name: integration-deploy-controller-run-test
456     builders:
457       - shell: !include-raw: integration-deploy-controller-run-test.sh
458
459 # Macro: integration-configure-clustering
460 # Operation: this macro configures the clustering
461 # Used by: {project}-csit-3node-* job templates
462
463 - builder:
464     name: integration-configure-clustering
465     builders:
466       - shell: !include-raw: integration-configure-clustering.sh
467
468 # Macro: integration-start-cluster-run-test
469 # Operation: this macro starts the 3-node cluster and runs test
470 # Used by: {project}-csit-3node-* job templates
471
472 - builder:
473     name: integration-start-cluster-run-test
474     builders:
475       - shell: !include-raw: integration-start-cluster-run-test.sh
476
477 # Macro: integration-install-robotframework
478 # Operation: Installs robotframework using pip to a virtualenv
479 # Used by: {project}-csit-* job templates
480
481 - builder:
482     name: integration-install-robotframework
483     builders:
484       - shell: !include-raw: integration-install-robotframework.sh
485
486 # Macro: integration-cleanup-tmp
487 # Operation: Cleans up temporary files created by build
488 # Used by: {project}-csit-* job templates
489
490 - builder:
491     name: integration-cleanup-tmp
492     builders:
493       - shell: !include-raw: integration-cleanup-tmp.sh
494
495 # Macro: integration-multipatch-builder
496 # Operation: checks out multiple patches and builds custom distribution
497 # Used by: integration-multipatch-test-* job templates
498
499 - builder:
500     name: integration-multipatch-builder
501     builders:
502       - shell: !include-raw: multipatch-distribution.sh
503
504 # Macro: integration-cleanup-workspace
505 # Operation: Cleans up files possibly left there by the previous build
506 # Used by: {project}-csit-* job templates
507
508 - builder:
509     name: integration-cleanup-workspace
510     builders:
511       - shell: !include-raw: integration-cleanup-workspace.sh
512
513 # Macro: integration-rebase-patch
514 # Operation: For cloned project, rebase checked-out Gerrit patch onto $DISTROBRANCH.
515 # Used by: integration-patch-distribution-* job template
516
517 - builder:
518     name: integration-rebase-gerrit-patch
519     builders:
520       - shell: !include-raw: integration-rebase-gerrit-patch.sh
521
522 # Macro: integration-install-common-functions
523 # Operation: Copy the common-functions.sh script to csit nodes
524 # Used by: {project}-csit-* job templates
525 - builder:
526     name: integration-install-common-functions
527     builders:
528       - shell: !include-raw:
529           - copy-common-functions.sh
530           - common-functions.sh
531
532 - builder:
533     name: integration-deploy-openstack-run-test
534     builders:
535       - shell: !include-raw:
536           - integration-deploy-openstack-run-test.sh
537
538 - builder:
539     name: integration-apex-image-manager
540     builders:
541       - shell: !include-raw:
542           - ../opendaylight-infra-apex-image-management.sh
543
544 - builder:
545     name: integration-compare-distributions
546     # Operation: will compare an already created distribtion (probably last
547     # published to nexus) to the current distribution being created.
548     # The comparison is done to find the list of patches that are new to the
549     # current distribution.
550     # Required bash variables:
551     #   KARAF_ARTIFACT: 'karaf' or 'distribution-karaf'. Use integration-set-variables.
552     builders:
553       - shell: !include-raw: integration-compare-distributions.sh
554
555 - builder:
556     name: integration-upload-distribution
557     # Upload distribution karaf artifact to Nexus SNAPSHOT repo for testing.
558     # Arguments:
559     #   {dist-pom} path to pom file containing the version
560     # Required bash variables:
561     #   KARAF_VERSION: 'karaf4' or 'karaf3'.
562     #     Use distribution-karaf-version macro to customize.
563     builders:
564       - config-file-provider:
565           files:
566             - file-id: global-settings
567               variable: GLOBAL_SETTINGS_FILE
568             - file-id: integration-settings
569               variable: SETTINGS_FILE
570       - integration-set-variables
571       - inject:
572           properties-content: BUNDLE_POM={dist-pom}
573       - shell: !include-raw-escape: integration-upload-distribution.sh
574       - inject:
575           properties-file: integration-upload-distribution.env
576
577 ##############
578 # Publishers #
579 ##############
580
581 # Macro: integration-robot
582 # Operation: this macro publishes robot results
583 # Used by: {project}-csit-* job templates
584
585 - publisher:
586     name: integration-robot
587     publishers:
588       - robot:
589           output-path: ''
590           other-files: ''
591           unstable-threshold: '{unstable-if}'
592           pass-threshold: '{pass-if}'
593           only-critical: false
594
595 - publisher:
596     name: integration-robot-tempest
597     publishers:
598       - robot:
599           output-path: ''
600           other-files:
601             - tempest_results.html
602           unstable-threshold: '{unstable-if}'
603           pass-threshold: '{pass-if}'
604           only-critical: false
605
606 - publisher:
607     name: integration-csit-archive-build
608     publishers:
609       - postbuildscript:
610           builders:
611             - role: BOTH
612               build-on:
613                 - ABORTED
614                 - FAILURE
615                 - NOT_BUILT
616                 - SUCCESS
617                 - UNSTABLE
618               build-steps:
619                 - shell: |
620                     #!/bin/bash
621                     echo "Archiving csit artifacts"
622                     cd $WORKSPACE
623                     mkdir -p ./archives
624                     for i in `seq 1 ${NUM_ODL_SYSTEM}`; do
625                         NODE_FOLDER="./archives/odl_${i}"
626                         mkdir -p ${NODE_FOLDER}
627                         mv odl${i}_* ${NODE_FOLDER} || true
628                         mv karaf_${i}_*_threads* ${NODE_FOLDER} || true
629                         mv *_${i}.png ${NODE_FOLDER} || true
630                         mv /tmp/odl${i}_* ${NODE_FOLDER} || true
631                     done
632                     curl --output robot-plugin.zip "$BUILD_URL/robot/report/*zip*/robot-plugin.zip"
633                     unzip -d ./archives robot-plugin.zip
634                     mv *.log *.log.gz *.csv *.png ./archives || true  # Don't fail if file missing
635                     # TODO: Can the following line ever fail?
636                     find . -type f -name *.hprof -print0 \
637                         | tar -cvf - --null -T - | xz --threads=0 > ./archives/hprof.tar.xz
638                     # TODO: Tweak the compression level if better ratio (or speed) is needed.
639           mark-unstable-if-failed: true
640
641
642 - publisher:
643     name: integration-csit-run-postscript
644     publishers:
645       - postbuildscript:
646           builders:
647             - role: BOTH
648               build-on:
649                 - ABORTED
650                 - FAILURE
651                 - NOT_BUILT
652                 - SUCCESS
653                 - UNSTABLE
654               build-steps:
655                 - config-file-provider:
656                     files:
657                       - file-id: 'odl-elastic-cloud'
658                         target: '${HOME}/.netrc'
659                 - shell: |
660                     #!/bin/bash
661                     #The following script runs any configurable postplan stored in test/csit/postplans.
662                     if [ -f "${WORKSPACE}/test/csit/postplans/${TESTPLAN}" ]; then
663                         echo "postplan exists!!!"
664                         echo "Changing the postplan path..."
665                         script_name=${WORKSPACE}/test/csit/postplans/${TESTPLAN}
666                         cat ${script_name} | sed "s:integration:${WORKSPACE}:" > postplan.txt
667                         cat postplan.txt
668                         egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' postplan.txt | while read -r line ; do
669                             echo "Executing ${line}..."
670                             ${line}
671                         done
672                     fi
673                     rm ${HOME}/.netrc
674           mark-unstable-if-failed: true
675
676 - publisher:
677     name: integration-csit-collect-netvirt-logs
678     publishers:
679       - postbuildscript:
680           builders:
681             - role: BOTH
682               build-on:
683                 - ABORTED
684                 - FAILURE
685                 - NOT_BUILT
686                 - SUCCESS
687                 - UNSTABLE
688               build-steps:
689                 - inject:
690                     properties-file: 'slave_addresses.txt'
691                 - shell: |
692                     #!/bin/bash
693                     source /tmp/common-functions.sh ${BUNDLEFOLDER}
694                     collect_netvirt_logs
695           mark-unstable-if-failed: true