From 07da564b3799b7915be617d57bf1972eac44ad7c Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Wed, 13 Apr 2022 15:12:33 +0200 Subject: [PATCH] TT#170350 fix cfgt disable * check.sh: remove none as the way to disable check results added -t to indicate that * run_tests.sh: add -T to enable cfgt don't call anything related to cfgt if not enabled * bench.sh: enable cfgt if check type is all or cfgt Change-Id: I4c13297b55503f99241cf5553c5deceba0f5bbf6 --- bench.sh | 13 +++--- bin/check.sh | 113 ++++++++++++++++++++++++++------------------------ run_tests.sh | 45 ++++++++++++-------- set_config.sh | 2 +- 4 files changed, 95 insertions(+), 78 deletions(-) diff --git a/bench.sh b/bench.sh index 78c4b907..487b9935 100755 --- a/bench.sh +++ b/bench.sh @@ -25,7 +25,7 @@ CAPTURE=false SINGLE_CAPTURE=false PROV_TYPE=step CHECK_TYPE=sipp -CFGT="" +CFGT_OPTS=() usage() { echo "Usage: bench.sh [-hCkK] [-p PROFILE] [-x GROUP] [-P ] [-S ] num_runs" @@ -36,7 +36,7 @@ usage() { echo -e "\\t-K capture messages with tcpdump. One big file for all scenarios" echo -e "\\t-x set GROUP scenario. Default: scenarios" echo -e "\\t-P provisioning, default:step" - echo -e "\\t-S check type. Default: all (cfgt, sipp)" + echo -e "\\t-S check type. Default: sipp (all|cfgt|sipp)" echo -e "\\t-h this help" echo -e "num_runs default is 20" } @@ -94,13 +94,15 @@ BASE_DIR=$(pwd) export BASE_DIR case "${CHECK_TYPE}" in - all|cfgt) CFGT="-T" ;; + all|cfgt) CFG_OPTS+=(-T); RUN_OPS+=(-T) ;; sipp) ;; *) echo "check type:${CHECK_TYPE} unknown" >&2; exit 2;; esac if ! "${SKIP_CONFIG}" ; then - "${BASE_DIR}/set_config.sh" "${CFGT}" -x "${GROUP}" -p "${PROFILE}" + CFG_OPTS+=(-x "${GROUP}" -p "${PROFILE}") + # shellcheck disable=SC2086 + "${BASE_DIR}/set_config.sh" ${CFG_OPTS[*]} fi echo "$(date) - Starting $NUM tests" @@ -126,5 +128,6 @@ done set +o pipefail if ! "${SKIP_CONFIG}" ; then - "${BASE_DIR}/set_config.sh" -c -x "${GROUP}" -p "${PROFILE}" + # shellcheck disable=SC2086 + "${BASE_DIR}/set_config.sh" -c ${CFG_OPTS[*]} fi diff --git a/bin/check.sh b/bin/check.sh index 52cd305f..09a7201b 100755 --- a/bin/check.sh +++ b/bin/check.sh @@ -25,6 +25,7 @@ MEMDBG=false SKIP_DELDOMAIN=false CHECK_TYPE=sipp SKIP_RUNSIPP=false +SKIP_CHECK=false FIX_RETRANS=false GRAPH=false GRAPH_FAIL=false @@ -597,13 +598,14 @@ cdr_check() { } usage() { - echo "Usage: check.sh [-hCDRGgKm] [-T ] [-p PROFILE ] [-s GROUP] check_name" + echo "Usage: check.sh [-hCDRGgKmt] [-T ] [-p PROFILE ] [-s GROUP] check_name" echo "Options:" echo -e "\\t-I: SIP_SERVER IP, default:127.0.0.1" echo -e "\\t-C: skip creation of domain and subscribers" echo -e "\\t-R: skip run sipp" echo -e "\\t-D: skip deletion of domain and subscribers as final step" echo -e "\\t-T check type . Default: sipp" + echo -e "\\t-t skip check results" echo -e "\\t-P: skip parse" echo -e "\\t-G: creation of graphviz image" echo -e "\\t-g: creation of graphviz image only if test fails" @@ -618,13 +620,14 @@ usage() { echo -e "\\tcheck_name. Scenario name to check. This is the name of the directory on GROUP dir." } -while getopts 'hI:Cp:Rs:DT:GgrcKMmw:' opt; do +while getopts 'hI:Cp:Rs:DtT:GgrcKMmw:' opt; do case $opt in h) usage; exit 0;; I) SIP_SERVER=${OPTARG};; C) SKIP=true; SKIP_DELDOMAIN=true;; p) PROFILE=${OPTARG};; R) SKIP_RUNSIPP=true; SKIP_DELDOMAIN=true;; + t) SKIP_CHECK=true;; s) GROUP=${OPTARG};; D) SKIP_DELDOMAIN=true;; T) CHECK_TYPE=${OPTARG};; @@ -691,8 +694,8 @@ if [ -f "${SCEN_CHECK_DIR}/pro.yml" ] && [ "${PROFILE}" == "CE" ]; then fi case "${CHECK_TYPE}" in - all|sipp|cfgt|none) ;; - *) echo "unknown check type"; exit 1;; + all|sipp|cfgt) echo "check type:${CHECK_TYPE}" ;; + *) echo "unknown check type ${CHECK_TYPE}"; exit 1;; esac if ! "$SKIP" ; then @@ -700,12 +703,12 @@ if ! "$SKIP" ; then fi if ! "$SKIP_RUNSIPP" ; then - if ! [ -d "${KAM_DIR}" ] ; then - echo "$(date) - dir and perms for ${KAM_DIR}" - mkdir -p "${KAM_DIR}" - chown -R kamailio:kamailio "${KAM_DIR}" - fi if [[ ${CHECK_TYPE} != sipp ]] ; then + if ! [ -d "${KAM_DIR}" ] ; then + echo "$(date) - dir and perms for ${KAM_DIR}" + mkdir -p "${KAM_DIR}" + chown -R kamailio:kamailio "${KAM_DIR}" + fi if ngcp-kamcmd proxy cfgt.list | grep -q "uuid: ${test_uuid}" ; then echo "$(date) - clean cfgt scenario ${test_uuid}" ngcp-kamcmd proxy cfgt.clean "${test_uuid}" @@ -720,57 +723,59 @@ if ! "$SKIP_RUNSIPP" ; then cp "${SCEN_CHECK_DIR}/scenario_ids.yml" "${LOG_DIR}" echo "$(date) - Done" - if [[ ${CHECK_TYPE} != sipp ]] && ! ${SKIP_MOVE_JSON_KAM} ; then - echo "$(date) - Move kamailio json files" - if [ -d "${JSON_DIR}" ] ; then - for i in "${JSON_DIR}"/*.json ; do - json_size_before=$(stat -c%s "${i}") - moved_file="${LOG_DIR}/$(printf "%04d.json" "$(basename "${i}" .json)")" - expand -t1 "${i}" > "${moved_file}" - json_size_after=$(stat -c%s "${moved_file}") - echo "$(date) - Moved file ${i} with size before: ${json_size_before} and after: ${json_size_after}" - rm "${i}" - done - else - echo "$(date) - No json files found" + if [[ ${CHECK_TYPE} != sipp ]] ; then + if ! ${SKIP_MOVE_JSON_KAM} ; then + echo "$(date) - Move kamailio json files" + if [ -d "${JSON_DIR}" ] ; then + for i in "${JSON_DIR}"/*.json ; do + json_size_before=$(stat -c%s "${i}") + moved_file="${LOG_DIR}/$(printf "%04d.json" "$(basename "${i}" .json)")" + expand -t1 "${i}" > "${moved_file}" + json_size_after=$(stat -c%s "${moved_file}") + echo "$(date) - Moved file ${i} with size before: ${json_size_before} and after: ${json_size_after}" + rm "${i}" + done + else + echo "$(date) - No json files found" + fi + echo "$(date) - clean cfgt scenario ${test_uuid}" + ngcp-kamcmd proxy cfgt.clean "${test_uuid}" + echo "$(date) - Done" fi - echo "$(date) - clean cfgt scenario ${test_uuid}" - ngcp-kamcmd proxy cfgt.clean "${test_uuid}" - echo "$(date) - Done" - fi - if "${FIX_RETRANS}" ; then - echo "$(date) - Checking retransmission issues" - RETRANS_ISSUE=false - mapfile -t file_find < <(find "${LOG_DIR}" -maxdepth 1 -name '*.json' | sort) - for json_file in "${file_find[@]}" ; do - file_find=("${file_find[@]:1}") - if ! [ -a "${json_file}" ] ; then - continue - fi - for next_json_file in "${file_find[@]}" ; do - if ! [ -a "${next_json_file}" ] ; then + if "${FIX_RETRANS}" ; then + echo "$(date) - Checking retransmission issues" + RETRANS_ISSUE=false + mapfile -t file_find < <(find "${LOG_DIR}" -maxdepth 1 -name '*.json' | sort) + for json_file in "${file_find[@]}" ; do + file_find=("${file_find[@]:1}") + if ! [ -a "${json_file}" ] ; then continue fi - if ( diff -q -u <(tail -n3 "${json_file}") <(tail -n3 "${next_json_file}") &> /dev/null ) ; then - echo "$(date) - $(basename "${next_json_file}") seems a retransmission of $(basename "${json_file}") ---> renaming the file in $(basename "${next_json_file}")_retransmission" - mv -f "${next_json_file}" "${next_json_file}_retransmission" - RETRANS_ISSUE=true - fi + for next_json_file in "${file_find[@]}" ; do + if ! [ -a "${next_json_file}" ] ; then + continue + fi + if ( diff -q -u <(tail -n3 "${json_file}") <(tail -n3 "${next_json_file}") &> /dev/null ) ; then + echo "$(date) - $(basename "${next_json_file}") seems a retransmission of $(basename "${json_file}") ---> renaming the file in $(basename "${next_json_file}")_retransmission" + mv -f "${next_json_file}" "${next_json_file}_retransmission" + RETRANS_ISSUE=true + fi + done done - done - if "${RETRANS_ISSUE}" ; then - echo "$(date) - Reordering kamailio json files" - mapfile -t file_find < <(find "${LOG_DIR}" -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}/${new_name}" &> /dev/null - ((a++)) - done + if "${RETRANS_ISSUE}" ; then + echo "$(date) - Reordering kamailio json files" + mapfile -t file_find < <(find "${LOG_DIR}" -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}/${new_name}" &> /dev/null + ((a++)) + done + fi + echo "$(date) - Done" fi - echo "$(date) - Done" fi echo "$(date) - check RTP sessions, wait 5 secs first" @@ -783,7 +788,7 @@ if ! "${SKIP_DELDOMAIN}" ; then fi # let's check the results -if [[ ${CHECK_TYPE} != none ]] ; then +if ! ${SKIP_CHECK} ; then echo "$(date) - =================================================================================" echo "$(date) - Check [${GROUP}/${PROFILE}]: ${NAME_CHECK}" diff --git a/run_tests.sh b/run_tests.sh index 9a0dccec..3c91bab0 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -16,7 +16,8 @@ TMP_LOG_DIR="/tmp" KAM_DIR="/tmp/cfgtest" COREDUMP_DIR="/ngcp-data/coredumps" PROFILE="${PROFILE:-}" -OPTS=(-Tnone -M -C) #SKIP_TESTS=true, SKIP_MOVE_JSON_KAM=true, SKIP=true +OPTS=(-t -M -C) #SKIP_TESTS=true, SKIP_MOVE_JSON_KAM=true, SKIP=true +CFG_OPTS=() SHOW_SCENARIOS=false SKIP_CONFIG=false @@ -29,6 +30,7 @@ PROV_TYPE="step" START_TIME=$(date +%s) error_flag=0 SCEN=() +CFGT=false get_scenarios() { if [ -n "${SCEN_FILE}" ]; then @@ -50,7 +52,7 @@ get_scenarios() { cfg_debug_off() { if ! "${SKIP_CONFIG}" ; then - "${BASE_DIR}/set_config.sh" -c -x "${GROUP}" -p "${PROFILE}" + "${BASE_DIR}/set_config.sh" -c "${CFG_OPTS[@]}" fi } @@ -225,11 +227,11 @@ get_config() { #PHONE_CC=${data[6]} #PHONE_AC=${data[7]} #PHONE_SN=${data[8]} - OPTS+=( "-I${data[9]}" ) + OPTS+=(-I"${data[9]}") } usage() { - echo "Usage: run_test.sh [-p PROFILE] [-C] [-P ]" + echo "Usage: run_test.sh [-x GROUP] [-p PROFILE] [-f file] [-hlCckKrTm] [-P ]" echo "Options:" echo -e "\\t-p CE|PRO default is autodetect" echo -e "\\t-l print available SCENARIOS in GROUP" @@ -245,13 +247,14 @@ usage() { echo -e "\\t\\tstep: provision scenario one by one before execution" echo -e "\\t\\tnone: skip any provision" echo -e "\\t-f scenarios file" + echo -e "\\t-T enable cfgt" echo -e "\\t-h this help" echo "BASE_DIR:${BASE_DIR}" echo "BIN_DIR:${BIN_DIR}" } -while getopts 'f:hlCcP:p:kKx:rm' opt; do +while getopts 'f:hlCcP:p:kKx:rTm' opt; do case $opt in h) usage; exit 0;; l) SHOW_SCENARIOS=true;; @@ -265,6 +268,7 @@ while getopts 'f:hlCcP:p:kKx:rm' opt; do c) CDR=true;; m) MEMDBG=true;; f) SCEN_FILE=${OPTARG};; + T) CFGT=true; CFG_OPTS+=(-T); OPTS+=(-Tall);; *) usage; exit 1;; esac done @@ -306,14 +310,16 @@ esac LOG_DIR="${BASE_DIR}/log/${GROUP}" -if ! [ -d "${KAM_DIR}" ]; then - echo "$(date) - Create temporary folder for json files" - mkdir -p "${KAM_DIR}" - chown kamailio:root "${KAM_DIR}" - chmod 0770 "${KAM_DIR}" -else - echo "$(date) - Clean temporary folder for json files" - rm -rf "${KAM_DIR:?}/*" +if ${CFGT} ; then + if ! [ -d "${KAM_DIR}" ]; then + echo "$(date) - Create temporary folder for json files" + mkdir -p "${KAM_DIR}" + chown kamailio:root "${KAM_DIR}" + chmod 0770 "${KAM_DIR}" + else + echo "$(date) - Clean temporary folder for json files" + rm -rf "${KAM_DIR:?}/*" + fi fi echo "$(date) - Clean mem log dir" @@ -321,7 +327,8 @@ rm -rf "${MLOG_DIR}" mkdir -p "${MLOG_DIR}" "${LOG_DIR}" if ! "${SKIP_CONFIG}" ; then - "${BASE_DIR}/set_config.sh" -x "${GROUP}" -p "${PROFILE}" + CFG_OPTS+=( -x "${GROUP}" -p "${PROFILE}" ) + "${BASE_DIR}/set_config.sh" "${CFG_OPTS[@]}" fi echo "$(date) - Initial mem stats" @@ -458,10 +465,12 @@ echo "$(date) - restore kamailio and sems logs with the original content" copy_logs_from_tmp service rsyslog restart -move_json_file +if ${CFGT} ; then + move_json_file -if "${FIX_RETRANS}" ; then - fix_retransmissions + if "${FIX_RETRANS}" ; then + fix_retransmissions + fi fi if "${CDR}" ; then @@ -475,7 +484,7 @@ if [[ ${MEMDBG} = 1 ]] ; then ngcp-memdbg-csv /var/log/ngcp/kamailio-proxy.log "${MLOG_DIR}" >/dev/null fi -if [ -d "${KAM_DIR}" ]; then +if ${CFGT} && [ -d "${KAM_DIR}" ]; then echo "$(date) - clean cfgt scenarios" ngcp-kamcmd proxy cfgt.clean all echo "$(date) - Removing temporary json dir" diff --git a/set_config.sh b/set_config.sh index f0befb60..b87dc751 100755 --- a/set_config.sh +++ b/set_config.sh @@ -46,7 +46,7 @@ usage() { echo "BIN_DIR:${BIN_DIR}" } -while getopts 'chp:st:x:' opt; do +while getopts 'chp:sTt:x:' opt; do case $opt in c) CLEAN=true;; h) usage; exit 0;;