7 TEST_DB_URL=http://testresults.opnfv.org/test/api/v1/results
8 ENERGY_RECORDER_API_URL=http://energy.opnfv.fr/resources
10 check_os_deployment() {
11 FUNCTEST_IMAGE=opnfv/functest-healthcheck:${DOCKER_TAG}
12 echo "Functest: Pulling Functest Docker image ${FUNCTEST_IMAGE} ..."
13 docker pull ${FUNCTEST_IMAGE}>/dev/null
14 cmd="docker run --rm --privileged=true ${volumes} ${FUNCTEST_IMAGE} check_deployment"
15 echo "Checking deployment, CMD: ${cmd}"
18 if [ ${ret_value} != 0 ]; then
19 echo "ERROR: Problem while checking OpenStack deployment."
22 echo "OpenStack deployment OK."
30 if [[ ${BRANCH##*/} == "master" ]]; then
31 cmd_opt="run_tests -r -t all"
32 [[ $BUILD_TAG =~ "suite" ]] && cmd_opt="run_tests -t all"
34 cmd_opt="prepare_env start && run_tests -r -t all"
35 [[ $BUILD_TAG =~ "suite" ]] && cmd_opt="prepare_env start && run_tests -t all"
37 ret_val_file="${HOME}/opnfv/functest/results/${BRANCH##*/}/return_value"
38 echo 0 > ${ret_val_file}
40 for tier in ${tiers[@]}; do
41 FUNCTEST_IMAGE=opnfv/functest-${tier}:${DOCKER_TAG}
42 echo "Functest: Pulling Functest Docker image ${FUNCTEST_IMAGE} ..."
43 docker pull ${FUNCTEST_IMAGE}>/dev/null
44 cmd="docker run --rm --privileged=true ${envs} ${volumes} ${TESTCASE_OPTIONS} ${FUNCTEST_IMAGE} /bin/bash -c '${cmd_opt}'"
45 echo "Running Functest tier '${tier}'. CMD: ${cmd}"
48 if [ ${ret_value} != 0 ]; then
49 echo ${ret_value} > ${ret_val_file}
50 if [ ${tier} == 'healthcheck' ]; then
51 echo "Healthcheck tier failed. Exiting Functest..."
60 if [[ ${BRANCH##*/} == "master" ]]; then
61 cmd_opt="run_tests -t ${test_name}"
63 cmd_opt="prepare_env start && run_tests -t ${test_name}"
65 ret_val_file="${HOME}/opnfv/functest/results/${BRANCH##*/}/return_value"
66 echo 0 > ${ret_val_file}
67 # Determine which Functest image should be used for the test case
69 connection_check|api_check|snaps_health_check)
70 FUNCTEST_IMAGE=opnfv/functest-healthcheck:${DOCKER_TAG} ;;
71 vping_ssh|vping_userdata|tempest_smoke_serial|rally_sanity|refstack_defcore|odl|odl_netvirt|snaps_smoke)
72 FUNCTEST_IMAGE=opnfv/functest-smoke:${DOCKER_TAG} ;;
73 tempest_full_parallel|rally_full)
74 FUNCTEST_IMAGE=opnfv/functest-components:${DOCKER_TAG} ;;
75 cloudify_ims|orchestra_openims|orchestra_clearwaterims|vyos_vrouter)
76 FUNCTEST_IMAGE=opnfv/functest-vnf:${DOCKER_TAG} ;;
77 promise|doctor-notification|bgpvpn|functest-odl-sfc|domino-multinode|barometercollectd|fds)
78 FUNCTEST_IMAGE=opnfv/functest-features:${DOCKER_TAG} ;;
80 FUNCTEST_IMAGE=opnfv/functest-parser:${DOCKER_TAG} ;;
82 echo "Unkown test case $test_name"
86 echo "Functest: Pulling Functest Docker image ${FUNCTEST_IMAGE} ..."
87 docker pull ${FUNCTEST_IMAGE}>/dev/null
88 cmd="docker run --rm --privileged=true ${envs} ${volumes} ${TESTCASE_OPTIONS} ${FUNCTEST_IMAGE} /bin/bash -c '${cmd_opt}'"
89 echo "Running Functest test case '${test_name}'. CMD: ${cmd}"
92 if [ ${ret_value} != 0 ]; then
93 echo ${ret_value} > ${ret_val_file}
98 [[ $CI_DEBUG == true ]] && redirect="/dev/stdout" || redirect="/dev/null"
99 FUNCTEST_DIR=/home/opnfv/functest
100 DEPLOY_TYPE=baremetal
101 [[ $BUILD_TAG =~ "virtual" ]] && DEPLOY_TYPE=virt
102 HOST_ARCH=$(uname -m)
103 DOCKER_TAG=`[[ ${BRANCH##*/} == "master" ]] && echo "latest" || echo ${BRANCH##*/}`
105 # Prepare OpenStack credentials volume
106 rc_file=${HOME}/opnfv-openrc.sh
108 if [[ ${INSTALLER_TYPE} == 'joid' ]]; then
109 rc_file=$LAB_CONFIG/admin-openrc
110 elif [[ ${INSTALLER_TYPE} == 'compass' ]]; then
111 cacert_file_vol="-v ${HOME}/os_cacert:${FUNCTEST_DIR}/conf/os_cacert"
112 echo "export OS_CACERT=${FUNCTEST_DIR}/conf/os_cacert" >> ${HOME}/opnfv-openrc.sh
113 elif [[ ${INSTALLER_TYPE} == 'fuel' && ${DEPLOY_TYPE} == 'baremetal' ]]; then
114 cacert_file_vol="-v ${HOME}/os_cacert:/etc/ssl/certs/mcp_os_cacert"
117 if [[ ${BRANCH} == "stable/euphrates" ]]; then
118 rc_file_vol="-v ${rc_file}:${FUNCTEST_DIR}/conf/openstack.creds"
120 rc_file_vol="-v ${rc_file}:${FUNCTEST_DIR}/conf/env_file"
123 # Set iptables rule to allow forwarding return traffic for container
124 if ! sudo iptables -C FORWARD -j RETURN 2> ${redirect} || ! sudo iptables -L FORWARD | awk 'NR==3' | grep RETURN 2> ${redirect}; then
125 sudo iptables -I FORWARD -j RETURN
128 echo "Functest: Start Docker and prepare environment"
130 echo "Functest: Download images that will be used by test cases"
131 images_dir="${HOME}/opnfv/functest/images"
132 download_script=${WORKSPACE}/functest/ci/download_images.sh
133 if [[ ! -f ${download_script} ]]; then
134 # to support Danube as well
135 wget https://git.opnfv.org/functest/plain/functest/ci/download_images.sh -O ${download_script} 2> ${redirect}
137 chmod +x ${download_script}
138 ${download_script} ${images_dir} ${DEPLOY_SCENARIO} ${HOST_ARCH} 2> ${redirect}
140 images_vol="-v ${images_dir}:${FUNCTEST_DIR}/images"
142 dir_result="${HOME}/opnfv/functest/results/${BRANCH##*/}"
143 mkdir -p ${dir_result}
144 sudo rm -rf ${dir_result}/*
145 results_vol="-v ${dir_result}:${FUNCTEST_DIR}/results"
147 test -f ${HOME}/opnfv/functest/custom/params_${DOCKER_TAG} && custom_params=$(cat ${HOME}/opnfv/functest/custom/params_${DOCKER_TAG})
149 envs="-e INSTALLER_TYPE=${INSTALLER_TYPE} -e INSTALLER_IP=${INSTALLER_IP} \
150 -e NODE_NAME=${NODE_NAME} -e DEPLOY_SCENARIO=${DEPLOY_SCENARIO} \
151 -e BUILD_TAG=${BUILD_TAG} -e DEPLOY_TYPE=${DEPLOY_TYPE} \
152 -e TEST_DB_URL=${TEST_DB_URL} -e ENERGY_RECORDER_API_URL=${ENERGY_RECORDER_API_URL}"
154 ssh_options="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
157 if [ "${INSTALLER_TYPE}" == 'fuel' ]; then
158 COMPUTE_ARCH=$(ssh -l ubuntu ${INSTALLER_IP} -i ${SSH_KEY} ${ssh_options} \
159 "sudo salt 'cmp*' grains.get cpuarch --out yaml | awk '{print \$2; exit}'")
160 envs="${envs} -e POD_ARCH=${COMPUTE_ARCH}"
163 volumes="${images_vol} ${results_vol} ${sshkey_vol} ${rc_file_vol} ${cacert_file_vol}"
168 if [[ ${DEPLOY_SCENARIO} =~ ^os-.* ]]; then
169 [[ ${BRANCH##*/} == "master" ]] && check_os_deployment
170 if [ ${FUNCTEST_MODE} == 'testcase' ]; then
171 echo "FUNCTEST_MODE=testcase, FUNCTEST_SUITE_NAME=${FUNCTEST_SUITE_NAME}"
172 run_test ${FUNCTEST_SUITE_NAME}
173 elif [ ${FUNCTEST_MODE} == 'tier' ]; then
174 echo "FUNCTEST_MODE=tier, FUNCTEST_TIER=${FUNCTEST_TIER}"
175 tiers=(${FUNCTEST_TIER})
178 if [ ${DEPLOY_TYPE} == 'baremetal' ]; then
179 tiers=(healthcheck smoke features vnf parser)
181 tiers=(healthcheck smoke features)
186 echo "k8 deployment has not been supported by functest yet"