Merge "Adding a new verification job for testapi UI."
[releng.git] / jjb / yardstick / yardstick-daily.sh
1 #!/bin/bash
2 set -e
3 [[ $CI_DEBUG == true ]] && redirect="/dev/stdout" || redirect="/dev/null"
4
5 rc_file_vol=""
6 cacert_file_vol=""
7 sshkey=""
8
9 rc_file_vol="-v ${HOME}/opnfv-openrc.sh:/etc/yardstick/openstack.creds"
10
11 if [[ ${INSTALLER_TYPE} == 'apex' ]]; then
12     instack_mac=$(sudo virsh domiflist undercloud | grep default | \
13                   grep -Eo "[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+")
14     INSTALLER_IP=$(/usr/sbin/arp -e | grep ${instack_mac} | awk {'print $1'})
15     sshkey="-v /root/.ssh/id_rsa:/root/.ssh/id_rsa"
16     if [[ -n $(sudo iptables -L FORWARD |grep "REJECT"|grep "reject-with icmp-port-unreachable") ]]; then
17         #note: this happens only in opnfv-lf-pod1
18         sudo iptables -D FORWARD -o virbr0 -j REJECT --reject-with icmp-port-unreachable
19         sudo iptables -D FORWARD -i virbr0 -j REJECT --reject-with icmp-port-unreachable
20     fi
21 fi
22
23 if [[ ${INSTALLER_TYPE} == 'joid' ]]; then
24     if [[ "${DEPLOY_SCENARIO:0:2}" == "k8" ]];then
25         rc_file_vol="-v ${HOME}/admin.conf:/etc/yardstick/admin.conf"
26     else
27         # If production lab then creds may be retrieved dynamically
28         # creds are on the jumphost, always in the same folder
29         rc_file_vol="-v $LAB_CONFIG/admin-openrc:/etc/yardstick/openstack.creds"
30         # If dev lab, credentials may not be the default ones, just provide a path to put them into docker
31         # replace the default one by the customized one provided by jenkins config
32     fi
33 elif [[ ${INSTALLER_TYPE} == 'compass' ]]; then
34     if [[ "${DEPLOY_SCENARIO:0:2}" == "k8" ]];then
35         rc_file_vol="-v ${HOME}/admin.conf:/etc/yardstick/admin.conf"
36     else
37         cacert_file_vol="-v ${HOME}/os_cacert:/etc/yardstick/os_cacert"
38         echo "export OS_CACERT=/etc/yardstick/os_cacert" >> ${HOME}/opnfv-openrc.sh
39     fi
40 elif [[ ${INSTALLER_TYPE} == 'fuel' ]]; then
41     cacert_file_vol="-v ${HOME}/os_cacert:/etc/ssl/certs/mcp_os_cacert"
42     sshkey="-v ${SSH_KEY}:/root/.ssh/mcp.rsa"
43 fi
44
45 opts="--privileged=true --rm"
46 envs="-e INSTALLER_TYPE=${INSTALLER_TYPE} -e INSTALLER_IP=${INSTALLER_IP} \
47     -e NODE_NAME=${NODE_NAME} -e EXTERNAL_NETWORK=${EXTERNAL_NETWORK} \
48     -e YARDSTICK_BRANCH=${BRANCH} -e BRANCH=${BRANCH} \
49     -e DEPLOY_SCENARIO=${DEPLOY_SCENARIO} -e CI_DEBUG=true"
50
51 if [[ "${INSTALLER_TYPE}" == 'fuel' ]]; then
52     envs+=" -e SSH_KEY=/root/.ssh/mcp.rsa"
53 fi
54
55 # Pull the image with correct tag
56 DOCKER_REPO='opnfv/yardstick'
57 if [ "$(uname -m)" = 'aarch64' ]; then
58     DOCKER_REPO="${DOCKER_REPO}_$(uname -m)"
59 fi
60 echo "Yardstick: Pulling image ${DOCKER_REPO}:${DOCKER_TAG}"
61 docker pull ${DOCKER_REPO}:$DOCKER_TAG >$redirect
62 docker images
63
64 # map log directory
65 branch=${BRANCH##*/}
66 dir_result="${HOME}/opnfv/yardstick/results/${branch}"
67 mkdir -p ${dir_result}
68 sudo rm -rf ${dir_result}/*
69 map_log_dir="-v ${dir_result}:/tmp/yardstick"
70
71 # Run docker
72 cmd="sudo docker run ${opts} ${envs} ${rc_file_vol} ${cacert_file_vol} ${map_log_dir} ${sshkey} ${DOCKER_REPO}:${DOCKER_TAG} \
73 exec_tests.sh ${YARDSTICK_DB_BACKEND} ${YARDSTICK_SCENARIO_SUITE_NAME}"
74
75 echo "Yardstick: Running docker cmd: ${cmd}"
76 ${cmd}
77
78 echo "Yardstick: done!"