1e9005cd4577218010f5cf60dbd8d771c08ac5ef
[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-openstack-controller-mininet
172 # Operation: this macro will spin the controller and mininet vms
173 # Used by: {project}-csit-* job templates
174
175 - wrapper:
176     name: integration-openstack-controller-mininet
177     wrappers:
178       - openstack:
179           instances:
180             - cloud-name: 'ODLRPC'
181               template-name: '{controller-image}'
182               count: '{controller-vms}'
183             - cloud-name: 'ODLRPC'
184               template-name: '{mininet-image}'
185               count: '{mininet-vms}'
186
187 # Macro: integration-openstack-controller-devstack
188 # Operation: this macro will spin the controller and devstack vms
189 # Used by: {project}-csit-openstack job templates
190 - wrapper:
191     name: integration-openstack-controller-devstack
192     wrappers:
193       - openstack:
194           instances:
195             - cloud-name: 'ODLRPC'
196               template-name: '{controller-image}'
197               count: '{controller-vms}'
198             - cloud-name: 'ODLRPC'
199               template-name: '{openstack-image}'
200               count: '{openstack-vms}'
201
202 #################
203 # Shell Scripts #
204 #################
205
206 # Macro: integration-infra-stack
207 # Operation: Sets environment and then calls opendaylight-infra-stack to spin
208 #            up csit lab using openstack-heat.
209 # Used by: {project}-csit-* job templates
210
211 - builder:
212     name: integration-infra-stack
213     builders:
214       - integration-cleanup-workspace
215       - shell: |
216           #!/bin/bash
217           # Setup openstack envirnoment file for use by
218           # the opendaylight-infra-stack macro
219           cat > $WORKSPACE/opendaylight-infra-environment.yaml << EOF
220           parameters:
221               vm_0_count: {vm_0_count}
222               vm_0_flavor: {vm_0_flavor}
223               vm_0_image: {vm_0_image}
224               vm_1_count: {vm_1_count}
225               vm_1_flavor: {vm_1_flavor}
226               vm_1_image: {vm_1_image}
227           EOF
228           echo "Contents of opendaylight-infra-environment.yaml ..."
229           cat $WORKSPACE/opendaylight-infra-environment.yaml
230       - opendaylight-infra-stack:
231           stack-template: '{stack-template}'
232
233 # Macro: integration-infra-stack-3-type
234 # Operation: Sets environment and then calls opendaylight-infra-stack to spin
235 #            up csit lab using openstack-heat.
236 # Used by: {project}-csit-* job templates
237
238 - builder:
239     name: integration-infra-stack-3-type
240     builders:
241       - integration-cleanup-workspace
242       - shell: |
243           #!/bin/bash
244           # Setup openstack envirnoment file for use by
245           # the opendaylight-infra-stack macro
246           cat > $WORKSPACE/opendaylight-infra-environment.yaml << EOF
247           parameters:
248               vm_0_count: {vm_0_count}
249               vm_0_flavor: {vm_0_flavor}
250               vm_0_image: {vm_0_image}
251               vm_1_count: {vm_1_count}
252               vm_1_flavor: {vm_1_flavor}
253               vm_1_image: {vm_1_image}
254               vm_2_count: {vm_2_count}
255               vm_2_flavor: {vm_2_flavor}
256               vm_2_image: {vm_2_image}
257           EOF
258           echo "Contents of opendaylight-infra-environment.yaml ..."
259           cat $WORKSPACE/opendaylight-infra-environment.yaml
260       - opendaylight-infra-stack:
261           stack-template: 'csit-3-instance-type.yaml'
262
263 # Macro: integration-get-slave-addresses
264 # Operation: this macro gets the IP addresses of the dynamic vms
265 # Used by: {project}-csit-* job templates
266
267 - builder:
268     name: integration-get-slave-addresses
269     builders:
270       - shell: !include-raw: include-raw-integration-get-slave-addresses.sh
271
272 - builder:
273     name: integration-set-variables
274     # Operation: Construct variables not requiring online detection and export using set_variables.env
275     # Required bash variables:
276     #   KARAF_VERSION: 'karaf4' or 'karaf3'. Use distribution-karaf-version macro to set.
277     builders:
278       - shell: !include-raw: integration-set-variables.sh
279       - inject:
280           properties-file: set_variables.env
281
282 - builder:
283     name: integration-detect-variables
284     # Operation: Construct variables including online detection and export using detect_variables.env
285     #   This calls integration-set-variables internally.
286     # Required bash variables:
287     #   KARAF_VERSION: 'karaf4' or 'karaf3'. Use distribution-karaf-version macro to set.
288     builders:
289       - integration-set-variables
290       - shell: !include-raw: integration-detect-variables.sh
291       - inject:
292           properties-file: detect_variables.env
293
294 - builder:
295     name: integration-distribution-check
296     # Operation: Locally deploy ODL with all fetures, check it is not broken.
297     # Required bash variables:
298     #   KARAF_VERSION: 'karaf4' or 'karaf3'.
299     #     Use distribution-karaf-version macro to customize.
300     builders:
301       - integration-set-variables
302       - shell: !include-raw: integration-distribution-check.sh
303
304 - builder:
305     name: distribution-deploy-verify
306     # Operation: Deploy ODL with all fetures and check it is not broken.
307     # Required bash variables:
308     #   KARAF_VERSION: 'karaf4' or 'karaf3'.
309     #     Use distribution-karaf-version macro to customize.
310     builders:
311       - integration-detect-variables
312       - shell: !include-raw: distribution-deploy-verify.sh
313
314 - builder:
315     name: distribution-deploy-offline
316     # Operation: Deploys ODL on the current system, with no external repo configuration, check it works.
317     # Required bash variables:
318     #   KARAF_VERSION: 'karaf4' or 'karaf3'.
319     #     Use distribution-karaf-version macro to customize.
320     builders:
321       - integration-detect-variables
322       - shell: !include-raw: distribution-deploy-offline.sh
323
324 # Macro: integration-deply-controller-run-test
325 # Operation: this macro deploys single contoller and runs test
326 # Used by: {project}-csit-1node-* job templates
327
328 - builder:
329     name: integration-deploy-controller-run-test
330     builders:
331       - shell: !include-raw: include-raw-integration-deploy-controller-run-test.sh
332
333 # Macro: integration-configure-clustering
334 # Operation: this macro configures the clustering
335 # Used by: {project}-csit-3node-* job templates
336
337 - builder:
338     name: integration-configure-clustering
339     builders:
340       - shell: !include-raw: include-raw-integration-configure-clustering.sh
341
342 # Macro: integration-start-cluster-run-test
343 # Operation: this macro starts the 3-node cluster and runs test
344 # Used by: {project}-csit-3node-* job templates
345
346 - builder:
347     name: integration-start-cluster-run-test
348     builders:
349       - shell: !include-raw: include-raw-integration-start-cluster-run-test.sh
350
351 # Macro: integration-install-robotframework
352 # Operation: Installs robotframework using pip to a virtualenv
353 # Used by: {project}-csit-* job templates
354
355 - builder:
356     name: integration-install-robotframework
357     builders:
358       - shell: !include-raw: include-raw-integration-install-robotframework.sh
359
360 # Macro: integration-cleanup-tmp
361 # Operation: Cleans up temporary files created by build
362 # Used by: {project}-csit-* job templates
363
364 - builder:
365     name: integration-cleanup-tmp
366     builders:
367       - shell: !include-raw: include-raw-integration-cleanup-tmp.sh
368
369 # Macro: integration-multipatch-builder
370 # Operation: checks out multiple patches and builds custom distribution
371 # Used by: integration-multipatch-test-* job templates
372
373 - builder:
374     name: integration-multipatch-builder
375     builders:
376       - shell: !include-raw: include-raw-integration-multipatch-distribution-test.sh
377
378 # Macro: integration-cleanup-workspace
379 # Operation: Cleans up files possibly left there by the previous build
380 # Used by: {project}-csit-* job templates
381
382 - builder:
383     name: integration-cleanup-workspace
384     builders:
385       - shell: !include-raw: include-raw-integration-cleanup-workspace.sh
386
387 # Macro: integration-rebase-patch
388 # Operation: For cloned project, rebase checked-out Gerrit patch onto $DISTROBRANCH.
389 # Used by: integration-patch-distribution-* job template
390
391 - builder:
392     name: integration-rebase-gerrit-patch
393     builders:
394       - shell: !include-raw: include-raw-integration-rebase-gerrit-patch.sh
395
396 - builder:
397     name: integration-deploy-openstack-run-test
398     builders:
399       - shell: !include-raw: include-raw-integration-deploy-openstack-run-test.sh
400
401 # Macro: integration-list-jobs
402 # Operation: queries Jenkins jobs from jenkins.opendaylight.org and
403 #   writes a list of the jobs corresponding to the search terms to a file.
404 # Used by: builder-merge job template
405 #
406 # This script requires the following JJB variables to be passed in:
407 #   {search_string}     Job type to act as a primary filter (e.g. csit)
408 #   {blacklist}         List of sub-projects to filter out (e.g. longevity)
409 #   {stream}            Development release name (e.g. boron)
410 #   {jobs-filename}     Filename to write list into (e.g. carbon-jobs.lst)
411 # NOTE: Requires xmlstarlet installed on node.
412
413 - builder:
414     name: integration-list-jobs
415     builders:
416       - shell: !include-raw: include-raw-integration-list-jobs.sh
417
418 # Macro: integration-replace-block-text
419 # Operation: using starting and ending regex to
420 # replace a block of text in a file with the text in
421 # another file. Regex should be basic and work with sed
422 # Used by: builder-merge job template
423 #
424 # This script requires the following JJB variables to be passed in:
425 #   {starting-regex}
426 #   {ending-regex}
427 #   {file-with-changes-to-insert}
428 #   {file-to-change}
429
430 - builder:
431     name: integration-replace-block-text
432     builders:
433       - shell: !include-raw: include-raw-integration-replace-block-text.sh
434
435
436 - builder:
437     name: integration-compare-distributions
438     # Operation: will compare an already created distribtion (probably last
439     # published to nexus) to the current distribution being created.
440     # The comparison is done to find the list of patches that are new to the
441     # current distribution.
442     # Required bash variables:
443     #   KARAF_ARTIFACT: 'karaf' or 'distribution-karaf'. Use integration-set-variables.
444     builders:
445       - shell: !include-raw: include-raw-integration-compare-distributions.sh
446
447 - builder:
448     name: integration-upload-distribution
449     # Upload distribution karaf artifact to Nexus SNAPSHOT repo for testing.
450     # Arguments:
451     #   {dist-pom} path to pom file containing the version
452     # Required bash variables:
453     #   KARAF_VERSION: 'karaf4' or 'karaf3'.
454     #     Use distribution-karaf-version macro to customize.
455     builders:
456       - config-file-provider:
457           files:
458             - file-id: odl-global-settings
459               variable: GLOBAL_SETTINGS_FILE
460             - file-id: integration-settings
461               variable: SETTINGS_FILE
462       - integration-set-variables
463       - inject:
464           properties-content: BUNDLE_POM={dist-pom}
465       - shell: !include-raw-escape: integration-upload-distribution.sh
466       - inject:
467           properties-file: integration-upload-distribution.env
468
469 ##############
470 # Publishers #
471 ##############
472
473 # Macro: integration-robot
474 # Operation: this macro publishes robot results
475 # Used by: {project}-csit-* job templates
476
477 - publisher:
478     name: integration-robot
479     publishers:
480       - robot:
481           output-path: ''
482           other-files: ''
483           unstable-threshold: '{unstable-if}'
484           pass-threshold: '{pass-if}'
485           only-critical: false
486
487 - publisher:
488     name: integration-robot-tempest
489     publishers:
490       - robot:
491           output-path: ''
492           other-files:
493             - tempest_results.html
494           unstable-threshold: '{unstable-if}'
495           pass-threshold: '{pass-if}'
496           only-critical: false
497
498 - publisher:
499     name: integration-csit-archive-build
500     publishers:
501       - postbuildscript:
502           builders:
503             - shell: |
504                 #!/bin/bash
505                 mkdir -p $WORKSPACE/archives
506                 curl --output robot-plugin.zip "$BUILD_URL/robot/report/*zip*/robot-plugin.zip"
507                 unzip -d $WORKSPACE/archives robot-plugin.zip
508                 mv *log* *.log *.log.gz *.csv *.png $WORKSPACE/archives || true  # Don't fail if file missing
509           script-only-if-succeeded: 'False'
510           script-only-if-failed: 'False'
511           mark-unstable-if-failed: 'True'