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