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