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