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