summaryrefslogtreecommitdiffstats
path: root/utils/infra_setup/heat_template/vstf_heat_template/vstf_test.sh
blob: 94e42e2351964ebcb6fd8a32fa32bbf19cfa827f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
##############################################################################
# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
set -x

VM_MANAGER_USER="root"
VM_MANAGER_PASSWD="root"
STACK_NAME="bottlenecks_vstf_stack"

function fn_parser_ipaddress(){
    #parser and get output ipaddress
    manager_control_private_ip=`heat output-show ${STACK_NAME} manager_control_private_ip | sed 's/\"//g'`
    manager_control_public_ip=`heat output-show ${STACK_NAME} manager_control_public_ip | sed 's/\"//g'`

    local ipaddr=""
    for ipaddr in ${manager_control_private_ip} ${manager_control_public_ip}
    do
        if [ "${ipaddr}x" == "x" ]
        then
            echo "[ERROR]The ipaddress is null ,get ip from heat output failed"
            exit 1
        fi
    done

    return 0
}

function fn_vstf_test_config(){
    #get testing ipaddress
    tester_testing_ip=`nova list | grep "vstf-tester" | grep "bottlenecks-testing" | awk -F'bottlenecks-testing=' '{print $2}' | awk '{print $1}'`
    target_testing_ip=`nova list | grep "vstf-target" | grep "bottlenecks-testing" | awk -F'bottlenecks-testing=' '{print $2}' | awk '{print $1}'`
    echo "tester_testing_ip = ${tester_testing_ip}"
    echo "target_testing_ip = ${target_testing_ip}"
    #setting testting ipaddress
    local cmd="vstfadm settings ${tester_testing_ip} ${target_testing_ip}"
    echo "$cmd"
    ssh-keygen -f "/home/jenkins-ci/.ssh/known_hosts" -R ${manager_control_public_ip}
    sshpass -p root ssh -o StrictHostKeyChecking=no root@${manager_control_public_ip} "${cmd}"

    return 0
}

function fn_testing_scenario(){
    local head_cmd="vstfadm perf-test "
    local test_length_list="64 128 256 512 1024"
    local test_scenario_list="Tu-1 Tu-3"
    local test_tool="netperf"
    local protocol="udp"
    local test_type="frameloss"
    for scene in ${test_scenario_list}
    do
        local cmd="${head_cmd} ${scene} ${test_tool} ${protocol} ${test_type} \"${test_length_list}\" > /root/${scene}-result.txt"
        echo ${cmd}

        ssh-keygen -f "/home/jenkins-ci/.ssh/known_hosts" -R ${manager_control_public_ip}
        sshpass -p root ssh -o StrictHostKeyChecking=no root@${manager_control_public_ip} "${cmd}"
        sleep 10        
    done
    return 0
}

function fn_result(){
    local test_scenario_list="Tu-1 Tu-3"
    mkdir ./result
    rm -rf ./result/*
    for scene in ${test_scenario_list}
    do
        sshpass -p root ssh -o StrictHostKeyChecking=no root@${manager_control_public_ip} "cat /root/${scene}-result.txt"
        sshpass -p root scp -o StrictHostKeyChecking=no root@${manager_control_public_ip}:/root/${scene}-result.txt "./result/${scene}"
    done
    return 0
}

function fn_upload(){
    python vstf_collector.py --config dashboard.json --dir result
}

function main(){
    fn_parser_ipaddress
    fn_vstf_test_config
    fn_testing_scenario
    fn_result
    fn_upload
    return 0
}

main
set +x