2 ##############################################################################
3 # Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
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 ##############################################################################
11 usage="Script to run the tests in bottlenecks auto.
14 bash $(basename "$0") [-h|--help] [-s <test suite>]
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:
25 $(basename "$0") -s rubbos"
29 arr_test_suite=(rubbos vstf posca)
31 Bottlenecks_key_dir="/home/opnfv/bottlenecks/utils/infra_setup"
33 function check_testcase(){
38 SUITE_PREFIX=$SUITE_PREFIX_CONFIG/rubbos/testcase_cfg
41 SUITE_PREFIX=$SUITE_PREFIX_CONFIG/vstf/testcase_cfg
44 SUITE_PREFIX=$SUITE_PREFIX_CONFIG/posca/testcase_cfg
50 #find all the test case yaml files first
51 find $SUITE_PREFIX -name "*yaml" > /tmp/all_testcases.yaml
52 all_testcases_insuite=`cat /tmp/all_testcases.yaml | awk -F '/' '{print $NF}' | awk -F '.' '{print $1}'`
53 all_testcases=(${all_testcases_insuite})
55 if [ "${TEST_CASE}" != "" ]; then
56 testcase_exec=(${TEST_CASE// /})
57 for i in "${testcase_exec[@]}"; do
58 if [[ " ${all_testcases[*]} " != *" $i "* ]]; then
59 error "unknown test case: $i. available test cases are: ${all_test_cases[@]}"
62 info "tests to execute: ${TEST_CASE}."
64 error "lack of testcase name"
70 echo "Running test suite $test_suite"
74 info "Running rubbos test suite"
75 test_file="/home/opnfv/bottlenecks/testsuites/rubbos/testsuite_story/rubbos_story1"
76 if [[ -f $test_file ]]; then
77 testcases=($(cat $test_file))
79 error "no rubbos test suite file"
82 for i in "${testcases[@]}"; do
83 #check if the testcase is legal or not
84 check_testcase -rubbos $i
85 #adjust config parameters, different test suite has different methods, take rubbos as an example
86 #run test case, different test suite has different methods
87 file=${BASEDIR}/testsuites/rubbos/testcase_cfg/${i}.yaml
88 python /home/opnfv/bottlenecks/testsuites/rubbos/run_rubbos.py -c $file
92 info "Running vstf test suite"
93 test_file="/home/opnfv/bottlenecks/testsuites/vstf/testsuite_story/vstf_story1"
94 if [[ -f $test_file ]]; then
95 testcases=($(cat $test_file))
97 error "no vstf test suite file "
100 for i in "${testcases[@]}"; do
101 #check if the testcase is legal or not
102 check_testcase -vstf $i
103 #adjust config parameters
105 file=${BASEDIR}/testsuites/vstf/testcase_cfg/${i}.yaml
106 python /home/opnfv/bottlenecks/testsuites/vstf/run_vstf.py -c $file
110 info "Running posca test suite"
111 test_file="/home/opnfv/bottlenecks/testsuites/posca/testsuite_story/posca_factor_test"
112 if [[ -f $test_file ]]; then
113 testcases=($(cat $test_file))
115 error "no posca test suite file "
118 for i in "${testcases[@]}"; do
119 #check if the testcase is legal or not
120 check_testcase -posca $i
121 #adjust config parameters
123 file=${BASEDIR}/testsuites/posca/testcase_cfg/${i}.yaml
124 python /home/opnfv/bottlenecks/testsuites/posca/run_posca.py -c ${i}
147 echo "unkown option $1 $2"
155 source ${BASEDIR}/common.sh
157 #Add random key generation
158 if [ ! -d $Bottlenecks_key_dir/bottlenecks_key ]; then
159 mkdir $Bottlenecks_key_dir/bottlenecks_key
161 rm -rf $Bottlenecks_key_dir/bottlenecks_key
162 mkdir $Bottlenecks_key_dir/bottlenecks_key
164 chmod 700 $Bottlenecks_key_dir/bottlenecks_key
166 ssh-keygen -t rsa -f $Bottlenecks_key_dir/bottlenecks_key/bottlenecks_key -q -N ""
167 chmod 600 $Bottlenecks_key_dir/bottlenecks_key/*
169 #check the test suite name is correct
170 if [ "${SUITE}" != "" ]; then
171 suite_exec=(${SUITE//,/ })
172 for i in "${suite_exec[@]}"; do
173 if [[ " ${arr_test_suite[*]} " != *" $i "* ]]; then
174 error "unkown test suite: $i"
177 info "Tests to execute: ${SUITE}"
181 info "Sourcing Credentials openstack.creds to run the tests.."
182 source /home/opnfv/bottlenecks/config/openstack.creds
185 if [ "${SUITE}" != "" ]; then
186 for i in "${suite_exec[@]}"; do