88f64907ec41dcc134bc8f1dff74ab1868eda261
[infra/cicd.git] / jjb / engine / verify-jobs / kubernetes-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: 'kubernetes-verify-deploy-test'
22
23     project: 'kubernetes-verify-deploy-test'
24
25     stream:
26       - 'master':
27           branch: '{stream}'
28       - '1.17':
29           branch: '{stream}'
30       - '1.15':
31           branch: '{stream}'
32
33     environment-type:
34       - online:
35           disabled: false
36           execution-mode: online-deployment
37           successful: false
38           failed: false
39           unstable: false
40           notbuilt: false
41       - offline:
42           disabled: false
43           execution-mode: offline-deployment
44           successful: false
45           failed: false
46           unstable: false
47           notbuilt: false
48
49     phase:
50       - deploy
51       - functest
52
53     type:
54       - virtual:
55           provisioner-type: 'bifrost'
56           slave-type: 'vpod'
57           gated-projects: 'infra/stack/kubernetes|infra/installer/kubespray'
58           pdf: 'https://gerrit.nordix.org/gitweb?p=infra/hwconfig.git;a=blob_plain;f=pods/nordix-vpod1-pdf.yml'
59           idf: 'https://gerrit.nordix.org/gitweb?p=infra/hwconfig.git;a=blob_plain;f=pods/nordix-vpod1-idf.yml'
60       - cloud:
61           provisioner-type: 'heat'
62           slave-type: 'jumphost'
63           gated-projects: 'infra/stack/kubernetes|infra/installer/kubespray'
64           pdf: "https://gerrit.nordix.org/gitweb?p=infra/provisioner/heat.git;a=blob_plain;f=playbooks/roles/create-stack/files/heat-environment-city-ubuntu1804.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     dependency-jobs: 'kubernetes-verify-package-{distro}-{stream}'
75     dependency-job-var: 'TRIGGER_kubernetes_verify_package_{distro}_{stream}_BUILD_RESULT'
76
77     jobs:
78       - 'kubernetes-verify-{environment-type}-deploy-test-{distro}-{cloud}-{type}-{stream}'
79       - 'kubernetes-verify-{environment-type}-{phase}-{distro}-{cloud}-{type}-{stream}'
80
81 - job-template:
82     name: 'kubernetes-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       - label:
92           name: SLAVE_LABEL
93           default: 'engine-{slave-type}-{environment-type}-{distro}-fra'
94           description: 'Slave label to schedule this job on.'
95       - string:
96           name: HW_TYPE
97           default: '{type}'
98           description: 'Hardware type - could be virtual, cloud, or baremetal'
99       - string:
100           name: EXECUTION_MODE
101           default: '{execution-mode}'
102           description: 'Execution mode to run in'
103       - string:
104           name: PDF
105           default: '{pdf}'
106           description: 'PDF file to use for deployment'
107       - string:
108           name: IDF
109           default: '{idf}'
110           description: 'IDF file to use for deployment'
111       - string:
112           name: HEAT_ENVIRONMENT_FILENAME
113           default: 'heat-environment-{cloud}-{distro}.yaml'
114           description: 'Name of heat-environment file to use.'
115       - string:
116           name: HEAT_STACK_NAME
117           default: "nordix-cicd-verify-kubernetes-{environment-type}-{distro}-$GERRIT_CHANGE_NUMBER"
118           description: 'Name of the created stack'
119       - string:
120           name: KEYPAIR_NAME
121           default: "keypair-nordix-cicd-verify-kubernetes-{environment-type}-{distro}-$GERRIT_CHANGE_NUMBER"
122           description: 'Name of the created keypair'
123       - string:
124           name: USE_PREBUILT_DEPLOYMENT_IMAGE
125           default: 'true'
126           description: 'Use prebuilt deployment image while running as part of CI/CD'
127       - string:
128           name: TEST_REPO_URL
129           default: 'https://gerrit.nordix.org/infra/test.git'
130           description: 'URL to clone the test repo from'
131       - string:
132           name: TEST_FW
133           default: 'functest'
134           description: 'Test framework to use'
135       - string:
136           name: TEST_SUITE
137           default: 'healthcheck'
138           description: 'Test suite to run'
139       - string:
140           name: YARDSTICK_DISPATCHER
141           default: 'file'
142           description: 'Dispatcher to use for Yardstick reporting'
143       - string:
144           name: DELETE_STACK
145           default: 'true'
146           description: 'Delete the stack upon completion of the build'
147       - string:
148           name: VERBOSITY
149           default: 'true'
150           description: 'Verbosity setting for the engine - true or false - default is false'
151       - string:
152           name: CI_LOOP
153           default: "verify"
154           description: 'CI loop the job belongs to'
155       - project-parameters:
156           project: $GERRIT_PROJECT
157           branch: '{branch}'
158           description: 'The project and branch which the change is proposed for'
159       - nordix-gerrit-parameters
160
161     properties:
162       - logrotate
163       - build-blocker:
164           use-build-blocker: true
165           blocking-jobs:
166             - 'engine-verify-online-deploy-test-.*'
167             - 'kubernetes-verify-offline-deploy-test-.*'
168             - 'onap-verify-offline-deploy-test-.*'
169             - 'openstack-verify-deploy-test-.*'
170           block-level: 'NODE'
171       - throttle:
172           max-per-node: 1
173           max-total: 3
174           option: project
175
176     scm:
177       - git-scm-gerrit:
178           ssh-credentials-id: nordixinfra-nordix-gerrit-ssh
179           branch: $GERRIT_BRANCH
180           refspec: $GERRIT_REFSPEC
181           wipe_workspace: true
182           clean_before: false
183
184     triggers:
185       - gerrit:
186           server-name: 'Nordix Gerrit'
187           trigger-on:
188             - patchset-created-event:
189                 exclude-drafts: 'false'
190                 exclude-trivial-rebase: 'false'
191                 exclude-no-code-change: 'false'
192             - draft-published-event
193             - comment-added-contains-event:
194                 comment-contains-value: 'recheck'
195             - comment-added-contains-event:
196                 comment-contains-value: 'reverify'
197           projects:
198             - project-compare-type: 'REG_EXP'
199               project-pattern: '{gated-projects}'
200               branches:
201                 - branch-compare-type: 'ANT'
202                   branch-pattern: '**/{branch}'
203               disable-strict-forbidden-file-verification: 'true'
204               forbidden-file-paths:
205                 - compare-type: ANT
206                   pattern: 'docs/**|releasenotes/**'
207           skip-vote:
208             successful: '{obj:successful}'
209             failed: '{obj:failed}'
210             unstable: '{obj:unstable}'
211             notbuilt: '{obj:notbuilt}'
212           custom-url: '* $JOB_NAME $BUILD_URL'
213           readable-message: 'true'
214           dependency-jobs: '{dependency-jobs}'
215
216     wrappers:
217       - build-timeout:
218           timeout: 180
219       - credentials-binding:
220           - file:
221               credential-id: '{openrc-credentials-file}'
222               variable: OPENRC_FILE
223           - username-password-separated:
224               credential-id: 'nordix-cicd-arm-credentials'
225               username: NORDIX_ARM_USERNAME
226               password: NORDIX_ARM_TOKEN
227       - mask-passwords
228       - openstack:
229           single-use: True
230       - pre-scm-buildstep:
231           failOnError: true
232           buildsteps:
233             - system-groovy:
234                 command: |
235                   def build = this.getProperty('binding').getVariable('build')
236                   def listener = this.getProperty('binding').getVariable('listener')
237                   if (build.getEnvironment(listener).{dependency-job-var} != "SUCCESS") {{
238                     println "WARN  : Aborting build since dependent job did not succeed!"
239                     throw new InterruptedException()
240                   }}
241             - shell: |
242                 #!/bin/bash
243                 sudo chown -R $USER:$USER $WORKSPACE || exit 1
244                 # offline nodes can not resolve Nordix Artifactory and Gerrit
245                 if [[ "$EXECUTION_MODE" == "offline-deployment" ]]; then
246                   echo "Info  : Offline deployment. Adding City OpenStack Endpoint, Nordix Artifactory and Gerrit Public IP to /etc/hosts"
247                   sudo sed -i 's/^search/# search/' /etc/resolv.conf
248                   sudo bash -c "cat << EOF >> /etc/hosts
249                 # managed by engine
250                 91.106.198.25 artifactory.nordix.org
251                 91.106.198.142 gerrit.nordix.org
252                 86.107.242.50 fra1.citycloud.com
253                 # managed by engine
254                 EOF"
255                   # we need to get rid of search domain as well
256                   sudo sed -i 's/^search/# search/' /etc/resolv.conf
257                 fi
258
259     builders:
260       - 'generate-change-metadata-macro'
261       - multijob:
262           name: "{environment-type} deployment on {type} instances"
263           condition: SUCCESSFUL
264           execution-type: PARALLEL
265           projects:
266             - name: 'kubernetes-verify-{environment-type}-deploy-{distro}-city-{type}-master'
267               current-parameters: true
268               git-revision: true
269               node-parameters: true
270               kill-phase-on: FAILURE
271               abort-all-job: false
272               property-file: $WORKSPACE/change.properties
273       - multijob:
274           name: "{environment-type} testing on {type} instances"
275           condition: SUCCESSFUL
276           execution-type: PARALLEL
277           projects:
278             - name: 'kubernetes-verify-{environment-type}-functest-{distro}-city-{type}-master'
279               current-parameters: true
280               git-revision: false
281               node-parameters: true
282               kill-phase-on: FAILURE
283               abort-all-job: false
284               property-file: $WORKSPACE/change.properties
285
286     publishers:
287       - postbuildscript:
288           builders:
289             - role: SLAVE
290               build-on:
291                 - SUCCESS
292                 - FAILURE
293                 - ABORTED
294                 - NOT_BUILT
295                 - UNSTABLE
296               build-steps:
297                 - 'wait-pkg-mgr-macro'
298                 - 'delete-stack-macro'
299
300 - job-template:
301     name: 'kubernetes-verify-{environment-type}-{phase}-{distro}-{cloud}-{type}-{stream}'
302
303     disabled: '{obj:disabled}'
304
305     concurrent: true
306
307     properties:
308       - logrotate
309       - throttle:
310           max-per-node: 1
311           max-total: 3
312           option: project
313
314     scm:
315       - git-scm-gerrit:
316           ssh-credentials-id: nordixinfra-nordix-gerrit-ssh
317           branch: $GERRIT_BRANCH
318           refspec: $GERRIT_REFSPEC
319           wipe_workspace: true
320           clean_before: false
321
322     wrappers:
323       - build-timeout:
324           timeout: 180
325       - credentials-binding:
326           - file:
327               credential-id: '{openrc-credentials-file}'
328               variable: OPENRC_FILE
329           - username-password-separated:
330               credential-id: 'nordix-cicd-arm-credentials'
331               username: NORDIX_ARM_USERNAME
332               password: NORDIX_ARM_TOKEN
333       - mask-passwords
334       - fix-workspace-permissions
335
336     builders:
337       - 'generate-ssh-keypair-macro'
338       - 'wait-pkg-mgr-macro'
339       - 'download-artifact-macro'
340       - '{phase}-macro'