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