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