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