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