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