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