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