Finalize docs for Danube 1.0
[bottlenecks.git] / run_posca.sh
1 #!/bin/bash
2 ##############################################################################
3 # Copyright (c) 2017 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 pip install -U /home/opnfv/bottlenecks
12
13 function check_testcase(){
14
15     check_suite="$1"
16     SUITE_PREFIX="/home/opnfv/bottlenecks/testsuites/posca/testcase_cfg"
17
18     TEST_CASE=$2
19
20     #find all the test case yaml files first
21     find $SUITE_PREFIX -name "*yaml" > /tmp/all_testcases.yaml
22     all_testcases_insuite=`cat /tmp/all_testcases.yaml | awk -F '/' '{print $NF}' | awk -F '.' '{print $1}'`
23     all_testcases=(${all_testcases_insuite})
24
25     if [ "${TEST_CASE}" != "" ]; then
26        testcase_exec=(${TEST_CASE// /})
27        for i in "${testcase_exec[@]}"; do
28            if [[ " ${all_testcases[*]} " != *" $i "* ]]; then
29                error "unknown test case: $i. available test cases are: ${all_test_cases[@]}"
30            fi
31        done
32        info "tests to execute: ${TEST_CASE}."
33     else
34        error "lack of testcase name"
35     fi
36 }
37
38 SUITE_PREFIX="/home/opnfv/bottlenecks/testsuites/posca/testcase_cfg"
39 source /home/opnfv/bottlenecks/common.sh
40 test_file="/home/opnfv/bottlenecks/testsuites/posca/testsuite_story/posca_factor_test"
41 if [[ -f $test_file ]]; then
42     testcases=($(cat $test_file))
43 else
44     error "no posca test suite file "
45 fi
46
47 for i in "${testcases[@]}"; do
48     #check if the testcase is legal or not
49     check_testcase -posca $i
50     #adjust config parameters
51     #run test case
52     file=${SUITE_PREFIX}/${i}.yaml
53     python /home/opnfv/bottlenecks/testsuites/posca/run_posca.py
54 done