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