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