TT#81700 fix discover of scenarios

* check for dirs with a scenario.yml file

* remove some shellcheck warnings:
  SC2207: Prefer mapfile or read -a to split command output (or quote to avoid splitting).

Change-Id: I88b48fcc9668c3be26755472d6001f630a341fca
changes/96/41496/1
Victor Seva 6 years ago
parent 1aa65df64c
commit 740408f3fc

@ -6,10 +6,10 @@ GROUP="${GROUP:-scenarios}"
usage() {
echo "Usage: bench.sh [-p PROFILE] [-C] [num_runs]"
echo "Options:"
echo -e "\t-p CE|PRO default is CE"
echo -e "\t-C skips configuration of the environment"
echo -e "\t-x set GROUP scenario. Default: scenarios"
echo -e "\t-h this help"
echo -e "\\t-p CE|PRO default is CE"
echo -e "\\t-C skips configuration of the environment"
echo -e "\\t-x set GROUP scenario. Default: scenarios"
echo -e "\\t-h this help"
echo -e "num_runs default is 20"
}

@ -840,7 +840,7 @@ if ! "$SKIP_RUNSIPP" ; then
for json_file in "${file_find[@]}" ; do
new_name=$(printf "%04d.json" "${a}")
mv -n "${json_file}" "${LOG_DIR}/${new_name}" &> /dev/null
((a=a+1))
((a++))
done
fi

@ -133,7 +133,7 @@ sub subst_common
$line =~ s/response="[^"]+"/response=".+"/;
$line =~ s/nonce="[^"]+"/nonce=".+"/;
} elsif($line =~ /^(Server|User-Agent): Sipwise/i) {
$line =~ s/: Sipwise NGCP (Proxy|PBX) Server.+/: Sipwise NGCP ${1} Server/;
$line =~ s/: Sipwise NGCP (Proxy|Application|PBX).+/: Sipwise NGCP ${1}/;
} elsif($line =~ /^Content-Length:[ ]+[1-9]/i) {
$line =~ s/:[ ]+\d+/:\\s+\\d+/;
} elsif($line =~ /^P-LB-Uptime: /i) {

@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright: 2013 Sipwise Development Team <support@sipwise.com>
# Copyright: 2013-2020 Sipwise Development Team <support@sipwise.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -21,15 +21,15 @@
usage() {
echo "Usage: sipp.sh [-p PORT] [-m MPORT] [-t TIMEOUT] [-r] [-T TRANSPORT] scenario.xml"
echo "Options:"
echo -e "\t-p: sip port. default 50602/50603(responder)"
echo -e "\t-m: media port"
echo -e "\t-t: timeout. default 10/25(responder)"
echo -e "\t-i: IP. default 127.0.0.1"
echo -e "\t-T: transport [UDP|TCP] default UDP"
echo -e "\t-r: responder"
echo -e "\t-b: run sipp in background (responder)"
echo -e "\\t-p: sip port. default 50602/50603(responder)"
echo -e "\\t-m: media port"
echo -e "\\t-t: timeout. default 10/25(responder)"
echo -e "\\t-i: IP. default 127.0.0.1"
echo -e "\\t-T: transport [UDP|TCP] default UDP"
echo -e "\\t-r: responder"
echo -e "\\t-b: run sipp in background (responder)"
echo "Arguments:"
echo -e "\t sipp_scenario.xml file"
echo -e "\\t sipp_scenario.xml file"
}
while getopts 'hrp:m:t:i:T:b' opt; do
@ -42,6 +42,7 @@ while getopts 'hrp:m:t:i:T:b' opt; do
i) IP=$OPTARG;;
T) TRANSPORT=${OPTARG,,};;
b) BACK="-bg";;
*) usage; exit 0;;
esac
done
shift $((OPTIND - 1))

