4 [[ $CI_DEBUG == true ]] && redirect="/dev/stdout" || redirect="/dev/null"
6 # Prepare OpenStack credentials volume
7 if [[ ${INSTALLER_TYPE} == 'joid' ]]; then
8 rc_file_vol="-v $LAB_CONFIG/admin-openrc:/home/opnfv/functest/conf/openstack.creds"
10 rc_file_vol="-v ${HOME}/opnfv-openrc.sh:/home/opnfv/functest/conf/openstack.creds"
14 # Set iptables rule to allow forwarding return traffic for container
15 if ! sudo iptables -C FORWARD -j RETURN 2> ${redirect} || ! sudo iptables -L FORWARD | awk 'NR==3' | grep RETURN 2> ${redirect}; then
16 sudo iptables -I FORWARD -j RETURN
20 [[ $BUILD_TAG =~ "virtual" ]] && DEPLOY_TYPE=virt
22 echo "Functest: Start Docker and prepare environment"
24 if [ "$BRANCH" != 'stable/danube' ]; then
25 echo "Functest: Download images that will be used by test cases"
26 images_dir="${HOME}/opnfv/functest/images"
27 chmod +x ${WORKSPACE}/functest/ci/download_images.sh
28 ${WORKSPACE}/functest/ci/download_images.sh ${images_dir} 2> ${redirect}
29 images_vol="-v ${images_dir}:/home/opnfv/functest/images"
32 dir_result="${HOME}/opnfv/functest/results/${BRANCH##*/}"
33 mkdir -p ${dir_result}
34 sudo rm -rf ${dir_result}/*
35 results_vol="-v ${dir_result}:/home/opnfv/functest/results"
37 test -f ${HOME}/opnfv/functest/custom/params_${DOCKER_TAG} && custom_params=$(cat ${HOME}/opnfv/functest/custom/params_${DOCKER_TAG})
39 envs="-e INSTALLER_TYPE=${INSTALLER_TYPE} -e INSTALLER_IP=${INSTALLER_IP} \
40 -e NODE_NAME=${NODE_NAME} -e DEPLOY_SCENARIO=${DEPLOY_SCENARIO} \
41 -e BUILD_TAG=${BUILD_TAG} -e CI_DEBUG=${CI_DEBUG} -e DEPLOY_TYPE=${DEPLOY_TYPE}"
43 if [[ ${INSTALLER_TYPE} == 'compass' && ${DEPLOY_SCENARIO} == *'os-nosdn-openo-ha'* ]]; then
44 ssh_options="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
45 openo_msb_port=${openo_msb_port:-80}
46 openo_msb_endpoint="$(sshpass -p'root' ssh 2>/dev/null $ssh_options root@${installer_ip} \
47 'mysql -ucompass -pcompass -Dcompass -e "select package_config from cluster;" \
48 | sed s/,/\\n/g | grep openo_ip | cut -d \" -f 4'):$openo_msb_port"
50 envs=${env}" -e OPENO_MSB_ENDPOINT=${openo_msb_endpoint}"
53 if [ "$BRANCH" != 'stable/danube' ]; then
54 volumes="${images_vol} ${results_vol} ${sshkey_vol} ${stackrc_vol} ${rc_file_vol}"
56 volumes="${results_vol} ${sshkey_vol} ${stackrc_vol} ${rc_file_vol}"
60 FUNCTEST_IMAGE="opnfv/functest"
61 if [ "$HOST_ARCH" = "aarch64" ]; then
62 FUNCTEST_IMAGE="${FUNCTEST_IMAGE}_${HOST_ARCH}"
65 echo "Functest: Pulling Functest Docker image ${FUNCTEST_IMAGE}:${DOCKER_TAG}"
66 docker pull ${FUNCTEST_IMAGE}:$DOCKER_TAG >/dev/null
68 cmd="sudo docker run --privileged=true -id ${envs} ${volumes} \
69 ${custom_params} ${TESTCASE_OPTIONS} \
70 ${FUNCTEST_IMAGE}:${DOCKER_TAG} /bin/bash"
71 echo "Functest: Running docker run command: ${cmd}"
74 container_id=$(docker ps | grep "${FUNCTEST_IMAGE}:${DOCKER_TAG}" | awk '{print $1}' | head -1)
75 echo "Container ID=${container_id}"
76 if [ -z ${container_id} ]; then
77 echo "Cannot find opnfv/functest container ID ${container_id}. Please check if it is existing."
81 echo "Starting the container: docker start ${container_id}"
82 docker start ${container_id}
84 docker ps >${redirect}
85 if [ $(docker ps | grep "${FUNCTEST_IMAGE}:${DOCKER_TAG}" | wc -l) == 0 ]; then
86 echo "The container ${FUNCTEST_IMAGE} with ID=${container_id} has not been properly started. Exiting..."
90 cmd="python ${FUNCTEST_REPO_DIR}/functest/ci/prepare_env.py start"
92 echo "Executing command inside the docker: ${cmd}"
93 docker exec ${container_id} ${cmd}