diff --git a/README b/README index d02926a0..139ad3f8 100644 --- a/README +++ b/README @@ -9,6 +9,8 @@ Requeriments: - python-yaml - libgraphviz-perl - libtemplate-perl + - ngcp-ossbss-clients-perl + - parallel Installation: ------------- @@ -19,7 +21,8 @@ Installation: #cd /usr/local/src #git clone git@git.mgm.sipwise.com:kamailio-config-tests #apt-get install python-yaml sip-tester \ - libgraphviz-perl libtemplate-perl + libgraphviz-perl libtemplate-perl \ + ngcp-ossbss-clients-perl parallel Usage: ------ @@ -27,22 +30,27 @@ Usage: "PRO" #bash /usr/local/src/kamailio-config-tests/run_tests.sh [-p PROFILE ] - This will create 2 directories: + This will create: - /usr/local/src/kamailio-config-tests/log with a directory per test with: - kamailio.log - parsed messages - sipp error logs + + #bash /usr/local/src/kamailio-config-tests/get_result.sh [-p PROFILE ] [-g] + + This will create: - /usr/local/src/kamailio-config-tests/result with a directory per test with: - a tap file ( test results ) - - a png file ( routes flow ) + - a png file ( routes flow ) If you use -g option If you want to run test manually just exec this onces: #./bin/config_debug.pl on #ngcpcfg apply and run the check that you want: #./bin/check.sh + this will run the test and the result taps -- Victor Seva diff --git a/bin/check.sh b/bin/check.sh index c5b65fd3..804897cc 100755 --- a/bin/check.sh +++ b/bin/check.sh @@ -179,9 +179,6 @@ function run_sipp if [[ $status -ne 0 ]]; then error_sipp "error in sipp" 2 fi - - echo "$(date) - Parsing ${LOG_DIR}/kamailio.log" - ${BIN_DIR}/ulog_parser.pl ${LOG_DIR}/kamailio.log ${LOG_DIR} } function usage @@ -192,6 +189,7 @@ function usage echo -e "\t-R: skip run sipp" echo -e "\t-D: skip deletion of domain and subscribers as final step" echo -e "\t-T: skip checks" + echo -e "\t-P: skip parse. -T is froced" echo -e "\t-G: creation of graphviz image" echo -e "\t-d: DOMAIN" echo -e "\t-p CE|PRO default is CE" @@ -199,7 +197,7 @@ function usage echo -e "\tcheck_name. Scenario name to check. This is the name of the directory on scenarios dir." } -while getopts 'hCRDTGd:p:' opt; do +while getopts 'hCd:p:RDTPG' opt; do case $opt in h) usage; exit 0;; C) SKIP=1;; @@ -208,6 +206,7 @@ while getopts 'hCRDTGd:p:' opt; do R) SKIP_RUNSIPP=1;; D) SKIP_DELDOMAIN=1;; T) SKIP_TESTS=1;; + P) SKIP_PARSE=1; SKIP_TESTS=1;; G) GRAPH=1;; esac done @@ -263,6 +262,12 @@ if [ -z $SKIP ]; then fi fi +if [ -z ${SKIP_PARSE} ]; then + echo "$(date) - Parsing ${LOG_DIR}/kamailio.log" + ${BIN_DIR}/ulog_parser.pl ${LOG_DIR}/kamailio.log ${LOG_DIR} + echo "$(date) - Done" +fi + # let's check the results ERR_FLAG=0 if [ -z ${SKIP_TESTS} ]; then diff --git a/bin/config_debug.pl b/bin/config_debug.pl index b22a6d86..ba48291a 100755 --- a/bin/config_debug.pl +++ b/bin/config_debug.pl @@ -10,7 +10,6 @@ sub usage { my $output = "usage: config_debug.pl [-h] MODE DOMAIN\n"; $output .= "Options:\n"; - $output .= "\t-p: [CE|PRO]\n"; $output .= "\t-h: this help\n"; $output .= "\tMODE: on|off\tdefault: off\n"; $output .= "\tDOMAIN: default: spce.test\n"; @@ -19,8 +18,7 @@ sub usage my $help = 0; my $profile = "CE"; -GetOptions ("h|help" => \$help, - "p|profile=s" => \$profile) +GetOptions ("h|help" => \$help) or die("Error in command line arguments\n".usage()); if($#ARGV>1 || $help) @@ -28,11 +26,6 @@ if($#ARGV>1 || $help) die("Wrong number of arguments\n".usage()) } -if($profile ne "CE" && $profile ne "PRO") -{ - die("Uknown PROFILE:$profile\n".usage()); -} - my $base_dir; my $yaml = YAML::Tiny->new; my $file = "/etc/ngcp-config/config.yml"; diff --git a/debian/control b/debian/control index 0d2b4d3f..d6f64ef2 100644 --- a/debian/control +++ b/debian/control @@ -13,6 +13,7 @@ Depends: ${misc:Depends}, python-yaml, libgraphviz-perl, libtemplate-perl, - sip-tester ( >= 1:3.2-1~ ) + sip-tester ( >= 1:3.2-1~ ), + parallel Description: Kamailio configuration tests scripts and tests scenarios to check Kamailio configuration diff --git a/get_results.sh b/get_results.sh new file mode 100755 index 00000000..a9c43591 --- /dev/null +++ b/get_results.sh @@ -0,0 +1,49 @@ +#!/bin/bash +BASE_DIR="${BASE_DIR:-/usr/local/src/kamailio-config-tests}" +BIN_DIR="${BASE_DIR}/bin" +LOG_DIR="${BASE_DIR}/log" +RESULT_DIR="${BASE_DIR}/result" +PROFILE="CE" +DOMAIN="spce.test" + +function usage +{ + echo "Usage: get_results.sh [-p PROFILE] [-h] [-g]" + echo "-p CE|PRO default is CE" + echo "-g generate png flow graphs" + echo "-h this help" + + echo "BASE_DIR:${BASE_DIR}" + echo "BIN_DIR:${BIN_DIR}" +} + +while getopts 'hcp:' opt; do + case $opt in + h) usage; exit 0;; + g) GRAPH="-G";; + p) PROFILE=$OPTARG;; + esac +done +shift $(($OPTIND - 1)) + +if [[ $# -ne 0 ]]; then + echo "Wrong number or arguments" + usage + exit 1 +fi + +if [ "${PROFILE}" != "CE" ] && [ "${PROFILE}" != "PRO" ]; then + echo "PROFILE ${PROFILE} unknown" + usage + exit 2 +fi + +echo "$(date) - Clean result dir" +rm -rf ${RESULT_DIR} + +for t in $(find ${BASE_DIR}/scenarios/ -depth -maxdepth 1 -mindepth 1 -type d | sort); do + echo "$(date) - Testing[${PROFILE}]: $(basename $t) =================================================" + echo $(basename $t) | parallel "${BIN_DIR}/check.sh ${GRAPH} -C -d ${DOMAIN} -p ${PROFILE}" +done + +echo "$(date) - All done" diff --git a/run_tests.sh b/run_tests.sh index f0884230..a25d1850 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -1,5 +1,5 @@ #!/bin/bash -BASE_DIR="${BASE_DIR:-/usr/local/src/kamailio-config-tests}" +BASE_DIR=${BASE_DIR:-"/usr/local/src/kamailio-config-tests"} BIN_DIR="${BASE_DIR}/bin" LOG_DIR="${BASE_DIR}/log" RESULT_DIR="${BASE_DIR}/result" @@ -13,18 +13,17 @@ function usage echo "Usage: run_test.sh [-p PROFILE] [-c] [-t]" echo "-p CE|PRO default is CE" echo "-c skips configuration of the environment" - echo "-t skips tests" - echo "-g generate route flow graphs" echo "-h this help" + + echo "BASE_DIR:${BASE_DIR}" + echo "BIN_DIR:${BIN_DIR}" } -while getopts 'hctp:' opt; do +while getopts 'hcp:' opt; do case $opt in h) usage; exit 0;; c) SKIP=1;; - t) TEST=1;; p) PROFILE=$OPTARG;; - g) GRAPH="-G" esac done shift $(($OPTIND - 1)) @@ -43,29 +42,26 @@ fi if [ -z $SKIP ]; then echo "$(date) - Setting config debug on" - ${BIN_DIR}/config_debug.pl -p ${PROFILE} on ${DOMAIN} + ${BIN_DIR}/config_debug.pl on ${DOMAIN} ngcpcfg apply echo "$(date) - Setting config debug on. Done." fi -for i in ${LOG_DIR} ${RESULT_DIR}; do - rm -rf $i -done +echo "$(date) - Clean log dir" +rm -rf ${LOG_DIR} for t in $(find ${BASE_DIR}/scenarios/ -depth -maxdepth 1 -mindepth 1 -type d | sort); do echo "$(date) - Run[${PROFILE}]: $(basename $t) =================================================" - if [ -z $TEST ]; then - ${BIN_DIR}/check.sh ${GRAPH} -d ${DOMAIN} -p ${PROFILE} $(basename $t) - if [ $? -ne 0 ]; then - error_flag=1 - fi + ${BIN_DIR}/check.sh -P -d ${DOMAIN} -p ${PROFILE} $(basename $t) + if [ $? -ne 0 ]; then + error_flag=1 fi echo "$(date) - =================================================================================" done if [ -z $SKIP ]; then echo "$(date) - Setting config debug off" - ${BIN_DIR}/config_debug.pl -p ${PROFILE} off ${DOMAIN} + ${BIN_DIR}/config_debug.pl off ${DOMAIN} ngcpcfg apply echo "$(date) - Setting config debug off. Done." fi