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