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