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