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}'
154 - 'functest-{testsuite}-builder'
156 ########################
158 ########################
160 name: functest-daily-parameter
163 name: FUNCTEST_SUITE_NAME
165 description: "Suite name to run"
167 name: functest-suite-parameter
170 name: FUNCTEST_SUITE_NAME
183 name: functest-parameter
187 default: '{gs-pathname}'
188 description: "Version directory where the opnfv documents will be stored in gs repository"
190 name: FUNCTEST_REPO_DIR
191 default: "/home/opnfv/repos/functest"
192 description: "Directory where the Functest repository is cloned"
194 name: PUSH_RESULTS_TO_DB
196 description: "Push the results of all the tests to the resultDB"
200 description: "Show debug output information"
201 ########################
203 ########################
205 name: 'functest-master'
209 ########################
211 ########################
213 name: functest-daily-builder
218 - 'functest-store-results'
221 name: functest-suite-builder
226 echo "Functest: run $FUNCTEST_SUITE_NAME"
227 cmd="${FUNCTEST_REPO_DIR}/docker/run_tests.sh --test $FUNCTEST_SUITE_NAME"
228 container_id=$(docker ps -a | grep opnfv/functest | awk '{print $1}' | head -1)
229 docker exec $container_id $cmd
238 [[ "$PUSH_RESULTS_TO_DB" == "true" ]] && flags+=" -r"
239 cmd="${FUNCTEST_REPO_DIR}/docker/run_tests.sh ${flags}"
240 container_id=$(docker ps -a | grep opnfv/functest | awk '{print $1}' | head -1)
241 docker exec $container_id $cmd
244 name: set-functest-env
249 [[ $CI_DEBUG == true ]] && redirect="/dev/stdout" || redirect="/dev/null"
250 # labconfig is used only for joid
252 if [[ ${INSTALLER_TYPE} == 'apex' ]]; then
253 if sudo virsh list | grep instack; then
254 instack_mac=$(sudo virsh domiflist instack | grep default | \
255 grep -Eo "[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+")
256 elif sudo virsh list | grep undercloud; then
257 instack_mac=$(sudo virsh domiflist undercloud | grep default | \
258 grep -Eo "[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+")
260 echo "No available installer VM exists...exiting"
263 INSTALLER_IP=$(/usr/sbin/arp -e | grep ${instack_mac} | awk {'print $1'})
264 sshkey="-v /root/.ssh/id_rsa:/root/.ssh/id_rsa"
265 if sudo iptables -C FORWARD -o virbr0 -j REJECT --reject-with icmp-port-unreachable 2> ${redirect}; then
266 sudo iptables -D FORWARD -o virbr0 -j REJECT --reject-with icmp-port-unreachable
268 if sudo iptables -C FORWARD -i virbr0 -j REJECT --reject-with icmp-port-unreachable 2> ${redirect}; then
269 sudo iptables -D FORWARD -i virbr0 -j REJECT --reject-with icmp-port-unreachable
271 elif [[ ${INSTALLER_TYPE} == 'joid' ]]; then
272 # If production lab then creds may be retrieved dynamically
273 # creds are on the jumphost, always in the same folder
274 labconfig="-v $LAB_CONFIG/admin-openrc:/home/opnfv/functest/conf/openstack.creds"
275 # If dev lab, credentials may not be the default ones, just provide a path to put them into docker
276 # replace the default one by the customized one provided by jenkins config
278 echo "Functest: Start Docker and prepare environment"
279 envs="-e INSTALLER_TYPE=${INSTALLER_TYPE} -e INSTALLER_IP=${INSTALLER_IP} \
280 -e NODE_NAME=${NODE_NAME} -e DEPLOY_SCENARIO=${DEPLOY_SCENARIO} \
281 -e BUILD_TAG=${BUILD_TAG} -e CI_DEBUG=${CI_DEBUG}"
282 branch=${GIT_BRANCH##*/}
283 dir_result="${HOME}/opnfv/functest/results/${branch}"
284 mkdir -p ${dir_result}
285 sudo rm -rf ${dir_result}/*
286 res_volume="-v ${dir_result}:/home/opnfv/functest/results"
288 echo "Functest: Pulling image opnfv/functest:${DOCKER_TAG}"
289 docker pull opnfv/functest:$DOCKER_TAG >${redirect}
291 cmd="sudo docker run --privileged=true -id ${envs} ${labconfig} ${sshkey} ${res_volume} opnfv/functest:${DOCKER_TAG} /bin/bash"
292 echo "Functest: Running docker run command: ${cmd}"
296 container_id=$(docker ps | grep "opnfv/functest:${DOCKER_TAG}" | awk '{print $1}' | head -1)
297 echo "Container ID=${container_id}"
298 if [ -z ${container_id} ]; then
299 echo "Cannot find opnfv/functest container ID ${container_id}. Please check if it is existing."
303 echo "Starting the container: docker start ${container_id}"
304 docker start ${container_id}
307 if [ $(docker ps | grep "opnfv/functest:${DOCKER_TAG}" | wc -l) == 0 ]; then
308 echo "The container opnfv/functest with ID=${container_id} has not been properly started. Exiting..."
311 cmd="${FUNCTEST_REPO_DIR}/docker/prepare_env.sh"
312 echo "Executing command inside the docker: ${cmd}"
313 docker exec ${container_id} ${cmd}
316 name: functest-store-results
319 !include-raw: ../../utils/push-test-logs.sh
322 name: functest-cleanup
326 [[ $CI_DEBUG == true ]] && redirect="/dev/stdout" || redirect="/dev/null"
328 echo "Cleaning up docker containers/images..."
329 # Remove previous running containers if exist
330 if [[ ! -z $(docker ps -a | grep opnfv/functest) ]]; then
331 echo "Removing existing opnfv/functest containers..."
332 docker ps -a | grep opnfv/functest | awk '{print $1}' | xargs docker rm -f >${redirect}
335 # Remove existing images if exist
336 if [[ ! -z $(docker images | grep opnfv/functest) ]]; then
337 echo "Docker images to remove:"
338 docker images | head -1 && docker images | grep opnfv/functest
339 image_tags=($(docker images | grep opnfv/functest | awk '{print $2}'))
340 for tag in "${image_tags[@]}"; do
341 echo "Removing docker image opnfv/functest:$tag..."
342 docker rmi opnfv/functest:$tag >${redirect}