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