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