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