EXAMPLES: opentracing: refined shell scripts for testing filter performance
When calling the 'basename' command, the argument ${0} is enclosed in quotation marks. This is necessary if the path of the executable script (contained in that argument) has "non-standard" elements, such as space and the like. Also, in the script 'test-speed.sh' the function sh_exit() has been added for easier printing of messages at the end of execution. This patch must be backported as far as 2.4.
This commit is contained in:
parent
9964ad8436
commit
9154e00f70
|
@ -3,7 +3,7 @@
|
||||||
_ARG_HAPROXY="${1:-$(realpath -L ${PWD}/../../../haproxy)}"
|
_ARG_HAPROXY="${1:-$(realpath -L ${PWD}/../../../haproxy)}"
|
||||||
_ARGS="-f cmp/haproxy.cfg"
|
_ARGS="-f cmp/haproxy.cfg"
|
||||||
_LOG_DIR="_logs"
|
_LOG_DIR="_logs"
|
||||||
_LOG="${_LOG_DIR}/_log-$(basename ${0} .sh)-$(date +%s)"
|
_LOG="${_LOG_DIR}/_log-$(basename "${0}" .sh)-$(date +%s)"
|
||||||
|
|
||||||
|
|
||||||
test -x "${_ARG_HAPROXY}" || exit 1
|
test -x "${_ARG_HAPROXY}" || exit 1
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
_ARG_HAPROXY="${1:-$(realpath -L ${PWD}/../../../haproxy)}"
|
_ARG_HAPROXY="${1:-$(realpath -L ${PWD}/../../../haproxy)}"
|
||||||
_ARGS="-f ctx/haproxy.cfg"
|
_ARGS="-f ctx/haproxy.cfg"
|
||||||
_LOG_DIR="_logs"
|
_LOG_DIR="_logs"
|
||||||
_LOG="${_LOG_DIR}/_log-$(basename ${0} .sh)-$(date +%s)"
|
_LOG="${_LOG_DIR}/_log-$(basename "${0}" .sh)-$(date +%s)"
|
||||||
|
|
||||||
|
|
||||||
test -x "${_ARG_HAPROXY}" || exit 1
|
test -x "${_ARG_HAPROXY}" || exit 1
|
||||||
|
|
|
@ -5,8 +5,8 @@ _ARG_HAPROXY="${1:-$(realpath -L ${PWD}/../../../haproxy)}"
|
||||||
_ARGS_BE="-f be/haproxy.cfg"
|
_ARGS_BE="-f be/haproxy.cfg"
|
||||||
_TIME="$(date +%s)"
|
_TIME="$(date +%s)"
|
||||||
_LOG_DIR="_logs"
|
_LOG_DIR="_logs"
|
||||||
_LOG_FE="${_LOG_DIR}/_log-$(basename ${0} fe-be.sh)fe-${_TIME}"
|
_LOG_FE="${_LOG_DIR}/_log-$(basename "${0}" fe-be.sh)fe-${_TIME}"
|
||||||
_LOG_BE="${_LOG_DIR}/_log-$(basename ${0} fe-be.sh)be-${_TIME}"
|
_LOG_BE="${_LOG_DIR}/_log-$(basename "${0}" fe-be.sh)be-${_TIME}"
|
||||||
|
|
||||||
|
|
||||||
__exit ()
|
__exit ()
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
_ARG_HAPROXY="${1:-$(realpath -L ${PWD}/../../../haproxy)}"
|
_ARG_HAPROXY="${1:-$(realpath -L ${PWD}/../../../haproxy)}"
|
||||||
_ARGS="-f sa/haproxy.cfg"
|
_ARGS="-f sa/haproxy.cfg"
|
||||||
_LOG_DIR="_logs"
|
_LOG_DIR="_logs"
|
||||||
_LOG="${_LOG_DIR}/_log-$(basename ${0} .sh)-$(date +%s)"
|
_LOG="${_LOG_DIR}/_log-$(basename "${0}" .sh)-$(date +%s)"
|
||||||
|
|
||||||
|
|
||||||
test -x "${_ARG_HAPROXY}" || exit 1
|
test -x "${_ARG_HAPROXY}" || exit 1
|
||||||
|
|
|
@ -1,11 +1,28 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
_ARG_CFG="${1}"
|
_ARG_CFG="${1}"
|
||||||
_ARG_DIR="${2}"
|
_ARG_DIR="${2:-${1}}"
|
||||||
_LOG_DIR="_logs"
|
_LOG_DIR="_logs"
|
||||||
_HTTPD_PIDFILE="${_LOG_DIR}/thttpd.pid"
|
_HTTPD_PIDFILE="${_LOG_DIR}/thttpd.pid"
|
||||||
|
_USAGE_MSG="usage: $(basename "${0}") cfg [dir]"
|
||||||
|
|
||||||
|
|
||||||
|
sh_exit ()
|
||||||
|
{
|
||||||
|
test -z "${2}" && {
|
||||||
|
echo
|
||||||
|
echo "Script killed!"
|
||||||
|
}
|
||||||
|
|
||||||
|
test -n "${1}" && {
|
||||||
|
echo
|
||||||
|
echo "${1}"
|
||||||
|
echo
|
||||||
|
}
|
||||||
|
|
||||||
|
exit ${2:-64}
|
||||||
|
}
|
||||||
|
|
||||||
httpd_run ()
|
httpd_run ()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -63,18 +80,22 @@ wrk_run ()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
mkdir -p "${_LOG_DIR}" || exit 1
|
command -v thttpd >/dev/null 2>&1 || sh_exit "thttpd: command not found" 5
|
||||||
|
command -v wrk >/dev/null 2>&1 || sh_exit "wrk: command not found" 6
|
||||||
|
|
||||||
|
mkdir -p "${_LOG_DIR}" || sh_exit "${_LOG_DIR}: Cannot create log directory" 1
|
||||||
|
|
||||||
if test "${_ARG_CFG}" = "all"; then
|
if test "${_ARG_CFG}" = "all"; then
|
||||||
${0} fe-be fe > "${_LOG_DIR}/README-speed-fe-be"
|
"${0}" fe-be fe > "${_LOG_DIR}/README-speed-fe-be"
|
||||||
${0} sa sa > "${_LOG_DIR}/README-speed-sa"
|
"${0}" sa sa > "${_LOG_DIR}/README-speed-sa"
|
||||||
${0} cmp cmp > "${_LOG_DIR}/README-speed-cmp"
|
"${0}" cmp cmp > "${_LOG_DIR}/README-speed-cmp"
|
||||||
${0} ctx ctx > "${_LOG_DIR}/README-speed-ctx"
|
"${0}" ctx ctx > "${_LOG_DIR}/README-speed-ctx"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
test -n "${_ARG_CFG}" -a -f "run-${_ARG_CFG}.sh" || exit 2
|
test -z "${_ARG_CFG}" -o -z "${_ARG_DIR}" && sh_exit "${_USAGE_MSG}" 4
|
||||||
test -n "${_ARG_DIR}" -a -d "${_ARG_DIR}" || exit 3
|
test -f "run-${_ARG_CFG}.sh" || sh_exit "run-${_ARG_CFG}.sh: No such configuration script" 2
|
||||||
|
test -d "${_ARG_DIR}" || sh_exit "${_ARG_DIR}: No such directory" 3
|
||||||
|
|
||||||
test -e "${_ARG_DIR}/haproxy.cfg.in" || cp -af "${_ARG_DIR}/haproxy.cfg" "${_ARG_DIR}/haproxy.cfg.in"
|
test -e "${_ARG_DIR}/haproxy.cfg.in" || cp -af "${_ARG_DIR}/haproxy.cfg" "${_ARG_DIR}/haproxy.cfg.in"
|
||||||
test -e "${_ARG_DIR}/ot.cfg.in" || cp -af "${_ARG_DIR}/ot.cfg" "${_ARG_DIR}/ot.cfg.in"
|
test -e "${_ARG_DIR}/ot.cfg.in" || cp -af "${_ARG_DIR}/ot.cfg" "${_ARG_DIR}/ot.cfg.in"
|
||||||
|
|
Loading…
Reference in New Issue