783c64ee1e79dd498af2bc7418f141471a60ceb0
[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 # Set iptables rule to allow forwarding return traffic for container
45 if ! sudo iptables -C FORWARD -j RETURN 2> ${redirect} || ! sudo iptables -L FORWARD | awk 'NR==3' | grep RETURN 2> ${redirect}; then
46     sudo iptables -I FORWARD -j RETURN
47 fi
48
49 opts="--privileged=true --rm"
50 envs="-e INSTALLER_TYPE=${INSTALLER_TYPE} -e INSTALLER_IP=${INSTALLER_IP} \
51     -e NODE_NAME=${NODE_NAME} -e EXTERNAL_NETWORK=${EXTERNAL_NETWORK} \
52     -e YARDSTICK_BRANCH=${BRANCH} -e BRANCH=${BRANCH} \
53     -e DEPLOY_SCENARIO=${DEPLOY_SCENARIO} -e CI_DEBUG=true"
54
55 if [[ "${INSTALLER_TYPE}" == 'fuel' ]]; then
56     envs+=" -e SSH_KEY=/root/.ssh/mcp.rsa"
57 fi
58
59 # Pull the image with correct tag
60 DOCKER_REPO='opnfv/yardstick'
61 if [ "$(uname -m)" = 'aarch64' ]; then
62     DOCKER_REPO="${DOCKER_REPO}_$(uname -m)"
63 fi
64 echo "Yardstick: Pulling image ${DOCKER_REPO}:${DOCKER_TAG}"
65 docker pull ${DOCKER_REPO}:$DOCKER_TAG >$redirect
66 docker images
67
68 # map log directory
69 branch=${BRANCH##*/}
70 dir_result="${HOME}/opnfv/yardstick/results/${branch}"
71 mkdir -p ${dir_result}
72 sudo rm -rf ${dir_result}/*
73 map_log_dir="-v ${dir_result}:/tmp/yardstick"
74
75 # Run docker
76 cmd="sudo docker run ${opts} ${envs} ${rc_file_vol} ${cacert_file_vol} ${map_log_dir} ${sshkey} ${DOCKER_REPO}:${DOCKER_TAG} \
77 exec_tests.sh ${YARDSTICK_DB_BACKEND} ${YARDSTICK_SCENARIO_SUITE_NAME}"
78
79 echo "Yardstick: Running docker cmd: ${cmd}"
80 ${cmd}
81
82 echo "Yardstick: done!"