1 ###################################
2 # job configuration for functest
3 ###################################
9 #--------------------------------
11 #--------------------------------
17 brahmaputra: &brahmaputra
19 branch: 'stable/{stream}'
20 gs-pathname: '/{stream}'
22 #--------------------------------
23 # POD, INSTALLER, AND BRANCH MAPPING
24 #--------------------------------
26 #--------------------------------
37 - huawei-us-deploy-bare-1:
58 #--------------------------------
60 #--------------------------------
91 - huawei-us-deploy-bare-2:
100 #--------------------------------
107 - 'functest-{installer}-{pod}-{testsuite}-{stream}'
109 ################################
111 ################################
113 name: 'functest-{installer}-{pod}-{testsuite}-{stream}'
124 name: '$BUILD_NUMBER Suite: $FUNCTEST_SUITE_NAME Scenario: $DEPLOY_SCENARIO'
133 - '{installer}-defaults'
134 - 'functest-{testsuite}-parameter'
136 name: DEPLOY_SCENARIO
137 default: 'os-odl_l2-nofeature-ha'
140 default: '{docker-tag}'
141 description: 'Tag to pull docker image'
142 - functest-parameter:
143 gs-pathname: '{gs-pathname}'
147 credentials-id: '{ssh-credentials}'
152 - 'functest-{testsuite}-builder'
154 ########################
156 ########################
158 name: functest-daily-parameter
161 name: FUNCTEST_SUITE_NAME
163 description: "Suite name to run"
165 name: functest-suite-parameter
168 name: FUNCTEST_SUITE_NAME
181 name: functest-parameter
185 default: '{gs-pathname}'
186 description: "Version directory where the opnfv documents will be stored in gs repository"
188 name: FUNCTEST_REPO_DIR
189 default: "/home/opnfv/repos/functest"
190 description: "Directory where the Functest repository is cloned"
192 name: PUSH_RESULTS_TO_DB
194 description: "Push the results of all the tests to the resultDB"
198 description: "Show debug output information"
199 ########################
201 ########################
203 name: 'functest-master'
207 ########################
209 ########################
211 name: functest-daily-builder
216 - 'functest-store-results'
219 name: functest-suite-builder
224 echo "Functest: run $FUNCTEST_SUITE_NAME"
225 cmd="${FUNCTEST_REPO_DIR}/ci/run_tests.py -t $FUNCTEST_SUITE_NAME"
226 container_id=$(docker ps -a | grep opnfv/functest | awk '{print $1}' | head -1)
227 docker exec $container_id $cmd
235 [[ "$PUSH_RESULTS_TO_DB" == "true" ]] && flags+="-r"
236 cmd="${FUNCTEST_REPO_DIR}/ci/run_tests.py -t all ${flags}"
237 container_id=$(docker ps -a | grep opnfv/functest | awk '{print $1}' | head -1)
238 docker exec $container_id $cmd
241 name: set-functest-env
246 [[ $CI_DEBUG == true ]] && redirect="/dev/stdout" || redirect="/dev/null"
247 # labconfig is used only for joid
249 if [[ ${INSTALLER_TYPE} == 'apex' ]]; then
250 if sudo virsh list | grep instack; then
251 instack_mac=$(sudo virsh domiflist instack | grep default | \
252 grep -Eo "[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+")
253 elif sudo virsh list | grep undercloud; then
254 instack_mac=$(sudo virsh domiflist undercloud | grep default | \
255 grep -Eo "[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+")
257 echo "No available installer VM exists...exiting"
260 INSTALLER_IP=$(/usr/sbin/arp -e | grep ${instack_mac} | awk {'print $1'})
261 sshkey="-v /root/.ssh/id_rsa:/root/.ssh/id_rsa"
262 if sudo iptables -C FORWARD -o virbr0 -j REJECT --reject-with icmp-port-unreachable 2> ${redirect}; then
263 sudo iptables -D FORWARD -o virbr0 -j REJECT --reject-with icmp-port-unreachable
265 if sudo iptables -C FORWARD -i virbr0 -j REJECT --reject-with icmp-port-unreachable 2> ${redirect}; then
266 sudo iptables -D FORWARD -i virbr0 -j REJECT --reject-with icmp-port-unreachable
268 elif [[ ${INSTALLER_TYPE} == 'joid' ]]; then
269 # If production lab then creds may be retrieved dynamically
270 # creds are on the jumphost, always in the same folder
271 labconfig="-v $LAB_CONFIG/admin-openrc:/home/opnfv/functest/conf/openstack.creds"
272 # If dev lab, credentials may not be the default ones, just provide a path to put them into docker
273 # replace the default one by the customized one provided by jenkins config
275 echo "Functest: Start Docker and prepare environment"
276 envs="-e INSTALLER_TYPE=${INSTALLER_TYPE} -e INSTALLER_IP=${INSTALLER_IP} \
277 -e NODE_NAME=${NODE_NAME} -e DEPLOY_SCENARIO=${DEPLOY_SCENARIO} \
278 -e BUILD_TAG=${BUILD_TAG} -e CI_DEBUG=${CI_DEBUG}"
279 branch=${GIT_BRANCH##*/}
280 dir_result="${HOME}/opnfv/functest/results/${branch}"
281 mkdir -p ${dir_result}
282 sudo rm -rf ${dir_result}/*
283 res_volume="-v ${dir_result}:/home/opnfv/functest/results"
285 echo "Functest: Pulling image opnfv/functest:${DOCKER_TAG}"
286 docker pull opnfv/functest:$DOCKER_TAG >${redirect}
288 cmd="sudo docker run --privileged=true -id ${envs} ${labconfig} ${sshkey} ${res_volume} opnfv/functest:${DOCKER_TAG} /bin/bash"
289 echo "Functest: Running docker run command: ${cmd}"
291 docker ps -a >${redirect}
293 container_id=$(docker ps | grep "opnfv/functest:${DOCKER_TAG}" | awk '{print $1}' | head -1)
294 echo "Container ID=${container_id}"
295 if [ -z ${container_id} ]; then
296 echo "Cannot find opnfv/functest container ID ${container_id}. Please check if it is existing."
300 echo "Starting the container: docker start ${container_id}"
301 docker start ${container_id}
303 docker ps >${redirect}
304 if [ $(docker ps | grep "opnfv/functest:${DOCKER_TAG}" | wc -l) == 0 ]; then
305 echo "The container opnfv/functest with ID=${container_id} has not been properly started. Exiting..."
308 cmd="python ${FUNCTEST_REPO_DIR}/ci/prepare_env.py start"
309 echo "Executing command inside the docker: ${cmd}"
310 docker exec ${container_id} ${cmd}
313 name: functest-store-results
316 !include-raw: ../../utils/push-test-logs.sh
319 name: functest-cleanup
323 [[ $CI_DEBUG == true ]] && redirect="/dev/stdout" || redirect="/dev/null"
325 echo "Cleaning up docker containers/images..."
326 # Remove previous running containers if exist
327 if [[ ! -z $(docker ps -a | grep opnfv/functest) ]]; then
328 echo "Removing existing opnfv/functest containers..."
329 docker ps -a | grep opnfv/functest | awk '{print $1}' | xargs docker rm -f >${redirect}
332 # Remove existing images if exist
333 if [[ ! -z $(docker images | grep opnfv/functest) ]]; then
334 echo "Docker images to remove:"
335 docker images | head -1 && docker images | grep opnfv/functest >${redirect}
336 image_tags=($(docker images | grep opnfv/functest | awk '{print $2}'))
337 for tag in "${image_tags[@]}"; do
338 echo "Removing docker image opnfv/functest:$tag..."
339 docker rmi opnfv/functest:$tag >${redirect}