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