Merge "Update docs structure according to Danube agreement"
[bottlenecks.git] / run_tests.sh
1 #!/bin/bash
2 ##############################################################################
3 # Copyright (c) 2016 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
11 usage="Script to run the tests in bottlenecks auto.
12
13 usage:
14     bash $(basename "$0") [-h|--help] [-s <test suite>]
15
16 where:
17     -h|--help         show the help text
18     -r|--report       push results to DB(true by default)
19     -s|--suite        run specific test suite
20       <test suite>    one of the following:
21                             rubbos, vstf, posca
22
23 examples:
24     $(basename "$0")
25     $(basename "$0") -s posca"
26
27 report=true
28
29 arr_test_suite=(rubbos vstf posca)
30
31 Bottlenecks_key_dir="/home/opnfv/bottlenecks/utils/infra_setup"
32
33 function run_test(){
34
35     test_suite=$1
36     echo "Running test suite $test_suite"
37
38     case $test_suite in
39         "rubbos")
40             info "After OPNFV Colorado release, Rubbos testsuite is not updating anymore.
41 This entrance for running Rubbos within Bottlenecks is no longer supported.
42 This testsuite is also not in the release plan with Bottlenecks since then.
43 If you want to run Rubbos, please refer to earlier releases.\n"
44         ;;
45         "vstf")
46             info "After OPNFV Colorado release, VSTF testsuite is not updating anymore.
47 This entrance for running VSTF within Bottlenecks is no longer supported.
48 This testsuite is also not in the release plan with Bottlenecks since then.
49 If you want to run VSTF, please refer to earlier releases.\n"
50         ;;
51         "posca")
52             POSCA_SCRIPT=/home/opnfv/bottlenecks/testsuites/posca
53             TEST_CASE=posca_factor_system_bandwidth
54             info "Composing up dockers"
55             docker-compose -f /home/opnfv/bottlenecks/docker/bottleneck-compose/docker-compose.yml up -d
56             info "Pulling tutum/influxdb for yardstick"
57             docker pull tutum/influxdb:0.13
58             info "Copying testing scripts to docker"
59             docker cp /home/opnfv/bottlenecks/run_posca.sh bottleneckcompose_bottlenecks_1:/home/opnfv/bottlenecks
60             sleep 5
61             info "Running posca test suite with default testcase posca_stress_traffic"
62             docker exec bottleneckcompose_bottlenecks_1 python ${POSCA_SCRIPT}/run_posca.py testcase $TEST_CASE
63         ;;
64     esac
65 }
66
67 while [[ $# > 0 ]]
68     do
69     key="$1"
70     case $key in
71         -h|--help)
72             echo "$usage"
73             exit 0
74             shift
75         ;;
76         -r|--report)
77             report="-r"
78         ;;
79         -s|--suite)
80             SUITE="$2"
81             shift
82         ;;
83         *)
84             echo "unkown option $1 $2"
85             exit 1
86         ;;
87      esac
88      shift
89 done
90
91 BASEDIR=`dirname $0`
92 source ${BASEDIR}/common.sh
93
94 #Add random key generation
95 if [ ! -d $Bottlenecks_key_dir/bottlenecks_key ]; then
96     mkdir $Bottlenecks_key_dir/bottlenecks_key
97 else
98     rm -rf $Bottlenecks_key_dir/bottlenecks_key
99     mkdir $Bottlenecks_key_dir/bottlenecks_key
100 fi
101 chmod 700 $Bottlenecks_key_dir/bottlenecks_key
102
103 ssh-keygen -t rsa -f $Bottlenecks_key_dir/bottlenecks_key/bottlenecks_key -q -N ""
104 chmod 600 $Bottlenecks_key_dir/bottlenecks_key/*
105
106 #check the test suite name is correct
107 if [ "${SUITE}" != "" ]; then
108     suite_exec=(${SUITE//,/ })
109     for i in "${suite_exec[@]}"; do
110         if [[ " ${arr_test_suite[*]} " != *" $i "* ]]; then
111             error "unkown test suite: $i"
112         fi
113     done
114     info "Tests to execute: ${SUITE}"
115 fi
116
117 # Source credentials
118 info "Sourcing Credentials openstack.creds to run the tests.."
119 source /home/opnfv/bottlenecks/config/openstack.creds
120
121 #run tests
122 if [ "${SUITE}" != "" ]; then
123     for i in "${suite_exec[@]}"; do
124         run_test $i
125     done
126 fi