Merge "Use eval command to append mail options"
[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 # Macro: integration-gerrit-scm
127 # Operation: this macro downloads a project gerrit
128 # Used by: all csit jobs
129
130 - scm:
131     name: integration-gerrit-scm
132     scm:
133       - git:
134           credentials-id: 'opendaylight-jenkins-ssh'
135           url: '$GIT_BASE'
136           basedir: '{basedir}'
137           refspec: '{refspec}'
138           branches:
139             - 'origin/{branch}'
140           skip-tag: true
141           choosing-strategy: 'gerrit'
142
143 # Macro: integration-distribution-scm
144 # Operation: this macro downloads the integration/distribution repo using distribution as basedir
145 # Used by: integration-patch-test-{stream} job template
146
147 - scm:
148     name: integration-distribution-scm
149     scm:
150       - git:
151           credentials-id: 'opendaylight-jenkins-ssh'
152           basedir: 'distribution'
153           url: '$DISTROGITURL'
154           refspec: ''
155           branches:
156             - 'origin/{branch}'
157           skip-tag: true
158
159 # Macro: integration-trigger-patch-submitted
160 # This is a single macro to use for all csit jobs who vote on every (relevant) patch set.
161 # Only 'recheck' trigger word is supported, it always triggers the full set of relevant jobs,
162 # in order to prevent Jenkins from starting only a subset and still voting Verified+1.
163 # Contrary to gerrit-trigger-patch-submitted, this votes +1 also on unstable runs.
164 # Arguments:
165 #     gerrit-server-name: name of gerrit server to listen to
166 #     project: pattern to match triggering projects
167 #     branch: triggering branch name
168 #     files: pattern to match triggering filepaths
169 - trigger:
170     name: integration-trigger-patch-submitted
171     triggers:
172       - gerrit:
173           server-name: '{gerrit-server-name}'
174           trigger-on:
175             - patchset-created-event:
176                 exclude-drafts: true
177                 exclude-trivial-rebase: false
178                 exclude-no-code-change: false
179             - draft-published-event
180             - comment-added-contains-event:
181                 comment-contains-value: recheck
182           override-votes: true
183           gerrit-build-unstable-verified-value: +1
184           gerrit-build-unstable-codereview-value: 0
185           projects:
186             - project-compare-type: ANT
187               project-pattern: '{project}'
188               branches:
189                 - branch-compare-type: ANT
190                   branch-pattern: '**/{branch}'
191               file-paths:
192                 - compare-type: ANT
193                   pattern: '{files}'
194
195 # Macro: integration-csit-only
196 # Operation: this macro sets a trigger on reverse job list
197 # Used by: csit -only- job templates
198
199 - trigger:
200     name: integration-csit-trigger
201     triggers:
202       - reverse:
203           jobs: '{jobs}'
204           result: 'success'
205
206 # Macro: integration-openstack-controller-mininet
207 # Operation: this macro will spin the controller and mininet vms
208 # Used by: {project}-csit-* job templates
209
210 - wrapper:
211     name: integration-openstack-controller-mininet
212     wrappers:
213       - openstack:
214           instances:
215             - cloud-name: 'ODLRPC'
216               template-name: '{controller-image}'
217               count: '{controller-vms}'
218             - cloud-name: 'ODLRPC'
219               template-name: '{mininet-image}'
220               count: '{mininet-vms}'
221
222 # Macro: integration-openstack-controller-devstack
223 # Operation: this macro will spin the controller and devstack vms
224 # Used by: {project}-csit-openstack job templates
225 - wrapper:
226     name: integration-openstack-controller-devstack
227     wrappers:
228       - openstack:
229           instances:
230             - cloud-name: 'ODLRPC'
231               template-name: '{controller-image}'
232               count: '{controller-vms}'
233             - cloud-name: 'ODLRPC'
234               template-name: '{openstack-image}'
235               count: '{openstack-vms}'
236
237 #################
238 # Shell Scripts #
239 #################
240
241 # Macro: integration-infra-stack
242 # Operation: Sets environment and then calls opendaylight-infra-stack to spin
243 #            up csit lab using openstack-heat.
244 # Used by: {project}-csit-* job templates
245
246 - builder:
247     name: integration-infra-stack
248     builders:
249       - integration-cleanup-workspace
250       - shell: |
251           #!/bin/bash
252           # Setup openstack envirnoment file for use by
253           # the opendaylight-infra-stack macro
254           cat > $WORKSPACE/opendaylight-infra-environment.yaml << EOF
255           parameters:
256               vm_0_count: {vm_0_count}
257               vm_0_flavor: {vm_0_flavor}
258               vm_0_image: {vm_0_image}
259               vm_1_count: {vm_1_count}
260               vm_1_flavor: {vm_1_flavor}
261               vm_1_image: {vm_1_image}
262           EOF
263           echo "Contents of opendaylight-infra-environment.yaml ..."
264           cat $WORKSPACE/opendaylight-infra-environment.yaml
265       - opendaylight-infra-stack:
266           stack-template: '{stack-template}'
267
268 # Macro: integration-infra-stack-3-type
269 # Operation: Sets environment and then calls opendaylight-infra-stack to spin
270 #            up csit lab using openstack-heat.
271 # Used by: {project}-csit-* job templates
272
273 - builder:
274     name: integration-infra-stack-3-type
275     builders:
276       - integration-cleanup-workspace
277       - shell: |
278           #!/bin/bash
279           # Setup openstack envirnoment file for use by
280           # the opendaylight-infra-stack macro
281           cat > $WORKSPACE/opendaylight-infra-environment.yaml << EOF
282           parameters:
283               vm_0_count: {vm_0_count}
284               vm_0_flavor: {vm_0_flavor}
285               vm_0_image: {vm_0_image}
286               vm_1_count: {vm_1_count}
287               vm_1_flavor: {vm_1_flavor}
288               vm_1_image: {vm_1_image}
289               vm_2_count: {vm_2_count}
290               vm_2_flavor: {vm_2_flavor}
291               vm_2_image: {vm_2_image}
292           EOF
293           echo "Contents of opendaylight-infra-environment.yaml ..."
294           cat $WORKSPACE/opendaylight-infra-environment.yaml
295       - opendaylight-infra-stack:
296           stack-template: 'csit-3-instance-type.yaml'
297
298 # Macro: integration-infra-stack-4-type
299 # Operation: Sets environment and then calls opendaylight-infra-stack to spin
300 #            up csit lab using openstack-heat.
301 # Used by: {project}-csit-* job templates
302
303 - builder:
304     name: integration-infra-stack-4-type
305     builders:
306       - integration-cleanup-workspace
307       - shell: |
308           #!/bin/bash
309           # Setup openstack envirnoment file for use by
310           # the opendaylight-infra-stack macro
311           cat > $WORKSPACE/opendaylight-infra-environment.yaml << EOF
312           parameters:
313               vm_0_count: {vm_0_count}
314               vm_0_flavor: {vm_0_flavor}
315               vm_0_image: {vm_0_image}
316               vm_1_count: {vm_1_count}
317               vm_1_flavor: {vm_1_flavor}
318               vm_1_image: {vm_1_image}
319               vm_2_count: {vm_2_count}
320               vm_2_flavor: {vm_2_flavor}
321               vm_2_image: {vm_2_image}
322               vm_3_count: {vm_3_count}
323               vm_3_flavor: {vm_3_flavor}
324               vm_3_image: {vm_3_image}
325           EOF
326           echo "Contents of opendaylight-infra-environment.yaml ..."
327           cat $WORKSPACE/opendaylight-infra-environment.yaml
328       - opendaylight-infra-stack:
329           stack-template: 'csit-4-instance-type.yaml'
330
331 # Macro: integration-get-slave-addresses
332 # Operation: this macro gets the IP addresses of the dynamic vms
333 # Used by: {project}-csit-* job templates
334
335 - builder:
336     name: integration-get-slave-addresses
337     builders:
338       - shell: !include-raw: integration-get-slave-addresses.sh
339
340 - builder:
341     name: integration-set-variables
342     # Operation: Construct variables not requiring online detection and export using set_variables.env
343     # Required bash variables:
344     #   KARAF_VERSION: 'karaf4' or 'karaf3'. Use distribution-karaf-version macro to set.
345     builders:
346       - shell: !include-raw: integration-set-variables.sh
347       - inject:
348           properties-file: set_variables.env
349
350 - builder:
351     name: integration-detect-variables
352     # Operation: Construct variables including online detection and export using detect_variables.env
353     #   This calls integration-set-variables internally.
354     # Required bash variables:
355     #   KARAF_VERSION: 'karaf4' or 'karaf3'. Use distribution-karaf-version macro to set.
356     builders:
357       - integration-set-variables
358       - shell: !include-raw: integration-detect-variables.sh
359       - inject:
360           properties-file: detect_variables.env
361
362 # Macro: integration-deply-controller-run-test
363 # Operation: this macro deploys single contoller and runs test
364 # Used by: {project}-csit-1node-* job templates
365
366 - builder:
367     name: integration-deploy-controller-run-test
368     builders:
369       - shell: !include-raw: integration-deploy-controller-run-test.sh
370
371 # Macro: integration-configure-clustering
372 # Operation: this macro configures the clustering
373 # Used by: {project}-csit-3node-* job templates
374
375 - builder:
376     name: integration-configure-clustering
377     builders:
378       - shell: !include-raw: integration-configure-clustering.sh
379
380 # Macro: integration-start-cluster-run-test
381 # Operation: this macro starts the 3-node cluster and runs test
382 # Used by: {project}-csit-3node-* job templates
383
384 - builder:
385     name: integration-start-cluster-run-test
386     builders:
387       - shell: !include-raw: integration-start-cluster-run-test.sh
388
389 # Macro: integration-install-robotframework
390 # Operation: Installs robotframework using pip to a virtualenv
391 # Used by: {project}-csit-* job templates
392
393 - builder:
394     name: integration-install-robotframework
395     builders:
396       - shell: !include-raw: integration-install-robotframework.sh
397
398 # Macro: integration-cleanup-tmp
399 # Operation: Cleans up temporary files created by build
400 # Used by: {project}-csit-* job templates
401
402 - builder:
403     name: integration-cleanup-tmp
404     builders:
405       - shell: !include-raw: integration-cleanup-tmp.sh
406
407 # Macro: integration-multipatch-builder
408 # Operation: checks out multiple patches and builds custom distribution
409 # Used by: integration-multipatch-test-* job templates
410
411 - builder:
412     name: integration-multipatch-builder
413     builders:
414       - shell: !include-raw: multipatch-distribution.sh
415
416 # Macro: integration-cleanup-workspace
417 # Operation: Cleans up files possibly left there by the previous build
418 # Used by: {project}-csit-* job templates
419
420 - builder:
421     name: integration-cleanup-workspace
422     builders:
423       - shell: !include-raw: integration-cleanup-workspace.sh
424
425 # Macro: integration-rebase-patch
426 # Operation: For cloned project, rebase checked-out Gerrit patch onto $DISTROBRANCH.
427 # Used by: integration-patch-distribution-* job template
428
429 - builder:
430     name: integration-rebase-gerrit-patch
431     builders:
432       - shell: !include-raw: integration-rebase-gerrit-patch.sh
433
434 - builder:
435     name: integration-deploy-openstack-run-test
436     builders:
437       - shell: !include-raw: integration-deploy-openstack-run-test.sh
438
439 - builder:
440     name: integration-compare-distributions
441     # Operation: will compare an already created distribtion (probably last
442     # published to nexus) to the current distribution being created.
443     # The comparison is done to find the list of patches that are new to the
444     # current distribution.
445     # Required bash variables:
446     #   KARAF_ARTIFACT: 'karaf' or 'distribution-karaf'. Use integration-set-variables.
447     builders:
448       - shell: !include-raw: integration-compare-distributions.sh
449
450 - builder:
451     name: integration-upload-distribution
452     # Upload distribution karaf artifact to Nexus SNAPSHOT repo for testing.
453     # Arguments:
454     #   {dist-pom} path to pom file containing the version
455     # Required bash variables:
456     #   KARAF_VERSION: 'karaf4' or 'karaf3'.
457     #     Use distribution-karaf-version macro to customize.
458     builders:
459       - config-file-provider:
460           files:
461             - file-id: global-settings
462               variable: GLOBAL_SETTINGS_FILE
463             - file-id: integration-settings
464               variable: SETTINGS_FILE
465       - integration-set-variables
466       - inject:
467           properties-content: BUNDLE_POM={dist-pom}
468       - shell: !include-raw-escape: integration-upload-distribution.sh
469       - inject:
470           properties-file: integration-upload-distribution.env
471
472 ##############
473 # Publishers #
474 ##############
475
476 # Macro: integration-robot
477 # Operation: this macro publishes robot results
478 # Used by: {project}-csit-* job templates
479
480 - publisher:
481     name: integration-robot
482     publishers:
483       - robot:
484           output-path: ''
485           other-files: ''
486           unstable-threshold: '{unstable-if}'
487           pass-threshold: '{pass-if}'
488           only-critical: false
489
490 - publisher:
491     name: integration-robot-tempest
492     publishers:
493       - robot:
494           output-path: ''
495           other-files:
496             - tempest_results.html
497           unstable-threshold: '{unstable-if}'
498           pass-threshold: '{pass-if}'
499           only-critical: false
500
501 - publisher:
502     name: integration-csit-archive-build
503     publishers:
504       - postbuildscript:
505           builders:
506             - shell: |
507                 #!/bin/bash
508                 cd $WORKSPACE
509                 mkdir -p ./archives
510                 curl --output robot-plugin.zip "$BUILD_URL/robot/report/*zip*/robot-plugin.zip"
511                 unzip -d ./archives robot-plugin.zip
512                 mv *log* *.log *.log.gz *.csv *.png ./archives || true  # Don't fail if file missing
513                 # TODO: Can the following line ever fail?
514                 find . -type f -name *.hprof -print0 | tar -cvf - --null -T - | xz -9 > ./archives/hprof.tar.xz
515                 # TODO: Tweak the compression level if better ratio (or speed) is needed.
516           script-only-if-succeeded: 'False'
517           script-only-if-failed: 'False'
518           mark-unstable-if-failed: 'True'
519
520 - publisher:
521     name: integration-csit-run-postscript
522     publishers:
523       - postbuildscript:
524           builders:
525             - config-file-provider:
526                 files:
527                   - file-id: 'odl-elastic-cloud'
528                     target: '${HOME}/.netrc'
529             - shell: |
530                 #!/bin/bash
531                 #The following script runs any configurable postplan stored in test/csit/postplans.
532                 if [ -f "${WORKSPACE}/test/csit/postplans/${TESTPLAN}" ]; then
533                     echo "postplan exists!!!"
534                     echo "Changing the postplan path..."
535                     script_name=${WORKSPACE}/test/csit/postplans/${TESTPLAN}
536                     cat ${script_name} | sed "s:integration:${WORKSPACE}:" > postplan.txt
537                     cat postplan.txt
538                     egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' postplan.txt | while read -r line ; do
539                         echo "Executing ${line}..."
540                         ${line}
541                     done
542                 fi
543                 rm ${HOME}/.netrc
544           script-only-if-succeeded: 'False'
545           script-only-if-failed: 'False'
546           mark-unstable-if-failed: 'True'