1 ###################################
2 # job configuration for functest
3 ###################################
9 #--------------------------------
11 #--------------------------------
16 brahmaputra: &brahmaputra
18 branch: 'stable/{stream}'
19 gs-pathname: '/{stream}'
20 #--------------------------------
21 # POD, INSTALLER, AND BRANCH MAPPING
22 #--------------------------------
24 #--------------------------------
35 - huawei-us-deploy-bare-1:
53 #--------------------------------
55 #--------------------------------
86 #--------------------------------
93 - 'functest-{installer}-{pod}-{testsuite}-{stream}'
95 ################################
97 ################################
99 name: 'functest-{installer}-{pod}-{testsuite}-{stream}'
110 name: '$BUILD_NUMBER Suite: $FUNCTEST_SUITE_NAME Scenario: $DEPLOY_SCENARIO'
119 - '{installer}-defaults'
120 - 'functest-{testsuite}-parameter'
122 name: DEPLOY_SCENARIO
123 default: 'os-odl_l2-nofeature-ha'
124 - functest-parameter:
125 gs-pathname: '{gs-pathname}'
129 credentials-id: '{ssh-credentials}'
134 - 'functest-{testsuite}-builder'
136 ########################
138 ########################
140 name: functest-daily-parameter
143 name: FUNCTEST_SUITE_NAME
145 description: "Suite name to run"
147 name: functest-suite-parameter
150 name: FUNCTEST_SUITE_NAME
162 name: functest-parameter
166 default: '{gs-pathname}'
167 description: "Version directory where the opnfv documents will be stored in gs repository"
169 name: FUNCTEST_REPO_DIR
170 default: "/home/opnfv/repos/functest"
171 description: "Directory where the Functest repository is cloned"
173 name: PUSH_RESULTS_TO_DB
175 description: "Push the results of all the tests to the resultDB"
179 description: "Show debug output information"
180 ########################
182 ########################
184 name: 'functest-master'
188 ########################
190 ########################
192 name: functest-daily-builder
197 - 'functest-store-results'
200 name: functest-suite-builder
206 if [ "${PUSH_RESULTS_TO_DB}" == "true" ]; then
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
221 if [ "${PUSH_RESULTS_TO_DB}" == "true" ]; then
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
229 name: set-functest-env
234 [[ $CI_DEBUG == true ]] && redirect="/dev/stdout" || redirect="/dev/null"
235 # labconfig is used only for joid
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
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"
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}"
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."
274 echo "Starting the container: docker start ${container_id}"
275 docker start ${container_id}
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..."
282 cmd="${FUNCTEST_REPO_DIR}/docker/prepare_env.sh"
283 echo "Executing command inside the docker: ${cmd}"
284 docker exec ${container_id} ${cmd}
287 name: functest-store-results
290 !include-raw: ../../utils/push-test-logs.sh
293 name: functest-cleanup
297 [[ $CI_DEBUG == true ]] && redirect="/dev/stdout" || redirect="/dev/null"
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
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