8 CI_LOOP=${CI_LOOP:-daily}
9 TEST_DB_URL=http://testresults.opnfv.org/test/api/v1/results
10 ENERGY_RECORDER_API_URL=http://energy.opnfv.fr/resources
11 DOCKER_TAG=${DOCKER_TAG:-$([[ ${BRANCH##*/} == "master" ]] && echo "latest" || echo ${BRANCH##*/})}
13 check_os_deployment() {
14 FUNCTEST_IMAGE=${REPO}/functest-healthcheck:${DOCKER_TAG}
15 echo "Functest: Pulling Functest Docker image ${FUNCTEST_IMAGE} ..."
16 docker pull ${FUNCTEST_IMAGE}>/dev/null
17 cmd="docker run --rm ${volumes} ${FUNCTEST_IMAGE} check_deployment"
18 echo "Checking deployment, CMD: ${cmd}"
21 if [ ${ret_value} != 0 ]; then
22 echo "ERROR: Problem while checking OpenStack deployment."
25 echo "OpenStack deployment OK."
32 cmd_opt="run_tests -r -t all"
33 [[ $BUILD_TAG =~ "suite" ]] && cmd_opt="run_tests -t all"
34 for tier in ${tiers[@]}; do
35 FUNCTEST_IMAGE=${REPO}/functest-${tier}:${DOCKER_TAG}
36 echo "Functest: Pulling Functest Docker image ${FUNCTEST_IMAGE} ..."
37 docker pull ${FUNCTEST_IMAGE}>/dev/null
38 cmd="docker run --rm ${envs} ${volumes} ${TESTCASE_OPTIONS} ${FUNCTEST_IMAGE} /bin/bash -c '${cmd_opt}'"
39 echo "Running Functest tier '${tier}'. CMD: ${cmd}"
42 if [ ${ret_value} != 0 ]; then
43 echo ${ret_value} > ${ret_val_file}
44 if [ ${tier} == 'healthcheck' ]; then
45 echo "Healthcheck tier failed. Exiting Functest..."
55 cmd_opt="run_tests -t ${test_name}"
56 # Determine which Functest image should be used for the test case
58 connection_check|tenantnetwork1|tenantnetwork2|vmready1|vmready2|singlevm1|singlevm2|vping_ssh|vping_userdata|cinder_test|odl|api_check|snaps_health_check|tempest_smoke)
59 FUNCTEST_IMAGE=${REPO}/functest-healthcheck:${DOCKER_TAG} ;;
60 neutron-tempest-plugin-api|rally_sanity|refstack_defcore|tempest_full|tempest_scenario|patrole|snaps_smoke|neutron_trunk|networking-bgpvpn|networking-sfc|barbican)
61 FUNCTEST_IMAGE=${REPO}/functest-smoke:${DOCKER_TAG} ;;
62 rally_jobs|shaker|vmtp)
63 FUNCTEST_IMAGE=${REPO}/functest-benchmarking:${DOCKER_TAG} ;;
65 FUNCTEST_IMAGE=${REPO}/functest-components:${DOCKER_TAG} ;;
66 cloudify|cloudify_ims|heat_ims|vyos_vrouter|juju_epc)
67 FUNCTEST_IMAGE=${REPO}/functest-vnf:${DOCKER_TAG} ;;
68 doctor-notification|bgpvpn|functest-odl-sfc|barometercollectd|fds|vgpu|stor4nfv_os)
69 FUNCTEST_IMAGE=${REPO}/functest-features:${DOCKER_TAG} ;;
71 echo "Unkown test case $test_name"
75 echo "Functest: Pulling Functest Docker image ${FUNCTEST_IMAGE} ..."
76 docker pull ${FUNCTEST_IMAGE}>/dev/null
77 cmd="docker run --rm ${envs} ${volumes} ${TESTCASE_OPTIONS} ${FUNCTEST_IMAGE} /bin/bash -c '${cmd_opt}'"
78 echo "Running Functest test case '${test_name}'. CMD: ${cmd}"
81 if [ ${ret_value} != 0 ]; then
82 echo ${ret_value} > ${ret_val_file}
87 [[ $CI_DEBUG == true ]] && redirect="/dev/stdout" || redirect="/dev/null"
88 redirect="/dev/stdout"
89 FUNCTEST_DIR=/home/opnfv/functest
91 [[ $BUILD_TAG =~ "virtual" ]] && DEPLOY_TYPE=virt
94 # Prepare OpenStack credentials volume
95 rc_file=${HOME}/opnfv-openrc.sh
97 if [[ ${INSTALLER_TYPE} == 'joid' ]]; then
98 rc_file=$LAB_CONFIG/admin-openrc
99 elif [[ ${INSTALLER_TYPE} == 'compass' ]]; then
100 cacert_file_vol="-v ${HOME}/os_cacert:${FUNCTEST_DIR}/conf/os_cacert"
101 echo "export OS_CACERT=${FUNCTEST_DIR}/conf/os_cacert" >> ${HOME}/opnfv-openrc.sh
102 elif [[ ${INSTALLER_TYPE} == 'fuel' ]] && [[ "${DEPLOY_SCENARIO}" =~ -ha$ ]]; then
103 cacert_file_vol="-v ${HOME}/os_cacert:/etc/ssl/certs/mcp_os_cacert"
106 rc_file_vol="-v ${rc_file}:${FUNCTEST_DIR}/conf/env_file"
108 echo "Functest: Start Docker and prepare environment"
110 echo "Functest: Download images that will be used by test cases"
114 images_dir="${HOME}/opnfv/functest/images"
115 download_script=${WORKSPACE}/functest/ci/download_images.sh
116 chmod +x ${download_script}
117 ${download_script} ${images_dir} ${DEPLOY_SCENARIO} ${HOST_ARCH} 2> ${redirect}
119 images_vol="-v ${images_dir}:${FUNCTEST_DIR}/images"
121 dir_result="${HOME}/opnfv/functest/results/${BRANCH##*/}"
122 mkdir -p ${dir_result}
123 sudo rm -rf ${dir_result}/*
124 results_vol="-v ${dir_result}:${FUNCTEST_DIR}/results"
126 test -f ${HOME}/opnfv/functest/custom/params_${DOCKER_TAG} && custom_params=$(cat ${HOME}/opnfv/functest/custom/params_${DOCKER_TAG})
128 envs="-e INSTALLER_TYPE=${INSTALLER_TYPE} -e INSTALLER_IP=${INSTALLER_IP} \
129 -e NODE_NAME=${NODE_NAME} -e DEPLOY_SCENARIO=${DEPLOY_SCENARIO} \
130 -e BUILD_TAG=${BUILD_TAG} -e DEPLOY_TYPE=${DEPLOY_TYPE} -e CI_LOOP=${CI_LOOP} \
131 -e TEST_DB_URL=${TEST_DB_URL} -e ENERGY_RECORDER_API_URL=${ENERGY_RECORDER_API_URL}"
133 ssh_options="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
135 if [ "${INSTALLER_TYPE}" == 'fuel' ]; then
136 COMPUTE_ARCH=$(ssh -l ubuntu ${INSTALLER_IP} -i ${SSH_KEY} ${ssh_options} \
137 "sudo salt 'cmp*' grains.get cpuarch --out yaml | awk '{print \$2; exit}'")
138 IMAGE_PROPERTIES="hw_disk_bus:scsi,hw_scsi_model:virtio-scsi"
139 envs="${envs} -e POD_ARCH=${COMPUTE_ARCH}"
142 if [[ ${INSTALLER_TYPE} == 'fuel' && ${DEPLOY_SCENARIO} == 'os-nosdn-nofeature-noha' ]]; then
143 libvirt_vol="-v ${ssh_key}:${FUNCTEST_DIR}/conf/libvirt_key"
144 envs="${envs} -e LIBVIRT_USER=ubuntu -e LIBVIRT_KEY_PATH=${FUNCTEST_DIR}/conf/libvirt_key"
147 if [[ ${INSTALLER_TYPE} == 'compass' && ${DEPLOY_SCENARIO} =~ 'sfc' ]]; then
148 ssh_key="/tmp/id_rsa"
149 user_config="/tmp/openstack_user_config.yml"
150 docker cp compass-tasks:/root/.ssh/id_rsa $ssh_key
151 docker cp compass-tasks:/etc/openstack_deploy/openstack_user_config.yml $user_config
152 sshkey_vol="-v ${ssh_key}:/root/.ssh/id_rsa"
153 userconfig_vol="-v ${user_config}:${user_config}"
154 envs="${envs} -e EXTERNAL_NETWORK=${EXTERNAL_NETWORK}"
157 if [[ ${INSTALLER_TYPE} == 'compass' ]] || [[ ${DEPLOY_SCENARIO} == *"odl"* ]]; then
158 envs="${envs} -e SDN_CONTROLLER_RESTCONFPORT=8080"
161 if [[ ${DEPLOY_SCENARIO} == *"ovs"* ]] || [[ ${DEPLOY_SCENARIO} == *"fdio"* ]]; then
162 if [[ -n ${IMAGE_PROPERTIES} ]]; then
163 IMAGE_PROPERTIES="${IMAGE_PROPERTIES},hw_mem_page_size:large"
165 IMAGE_PROPERTIES="hw_mem_page_size:large"
167 FLAVOR_EXTRA_SPECS="hw:mem_page_size:large"
170 if [[ -n ${IMAGE_PROPERTIES} ]] || [[ -n ${FLAVOR_EXTRA_SPECS} ]]; then
171 envs="${envs} -e IMAGE_PROPERTIES=${IMAGE_PROPERTIES} -e FLAVOR_EXTRA_SPECS=${FLAVOR_EXTRA_SPECS}"
174 tempest_conf_yaml=$(mktemp)
175 case ${INSTALLER_TYPE} in
177 cat << EOF > "${tempest_conf_yaml}"
179 compute-feature-enabled:
182 identity-feature-enabled:
185 image-feature-enabled:
189 storage_protocol: ceph
190 volume-feature-enabled:
195 cat << EOF > "${tempest_conf_yaml}"
197 compute-feature-enabled:
201 identity-feature-enabled:
204 image-feature-enabled:
208 storage_protocol: ceph
209 volume-feature-enabled:
214 cat << EOF > "${tempest_conf_yaml}"
216 compute-feature-enabled:
220 identity-feature-enabled:
223 image-feature-enabled:
227 storage_protocol: iSCSI
228 volume-feature-enabled:
233 cat << EOF > "${tempest_conf_yaml}"
235 compute-feature-enabled:
238 identity-feature-enabled:
241 image-feature-enabled:
245 storage_protocol: iSCSI
246 volume-feature-enabled:
251 echo "tempest_conf.yaml:" && cat "${tempest_conf_yaml}"
253 volumes="${images_vol} ${results_vol} ${sshkey_vol} ${libvirt_vol} \
254 ${userconfig_vol} ${rc_file_vol} ${cacert_file_vol} \
255 -v ${tempest_conf_yaml}:/usr/lib/python2.7/site-packages/functest/opnfv_tests/openstack/tempest/custom_tests/tempest_conf.yaml"
257 ret_val_file="${HOME}/opnfv/functest/results/${BRANCH##*/}/return_value"
258 echo 0 > ${ret_val_file}
262 if [ ${FUNCTEST_MODE} == 'testcase' ]; then
263 echo "FUNCTEST_MODE=testcase, FUNCTEST_SUITE_NAME=${FUNCTEST_SUITE_NAME}"
264 run_test ${FUNCTEST_SUITE_NAME}
265 elif [ ${FUNCTEST_MODE} == 'tier' ]; then
266 echo "FUNCTEST_MODE=tier, FUNCTEST_TIER=${FUNCTEST_TIER}"
267 tiers=(${FUNCTEST_TIER})
272 if [ ${DEPLOY_TYPE} == 'baremetal' ] && [ "${HOST_ARCH}" != "aarch64" ]; then
273 if [[ ${BRANCH} == "stable/fraser" ]]; then
274 tiers=(healthcheck smoke features vnf parser)
275 tests=(tempest_full_parallel)
277 tiers=(healthcheck smoke benchmarking features vnf components)
280 if [[ ${BRANCH} == "stable/fraser" ]]; then
281 tiers=(healthcheck smoke features parser)
282 tests=(tempest_full_parallel)
284 tiers=(healthcheck smoke benchmarking features components)
288 if [ ${skip_tests} -eq 0 ]; then
289 for test in "${tests[@]}"; do