da9042bbc95949603ef2cd93a7f5c1735645f9fc
[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 # labconfig is used only for joid
6 labconfig=""
7 sshkey=""
8 if [[ ${INSTALLER_TYPE} == 'apex' ]]; then
9     instack_mac=$(sudo virsh domiflist undercloud | grep default | \
10                   grep -Eo "[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+")
11     INSTALLER_IP=$(/usr/sbin/arp -e | grep ${instack_mac} | awk {'print $1'})
12     sshkey="-v /root/.ssh/id_rsa:/root/.ssh/id_rsa"
13     if [[ -n $(sudo iptables -L FORWARD |grep "REJECT"|grep "reject-with icmp-port-unreachable") ]]; then
14         #note: this happens only in opnfv-lf-pod1
15         sudo iptables -D FORWARD -o virbr0 -j REJECT --reject-with icmp-port-unreachable
16         sudo iptables -D FORWARD -i virbr0 -j REJECT --reject-with icmp-port-unreachable
17     fi
18 elif [[ ${INSTALLER_TYPE} == 'joid' ]]; then
19     # If production lab then creds may be retrieved dynamically
20     # creds are on the jumphost, always in the same folder
21     labconfig="-v $LAB_CONFIG/admin-openrc:/home/opnfv/openrc"
22     # If dev lab, credentials may not be the default ones, just provide a path to put them into docker
23     # replace the default one by the customized one provided by jenkins config
24 fi
25
26 # Set iptables rule to allow forwarding return traffic for container
27 if ! sudo iptables -C FORWARD -j RETURN 2> ${redirect} || ! sudo iptables -L FORWARD | awk 'NR==3' | grep RETURN 2> ${redirect}; then
28     sudo iptables -I FORWARD -j RETURN
29 fi
30
31 opts="--privileged=true --rm"
32 envs="-e INSTALLER_TYPE=${INSTALLER_TYPE} -e INSTALLER_IP=${INSTALLER_IP} \
33     -e NODE_NAME=${NODE_NAME} -e EXTERNAL_NETWORK=${EXTERNAL_NETWORK} \
34     -e YARDSTICK_BRANCH=${GIT_BRANCH##origin/} -e DEPLOY_SCENARIO=${DEPLOY_SCENARIO}"
35
36 # Pull the image with correct tag
37 echo "Yardstick: Pulling image opnfv/yardstick:${DOCKER_TAG}"
38 docker pull opnfv/yardstick:$DOCKER_TAG >$redirect
39
40 # map log directory
41 branch=${GIT_BRANCH##*/}
42 dir_result="${HOME}/opnfv/yardstick/results/${branch}"
43 mkdir -p ${dir_result}
44 sudo rm -rf ${dir_result}/*
45 map_log_dir="-v ${dir_result}:/tmp/yardstick"
46
47 # Run docker
48 cmd="sudo docker run ${opts} ${envs} ${labconfig} ${map_log_dir} ${sshkey} opnfv/yardstick:${DOCKER_TAG} \
49     exec_tests.sh ${YARDSTICK_DB_BACKEND} ${YARDSTICK_SCENARIO_SUITE_NAME}"
50 echo "Yardstick: Running docker cmd: ${cmd}"
51 ${cmd}
52
53 echo "Yardstick: done!"