b96fec8754bc6797f88ed97a9b99d7acc0efd0b5
[infra/cicd.git] / jjb / engine / 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-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: 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       - string:
184           name: CI_LOOP
185           default: "verify"
186           description: 'CI loop the job belongs to'
187       - project-parameters:
188           project: $GERRIT_PROJECT
189           branch: '{branch}'
190           description: 'The project and branch which the change is proposed for'
191       - nordix-gerrit-parameters
192
193     properties:
194       - logrotate
195       - build-blocker:
196           use-build-blocker: true
197           blocking-jobs:
198             - 'engine-verify-online-deploy-test-.*'
199             - 'engine-verify-offline-deploy-test-.*'
200           block-level: 'NODE'
201       - throttle:
202           max-per-node: 1
203           max-total: 3
204           option: project
205
206     scm:
207       - git-scm-gerrit:
208           ssh-credentials-id: nordixinfra-nordix-gerrit-ssh
209           branch: refs/heads/$GERRIT_BRANCH
210           refspec: $GERRIT_REFSPEC
211           wipe_workspace: true
212           clean_before: false
213
214     triggers:
215       - gerrit:
216           server-name: 'Nordix Gerrit'
217           trigger-on:
218             - patchset-created-event:
219                 exclude-drafts: 'false'
220                 exclude-trivial-rebase: 'false'
221                 exclude-no-code-change: 'false'
222             - draft-published-event
223             - comment-added-contains-event:
224                 comment-contains-value: 'recheck'
225             - comment-added-contains-event:
226                 comment-contains-value: 'reverify'
227           projects:
228             - project-compare-type: 'REG_EXP'
229               project-pattern: '{gated-projects}'
230               branches:
231                 - branch-compare-type: 'ANT'
232                   branch-pattern: '**/{branch}'
233               disable-strict-forbidden-file-verification: 'true'
234               forbidden-file-paths:
235                 - compare-type: ANT
236                   pattern: 'docs/**|releasenotes/**'
237           skip-vote:
238             successful: '{obj:successful}'
239             failed: '{obj:failed}'
240             unstable: '{obj:unstable}'
241             notbuilt: '{obj:notbuilt}'
242           custom-url: '* $JOB_NAME $BUILD_URL'
243           readable-message: 'true'
244           dependency-jobs: '{dependency-jobs}'
245
246     wrappers:
247       - build-timeout:
248           timeout: 180
249       - credentials-binding:
250           - file:
251               credential-id: '{openrc-credentials-file}'
252               variable: OPENRC_FILE
253           - username-password-separated:
254               credential-id: 'nordix-cicd-arm-credentials'
255               username: NORDIX_ARM_USERNAME
256               password: NORDIX_ARM_TOKEN
257       - mask-passwords
258       - openstack:
259           single-use: True
260       - pre-scm-buildstep:
261           failOnError: true
262           buildsteps:
263             - system-groovy:
264                 command: |
265                   def build = this.getProperty('binding').getVariable('build')
266                   def listener = this.getProperty('binding').getVariable('listener')
267                   if (build.getEnvironment(listener).{dependency-job-var} != "SUCCESS") {{
268                     println "WARN  : Aborting build since dependent job did not succeed!"
269                     throw new InterruptedException()
270                   }}
271             - shell: |
272                 #!/bin/bash
273                 sudo chown -R $USER:$USER $WORKSPACE || exit 1
274                 # offline nodes can not resolve Nordix Gerrit
275                 if [[ "$EXECUTION_MODE" == "offline-deployment" ]]; then
276                   echo "Info  : Offline deployment. Adding Nordix Gerrit Public IP to /etc/hosts"
277                   sudo sed -i 's/^search/# search/' /etc/resolv.conf
278                   sudo bash -c "cat << EOF >> /etc/hosts
279                 # managed by engine
280                 $NORDIX_GERRIT_PUBLIC_IP gerrit.nordix.org
281                 # managed by engine
282                 EOF"
283                 fi
284
285     builders:
286       - multijob:
287           name: "{environment-type} deployment on {type} instances"
288           condition: SUCCESSFUL
289           execution-type: PARALLEL
290           projects:
291             - name: 'engine-verify-{environment-type}-deploy-{distro}-city-{type}-master'
292               current-parameters: true
293               git-revision: true
294               node-parameters: true
295               kill-phase-on: FAILURE
296               abort-all-job: false
297       - multijob:
298           name: "{environment-type} testing on {type} instances"
299           condition: SUCCESSFUL
300           execution-type: PARALLEL
301           projects:
302             - name: 'engine-verify-{environment-type}-functest-{distro}-city-{type}-master'
303               current-parameters: true
304               git-revision: false
305               node-parameters: true
306               kill-phase-on: FAILURE
307               abort-all-job: false
308
309     publishers:
310       - postbuildscript:
311           builders:
312             - role: SLAVE
313               build-on:
314                 - SUCCESS
315                 - FAILURE
316                 - ABORTED
317                 - NOT_BUILT
318                 - UNSTABLE
319               build-steps:
320                 - 'wait-pkg-mgr-macro'
321                 - 'delete-stack-macro'
322
323 - job-template:
324     name: 'engine-verify-{environment-type}-{phase}-{distro}-{cloud}-{type}-{stream}'
325
326     disabled: '{obj:disabled}'
327
328     concurrent: true
329
330     properties:
331       - logrotate
332       - throttle:
333           max-per-node: 1
334           max-total: 3
335           option: project
336
337     scm:
338       - git-scm-gerrit:
339           ssh-credentials-id: nordixinfra-nordix-gerrit-ssh
340           branch: refs/heads/$GERRIT_BRANCH
341           refspec: $GERRIT_REFSPEC
342           wipe_workspace: true
343           clean_before: false
344
345     wrappers:
346       - build-timeout:
347           timeout: 180
348       - credentials-binding:
349           - file:
350               credential-id: '{openrc-credentials-file}'
351               variable: OPENRC_FILE
352           - username-password-separated:
353               credential-id: 'nordix-cicd-arm-credentials'
354               username: NORDIX_ARM_USERNAME
355               password: NORDIX_ARM_TOKEN
356       - mask-passwords
357       - fix-workspace-permissions
358
359     builders:
360       - shell: |
361           #!/bin/bash
362           if [[ "$EXECUTION_MODE" == "offline-deployment" && "$PROVISIONER_TYPE" == "heat" ]]; then
363             echo "Info  : Offline deployment and testing on cloud instances is not currently supported!"
364             exit 0
365           fi
366       - 'generate-sdf-for-change-macro'
367       - 'generate-ssh-keypair-macro'
368       - 'wait-pkg-mgr-macro'
369       - 'download-artifact-macro'
370       - '{phase}-macro'