From d75a861967ec2041ec103ba9aa84bbe669b07b36 Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Mon, 16 Jun 2014 17:02:55 +0200 Subject: [PATCH] MT#7523 allow use of SCENARIOS env var --- README | 6 ++++++ get_results.sh | 25 ++++++++++++++++++++++++- run_tests.sh | 32 +++++++++++++++++++++++++------- 3 files changed, 55 insertions(+), 8 deletions(-) diff --git a/README b/README index f6d8d124..30650f5d 100644 --- a/README +++ b/README @@ -54,6 +54,12 @@ Usage: or run all the tests as many times you want with: #./bin/bench.sh $NUM +If you want to test just a set of scenarios, set the SCENARIOS +environment var. + +#bash SCENARIOS="invite invite_callforward" ./run_tests.sh +#bash SCENARIOS="invite invite_callforward" ./get_results.sh + Development: ------------ diff --git a/get_results.sh b/get_results.sh index dcb54a36..de8535f3 100755 --- a/get_results.sh +++ b/get_results.sh @@ -19,6 +19,27 @@ function usage echo "BIN_DIR:${BIN_DIR}" } +function get_scenarios +{ + local t + local flag + flag=0 + if [ -n "${SCENARIOS}" ]; then + for t in ${SCENARIOS}; do + if [ ! -d "${BASE_DIR}/scenarios/$t" ]; then + echo "$(date) - scenario: $t not found" + flag=1 + fi + done + if [ $flag != 0 ]; then + exit 1 + fi + else + SCENARIOS=$(find ${BASE_DIR}/scenarios/ -depth -maxdepth 1 -mindepth 1 \ + -type d -exec basename {} \; | grep -v templates | sort) + fi +} + while getopts 'hgGp:TP' opt; do case $opt in h) usage; exit 0;; @@ -46,7 +67,9 @@ fi echo "$(date) - Clean result dir" rm -rf ${RESULT_DIR} -find ${BASE_DIR}/scenarios/ -depth -maxdepth 1 -mindepth 1 -type d -exec basename {} \; | grep -v templates| sort \ +get_scenarios + +echo ${SCENARIOS} | tr ' ' '\n' \ | parallel "${BIN_DIR}/check.sh ${GRAPH} -C -R ${OPTS} -d ${DOMAIN} -p ${PROFILE}" status=$? echo "$(date) - All done[$status]" diff --git a/run_tests.sh b/run_tests.sh index 725bd06b..073c19ac 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -20,9 +20,25 @@ function usage echo "BIN_DIR:${BIN_DIR}" } -function list +function get_scenarios { - find ${BASE_DIR}/scenarios/ -depth -maxdepth 1 -mindepth 1 -type d -exec basename {} \;| grep -v templates | sort + local t + local flag + flag=0 + if [ -n "${SCENARIOS}" ]; then + for t in ${SCENARIOS}; do + if [ ! -d "${BASE_DIR}/scenarios/$t" ]; then + echo "$(date) - scenario: $t not found" + flag=1 + fi + done + if [ $flag != 0 ]; then + exit 1 + fi + else + SCENARIOS=$(find ${BASE_DIR}/scenarios/ -depth -maxdepth 1 -mindepth 1 \ + -type d -exec basename {} \; | grep -v templates | sort) + fi } function cfg_debug_off @@ -44,7 +60,7 @@ function cfg_debug_off while getopts 'hlcp:' opt; do case $opt in h) usage; exit 0;; - l) list; exit 0;; + l) get_scenarios; echo "${SCENARIOS}"; exit 0;; c) SKIP=1;; p) PROFILE=$OPTARG;; esac @@ -85,8 +101,8 @@ if [ -z $SKIP ]; then wait $! if [ "$?" != "0" ]; then echo "error on apply config" - echo "$(date) - Done[1]" cfg_debug_off + echo "$(date) - Done[1]" exit 1 fi fi @@ -98,9 +114,11 @@ VERSION="${PROFILE}_$(cat /etc/ngcp_version | cut -f1 -d' ')_" ${BIN_DIR}/mem_stats.py --private_file=${MLOG_DIR}/${VERSION}initial_pvm.cvs \ --share_file=${MLOG_DIR}/${VERSION}initial_shm.cvs -for t in $(find ${BASE_DIR}/scenarios/ -depth -maxdepth 1 -mindepth 1 -type d | grep -v templates | sort); do - echo "$(date) - Run[${PROFILE}]: $(basename $t) =================================================" - ${BIN_DIR}/check.sh -P -T -d ${DOMAIN} -p ${PROFILE} $(basename $t) +get_scenarios + +for t in ${SCENARIOS}; do + echo "$(date) - Run[${PROFILE}]: $t =================================================" + ${BIN_DIR}/check.sh -P -T -d ${DOMAIN} -p ${PROFILE} $t if [ $? -ne 0 ]; then error_flag=1 fi