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}/docker/run_tests.sh --test $FUNCTEST_SUITE_NAME"
226 container_id=$(docker ps -a | grep opnfv/functest | awk '{print $1}' | head -1)
227 docker exec $container_id $cmd
236 [[ "$PUSH_RESULTS_TO_DB" == "true" ]] && flags+=" -r"
237 cmd="${FUNCTEST_REPO_DIR}/docker/run_tests.sh ${flags}"
238 container_id=$(docker ps -a | grep opnfv/functest | awk '{print $1}' | head -1)
239 docker exec $container_id $cmd
242 name: set-functest-env
247 [[ $CI_DEBUG == true ]] && redirect="/dev/stdout" || redirect="/dev/null"
248 # labconfig is used only for joid
250 if [[ ${INSTALLER_TYPE} == 'apex' ]]; then
251 if sudo virsh list | grep instack; then
252 instack_mac=$(sudo virsh domiflist instack | grep default | \
253 grep -Eo "[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+")
254 elif sudo virsh list | grep undercloud; then
255 instack_mac=$(sudo virsh domiflist undercloud | grep default | \
256 grep -Eo "[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+")
258 echo "No available installer VM exists...exiting"
261 INSTALLER_IP=$(/usr/sbin/arp -e | grep ${instack_mac} | awk {'print $1'})
262 sshkey="-v /root/.ssh/id_rsa:/root/.ssh/id_rsa"
263 sudo iptables -D FORWARD -o virbr0 -j REJECT --reject-with icmp-port-unreachable
264 sudo iptables -D FORWARD -i virbr0 -j REJECT --reject-with icmp-port-unreachable
265 elif [[ ${INSTALLER_TYPE} == 'joid' ]]; then
266 # If production lab then creds may be retrieved dynamically
267 # creds are on the jumphost, always in the same folder
268 labconfig="-v $LAB_CONFIG/admin-openrc:/home/opnfv/functest/conf/openstack.creds"
269 # If dev lab, credentials may not be the default ones, just provide a path to put them into docker
270 # replace the default one by the customized one provided by jenkins config
272 echo "Functest: Start Docker and prepare environment"
273 envs="-e INSTALLER_TYPE=${INSTALLER_TYPE} -e INSTALLER_IP=${INSTALLER_IP} \
274 -e NODE_NAME=${NODE_NAME} -e DEPLOY_SCENARIO=${DEPLOY_SCENARIO} \
275 -e BUILD_TAG=${BUILD_TAG} -e CI_DEBUG=${CI_DEBUG}"
276 branch=${GIT_BRANCH##*/}
277 dir_result="${HOME}/opnfv/functest/results/${branch}"
278 mkdir -p ${dir_result}
279 sudo rm -rf ${dir_result}/*
280 res_volume="-v ${dir_result}:/home/opnfv/functest/results"
282 echo "Functest: Pulling image opnfv/functest:${DOCKER_TAG}"
283 docker pull opnfv/functest:$DOCKER_TAG >${redirect}
285 cmd="sudo docker run --privileged=true -id ${envs} ${labconfig} ${sshkey} ${res_volume} opnfv/functest:${DOCKER_TAG} /bin/bash"
286 echo "Functest: Running docker run command: ${cmd}"
288 docker ps -a >${redirect}
290 container_id=$(docker ps | grep "opnfv/functest:${DOCKER_TAG}" | awk '{print $1}' | head -1)
291 echo "Container ID=${container_id}"
292 if [ -z ${container_id} ]; then
293 echo "Cannot find opnfv/functest container ID ${container_id}. Please check if it is existing."
297 echo "Starting the container: docker start ${container_id}"
298 docker start ${container_id}
300 docker ps >${redirect}
301 if [ $(docker ps | grep "opnfv/functest:${DOCKER_TAG}" | wc -l) == 0 ]; then
302 echo "The container opnfv/functest with ID=${container_id} has not been properly started. Exiting..."
305 cmd="${FUNCTEST_REPO_DIR}/docker/prepare_env.sh"
306 echo "Executing command inside the docker: ${cmd}"
307 docker exec ${container_id} ${cmd}
310 name: functest-store-results
313 !include-raw: ../../utils/push-test-logs.sh
316 name: functest-cleanup
320 [[ $CI_DEBUG == true ]] && redirect="/dev/stdout" || redirect="/dev/null"
322 echo "Cleaning up docker containers/images..."
323 # Remove previous running containers if exist
324 if [[ ! -z $(docker ps -a | grep opnfv/functest) ]]; then
325 echo "Removing existing opnfv/functest containers..."
326 docker ps -a | grep opnfv/functest | awk '{print $1}' | xargs docker rm -f >${redirect}
329 # Remove existing images if exist
330 if [[ ! -z $(docker images | grep opnfv/functest) ]]; then
331 echo "Docker images to remove:"
332 docker images | head -1 && docker images | grep opnfv/functest >${redirect}
333 image_tags=($(docker images | grep opnfv/functest | awk '{print $2}'))
334 for tag in "${image_tags[@]}"; do
335 echo "Removing docker image opnfv/functest:$tag..."
336 docker rmi opnfv/functest:$tag >${redirect}