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