Merge "rubbos instance workflow improvement"
authorMatthewLi <matthew.lijun@huawei.com>
Fri, 25 Mar 2016 02:33:18 +0000 (02:33 +0000)
committerGerrit Code Review <gerrit@172.30.200.206>
Fri, 25 Mar 2016 02:33:18 +0000 (02:33 +0000)
ci/common.sh [new file with mode: 0755]
ci/run_tests.sh [new file with mode: 0755]
config/bottlenecks_cfg.yaml [new file with mode: 0755]
config/testcase_conf/rubbos.yaml [new file with mode: 0755]
config/testcase_conf/rubbos/rubbos_1-1-1.yaml [new file with mode: 0755]
config/testcase_conf/rubbos/rubbos_1-2-1.yaml [new file with mode: 0755]
config/testcase_conf/vstf.yaml [new file with mode: 0755]
config/testcase_conf/vstf/tu1.yaml [new file with mode: 0755]
config/testcase_conf/vstf/tu3.yaml [new file with mode: 0755]

diff --git a/ci/common.sh b/ci/common.sh
new file mode 100755 (executable)
index 0000000..5ee858f
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+
+mkdir -p /home/opnfv/bottlenecks/config
+config_file=/home/opnfv/functest/config/bottlenecks_cfg.yaml
+
+if [ ! -f ${config_file} ]; then
+    default_config_file=$(find /home/opnfv/repos -name bottlenecks_cfg.yaml)
+    cp $default_config_file $config_file
+    echo "bottlenecks_cfg.yaml not provided. Using default one"
+fi
+
+SUITE_PREFIX_CONFIG=$(cat $config_file | grep -w suite_prefix_config | awk 'END {print $NF}')
+
+info () {
+    logger -s -t "bottlenecks.info" "$*"
+}
+
+error () {
+    logger -s -t "bottlenecks.error" "$*"
+    exit 1
+}
diff --git a/ci/run_tests.sh b/ci/run_tests.sh
new file mode 100755 (executable)
index 0000000..95f53d5
--- /dev/null
@@ -0,0 +1,146 @@
+#!/bin/bash
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+usage="Script to run the tests in bottlenecks auto.
+
+usage:
+    bash $(basename "$0") [-h|--help] [-s <test suite>]
+
+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
+
+examples:
+    $(basename "$0")
+    $(basename "$0") -s rubbos"
+
+report=true
+
+arr_test_suite=(rubbos vstf)
+
+function check_testcase(){
+
+    check_suite="$1"
+    case $check_suite in
+         "-rubbos")
+             $SUITE_PREFIX=$SUITE_PREFIX_CONFIG/rubbos
+         ;;
+         "-vstf")
+             $SUITE_PREFIX=$SUITE_PREFIX_CONFIG/vstf
+         ;;
+    esac
+
+    TEST_CASE=$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_CASE}" != ""]; then
+       testcase_exec=(${TEST_CASE// /})
+       for i in "${testcase_exec[@]}"; do
+           if [[ " ${all_test_cases[*]} " != *" $i "* ]]; then
+               error "unknown test case: $i. available test cases are: ${all_test_cases[@]}"
+           fi
+       done
+       info "tests to execute: ${TEST_CASE}."
+    else
+       error "lack of testcase name"
+    fi
+}
+function run_test(){
+
+    test_suite=$1
+    echo "Running test suite $test_suite"
+
+    case $test_suite in
+        "rubbos")
+            info "Running rubbos test suite"
+            test_file="/home/opnfv/bottlenecks/config/testcase_conf/rubbos.yaml"
+            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
+
+            done
+        ;;
+        "vstf")
+            info "Running vstf test suite"
+            test_file="/home/opnfv/bottlenecks/config/testcase_conf/vstf.yaml"
+            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
+        ;;
+    esac
+}
+
+while [[ $# > 0 ]]
+    do
+    key="$1"
+    case $key in
+        -h|--help)
+            echo "$usage"
+            exit 0
+            shift
+        ;;
+        -r|--report)
+            report="-r"
+        ;;
+        -s|--suite)
+            SUITE="$2"
+            shift
+        ;;
+        *)
+            echo "unkown option $1 $2"
+            exit 1
+        ;;
+     esac
+     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
+    done
+    info "Tests to execute: ${SUITE}"
+fi
+
+#run tests
+if [ "${SUITE}" != "" ]; then
+    for i in "${suite_exec[@]}"; do
+        run_test $i
+    done
+fi
diff --git a/config/bottlenecks_cfg.yaml b/config/bottlenecks_cfg.yaml
new file mode 100755 (executable)
index 0000000..d22a885
--- /dev/null
@@ -0,0 +1 @@
+suite_prefix_config: /home/opnfv/bottlenecks/config/testcase_conf
diff --git a/config/testcase_conf/rubbos.yaml b/config/testcase_conf/rubbos.yaml
new file mode 100755 (executable)
index 0000000..f3e7f31
--- /dev/null
@@ -0,0 +1,2 @@
+rubbos_1-1-1
+rubbos_1-2-1
diff --git a/config/testcase_conf/rubbos/rubbos_1-1-1.yaml b/config/testcase_conf/rubbos/rubbos_1-1-1.yaml
new file mode 100755 (executable)
index 0000000..e69de29
diff --git a/config/testcase_conf/rubbos/rubbos_1-2-1.yaml b/config/testcase_conf/rubbos/rubbos_1-2-1.yaml
new file mode 100755 (executable)
index 0000000..e69de29
diff --git a/config/testcase_conf/vstf.yaml b/config/testcase_conf/vstf.yaml
new file mode 100755 (executable)
index 0000000..3987262
--- /dev/null
@@ -0,0 +1,2 @@
+tu1
+tu3
diff --git a/config/testcase_conf/vstf/tu1.yaml b/config/testcase_conf/vstf/tu1.yaml
new file mode 100755 (executable)
index 0000000..e69de29
diff --git a/config/testcase_conf/vstf/tu3.yaml b/config/testcase_conf/vstf/tu3.yaml
new file mode 100755 (executable)
index 0000000..e69de29