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