Clean netvirt csit jobs
[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 #################
286 # Shell Scripts #
287 #################
288
289 # Macro: integration-get-slave-addresses
290 # Operation: this macro gets the IP addresses of the dynamic vms
291 # Used by: {project}-csit-* job templates
292
293 - builder:
294     name: integration-get-slave-addresses
295     builders:
296       - shell: !include-raw: integration-get-slave-addresses.sh
297
298 - builder:
299     name: integration-set-variables
300     # Operation: Construct variables not requiring online detection and export using set_variables.env
301     # Required bash variables:
302     #   KARAF_VERSION: 'karaf4' or 'karaf3'. Use distribution-karaf-version macro to set.
303     builders:
304       - shell: !include-raw: integration-set-variables.sh
305       - inject:
306           properties-file: set_variables.env
307
308 - builder:
309     name: integration-detect-variables
310     # Operation: Construct variables including online detection and export using detect_variables.env
311     #   This calls integration-set-variables internally.
312     # Required bash variables:
313     #   KARAF_VERSION: 'karaf4' or 'karaf3'. Use distribution-karaf-version macro to set.
314     builders:
315       - integration-set-variables
316       - shell: !include-raw: integration-detect-variables.sh
317       - inject:
318           properties-file: detect_variables.env
319
320 # Macro: integration-deply-controller-run-test
321 # Operation: this macro deploys single contoller and runs test
322 # Used by: {project}-csit-1node-* job templates
323
324 - builder:
325     name: integration-deploy-controller-run-test
326     builders:
327       - shell: !include-raw: integration-deploy-controller-run-test.sh
328
329 # Macro: integration-deply-non-karaf-controller-run-test
330 # Operation: this macro deploys non-karaf controller application and run test
331 # Used by: {project}-csit-1node-* job templates
332
333 - builder:
334     name: integration-run-test
335     builders:
336       - shell: !include-raw: integration-run-test.sh
337
338 # Macro: integration-configure-clustering
339 # Operation: this macro configures the clustering
340 # Used by: {project}-csit-3node-* job templates
341
342 - builder:
343     name: integration-configure-clustering
344     builders:
345       - shell: !include-raw: integration-configure-clustering.sh
346
347 # Macro: integration-start-cluster-run-test
348 # Operation: this macro starts the 3-node cluster and runs test
349 # Used by: {project}-csit-3node-* job templates
350
351 - builder:
352     name: integration-start-cluster-run-test
353     builders:
354       - shell: !include-raw: integration-start-cluster-run-test.sh
355
356 # Macro: integration-install-robotframework
357 # Operation: Installs robotframework using pip to a virtualenv
358 # Used by: {project}-csit-* job templates
359
360 - builder:
361     name: integration-install-robotframework
362     builders:
363       - shell: !include-raw: integration-install-robotframework.sh
364
365 # Macro: integration-cleanup-tmp
366 # Operation: Cleans up temporary files created by build
367 # Used by: {project}-csit-* job templates
368
369 - builder:
370     name: integration-cleanup-tmp
371     builders:
372       - shell: !include-raw: integration-cleanup-tmp.sh
373
374 # Macro: integration-multipatch-builder
375 # Operation: checks out multiple patches and builds custom distribution
376 # Used by: integration-multipatch-test-* job templates
377
378 - builder:
379     name: integration-multipatch-builder
380     builders:
381       - shell: !include-raw: multipatch-distribution.sh
382
383 # Macro: integration-rebase-patch
384 # Operation: For cloned project, rebase checked-out Gerrit patch onto $DISTROBRANCH.
385 # Used by: integration-patch-distribution-* job template
386
387 - builder:
388     name: integration-rebase-gerrit-patch
389     builders:
390       - shell: !include-raw: integration-rebase-gerrit-patch.sh
391
392 # Macro: integration-install-common-functions
393 # Operation: Copy the common-functions.sh script to csit nodes
394 # Used by: {project}-csit-* job templates
395 - builder:
396     name: integration-install-common-functions
397     builders:
398       - shell: !include-raw:
399           - copy-common-functions.sh
400           - common-functions.sh
401
402 - builder:
403     name: integration-compare-distributions
404     # Operation: will compare an already created distribtion (probably last
405     # published to nexus) to the current distribution being created.
406     # The comparison is done to find the list of patches that are new to the
407     # current distribution.
408     # Required bash variables:
409     #   KARAF_ARTIFACT: 'karaf' or 'distribution-karaf'. Use integration-set-variables.
410     builders:
411       - shell: !include-raw: integration-compare-distributions.sh
412
413 - builder:
414     name: integration-upload-distribution
415     # Upload distribution karaf artifact to Nexus SNAPSHOT repo for testing.
416     # Arguments:
417     #   {dist-pom} path to pom file containing the version
418     # Required bash variables:
419     #   KARAF_VERSION: 'karaf4' or 'karaf3'.
420     #     Use distribution-karaf-version macro to customize.
421     builders:
422       - config-file-provider:
423           files:
424             - file-id: global-settings
425               variable: GLOBAL_SETTINGS_FILE
426             - file-id: "{settings-project}-settings"
427               variable: SETTINGS_FILE
428       - integration-set-variables
429       - inject:
430           properties-content: BUNDLE_POM={dist-pom}
431       - shell: !include-raw-escape: integration-upload-distribution.sh
432       - inject:
433           properties-file: integration-upload-distribution.env
434
435 ##############
436 # Publishers #
437 ##############
438
439 - publisher:
440     name: integration-csit-publish
441     publishers:
442       - robot:
443           output-path: ""
444           other-files: "{obj:robot_other_files}"
445           unstable-threshold: "{robot-unstable-threshold}"
446           pass-threshold: "{robot-pass-threshold}"
447           only-critical: false
448       - integration-csit-archive-build
449       - integration-csit-run-postscript
450
451 - publisher:
452     name: integration-csit-archive-build
453     publishers:
454       - postbuildscript:
455           builders:
456             - role: BOTH
457               build-on:
458                 - ABORTED
459                 - FAILURE
460                 - NOT_BUILT
461                 - SUCCESS
462                 - UNSTABLE
463               build-steps:
464                 - shell: |
465                     #!/bin/bash
466                     echo "Archiving csit artifacts"
467                     cd $WORKSPACE
468                     mkdir -p ./archives
469                     for i in `seq 1 ${NUM_ODL_SYSTEM}`; do
470                         NODE_FOLDER="./archives/odl_${i}"
471                         mkdir -p ${NODE_FOLDER}
472                         mv odl${i}_* ${NODE_FOLDER} || true
473                         mv karaf_${i}_*_threads* ${NODE_FOLDER} || true
474                         mv *_${i}.png ${NODE_FOLDER} || true
475                         mv /tmp/odl${i}_* ${NODE_FOLDER} || true
476                         mv gclogs-${i} ${NODE_FOLDER} || true
477                     done
478                     curl --output robot-plugin.zip "$BUILD_URL/robot/report/*zip*/robot-plugin.zip"
479                     unzip -d ./archives robot-plugin.zip
480                     mv *.log *.log.gz *.csv *.png ./archives || true  # Don't fail if file missing
481                     # TODO: Can the following line ever fail?
482                     find . -type f -name *.hprof -print0 \
483                         | tar -cvf - --null -T - | xz --threads=0 > ./archives/hprof.tar.xz
484                     # TODO: Tweak the compression level if better ratio (or speed) is needed.
485           mark-unstable-if-failed: true
486
487 - publisher:
488     name: integration-csit-run-postscript
489     publishers:
490       - postbuildscript:
491           builders:
492             - role: BOTH
493               build-on:
494                 - ABORTED
495                 - FAILURE
496                 - NOT_BUILT
497                 - SUCCESS
498                 - UNSTABLE
499               build-steps:
500                 - shell: |
501                     #!/bin/bash
502                     #The following script runs any configurable postplan stored in test/csit/postplans.
503                     if [ -f "${WORKSPACE}/test/csit/postplans/${TESTPLAN}" ]; then
504                         echo "postplan exists!!!"
505                         echo "Changing the postplan path..."
506                         script_name=${WORKSPACE}/test/csit/postplans/${TESTPLAN}
507                         cat ${script_name} | sed "s:integration:${WORKSPACE}:" > postplan.txt
508                         cat postplan.txt
509                         egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' postplan.txt | while read -r line ; do
510                             echo "Executing ${line}..."
511                             ${line}
512                         done
513                     fi
514           mark-unstable-if-failed: true
515