Merge "Add hardcoded list of CI PODs to avoid pushing logs from non-CI PODs"
[releng.git] / jjb / functest / functest-ci-jobs.yml
1 ###################################
2 # job configuration for functest
3 ###################################
4 - project:
5     name: functest
6
7     project: '{name}'
8
9 #--------------------------------
10 # BRANCH ANCHORS
11 #--------------------------------
12     master: &master
13         stream: master
14         branch: '{stream}'
15         gs-pathname: ''
16     brahmaputra: &brahmaputra
17         stream: brahmaputra
18         branch: 'stable/{stream}'
19         gs-pathname: '/{stream}'
20 #--------------------------------
21 # POD, INSTALLER, AND BRANCH MAPPING
22 #--------------------------------
23 #        brahmaputra
24 #--------------------------------
25     pod:
26         - opnfv-jump-1:
27             installer: apex
28             <<: *brahmaputra
29         - opnfv-jump-2:
30             installer: fuel
31             <<: *brahmaputra
32         - intel-pod5:
33             installer: joid
34             <<: *brahmaputra
35         - huawei-us-deploy-bare-1:
36             installer: compass
37             <<: *brahmaputra
38         - ericsson-pod1:
39             installer: fuel
40             <<: *brahmaputra
41         - ericsson-pod2:
42             installer: fuel
43             <<: *brahmaputra
44         - virtual:
45             installer: fuel
46             <<: *brahmaputra
47         - huawei-virtual:
48             installer: compass
49             <<: *brahmaputra
50         - virtual:
51             installer: joid
52             <<: *brahmaputra
53 #--------------------------------
54 #        master
55 #--------------------------------
56         - opnfv-jump-2:
57             installer: fuel
58             <<: *master
59         - intel-pod6:
60             installer: joid
61             <<: *master
62         - intel-pod8:
63             installer: compass
64             <<: *master
65         - opnfv-jump-1:
66             installer: apex
67             <<: *master
68         - ericsson-pod1:
69             installer: fuel
70             <<: *master
71         - ericsson-pod2:
72             installer: fuel
73             <<: *master
74         - orange-test1:
75             installer: fuel
76             <<: *master
77         - orange-pod2:
78             installer: joid
79             <<: *master
80         - virtual:
81             installer: fuel
82             <<: *master
83         - huawei-virtual:
84             installer: compass
85             <<: *master
86         - virtual:
87             installer: joid
88             <<: *master
89 #--------------------------------
90
91     testsuite:
92         - 'daily'
93         - 'suite'
94
95     jobs:
96         - 'functest-{installer}-{pod}-{testsuite}-{stream}'
97
98 ################################
99 # job template
100 ################################
101 - job-template:
102     name: 'functest-{installer}-{pod}-{testsuite}-{stream}'
103
104     concurrent: true
105
106     properties:
107         - throttle:
108             enabled: true
109             max-per-node: 1
110
111     wrappers:
112         - build-name:
113             name: '$BUILD_NUMBER Suite: $FUNCTEST_SUITE_NAME Scenario: $DEPLOY_SCENARIO'
114         - timeout:
115             timeout: 400
116             abort: true
117
118     parameters:
119         - project-parameter:
120             project: '{project}'
121         - '{pod}-defaults'
122         - '{installer}-defaults'
123         - 'functest-{testsuite}-parameter'
124         - string:
125             name: DEPLOY_SCENARIO
126             default: 'os-odl_l2-nofeature-ha'
127         - functest-parameter:
128             gs-pathname: '{gs-pathname}'
129
130     scm:
131         - git-scm:
132             credentials-id: '{ssh-credentials}'
133             refspec: ''
134             branch: '{branch}'
135
136     builders:
137         - 'functest-{testsuite}-builder'
138
139 ########################
140 # parameter macros
141 ########################
142 - parameter:
143     name: functest-daily-parameter
144     parameters:
145         - string:
146             name: FUNCTEST_SUITE_NAME
147             default: 'daily'
148             description: "Suite name to run"
149 - parameter:
150     name: functest-suite-parameter
151     parameters:
152         - choice:
153             name: FUNCTEST_SUITE_NAME
154             choices:
155                 - 'tempest'
156                 - 'rally'
157                 - 'odl'
158                 - 'onos'
159                 - 'ovno'
160                 - 'promise'
161                 - 'doctor'
162                 - 'vims'
163                 - 'vping'
164 - parameter:
165     name: functest-parameter
166     parameters:
167         - string:
168             name: GS_PATHNAME
169             default: '{gs-pathname}'
170             description: "Version directory where the opnfv documents will be stored in gs repository"
171         - string:
172             name: FUNCTEST_REPO_DIR
173             default: "/home/opnfv/repos/functest"
174             description: "Directory where the Functest repository is cloned"
175         - string:
176             name: PUSH_RESULTS_TO_DB
177             default: "true"
178             description: "Push the results of all the tests to the resultDB"
179         - string:
180             name: CI_DEBUG
181             default: 'false'
182             description: "Show debug output information"
183 ########################
184 # trigger macros
185 ########################
186 - trigger:
187     name: 'functest-master'
188     triggers:
189         - pollscm:
190             cron: "H 9 * * *"
191 ########################
192 # builder macros
193 ########################
194 - builder:
195     name: functest-daily-builder
196     builders:
197         - 'functest-cleanup'
198         - 'set-functest-env'
199         - 'functest-all'
200         - 'functest-store-results'
201
202 - builder:
203     name: functest-suite-builder
204     builders:
205         - shell: |
206             #!/bin/bash
207             set +e
208             flag=""
209             if [ "${PUSH_RESULTS_TO_DB}" == "true" ]; then
210                 flag="-r"
211             fi
212             echo "Functest: run $FUNCTEST_SUITE_NAME"
213             cmd="${FUNCTEST_REPO_DIR}/docker/run_tests.sh --test $FUNCTEST_SUITE_NAME ${flag}"
214             container_id=$(docker ps -a | grep opnfv/functest | awk '{print $1}' | head -1)
215             docker exec $container_id $cmd
216
217 - builder:
218     name: functest-all
219     builders:
220         - shell: |
221             #!/bin/bash
222             set +e
223             flag=""
224             if [ "${PUSH_RESULTS_TO_DB}" == "true" ]; then
225                 flag="-r"
226             fi
227             cmd="${FUNCTEST_REPO_DIR}/docker/run_tests.sh ${flag}"
228             container_id=$(docker ps -a | grep opnfv/functest | awk '{print $1}' | head -1)
229             docker exec $container_id $cmd
230
231 - builder:
232     name: set-functest-env
233     builders:
234         - shell: |
235             #!/bin/bash
236             set +e
237             [[ $CI_DEBUG == true ]] && redirect="/dev/stdout" || redirect="/dev/null"
238             # labconfig is used only for joid
239             labconfig=""
240             if [[ ${INSTALLER_TYPE} == 'apex' ]]; then
241                 instack_mac=$(sudo virsh domiflist instack | grep default | \
242                               grep -Eo "[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+")
243                 INSTALLER_IP=$(/usr/sbin/arp -e | grep ${instack_mac} | awk {'print $1'})
244                 sshkey="-v /root/.ssh/id_rsa:/root/.ssh/id_rsa"
245                 sudo iptables -D FORWARD -o virbr0 -j REJECT --reject-with icmp-port-unreachable
246                 sudo iptables -D FORWARD -i virbr0 -j REJECT --reject-with icmp-port-unreachable
247             elif [[ ${INSTALLER_TYPE} == 'joid' ]]; then
248                 # If production lab then creds may be retrieved dynamically
249                 # creds are on the jumphost, always in the same folder
250                 labconfig="-v $LAB_CONFIG/admin-openrc:/home/opnfv/functest/conf/openstack.creds"
251                 # If dev lab, credentials may not be the default ones, just provide a path to put them into docker
252                 # replace the default one by the customized one provided by jenkins config
253             fi
254             echo "Functest: Start Docker and prepare environment"
255             envs="-e INSTALLER_TYPE=${INSTALLER_TYPE} -e INSTALLER_IP=${INSTALLER_IP} \
256                 -e NODE_NAME=${NODE_NAME} -e DEPLOY_SCENARIO=${DEPLOY_SCENARIO} \
257                 -e CI_DEBUG=${CI_DEBUG}"
258             branch=${GIT_BRANCH##*/}
259             dir_result="${HOME}/opnfv/functest/results/${branch}"
260             mkdir -p ${dir_result}
261             sudo rm -rf ${dir_result}/*
262             res_volume="-v ${dir_result}:/home/opnfv/functest/results"
263
264             docker pull opnfv/functest:latest >$redirect
265             cmd="sudo docker run --privileged=true -id ${envs} ${labconfig} ${sshkey} ${res_volume} opnfv/functest:latest /bin/bash"
266             echo "Functest: Running docker run command: ${cmd}"
267             ${cmd}
268             docker ps -a
269             sleep 5
270             container_id=$(docker ps | grep 'opnfv/functest:latest' | awk '{print $1}' | head -1)
271             echo "Container ID=${container_id}"
272             if [ -z ${container_id} ]; then
273                 echo "Cannot find opnfv/functest container ID ${container_id}. Please check if it is existing."
274                 docker ps -a
275                 exit 1
276             fi
277             echo "Starting the container: docker start ${container_id}"
278             docker start ${container_id}
279             sleep 5
280             docker ps
281             if [ $(docker ps | grep 'opnfv/functest:latest' | wc -l) == 0 ]; then
282                 echo "The container opnfv/functest with ID=${container_id} has not been properly started. Exiting..."
283                 exit 1
284             fi
285             cmd="${FUNCTEST_REPO_DIR}/docker/prepare_env.sh"
286             echo "Executing command inside the docker: ${cmd}"
287             docker exec ${container_id} ${cmd}
288
289 - builder:
290     name: functest-store-results
291     builders:
292         - shell:
293             !include-raw: ../../utils/push-test-logs.sh
294
295 - builder:
296     name: functest-cleanup
297     builders:
298         - shell: |
299             #!/bin/bash
300             [[ $CI_DEBUG == true ]] && redirect="/dev/stdout" || redirect="/dev/null"
301
302             echo "Cleaning up docker containers/images..."
303             # Remove previous running containers if exist
304             if [[ ! -z $(docker ps -a | grep opnfv/functest) ]]; then
305                 echo "Removing existing opnfv/functest containers..."
306                 docker ps -a | grep opnfv/functest | awk '{print $1}' | xargs docker rm -f >$redirect
307             fi
308
309             # Remove existing images if exist
310             if [[ ! -z $(docker images | grep opnfv/functest) ]]; then
311                 echo "Docker images to remove:"
312                 docker images | head -1 && docker images | grep opnfv/functest
313                 image_tags=($(docker images | grep opnfv/functest | awk '{print $2}'))
314                 for tag in "${image_tags[@]}"; do
315                     echo "Removing docker image opnfv/functest:$tag..."
316                     docker rmi opnfv/functest:$tag >$redirect
317                 done
318             fi