1 ###################################
2 # job configuration for functest
3 ###################################
9 #--------------------------------
11 #--------------------------------
17 brahmaputra: &brahmaputra
19 branch: 'stable/{stream}'
20 gs-pathname: '/{stream}'
21 docker-tag: 'brahmaputra.1.0'
22 #--------------------------------
23 # POD, INSTALLER, AND BRANCH MAPPING
24 #--------------------------------
26 #--------------------------------
37 - huawei-us-deploy-bare-1:
58 #--------------------------------
60 #--------------------------------
91 - huawei-us-deploy-bare-2:
94 #--------------------------------
101 - 'functest-{installer}-{pod}-{testsuite}-{stream}'
103 ################################
105 ################################
107 name: 'functest-{installer}-{pod}-{testsuite}-{stream}'
118 name: '$BUILD_NUMBER Suite: $FUNCTEST_SUITE_NAME Scenario: $DEPLOY_SCENARIO'
127 - '{installer}-defaults'
128 - 'functest-{testsuite}-parameter'
130 name: DEPLOY_SCENARIO
131 default: 'os-odl_l2-nofeature-ha'
134 default: '{docker-tag}'
135 description: 'Tag to pull docker image'
136 - functest-parameter:
137 gs-pathname: '{gs-pathname}'
141 credentials-id: '{ssh-credentials}'
146 - 'functest-{testsuite}-builder'
148 ########################
150 ########################
152 name: functest-daily-parameter
155 name: FUNCTEST_SUITE_NAME
157 description: "Suite name to run"
159 name: functest-suite-parameter
162 name: FUNCTEST_SUITE_NAME
174 name: functest-parameter
178 default: '{gs-pathname}'
179 description: "Version directory where the opnfv documents will be stored in gs repository"
181 name: FUNCTEST_REPO_DIR
182 default: "/home/opnfv/repos/functest"
183 description: "Directory where the Functest repository is cloned"
185 name: PUSH_RESULTS_TO_DB
187 description: "Push the results of all the tests to the resultDB"
191 description: "Show debug output information"
192 ########################
194 ########################
196 name: 'functest-master'
200 ########################
202 ########################
204 name: functest-daily-builder
209 - 'functest-store-results'
212 name: functest-suite-builder
218 [[ "$PUSH_RESULTS_TO_DB" == "true" ]] && flags+=" -r"
219 echo "Functest: run $FUNCTEST_SUITE_NAME"
220 cmd="${FUNCTEST_REPO_DIR}/docker/run_tests.sh --test $FUNCTEST_SUITE_NAME ${flags}"
221 container_id=$(docker ps -a | grep opnfv/functest | awk '{print $1}' | head -1)
222 docker exec $container_id $cmd
231 [[ "$PUSH_RESULTS_TO_DB" == "true" ]] && flags+=" -r"
232 cmd="${FUNCTEST_REPO_DIR}/docker/run_tests.sh ${flags}"
233 container_id=$(docker ps -a | grep opnfv/functest | awk '{print $1}' | head -1)
234 docker exec $container_id $cmd
237 name: set-functest-env
242 [[ $CI_DEBUG == true ]] && redirect="/dev/stdout" || redirect="/dev/null"
243 # labconfig is used only for joid
245 if [[ ${INSTALLER_TYPE} == 'apex' ]]; then
246 instack_mac=$(sudo virsh domiflist instack | grep default | \
247 grep -Eo "[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+")
248 INSTALLER_IP=$(/usr/sbin/arp -e | grep ${instack_mac} | awk {'print $1'})
249 sshkey="-v /root/.ssh/id_rsa:/root/.ssh/id_rsa"
250 sudo iptables -D FORWARD -o virbr0 -j REJECT --reject-with icmp-port-unreachable
251 sudo iptables -D FORWARD -i virbr0 -j REJECT --reject-with icmp-port-unreachable
252 elif [[ ${INSTALLER_TYPE} == 'joid' ]]; then
253 # If production lab then creds may be retrieved dynamically
254 # creds are on the jumphost, always in the same folder
255 labconfig="-v $LAB_CONFIG/admin-openrc:/home/opnfv/functest/conf/openstack.creds"
256 # If dev lab, credentials may not be the default ones, just provide a path to put them into docker
257 # replace the default one by the customized one provided by jenkins config
259 echo "Functest: Start Docker and prepare environment"
260 envs="-e INSTALLER_TYPE=${INSTALLER_TYPE} -e INSTALLER_IP=${INSTALLER_IP} \
261 -e NODE_NAME=${NODE_NAME} -e DEPLOY_SCENARIO=${DEPLOY_SCENARIO} \
262 -e BUILD_TAG=${BUILD_TAG} -e CI_DEBUG=${CI_DEBUG}"
263 branch=${GIT_BRANCH##*/}
264 dir_result="${HOME}/opnfv/functest/results/${branch}"
265 mkdir -p ${dir_result}
266 sudo rm -rf ${dir_result}/*
267 res_volume="-v ${dir_result}:/home/opnfv/functest/results"
269 docker pull opnfv/functest:$DOCKER_TAG >$redirect
270 cmd="sudo docker run --privileged=true -id ${envs} ${labconfig} ${sshkey} ${res_volume} opnfv/functest:latest /bin/bash"
271 echo "Functest: Running docker run command: ${cmd}"
275 container_id=$(docker ps | grep 'opnfv/functest:latest' | awk '{print $1}' | head -1)
276 echo "Container ID=${container_id}"
277 if [ -z ${container_id} ]; then
278 echo "Cannot find opnfv/functest container ID ${container_id}. Please check if it is existing."
282 echo "Starting the container: docker start ${container_id}"
283 docker start ${container_id}
286 if [ $(docker ps | grep 'opnfv/functest:latest' | wc -l) == 0 ]; then
287 echo "The container opnfv/functest with ID=${container_id} has not been properly started. Exiting..."
290 cmd="${FUNCTEST_REPO_DIR}/docker/prepare_env.sh"
291 echo "Executing command inside the docker: ${cmd}"
292 docker exec ${container_id} ${cmd}
295 name: functest-store-results
298 !include-raw: ../../utils/push-test-logs.sh
301 name: functest-cleanup
305 [[ $CI_DEBUG == true ]] && redirect="/dev/stdout" || redirect="/dev/null"
307 echo "Cleaning up docker containers/images..."
308 # Remove previous running containers if exist
309 if [[ ! -z $(docker ps -a | grep opnfv/functest) ]]; then
310 echo "Removing existing opnfv/functest containers..."
311 docker ps -a | grep opnfv/functest | awk '{print $1}' | xargs docker rm -f >$redirect
314 # Remove existing images if exist
315 if [[ ! -z $(docker images | grep opnfv/functest) ]]; then
316 echo "Docker images to remove:"
317 docker images | head -1 && docker images | grep opnfv/functest
318 image_tags=($(docker images | grep opnfv/functest | awk '{print $2}'))
319 for tag in "${image_tags[@]}"; do
320 echo "Removing docker image opnfv/functest:$tag..."
321 docker rmi opnfv/functest:$tag >$redirect