@ -10,15 +10,15 @@ CDR=""
usage() {
echo "Usage: get_results.sh [-p PROFILE] [-h] [-g]"
echo "-p CE|PRO default is CE"
echo "-g generate png flow graphs if test fails"
echo "-G generate png all flow graphs"
echo "-h this help"
echo "-P parse only will disable test"
echo "-T test only will disable parse"
echo "-r fix retransmission issues"
echo "-c enable cdr validation"
echo "-x set GROUP scenario. Default: scenarios"
echo -e "\\t-p CE|PRO default is CE"
echo -e "\\t-g generate png flow graphs if test fails"
echo -e "\\t-G generate png all flow graphs"
echo -e "\\t-h this help"
echo -e "\\t-P parse only will disable test"
echo -e "\\t-T test only will disable parse"
echo -e "\\t-r fix retransmission issues"
echo -e "\\t-c enable cdr validation"
echo -e "\\t-x set GROUP scenario. Default: scenarios"
echo "BASE_DIR:${BASE_DIR}"
echo "BIN_DIR:${BIN_DIR}"
}
@ -26,20 +26,23 @@ usage() {
get_scenarios() {
local t
local flag
flag=0
flag=false
if [ -n "${SCENARIOS}" ]; then
for t in ${SCENARIOS}; do
if [ ! -d "${BASE_DIR}/${GROUP}/${t}" ]; then
echo "$(date) - scenario: $t not found"
flag=1
if [ ! -f "${BASE_DIR}/${GROUP}/${t}/scenario.yml" ]; then
echo "$(date) - scenario: ${t}/scenario.yml at ${GROUP} not found"
flag=true
else
SCEN+=( "${t}" )
fi
done
if [ $flag != 0 ]; then
exit 1
fi
${flag} && exit 1
else
SCENARIOS=$(find "${BASE_DIR}/${GROUP}/" -depth -maxdepth 1 -mindepth 1 \
-type d -exec basename {} \; | grep -v templates | sort)
while read -r t; do
SCEN+=( "$(basename "${t}")" )
done < <(find "${BASE_DIR}/${GROUP}/" -name scenario.yml \
-type f -exec dirname {} \; | sort)
fi
}
@ -82,7 +85,7 @@ fi
get_scenarios
echo "${SCENARIOS}" | tr ' ' '\n' \
echo "${SCEN[@]}" | tr ' ' '\n' \
| parallel "${BIN_DIR}/check.sh ${GRAPH} -C -R ${OPTS} ${RETRANS} ${CDR} -d ${DOMAIN} -p ${PROFILE} -s ${GROUP}"
status=$?
echo "$(date) - All done[${status}]"

@ -26,24 +26,28 @@ MEMDBG=false
CDR=false
START_TIME=$(date +%s)
error_flag=0
SCEN=()
get_scenarios() {
local t
local flag
flag=0
flag=false
if [ -n "${SCENARIOS}" ]; then
for t in ${SCENARIOS}; do
if [ ! -d "${BASE_DIR}/${GROUP}/${t}" ]; then
echo "$(date) - scenario: $t at ${GROUP} not found"
flag=1
if [ ! -f "${BASE_DIR}/${GROUP}/${t}/scenario.yml" ]; then
echo "$(date) - scenario: ${t}/scenario.yml at ${GROUP} not found"
flag=true
else
SCEN+=( "${t}" )
fi
done
if [ ${flag} != 0 ]; then
exit 1
fi
${flag} && exit 1
else
SCENARIOS=$(find "${BASE_DIR}/${GROUP}/" -depth -maxdepth 1 -mindepth 1 \
-type d -exec basename {} \; | grep -v templates | sort)
while read -r t; do
SCEN+=( "$(basename "${t}")" )
done < <(find "${BASE_DIR}/${GROUP}/" -name scenario.yml \
-type f -exec dirname {} \; | sort)
fi
}
@ -126,7 +130,7 @@ stop_capture() {
move_json_file() {
echo "$(date) - ================================================================================="
echo "$(date) - Move kamailio json files"
for t in ${SCENARIOS}; do
for t in "${SCEN[@]}"; do
echo "$(date) - - Scenario: ${t}"
json_dir="${KAM_DIR}/${t}"
if [ -d "${json_dir}" ] ; then
@ -155,7 +159,7 @@ fix_retransmissions() {
continue
fi
RETRANS_ISSUE=false
file_find=($(find "${LOG_DIR}/${t}" -maxdepth 1 -name '*.json' | sort))
mapfile -t file_find < <(find "${LOG_DIR}/${t}" -maxdepth 1 -name '*.json' | sort)
for json_file in "${file_find[@]}" ; do
file_find=("${file_find[@]:1}")
if ! [ -a "${json_file}" ] ; then
@ -184,12 +188,12 @@ fix_retransmissions() {
if "${RETRANS_ISSUE}" ; then
echo "$(date) - - - Reordering kamailio json files"
file_find=($(find "${LOG_DIR}/${t}" -maxdepth 1 -name '*.json' | sort))
mapfile -t file_find < <(find "${LOG_DIR}/${t}" -maxdepth 1 -name '*.json' | sort)
a=1
for json_file in "${file_find[@]}" ; do
new_name=$(printf "%04d.json" "${a}")
mv -n "${json_file}" "${LOG_DIR}/${t}/${new_name}" &> /dev/null
let a=a+1
((a++))
done
fi
done
@ -201,7 +205,7 @@ fix_retransmissions() {
cdr_export() {
echo "$(date) - ================================================================================="
echo "$(date) - Extracting CDRs"
for t in ${SCENARIOS}; do
for t in "${SCEN[@]}"; do
echo "$(date) - - Scenario: $t"
if ! "${BIN_DIR}/cdr_extract.sh" -m -t "${START_TIME}" -s "${GROUP}" "${t}" ; then
echo "ERROR: ${t}"
@ -216,16 +220,16 @@ cdr_export() {
usage() {
echo "Usage: run_test.sh [-p PROFILE] [-C] [-t]"
echo "Options:"
echo -e "\t-p CE|PRO default is CE"
echo -e "\t-l print available SCENARIOS in GROUP"
echo -e "\t-C skips configuration of the environment"
echo -e "\t-K capture messages with tcpdump"
echo -e "\t-x set GROUP scenario. Default: scenarios"
echo -e "\t-t set timeout in secs for pid_watcher.py [PRO]. Default: 300"
echo -e "\t-r fix retransmission issues"
echo -e "\t-c export CDRs at the end of the test"
echo -e "\t-m mem debug"
echo -e "\t-h this help"
echo -e "\\t-p CE|PRO default is CE"
echo -e "\\t-l print available SCENARIOS in GROUP"
echo -e "\\t-C skips configuration of the environment"
echo -e "\\t-K capture messages with tcpdump"
echo -e "\\t-x set GROUP scenario. Default: scenarios"
echo -e "\\t-t set timeout in secs for pid_watcher.py [PRO]. Default: 300"
echo -e "\\t-r fix retransmission issues"
echo -e "\\t-c export CDRs at the end of the test"
echo -e "\\t-m mem debug"
echo -e "\\t-h this help"
echo "BASE_DIR:${BASE_DIR}"
echo "BIN_DIR:${BIN_DIR}"
@ -256,7 +260,7 @@ fi
if "${SHOW_SCENARIOS}" ; then
get_scenarios
echo "${SCENARIOS}"
echo "${SCEN[@]}"
exit 0
fi
@ -356,7 +360,7 @@ if "${CAPTURE}" ; then
capture
fi
for t in ${SCENARIOS}; do
for t in "${SCEN[@]}"; do
echo "$(date) - ================================================================================="
echo "$(date) - Run [${GROUP}/${PROFILE}]: ${t}"

Loading…
Cancel
Save