a5f06f8e9fa58fe34f6fac31040e0c2a676ed66f
[bottlenecks.git] / utils / infra_setup / heat_template / vstf_heat_template / vstf_test.sh
1 #!/bin/bash
2 set -x
3
4 VM_MANAGER_USER="root"
5 VM_MANAGER_PASSWD="root"
6 STACK_NAME="vstf"
7 #load func
8 source ./ssh.sh
9 source ./scp.sh
10
11 function fn_parser_ipaddress(){
12     #parser and get output ipaddress
13     manager_control_private_ip=`heat output-show ${STACK_NAME} manager_control_private_ip | sed 's/\"//g'`
14     manager_control_public_ip=`heat output-show ${STACK_NAME} manager_control_public_ip | sed 's/\"//g'`
15
16     local ipaddr=""
17     for ipaddr in ${manager_control_private_ip} ${manager_control_public_ip}
18     do
19         if [ "${ipaddr}x" == "x" ]
20         then
21             echo "[ERROR]The ipaddress is null ,get ip from heat output failed"
22             exit 1
23         fi
24     done
25
26     return 0
27 }
28
29 function fn_vstf_test_config(){
30     #get testing ipaddress
31     tester_testing_ip=`nova list | grep "vstf-tester" | grep "bottlenecks-testing" | awk -F'bottlenecks-testing=' '{print $2}' | awk '{print $1}'`
32     target_testing_ip=`nova list | grep "vstf-target" | grep "bottlenecks-testing" | awk -F'bottlenecks-testing=' '{print $2}' | awk '{print $1}'`
33     echo "tester_testing_ip = ${tester_testing_ip}"
34     echo "target_testing_ip = ${target_testing_ip}"
35     #setting testting ipaddress
36     local cmd="vstfadm settings ${tester_testing_ip} ${target_testing_ip}"
37     echo "$cmd"
38     #run_cmd ${manager_control_public_ip} ${VM_MANAGER_USER} ${VM_MANAGER_PASSWD} "${cmd}"
39     ssh-keygen -f "/home/jenkins-ci/.ssh/known_hosts" -R ${manager_control_public_ip}
40     sshpass -p root ssh -o StrictHostKeyChecking=no root@${manager_control_public_ip} "${cmd}"
41
42     return 0
43 }
44
45 function fn_testing_scenario(){
46     local head_cmd="vstfadm perf-test "
47     local test_length_list="64 128 256 512 1024"
48     local test_scenario_list="Tu-1 Tu-3"
49     local test_tool="netperf"
50     local protocol="udp"
51     local test_type="frameloss"
52     for scene in ${test_scenario_list}
53     do
54         local cmd="${head_cmd} ${scene} ${test_tool} ${protocol} ${test_type} \"${test_length_list}\" > /root/${scene}-result.txt"
55         echo ${cmd}
56
57         ssh-keygen -f "/home/jenkins-ci/.ssh/known_hosts" -R ${manager_control_public_ip}
58         #run_cmd ${manager_control_public_ip} ${VM_MANAGER_USER} ${VM_MANAGER_PASSWD} "${head_cmd} ${scene} ${test_tool} ${protocol} ${test_type} \"${test_length_list}\" > /root/${scene}"
59         sshpass -p root ssh -o StrictHostKeyChecking=no root@${manager_control_public_ip} "${cmd}"
60         sleep 10        
61     done
62     return 0
63 }
64
65 function fn_result(){
66     local test_scenario_list="Tu-1 Tu-3"
67     mkdir ./result
68     rm -rf ./result/*
69     for scene in ${test_scenario_list}
70     do
71         #remote_scp_cmd ${manager_control_public_ip} ${VM_MANAGER_USER} ${VM_MANAGER_PASSWD} "/root/${scene}-result.txt" "./result/${scene}" "file"
72         sshpass -p root ssh -o StrictHostKeyChecking=no root@${manager_control_public_ip} "cat /root/${scene}-result.txt"
73         sshpass -p root scp -o StrictHostKeyChecking=no root@${manager_control_public_ip}:/root/${scene}-result.txt "./result/${scene}"
74     done
75     return 0
76 }
77
78 function fn_upload(){
79     python vstf_collector.py --config dashboard.json --dir result
80 }
81
82 function main(){
83     fn_parser_ipaddress
84     fn_vstf_test_config
85     fn_testing_scenario
86     fn_result
87     fn_upload
88     return 0
89 }
90
91 main
92 set +x