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