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