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