# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-usage="Script to run the tests in bottlenecks auto.
+usage="Script to run the tests in Bottlenecks.
usage:
- bash $(basename "$0") [-h|--help] [-s <test suite>]
+ bash $(basename "$0") [-h|--help] [-s <test suite>] [-c <test case>] [--report] [--cleanup]
where:
-h|--help show the help text
- -r|--report push results to DB(true by default)
- -s|--suite run specific test suite
- <test suite> one of the following:
- rubbos, vstf
+ -s|--teststory run specific test story
+ <test story> one of the following:
+ (rubbos, vstf, posca_factor_test)
+ user can also define their own test story and pass as var to this file,
+ please refer to testsuites/posca/testsuite_story/ for details
+ -c|--testcase run specific test case
+ <test case> one of the following:
+ (posca_factor_system_bandwidth, posca_factor_ping)
+ --cleanup cleanup test dockers runing when test is done (false by default)
+ --report push results to DB (false by default)
examples:
- $(basename "$0")
- $(basename "$0") -s rubbos"
+ $(basename "$0") -s posca_factor_test"
-report=true
+# Define global variables
+Bottlenecks_key_dir="/home/opnfv/bottlenecks/utils/infra_setup"
+POSCA_SUITE="/home/opnfv/bottlenecks/testsuites/posca"
+POSCA_TESTCASE="/home/opnfv/bottlenecks/testsuites/posca/testcase_cfg"
+POSCA_TESTSTORY="/home/opnfv/bottlenecks/testsuites/posca/testsuite_story"
+BASEDIR=`dirname $0`
-arr_test_suite=(rubbos vstf)
+REPORT="False"
+cleanup=false
-function check_testcase(){
+# Define alias for log printing
+info () {
+ logger -s -t "BOTTLENECKS INFO" "$*"
+}
- check_suite="$1"
- case $check_suite in
- "-rubbos")
- SUITE_PREFIX=$SUITE_PREFIX_CONFIG/rubbos/testcase_cfg
- ;;
- "-vstf")
- SUITE_PREFIX=$SUITE_PREFIX_CONFIG/vstf/testcase_cfg
- ;;
- esac
+error () {
+ logger -s -t "BOTTLENECKS ERROR" "$*"
+ exit 1
+}
+
+# Define check_test function for test case/story list check
+function check_test(){
- TEST_CASE=$2
+ TEST_LEVEL="$1"
+ TEST_NAME="$2"
- #find all the test case yaml files first
- find $SUITE_PREFIX -name "*yaml" > /tmp/all_testcases.yaml
- all_testcases_insuite=`cat /tmp/all_testcases.yaml | awk -F '/' '{print $NF}' | awk -F '.' '{print $1}'`
- all_testcases=(${all_testcases_insuite})
+ if [[ "${TEST_LEVEL}" == "testcase" ]]; then
+ TEST_CONFIG="${POSCA_TESTCASE}"
+ else
+ if [[ "${TEST_LEVEL}" == "teststory" ]]; then
+ TEST_CONFIG="${POSCA_TESTSTORY}"
+ else
+ info "Invalid name for test level: testcase or teststory"
+ fi
+ fi
- if [ "${TEST_CASE}" != "" ]; then
- testcase_exec=(${TEST_CASE// /})
- for i in "${testcase_exec[@]}"; do
- if [[ " ${all_testcases[*]} " != *" $i "* ]]; then
- error "unknown test case: $i. available test cases are: ${all_test_cases[@]}"
+ # Find all the test case yaml files first
+ find $TEST_CONFIG -name "*yaml" > /tmp/all_tests.yaml
+ all_tests_insuite=`cat /tmp/all_tests.yaml | awk -F '/' '{print $NF}' | awk -F '.' '{print $1}'`
+ all_tests=(${all_tests_insuite})
+
+ if [ "${TEST_NAME}" != "" ]; then
+ TEST_EXEC=(${TEST_NAME// /})
+ for i in "${TEST_EXEC[@]}"; do
+ if [[ " ${all_tests[*]} " != *" $i "* ]]; then
+ error "Unknown $TEST_LEVEL: $i. Available $TEST_LEVEL are: ${all_tests[@]}"
fi
done
- info "tests to execute: ${TEST_CASE}."
+ info "Tests to execute: ${TEST_NAME}."
else
- error "lack of testcase name"
+ error "Lack of $TEST_LEVEL name"
fi
}
+
+# Define run test function
function run_test(){
- test_suite=$1
- echo "Running test suite $test_suite"
+ test_exec=$1
- case $test_suite in
+ case $test_exec in
"rubbos")
- info "Running rubbos test suite"
- test_file="/home/opnfv/bottlenecks/testsuites/rubbos/testsuite_story/rubbos_story1"
- if [[ -f $test_file ]]; then
- testcases=($(cat $test_file))
- else
- error "no rubbos test suite file"
- fi
- for i in "${testcases[@]}"; do
- #check if the testcase is legal or not
- check_testcase -rubbos $i
- #adjust config parameters, different test suite has different methods, take rubbos as an example
- #run test case, different test suite has different methods
- file={$BASEDIR}/testsuites/rubbos/testcase_cfg/{$i}.yaml
- python /home/opnfv/bottlenecks/testsuites/rubbos/run_rubbos.py -c $file
- done
+ info "After OPNFV Colorado release, Rubbos testsuite is not updating anymore.
+ This entrance for running Rubbos within Bottlenecks is no longer supported.
+ This testsuite is also not in the release plan with Bottlenecks since then.
+ If you want to run Rubbos, please refer to earlier releases."
;;
"vstf")
- info "Running vstf test suite"
- test_file="/home/opnfv/bottlenecks/testsuite/vstf/testsuite_story/vstf_story1"
- if [[ -f $test_file ]]; then
- testcases=($(cat $test_file))
- else
- error "no vstf test suite file "
- fi
- for i in "${testcases[@]}"; do
- #check if the testcase is legal or not
- check_testcase -vstf $i
- #adjust config parameters
- #run test case
- done
+ info "After OPNFV Colorado release, VSTF testsuite is not updating anymore.
+ This entrance for running VSTF within Bottlenecks is no longer supported.
+ This testsuite is also not in the release plan with Bottlenecks since then.
+ If you want to run VSTF, please refer to earlier releases."
+ ;;
+ *)
+ info "Running posca $test_level: $test_exec"
+ opts="--privileged=true -id"
+ docker_volume="-v /var/run/docker.sock:/var/run/docker.sock -v /tmp:/tmp"
+ docker run $opts --name bottlenecks-load-master $docker_volume opnfv/bottlenecks:latest /bin/bash
+ sleep 5
+ POSCA_SCRIPT="/home/opnfv/bottlenecks/testsuites/posca"
+ docker exec bottlenecks-load-master python ${POSCA_SCRIPT}/../run_testsuite.py ${test_level} ${test_exec} ${REPORT}
;;
esac
}
+# Process input variables
while [[ $# > 0 ]]
do
key="$1"
exit 0
shift
;;
- -r|--report)
- report="-r"
+ -s|--teststory)
+ teststory="$2"
+ shift
;;
- -s|--suite)
- SUITE="$2"
+ -c|--testcase)
+ testcase="$2"
shift
;;
+ --report)
+ REPORT="True"
+ ;;
+ --cleanup)
+ cleanup=true
+ ;;
*)
echo "unkown option $1 $2"
exit 1
shift
done
-BASEDIR=`dirname $0`
-source ${BASEDIR}/common.sh
-
-#check the test suite name is correct
-if [ "${SUITE}" != "" ]; then
- suite_exec=(${SUITE//,/ })
- for i in "${suite_exec[@]}"; do
- if [[ " ${arr_test_suite[*]} " != *" $i "* ]]; then
- error "unkown test suite: $i"
- fi
+# Clean up related docker images
+#bash ${BASEDIR}/docker/docker_cleanup.sh -d bottlenecks --debug
+#bash ${BASEDIR}/docker/docker_cleanup.sh -d yardstick --debug
+#bash ${BASEDIR}/docker/docker_cleanup.sh -d kibana --debug
+#bash ${BASEDIR}/docker/docker_cleanup.sh -d elasticsearch --debug
+#bash ${BASEDIR}/docker/docker_cleanup.sh -d influxdb --debug
+
+# Run tests
+if [ "${teststory}" != "" ]; then
+ test_level="teststory"
+ teststory_exec=(${teststory//,/ })
+ check_test $test_level $teststory
+ for i in "${teststory_exec[@]}"; do
+ info "Start to run test story $i"
+ run_test $i
done
- info "Tests to execute: ${SUITE}"
fi
-#run tests
-if [ "${SUITE}" != "" ]; then
- for i in "${suite_exec[@]}"; do
+if [ "${testcase}" != "" ]; then
+ test_level="testcase"
+ testcase_exec=(${testcase//,/ })
+ check_test $test_level $testcase
+ for i in "${testcase_exec[@]}"; do
+ info "Start to run test case $i"
run_test $i
done
fi
+
+# Clean up testing dockers
+if [[ ${cleanup} == true ]]; then
+ info "Cleaning up docker-compose images and dockers"
+ bash ${BASEDIR}/docker/docker_cleanup.sh -d influxdb --debug
+ bash ${BASEDIR}/docker/docker_cleanup.sh -d bottlenecks --debug
+ bash ${BASEDIR}/docker/docker_cleanup.sh -d yardstick --debug
+fi