7 CI_LOOP=${CI_LOOP:-daily}
8 TEST_DB_URL=http://testresults.opnfv.org/test/api/v1/results
9 ENERGY_RECORDER_API_URL=http://energy.opnfv.fr/resources
11 check_os_deployment() {
12 FUNCTEST_IMAGE=opnfv/functest-healthcheck:${DOCKER_TAG}
13 echo "Functest: Pulling Functest Docker image ${FUNCTEST_IMAGE} ..."
14 docker pull ${FUNCTEST_IMAGE}>/dev/null
15 cmd="docker run --rm --privileged=true ${volumes} ${FUNCTEST_IMAGE} check_deployment"
16 echo "Checking deployment, CMD: ${cmd}"
19 if [ ${ret_value} != 0 ]; then
20 echo "ERROR: Problem while checking OpenStack deployment."
23 echo "OpenStack deployment OK."
31 if [[ ${BRANCH##*/} == "master" ]]; then
32 cmd_opt="run_tests -r -t all"
33 [[ $BUILD_TAG =~ "suite" ]] && cmd_opt="run_tests -t all"
35 cmd_opt="prepare_env start && run_tests -r -t all"
36 [[ $BUILD_TAG =~ "suite" ]] && cmd_opt="prepare_env start && run_tests -t all"
38 ret_val_file="${HOME}/opnfv/functest/results/${BRANCH##*/}/return_value"
39 echo 0 > ${ret_val_file}
41 for tier in ${tiers[@]}; do
42 FUNCTEST_IMAGE=opnfv/functest-${tier}:${DOCKER_TAG}
43 echo "Functest: Pulling Functest Docker image ${FUNCTEST_IMAGE} ..."
44 docker pull ${FUNCTEST_IMAGE}>/dev/null
45 cmd="docker run --rm --privileged=true ${envs} ${volumes} ${TESTCASE_OPTIONS} ${FUNCTEST_IMAGE} /bin/bash -c '${cmd_opt}'"
46 echo "Running Functest tier '${tier}'. CMD: ${cmd}"
49 if [ ${ret_value} != 0 ]; then
50 echo ${ret_value} > ${ret_val_file}
51 if [ ${tier} == 'healthcheck' ]; then
52 echo "Healthcheck tier failed. Exiting Functest..."
61 if [[ ${BRANCH##*/} == "master" ]]; then
62 cmd_opt="run_tests -t ${test_name}"
64 cmd_opt="prepare_env start && run_tests -t ${test_name}"
66 ret_val_file="${HOME}/opnfv/functest/results/${BRANCH##*/}/return_value"
67 echo 0 > ${ret_val_file}
68 # Determine which Functest image should be used for the test case
70 connection_check|api_check|snaps_health_check)
71 FUNCTEST_IMAGE=opnfv/functest-healthcheck:${DOCKER_TAG} ;;
72 vping_ssh|vping_userdata|tempest_smoke_serial|rally_sanity|refstack_defcore|odl|odl_netvirt|snaps_smoke)
73 FUNCTEST_IMAGE=opnfv/functest-smoke:${DOCKER_TAG} ;;
74 tempest_full_parallel|rally_full)
75 FUNCTEST_IMAGE=opnfv/functest-components:${DOCKER_TAG} ;;
76 cloudify_ims|orchestra_openims|orchestra_clearwaterims|vyos_vrouter)
77 FUNCTEST_IMAGE=opnfv/functest-vnf:${DOCKER_TAG} ;;
78 promise|doctor-notification|bgpvpn|functest-odl-sfc|domino-multinode|barometercollectd|fds)
79 FUNCTEST_IMAGE=opnfv/functest-features:${DOCKER_TAG} ;;
81 FUNCTEST_IMAGE=opnfv/functest-parser:${DOCKER_TAG} ;;
83 echo "Unkown test case $test_name"
87 echo "Functest: Pulling Functest Docker image ${FUNCTEST_IMAGE} ..."
88 docker pull ${FUNCTEST_IMAGE}>/dev/null
89 cmd="docker run --rm --privileged=true ${envs} ${volumes} ${TESTCASE_OPTIONS} ${FUNCTEST_IMAGE} /bin/bash -c '${cmd_opt}'"
90 echo "Running Functest test case '${test_name}'. CMD: ${cmd}"
93 if [ ${ret_value} != 0 ]; then
94 echo ${ret_value} > ${ret_val_file}
99 [[ $CI_DEBUG == true ]] && redirect="/dev/stdout" || redirect="/dev/null"
100 FUNCTEST_DIR=/home/opnfv/functest
101 DEPLOY_TYPE=baremetal
102 [[ $BUILD_TAG =~ "virtual" ]] && DEPLOY_TYPE=virt
103 HOST_ARCH=$(uname -m)
104 DOCKER_TAG=`[[ ${BRANCH##*/} == "master" ]] && echo "latest" || echo ${BRANCH##*/}`
106 # Prepare OpenStack credentials volume
107 rc_file=${HOME}/opnfv-openrc.sh
109 if [[ ${INSTALLER_TYPE} == 'joid' ]]; then
110 rc_file=$LAB_CONFIG/admin-openrc
111 elif [[ ${INSTALLER_TYPE} == 'compass' ]]; then
112 cacert_file_vol="-v ${HOME}/os_cacert:${FUNCTEST_DIR}/conf/os_cacert"
113 echo "export OS_CACERT=${FUNCTEST_DIR}/conf/os_cacert" >> ${HOME}/opnfv-openrc.sh
114 elif [[ ${INSTALLER_TYPE} == 'fuel' && ${DEPLOY_TYPE} == 'baremetal' ]]; then
115 cacert_file_vol="-v ${HOME}/os_cacert:/etc/ssl/certs/mcp_os_cacert"
118 if [[ ${BRANCH} == "stable/euphrates" ]]; then
119 rc_file_vol="-v ${rc_file}:${FUNCTEST_DIR}/conf/openstack.creds"
121 rc_file_vol="-v ${rc_file}:${FUNCTEST_DIR}/conf/env_file"
124 # Set iptables rule to allow forwarding return traffic for container
125 if ! sudo iptables -C FORWARD -j RETURN 2> ${redirect} || ! sudo iptables -L FORWARD | awk 'NR==3' | grep RETURN 2> ${redirect}; then
126 sudo iptables -I FORWARD -j RETURN
129 echo "Functest: Start Docker and prepare environment"
131 echo "Functest: Download images that will be used by test cases"
132 images_dir="${HOME}/opnfv/functest/images"
133 download_script=${WORKSPACE}/functest/ci/download_images.sh
134 if [[ ! -f ${download_script} ]]; then
135 # to support Danube as well
136 wget https://git.opnfv.org/functest/plain/functest/ci/download_images.sh -O ${download_script} 2> ${redirect}
138 chmod +x ${download_script}
139 ${download_script} ${images_dir} ${DEPLOY_SCENARIO} ${HOST_ARCH} 2> ${redirect}
141 images_vol="-v ${images_dir}:${FUNCTEST_DIR}/images"
143 dir_result="${HOME}/opnfv/functest/results/${BRANCH##*/}"
144 mkdir -p ${dir_result}
145 sudo rm -rf ${dir_result}/*
146 results_vol="-v ${dir_result}:${FUNCTEST_DIR}/results"
148 test -f ${HOME}/opnfv/functest/custom/params_${DOCKER_TAG} && custom_params=$(cat ${HOME}/opnfv/functest/custom/params_${DOCKER_TAG})
150 envs="-e INSTALLER_TYPE=${INSTALLER_TYPE} -e INSTALLER_IP=${INSTALLER_IP} \
151 -e NODE_NAME=${NODE_NAME} -e DEPLOY_SCENARIO=${DEPLOY_SCENARIO} \
152 -e BUILD_TAG=${BUILD_TAG} -e DEPLOY_TYPE=${DEPLOY_TYPE} -e CI_LOOP=${CI_LOOP} \
153 -e TEST_DB_URL=${TEST_DB_URL} -e ENERGY_RECORDER_API_URL=${ENERGY_RECORDER_API_URL}"
155 ssh_options="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
158 if [ "${INSTALLER_TYPE}" == 'fuel' ]; then
159 COMPUTE_ARCH=$(ssh -l ubuntu ${INSTALLER_IP} -i ${SSH_KEY} ${ssh_options} \
160 "sudo salt 'cmp*' grains.get cpuarch --out yaml | awk '{print \$2; exit}'")
161 envs="${envs} -e POD_ARCH=${COMPUTE_ARCH}"
165 if [[ ${INSTALLER_TYPE} == 'compass' && ${DEPLOY_SCENARIO} =~ 'odl.*sfc' ]]; then
166 ssh_key="/tmp/id_rsa"
167 user_config="/tmp/openstack_user_config.yml"
168 docker cp compass-tasks:/root/.ssh/id_rsa $ssh_key
169 docker cp compass-tasks:/etc/openstack_deploy/openstack_user_config.yml $user_config
170 sshkey_vol="-v ${ssh_key}:/root/.ssh/id_rsa"
171 userconfig_vol="-v ${user_config}:${user_config}"
172 envs="${envs} -e EXTERNAL_NETWORK=${EXTERNAL_NETWORK}"
176 volumes="${images_vol} ${results_vol} ${sshkey_vol} ${userconfig_vol} ${rc_file_vol} ${cacert_file_vol}"
180 [[ ${BRANCH##*/} == "master" ]] && check_os_deployment
181 if [ ${FUNCTEST_MODE} == 'testcase' ]; then
182 echo "FUNCTEST_MODE=testcase, FUNCTEST_SUITE_NAME=${FUNCTEST_SUITE_NAME}"
183 run_test ${FUNCTEST_SUITE_NAME}
184 elif [ ${FUNCTEST_MODE} == 'tier' ]; then
185 echo "FUNCTEST_MODE=tier, FUNCTEST_TIER=${FUNCTEST_TIER}"
186 tiers=(${FUNCTEST_TIER})
189 if [ ${DEPLOY_TYPE} == 'baremetal' ]; then
190 tiers=(healthcheck smoke features vnf parser)
192 tiers=(healthcheck smoke features)