JIRA: BOTTLENECKS-29
[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
40     return 0
41 }
42
43 function fn_testing_scenario(){
44     local head_cmd="vstfadm perf-test "
45     local test_length_list="64"
46     local test_scenario_list="Tu-1 Tu-3"
47     local test_tool="netperf"
48     local protocol="udp"
49     local test_type="frameloss"
50     for scene in ${test_scenario_list}
51     do
52         local cmd="${head_cmd} ${scene} ${test_tool} ${protocol} ${test_type} \"${test_length_list}\" > /root/${scene}-result.txt"
53         echo ${cmd}
54         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}"
55     done
56     return 0
57 }
58
59 function fn_result(){
60     local test_scenario_list="Tu-1 Tu-3"
61     mkdir ./result
62     rm -rf ./result/*
63     for scene in ${test_scenario_list}
64     do
65         remote_scp_cmd ${manager_control_public_ip} ${VM_MANAGER_USER} ${VM_MANAGER_PASSWD} "/root/${scene}-result.txt" "./result/${scene}" "file"
66     done
67     return 0
68 }
69
70 function main(){
71     fn_parser_ipaddress
72     fn_vstf_test_config
73     #fn_testing_scenario
74     #fn_result
75     return 0
76 }
77
78 main
79 set +x