Modify ONAP verify job to include k8s deployment
[infra/cicd.git] / jjb / cloud-infra / onap-jobs / onap-verify-deploy-test.yaml
1 ---
2 # ============LICENSE_START=======================================================
3 #  Copyright (C) 2019 Nordix Foundation.
4 # ================================================================================
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #      http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #
17 # SPDX-License-Identifier: Apache-2.0
18 # ============LICENSE_END=========================================================
19
20 - project:
21     name: 'onap-verify-deploy-test'
22
23     project: 'onap-verify-deploy-test'
24
25     stream:
26       - 'master':
27           branch: '{stream}'
28           k8s-version: '1.15'
29           deploy-scenario: 'onap-sdc-nofeature'
30       - 'frankfurt':
31           branch: '{stream}'
32           k8s-version: '1.15'
33           deploy-scenario: 'onap-sdc-nofeature'
34       - 'elalto':
35           branch: '{stream}'
36           k8s-version: '1.15'
37           deploy-scenario: 'onap-sdc-nofeature'
38
39     environment-type:
40       - online:
41           disabled: false
42           execution-mode: online-deployment
43           successful: false
44           failed: false
45           unstable: false
46           notbuilt: false
47       - offline:
48           disabled: false
49           execution-mode: offline-deployment
50           successful: false
51           failed: false
52           unstable: false
53           notbuilt: false
54     # just deploy phase for now and ONAP testing isn't defined yet
55     phase:
56       - deploy
57
58
59     type:
60       - cloud:
61           provisioner-type: 'heat'
62           slave-type: 'jumphost'
63           gated-projects: 'infra/stack/onap|infra/installer/oom'
64           pdf: "https://gerrit.nordix.org/gitweb?p=infra/provisioner/heat.git;a=blob_plain;f=playbooks/roles/create-stack/files/heat-environment-ci-city-ubuntu1804-onap.yaml"
65           idf: "https://gerrit.nordix.org/gitweb?p=infra/provisioner/heat.git;a=blob_plain;f=playbooks/roles/create-stack/files/heat-idf.yaml"
66
67     distro:
68       - ubuntu1804
69
70     cloud:
71       - city:
72           openrc-credentials-file: 'est-jenkins-openrcfile-city-frankfurt-cicd'
73
74     # This should be
75     dependency-jobs: 'onap-verify-package-{distro}-{stream}'
76     dependency-job-var: 'TRIGGER_onap_verify_package_{distro}_{stream}_BUILD_RESULT'
77
78     jobs:
79       - 'onap-verify-{environment-type}-deploy-test-{distro}-{cloud}-{type}-{stream}'
80
81 - job-template:
82     name: 'onap-verify-{environment-type}-deploy-test-{distro}-{cloud}-{type}-{stream}'
83
84     project-type: multijob
85
86     disabled: '{obj:disabled}'
87
88     concurrent: true
89
90     parameters:
91       - string:
92           name: DEPLOY_SCENARIO
93           default: '{deploy-scenario}'
94           description: 'Scenario to test change with.'
95       - string:
96           name: K8S_VERSION
97           default: '{k8s-version}'
98           description: 'K8S version to use for this deployment'
99       - string:
100           name: INVENTORY_INI
101           default: /tmp/inventory.ini
102           description: 'Location of the inventory file. Copied from k8s install'
103       - string:
104           name: DISTRO
105           default: '{distro}'
106           description: 'Distribution to use for configuring target nodes (networking etc.)'
107       - label:
108           name: SLAVE_LABEL
109           default: 'engine-{slave-type}-{environment-type}-{distro}-fra'
110           description: 'Slave label to schedule this job on.'
111       - string:
112           name: HW_TYPE
113           default: '{type}'
114           description: 'Hardware type - could be virtual, cloud, or baremetal'
115       - string:
116           name: EXECUTION_MODE
117           default: '{execution-mode}'
118           description: 'Execution mode to run in'
119       - string:
120           name: PDF
121           default: '{pdf}'
122           description: 'PDF file to use for deployment'
123       - string:
124           name: IDF
125           default: '{idf}'
126           description: 'IDF file to use for deployment'
127       - string:
128           name: HEAT_STACK_NAME
129           default: "nordix-cicd-verify-onap-{environment-type}-{distro}-$GERRIT_CHANGE_NUMBER"
130           description: 'Name of the created stack'
131       - string:
132           name: KEYPAIR_NAME
133           default: "keypair-nordix-cicd-verify-onap-{environment-type}-{distro}-$GERRIT_CHANGE_NUMBER"
134           description: 'Name of the created keypair'
135       - string:
136           name: USE_PREBUILT_DEPLOYMENT_IMAGE
137           default: 'true'
138           description: 'Use prebuilt deployment image while running as part of CI/CD'
139       - string:
140           name: TEST_REPO_URL
141           default: 'https://gerrit.nordix.org/infra/test.git'
142           description: 'URL to clone the test repo from'
143       - string:
144           name: TEST_FW
145           default: 'functest'
146           description: 'Test framework to use'
147       - string:
148           name: TEST_SUITE
149           default: 'healthcheck'
150           description: 'Test suite to run'
151       - string:
152           name: YARDSTICK_DISPATCHER
153           default: 'file'
154           description: 'Dispatcher to use for Yardstick reporting'
155       - string:
156           name: DELETE_STACK
157           default: 'true'
158           description: 'Delete the stack upon completion of the build'
159       - string:
160           name: VERBOSITY
161           default: 'true'
162           description: 'Verbosity setting for the engine - true or false - default is false'
163       - string:
164           name: CI_LOOP
165           default: "verify"
166           description: 'CI loop the job belongs to'
167       - project-parameters:
168           project: $GERRIT_PROJECT
169           branch: '{branch}'
170           description: 'The project and branch which the change is proposed for'
171       - nordix-gerrit-parameters
172
173     properties:
174       - logrotate
175       # NOTE (fdegir): throttle categories are controlled in jenkins global configuration
176       - throttle:
177           enabled: true
178           max-per-node: 1
179           max-total: 8
180           option: category
181           categories:
182             - engine-verify-deploy-test
183
184     scm:
185       - git-scm-gerrit:
186           ssh-credentials-id: nordixinfra-nordix-gerrit-ssh
187           branch: $GERRIT_BRANCH
188           refspec: $GERRIT_REFSPEC
189           wipe_workspace: true
190           clean_before: false
191
192     triggers:
193       - gerrit:
194           server-name: 'Nordix Gerrit'
195           trigger-on:
196             - patchset-created-event:
197                 exclude-drafts: 'false'
198                 exclude-trivial-rebase: 'false'
199                 exclude-no-code-change: 'false'
200             - draft-published-event
201             - comment-added-contains-event:
202                 comment-contains-value: 'recheck'
203             - comment-added-contains-event:
204                 comment-contains-value: 'reverify'
205           projects:
206             - project-compare-type: 'REG_EXP'
207               project-pattern: '{gated-projects}'
208               branches:
209                 - branch-compare-type: 'ANT'
210                   branch-pattern: '**/{branch}'
211               disable-strict-forbidden-file-verification: 'true'
212               forbidden-file-paths:
213                 - compare-type: ANT
214                   pattern: 'docs/**|releasenotes/**'
215           skip-vote:
216             successful: '{obj:successful}'
217             failed: '{obj:failed}'
218             unstable: '{obj:unstable}'
219             notbuilt: '{obj:notbuilt}'
220           custom-url: '* $JOB_NAME $BUILD_URL'
221           readable-message: 'true'
222           dependency-jobs: '{dependency-jobs}'
223
224     wrappers:
225       - build-timeout:
226           timeout: 180
227       - credentials-binding:
228           - file:
229               credential-id: '{openrc-credentials-file}'
230               variable: OPENRC_FILE
231           - username-password-separated:
232               credential-id: 'nordix-cicd-arm-credentials'
233               username: NORDIX_ARM_USERNAME
234               password: NORDIX_ARM_TOKEN
235       - mask-passwords
236       - openstack:
237           single-use: True
238       - pre-scm-buildstep:
239           failOnError: true
240           buildsteps:
241             - system-groovy:
242                 command: |
243                   def build = this.getProperty('binding').getVariable('build')
244                   def listener = this.getProperty('binding').getVariable('listener')
245                   if (build.getEnvironment(listener).{dependency-job-var} != "SUCCESS") {{
246                     println "WARN  : Aborting build since dependent job did not succeed!"
247                     throw new InterruptedException()
248                   }}
249             - shell: |
250                 #!/bin/bash
251                 sudo chown -R $USER:$USER $WORKSPACE || exit 1
252                 # offline nodes can not resolve Nordix Artifactory and Gerrit
253                 if [[ "$EXECUTION_MODE" == "offline-deployment" ]]; then
254                   echo "Info  : Offline deployment. Adding City OpenStack Endpoint, Nordix Artifactory and Gerrit Public IP to /etc/hosts"
255                   sudo sed -i 's/^search/# search/' /etc/resolv.conf
256                   sudo bash -c "cat << EOF >> /etc/hosts
257                 # managed by engine
258                 91.106.198.25 artifactory.nordix.org
259                 91.106.198.142 gerrit.nordix.org
260                 86.107.242.50 fra1.citycloud.com
261                 # managed by engine
262                 EOF"
263                   # we need to get rid of search domain as well
264                   sudo sed -i 's/^search/# search/' /etc/resolv.conf
265                 fi
266
267     builders:
268       - 'generate-change-metadata-macro'
269       - 'generate-k8sdeployment-environment-macro'
270       - multijob:
271           name: "{environment-type} deployment on {type} instances"
272           condition: SUCCESSFUL
273           execution-type: SEQUENTIAL
274           projects:
275             - name: 'onap-verify-{environment-type}-deployk8s-{distro}-city-{type}-{stream}'
276               current-parameters: true
277               git-revision: true
278               node-parameters: true
279               kill-phase-on: FAILURE
280               abort-all-job: false
281               property-file: $WORKSPACE/k8s.properties
282             - name: 'onap-verify-{environment-type}-deploy-{distro}-city-{type}-{stream}'
283               current-parameters: true
284               git-revision: true
285               node-parameters: true
286               kill-phase-on: FAILURE
287               abort-all-job: false
288               property-file: $WORKSPACE/change.properties
289     publishers:
290       - postbuildscript:
291           builders:
292             - role: SLAVE
293               build-on:
294                 - SUCCESS
295                 - FAILURE
296                 - ABORTED
297                 - NOT_BUILT
298                 - UNSTABLE
299               build-steps:
300                 - 'wait-pkg-mgr-macro'
301                 - 'delete-stack-macro'
302
303 - job-template:
304     name: 'onap-verify-{environment-type}-deploy-{distro}-{cloud}-{type}-{stream}'
305
306     disabled: '{obj:disabled}'
307
308     concurrent: true
309
310     properties:
311       - logrotate
312       - throttle:
313           max-per-node: 1
314           max-total: 3
315           option: project
316
317     scm:
318       - git-scm-gerrit:
319           ssh-credentials-id: nordixinfra-nordix-gerrit-ssh
320           branch: $GERRIT_BRANCH
321           refspec: $GERRIT_REFSPEC
322           wipe_workspace: true
323           clean_before: false
324
325     wrappers:
326       - build-timeout:
327           timeout: 180
328       - credentials-binding:
329           - file:
330               credential-id: '{openrc-credentials-file}'
331               variable: OPENRC_FILE
332           - username-password-separated:
333               credential-id: 'nordix-cicd-arm-credentials'
334               username: NORDIX_ARM_USERNAME
335               password: NORDIX_ARM_TOKEN
336       - mask-passwords
337       - fix-workspace-permissions
338
339     builders:
340       - 'generate-ssh-keypair-macro'
341       - 'wait-pkg-mgr-macro'
342       - 'download-deploy-artifact-macro'
343       - 'deploy-macro'
344
345 - job-template:
346     name: 'onap-verify-{environment-type}-deployk8s-{distro}-{cloud}-{type}-{stream}'
347
348     disabled: '{obj:disabled}'
349
350     concurrent: true
351
352     properties:
353       - logrotate
354       - throttle:
355           max-per-node: 1
356           max-total: 3
357           option: project
358
359     scm:
360       - git-scm-gerrit:
361           ssh-credentials-id: nordixinfra-nordix-gerrit-ssh
362           branch: $GERRIT_BRANCH
363           refspec: $GERRIT_REFSPEC
364           wipe_workspace: true
365           clean_before: false
366
367     wrappers:
368       - build-timeout:
369           timeout: 180
370       - credentials-binding:
371           - file:
372               credential-id: '{openrc-credentials-file}'
373               variable: OPENRC_FILE
374           - username-password-separated:
375               credential-id: 'nordix-cicd-arm-credentials'
376               username: NORDIX_ARM_USERNAME
377               password: NORDIX_ARM_TOKEN
378       - mask-passwords
379       - fix-workspace-permissions
380
381     builders:
382       - 'generate-ssh-keypair-macro'
383       - 'wait-pkg-mgr-macro'
384       - 'download-deploy-artifact-macro'
385       - 'deploy-macro'