xci: Enable daily baremetal jobs
[releng.git] / jjb / xci / xci-daily-jobs.yaml
1 ---
2 - project:
3     project: 'releng-xci'
4
5     name: 'xci-daily'
6
7     # -------------------------------
8     # Branch Anchors
9     # -------------------------------
10     master: &master
11       stream: master
12       opnfv-releng-version: master
13       gs-pathname: ''
14
15     # -------------------------------
16     # Scenarios
17     # -------------------------------
18     scenario:
19       - 'os-nosdn-nofeature-noha':
20           deploy-scenario: 'os-nosdn-nofeature'
21           installer-type: 'osa'
22           xci-flavor: 'noha'
23       - 'k8-calico-nofeature-noha':
24           deploy-scenario: 'k8-calico-nofeature'
25           installer-type: 'kubespray'
26           xci-flavor: 'noha'
27
28     # -------------------------------
29     # XCI PODs
30     # -------------------------------
31     pod:
32       - baremetal:
33           <<: *master
34
35     # -------------------------------
36     # Supported Distros
37     # -------------------------------
38     distro:
39       - 'ubuntu':
40           disabled: false
41           slave-label: xci-baremetal
42       - 'centos':
43           disabled: true
44           slave-label: xci-baremetal
45       - 'opensuse':
46           disabled: false
47           slave-label: xci-baremetal
48
49     # -------------------------------
50     #        Phases
51     # -------------------------------
52     phase:
53       - 'deploy'
54       - 'functest'
55       - 'yardstick'
56
57     # -------------------------------
58     # jobs
59     # -------------------------------
60     jobs:
61       - 'xci-{scenario}-{pod}-{distro}-daily-{stream}'
62       - 'xci-{phase}-{pod}-{distro}-daily-{stream}'
63
64 # -------------------------------
65 # job templates
66 # -------------------------------
67 - job-template:
68     name: 'xci-{scenario}-{pod}-{distro}-daily-{stream}'
69
70     disabled: '{obj:disabled}'
71
72     concurrent: false
73
74     properties:
75       - build-blocker:
76           use-build-blocker: true
77           blocking-jobs:
78             - '^xci-verify.*'
79             - '^xci-merge.*'
80             - '^xci-os.*'
81             - '^xci-k8.*'
82             - '^xci-deploy.*'
83             - '^xci-functest.*'
84             - '^bifrost-.*periodic.*'
85             - '^osa-.*periodic.*'
86           blocking-level: 'NODE'
87       - logrotate-default
88
89     triggers:
90       - timed: '@midnight'
91
92     parameters:
93       - string:
94           name: DEPLOY_SCENARIO
95           default: '{deploy-scenario}'
96       - string:
97           name: INSTALLER_TYPE
98           default: '{installer-type}'
99       - string:
100           name: XCI_FLAVOR
101           default: '{xci-flavor}'
102       - label:
103           name: SLAVE_LABEL
104           default: '{slave-label}'
105           all-nodes: false
106           node-eligibility: 'ignore-offline'
107       - string:
108           name: XCI_DISTRO
109           default: '{distro}'
110       - string:
111           name: FUNCTEST_VERSION
112           default: 'hunter'
113       - string:
114           name: FUNCTEST_MODE
115           default: 'tier'
116       - string:
117           name: FUNCTEST_SUITE_NAME
118           default: 'smoke'
119       - string:
120           name: CI_LOOP
121           default: 'daily'
122       - string:
123           name: GIT_BASE
124           default: https://gerrit.opnfv.org/gerrit/$PROJECT
125           description: 'Git URL to use on this Jenkins Slave'
126
127     wrappers:
128       - ssh-agent-wrapper
129       - build-timeout:
130           timeout: 240
131       - fix-workspace-permissions
132
133     builders:
134       - description-setter:
135           description: "Scenario: $DEPLOY_SCENARIO | Node: $NODE_NAME"
136       - trigger-builds:
137           - project: 'xci-deploy-{pod}-{distro}-daily-{stream}'
138             current-parameters: false
139             predefined-parameters: |
140               DEPLOY_SCENARIO=$DEPLOY_SCENARIO
141               INSTALLER_TYPE=$INSTALLER_TYPE
142               XCI_FLAVOR=$XCI_FLAVOR
143               CI_LOOP=$CI_LOOP
144               XCI_DISTRO=$XCI_DISTRO
145               FUNCTEST_VERSION=$FUNCTEST_VERSION
146               FUNCTEST_MODE=$FUNCTEST_MODE
147               FUNCTEST_SUITE_NAME=$FUNCTEST_SUITE_NAME
148             same-node: true
149             block: true
150       - trigger-builds:
151           - project: 'xci-functest-{pod}-{distro}-daily-{stream}'
152             current-parameters: false
153             predefined-parameters: |
154               DEPLOY_SCENARIO=$DEPLOY_SCENARIO
155               INSTALLER_TYPE=$INSTALLER_TYPE
156               XCI_FLAVOR=$XCI_FLAVOR
157               CI_LOOP=$CI_LOOP
158               XCI_DISTRO=$XCI_DISTRO
159               FUNCTEST_VERSION=$FUNCTEST_VERSION
160               FUNCTEST_MODE=$FUNCTEST_MODE
161               FUNCTEST_SUITE_NAME=$FUNCTEST_SUITE_NAME
162             same-node: true
163             block: true
164             block-thresholds:
165               build-step-failure-threshold: 'never'
166               failure-threshold: 'never'
167               unstable-threshold: 'FAILURE'
168       - trigger-builds:
169           - project: 'xci-yardstick-{pod}-{distro}-daily-{stream}'
170             current-parameters: false
171             predefined-parameters: |
172               DEPLOY_SCENARIO=$DEPLOY_SCENARIO
173               INSTALLER_TYPE=$INSTALLER_TYPE
174               XCI_FLAVOR=$XCI_FLAVOR
175               CI_LOOP=$CI_LOOP
176               XCI_DISTRO=$XCI_DISTRO
177             same-node: true
178             block: true
179             block-thresholds:
180               build-step-failure-threshold: 'never'
181               failure-threshold: 'never'
182               unstable-threshold: 'FAILURE'
183
184     publishers:
185       # yamllint disable rule:line-length
186       # yamllint enable rule:line-length
187       - email-jenkins-admins-on-failure
188
189 - job-template:
190     name: 'xci-{phase}-{pod}-{distro}-daily-{stream}'
191
192     disabled: false
193
194     concurrent: true
195
196     properties:
197       - build-blocker:
198           use-build-blocker: true
199           blocking-jobs:
200             - '^xci-verify.*'
201             - '^xci-merge.*'
202             - '^xci-deploy.*'
203             - '^xci-functest.*'
204             - '^bifrost-.*periodic.*'
205             - '^osa-.*periodic.*'
206           blocking-level: 'NODE'
207       - throttle:
208           enabled: true
209           max-per-node: 1
210           option: 'project'
211       - logrotate-default
212
213     wrappers:
214       - ssh-agent-wrapper
215       - build-timeout:
216           timeout: 240
217       - fix-workspace-permissions
218
219     scm:
220       - git-scm
221
222     parameters:
223       - project-parameter:
224           project: '{project}'
225           branch: '{opnfv-releng-version}'
226       - string:
227           name: DEPLOY_SCENARIO
228           default: 'os-nosdn-nofeature-noha'
229       - string:
230           name: INSTALLER_TYPE
231           default: 'osa'
232       - string:
233           name: XCI_FLAVOR
234           default: 'noha'
235       - string:
236           name: XCI_DISTRO
237           default: 'ubuntu'
238       - label:
239           name: SLAVE_LABEL
240           default: '{slave-label}'
241           all-nodes: false
242           node-eligibility: 'ignore-offline'
243       - string:
244           name: FUNCTEST_VERSION
245           default: 'hunter'
246       - string:
247           name: FUNCTEST_MODE
248           default: 'tier'
249       - string:
250           name: FUNCTEST_SUITE_NAME
251           default: 'smoke'
252       - string:
253           name: CI_LOOP
254           default: 'daily'
255       - string:
256           name: GIT_BASE
257           default: https://gerrit.opnfv.org/gerrit/$PROJECT
258
259     builders:
260       - description-setter:
261           description: "Scenario: $DEPLOY_SCENARIO | Node: $NODE_NAME"
262       - 'xci-daily-{phase}-macro'
263
264 # --------------------------
265 # builder macros
266 # --------------------------
267 # These need to be properly fixed once the basic deployment, functest, and
268 # yardstick jobs are working outside of clean vm.
269 # One of the ugly fixes is moving test  preparation step into the
270 # deployment job itself since test preparation requires some of the
271 # things from deployment job. With clean VM, this wasn't an issue
272 # since everything was on clean VM. When we move things out of clean
273 # VM, things are done in workspaces of the jobs that are different.
274 #
275 # Apart from these things, we will need to go through the scripts
276 # used for verify jobs and make them updated in order to be able to
277 # use them for jobs that don't use clean VM.
278 - builder:
279     name: 'xci-daily-deploy-macro'
280     builders:
281       - shell: |
282           #!/bin/bash
283           set -o errexit
284           set -o pipefail
285
286           echo "Cleaning the leftovers from the earlier run"
287           echo "---------------------------------------------------------------------------------"
288           for vm in $(sudo virsh list --all --name | grep -v xci_vm); do
289               echo "Removing $vm"
290               sudo virsh destroy $vm > /dev/null 2>&1 || true
291               sudo virsh undefine $vm > /dev/null 2>&1 || true
292               sudo killall -r vbmc > /dev/null 2>&1 || true
293               sudo rm -rf /root/.vbmc > /dev/null 2>&1 || true
294           done
295           echo "---------------------------------------------------------------------------------"
296
297           # select the right pdf/idf
298           pdf=$WORKSPACE/xci/var/${NODE_NAME}-pdf.yml
299           idf=$WORKSPACE/xci/var/${NODE_NAME}-idf.yml
300           if [[ "$NODE_NAME" =~ "virtual" ]]; then
301               pdf=$WORKSPACE/xci/var/pdf.yml
302               idf=$WORKSPACE/xci/var/idf.yml
303           fi
304
305           cd $WORKSPACE/xci && ./xci-deploy.sh -p $pdf -i $idf
306
307           echo "Prepare OPNFV VM for Tests"
308           echo "---------------------------------------------------------------------------------"
309           export XCI_PATH=$WORKSPACE
310           export XCI_VENV=${XCI_PATH}/venv
311           source $XCI_VENV/bin/activate
312           while read var; do
313               declare -x "\${var}" 2>/dev/null
314               echo $var
315           done < ${XCI_PATH}/.cache/xci.env && cd ${XCI_PATH}/xci && \
316           ansible-playbook -i playbooks/dynamic_inventory.py playbooks/prepare-tests.yml
317           ssh root@192.168.122.2 "/root/prepare-tests.sh"
318           echo "---------------------------------------------------------------------------------"
319
320 - builder:
321     name: 'xci-daily-functest-macro'
322     builders:
323       - shell: |
324           #!/bin/bash
325           set -o pipefail
326
327           ssh root@192.168.122.2 "/root/run-functest.sh"
328           functest_exit=$?
329
330           case ${DEPLOY_SCENARIO[0]} in
331               os-*)
332                   FUNCTEST_LOG=/root/functest-results/functest.log
333                   ;;
334               k8-*)
335                   FUNCTEST_LOG=/root/functest-results/functest-kubernetes.log
336                   ;;
337               *)
338                   echo "Unable to determine the installer. Exiting!"
339                   exit $functest_exit
340                   ;;
341           esac
342
343           echo "Functest log"
344           echo "---------------------------------------------------------------------------------"
345           ssh root@192.168.122.2 "cat $FUNCTEST_LOG"
346           echo "---------------------------------------------------------------------------------"
347           exit ${functest_exit}
348 - builder:
349     name: 'xci-daily-yardstick-macro'
350     builders:
351       - shell: |
352           #!/bin/bash
353           set -o errexit
354           set -o pipefail
355
356           ssh root@192.168.122.2 "/root/run-yardstick.sh"