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