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\n"
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 "Composing up dockers"
111 docker-compose -f /home/opnfv/bottlenecks/docker/bottleneck-compose/docker-compose.yml up -d
112 info "Pulling tutum/influxdb for yardstick"
113 docker pull tutum/influxdb:0.13
114 info "Copying testing scripts to docker"
115 docker cp /home/opnfv/bottlenecks/run_posca.sh bottleneckcompose_bottlenecks_1:/home/opnfv/bottlenecks
117 info "Running posca test suite"
118 docker exec bottleneckcompose_bottlenecks_1 bash /home/opnfv/bottlenecks/run_posca.sh
140 echo "unkown option $1 $2"
148 source ${BASEDIR}/common.sh
150 #Add random key generation
151 if [ ! -d $Bottlenecks_key_dir/bottlenecks_key ]; then
152 mkdir $Bottlenecks_key_dir/bottlenecks_key
154 rm -rf $Bottlenecks_key_dir/bottlenecks_key
155 mkdir $Bottlenecks_key_dir/bottlenecks_key
157 chmod 700 $Bottlenecks_key_dir/bottlenecks_key
159 ssh-keygen -t rsa -f $Bottlenecks_key_dir/bottlenecks_key/bottlenecks_key -q -N ""
160 chmod 600 $Bottlenecks_key_dir/bottlenecks_key/*
162 #check the test suite name is correct
163 if [ "${SUITE}" != "" ]; then
164 suite_exec=(${SUITE//,/ })
165 for i in "${suite_exec[@]}"; do
166 if [[ " ${arr_test_suite[*]} " != *" $i "* ]]; then
167 error "unkown test suite: $i"
170 info "Tests to execute: ${SUITE}"
174 info "Sourcing Credentials openstack.creds to run the tests.."
175 source /home/opnfv/bottlenecks/config/openstack.creds
178 if [ "${SUITE}" != "" ]; then
179 for i in "${suite_exec[@]}"; do