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