42e3e3e7b710910164b9ec8dd9ee23e6aee499c9
[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_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-ci-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_STACK_NAME
130           default: "nordix-cicd-verify-kubernetes-{environment-type}-{distro}-$GERRIT_CHANGE_NUMBER"
131           description: 'Name of the created stack'
132       - string:
133           name: KEYPAIR_NAME
134           default: "keypair-nordix-cicd-verify-kubernetes-{environment-type}-{distro}-$GERRIT_CHANGE_NUMBER"
135           description: 'Name of the created keypair'
136       - string:
137           name: USE_PREBUILT_DEPLOYMENT_IMAGE
138           default: 'true'
139           description: 'Use prebuilt deployment image while running as part of CI/CD'
140       - string:
141           name: TEST_REPO_URL
142           default: 'https://gerrit.nordix.org/infra/test.git'
143           description: 'URL to clone the test repo from'
144       - string:
145           name: TEST_FW
146           default: 'functest'
147           description: 'Test framework to use'
148       - string:
149           name: TEST_SUITE
150           default: 'healthcheck'
151           description: 'Test suite to run'
152       - string:
153           name: YARDSTICK_DISPATCHER
154           default: 'file'
155           description: 'Dispatcher to use for Yardstick reporting'
156       - string:
157           name: DELETE_STACK
158           default: 'true'
159           description: 'Delete the stack upon completion of the build'
160       - string:
161           name: VERBOSITY
162           default: 'true'
163           description: 'Verbosity setting for the engine - true or false - default is false'
164       - string:
165           name: CI_LOOP
166           default: "verify"
167           description: 'CI loop the job belongs to'
168       - project-parameters:
169           project: $GERRIT_PROJECT
170           branch: '{branch}'
171           description: 'The project and branch which the change is proposed for'
172       - nordix-gerrit-parameters
173
174     properties:
175       - logrotate
176       # NOTE (fdegir): throttle categories are controlled in jenkins global configuration
177       - throttle:
178           enabled: true
179           max-per-node: 1
180           max-total: 8
181           option: category
182           categories:
183             - engine-verify-deploy-test
184
185     scm:
186       - git-scm-gerrit:
187           ssh-credentials-id: nordixinfra-nordix-gerrit-ssh
188           branch: $GERRIT_BRANCH
189           refspec: $GERRIT_REFSPEC
190           wipe_workspace: true
191           clean_before: false
192
193     triggers:
194       - gerrit:
195           server-name: 'Nordix Gerrit'
196           trigger-on:
197             - patchset-created-event:
198                 exclude-drafts: 'false'
199                 exclude-trivial-rebase: 'false'
200                 exclude-no-code-change: 'false'
201             - draft-published-event
202             - comment-added-contains-event:
203                 comment-contains-value: 'recheck'
204             - comment-added-contains-event:
205                 comment-contains-value: 'reverify'
206           projects:
207             - project-compare-type: 'REG_EXP'
208               project-pattern: '{gated-projects}'
209               branches:
210                 - branch-compare-type: 'ANT'
211                   branch-pattern: '**/{branch}'
212               disable-strict-forbidden-file-verification: 'true'
213               forbidden-file-paths:
214                 - compare-type: ANT
215                   pattern: 'docs/**|releasenotes/**'
216           skip-vote:
217             successful: '{obj:successful}'
218             failed: '{obj:failed}'
219             unstable: '{obj:unstable}'
220             notbuilt: '{obj:notbuilt}'
221           custom-url: '* $JOB_NAME $BUILD_URL'
222           readable-message: 'true'
223           dependency-jobs: '{dependency-jobs}'
224
225     wrappers:
226       - build-timeout:
227           timeout: 180
228       - credentials-binding:
229           - file:
230               credential-id: '{openrc-credentials-file}'
231               variable: OPENRC_FILE
232           - username-password-separated:
233               credential-id: 'nordix-cicd-arm-credentials'
234               username: NORDIX_ARM_USERNAME
235               password: NORDIX_ARM_TOKEN
236       - mask-passwords
237       - openstack:
238           single-use: True
239       - pre-scm-buildstep:
240           failOnError: true
241           buildsteps:
242             - system-groovy:
243                 command: |
244                   def build = this.getProperty('binding').getVariable('build')
245                   def listener = this.getProperty('binding').getVariable('listener')
246                   if (build.getEnvironment(listener).{dependency-job-var} != "SUCCESS") {{
247                     println "WARN  : Aborting build since dependent job did not succeed!"
248                     throw new InterruptedException()
249                   }}
250             - shell: |
251                 #!/bin/bash
252                 sudo chown -R $USER:$USER $WORKSPACE || exit 1
253                 # offline nodes can not resolve Nordix Artifactory and Gerrit
254                 if [[ "$EXECUTION_MODE" == "offline-deployment" ]]; then
255                   echo "Info  : Offline deployment. Adding City OpenStack Endpoint, Nordix Artifactory and Gerrit Public IP to /etc/hosts"
256                   sudo sed -i 's/^search/# search/' /etc/resolv.conf
257                   sudo bash -c "cat << EOF >> /etc/hosts
258                 # managed by engine
259                 91.106.198.25 artifactory.nordix.org
260                 91.106.198.142 gerrit.nordix.org
261                 86.107.242.50 fra1.citycloud.com
262                 # managed by engine
263                 EOF"
264                   # we need to get rid of search domain as well
265                   sudo sed -i 's/^search/# search/' /etc/resolv.conf
266                 fi
267
268     builders:
269       - 'generate-change-metadata-macro'
270       - multijob:
271           name: "{environment-type} deployment on {type} instances"
272           condition: SUCCESSFUL
273           execution-type: PARALLEL
274           projects:
275             - name: 'kubernetes-verify-{environment-type}-deploy-{distro}-city-{type}-{stream}'
276               current-parameters: true
277               git-revision: true
278               node-parameters: true
279               kill-phase-on: FAILURE
280               abort-all-job: false
281               property-file: $WORKSPACE/change.properties
282       - multijob:
283           name: "{environment-type} testing on {type} instances"
284           condition: SUCCESSFUL
285           execution-type: PARALLEL
286           projects:
287             - name: 'kubernetes-verify-{environment-type}-functest-{distro}-city-{type}-{stream}'
288               current-parameters: true
289               git-revision: false
290               node-parameters: true
291               kill-phase-on: FAILURE
292               abort-all-job: false
293               property-file: $WORKSPACE/change.properties
294
295     publishers:
296       - postbuildscript:
297           builders:
298             - role: SLAVE
299               build-on:
300                 - SUCCESS
301                 - FAILURE
302                 - ABORTED
303                 - NOT_BUILT
304                 - UNSTABLE
305               build-steps:
306                 - 'wait-pkg-mgr-macro'
307                 - 'delete-stack-macro'
308
309 - job-template:
310     name: 'kubernetes-verify-{environment-type}-{phase}-{distro}-{cloud}-{type}-{stream}'
311
312     disabled: '{obj:disabled}'
313
314     concurrent: true
315
316     properties:
317       - logrotate
318       - throttle:
319           max-per-node: 1
320           max-total: 3
321           option: project
322
323     scm:
324       - git-scm-gerrit:
325           ssh-credentials-id: nordixinfra-nordix-gerrit-ssh
326           branch: $GERRIT_BRANCH
327           refspec: $GERRIT_REFSPEC
328           wipe_workspace: true
329           clean_before: false
330
331     wrappers:
332       - build-timeout:
333           timeout: 180
334       - credentials-binding:
335           - file:
336               credential-id: '{openrc-credentials-file}'
337               variable: OPENRC_FILE
338           - username-password-separated:
339               credential-id: 'nordix-cicd-arm-credentials'
340               username: NORDIX_ARM_USERNAME
341               password: NORDIX_ARM_TOKEN
342       - mask-passwords
343       - fix-workspace-permissions
344
345     builders:
346       - 'generate-ssh-keypair-macro'
347       - 'wait-pkg-mgr-macro'
348       - 'download-artifact-macro'
349       - '{phase}-macro'