Skip to content

Commit

Permalink
Allocate rtpp_notify_client port dynamically. The random
Browse files Browse the repository at this point in the history
allocation fails once in a while.
  • Loading branch information
sobomax committed Jul 24, 2023
1 parent d3818f3 commit 2b7e45f
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 28 deletions.
5 changes: 2 additions & 3 deletions tests/acct_rtcp_hep/basic
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ run_rtpproxy() {
then
rm "${rname}" || return 1
fi
(sed "s|%%RTPP_NOTIFY_SOCK_TCP%%|${RTPP_NOTIFY_SOCK_TCP}|g ; \
s|%%CALLID%%|${CALL_ID}|g" "${CD_DIR}/basic.input" | \
(sed "s|%%CALLID%%|${CALL_ID}|g" "${CD_DIR}/basic.input" | \
${RTPPROXY} ${RTPP_ARGS} ${RTPP_REC_ARGS}) | sed \
"s|^${rtp_porta}$|%%PORT_A%%|g ; s|^${rtp_porto}$|%%PORT_O%%|g"
(env RTPP_GLITCH_ACT="" ${EXTRACTAUDIO} -S -A "${rname}" || return 1) | \
Expand Down Expand Up @@ -64,7 +63,7 @@ run_acct_rtcp_hep() {
LNAME="acct_rtcp_hep.${HEP_PROTO}.rlog"
sed "s|%%HEP_PORT%%|${HEP_PORT}|g ; s|%%HEP_PROTO%%|${HEP_PROTO}|g" < \
${CD_DIR}/basic.conf > "${CNAME}"
RTPP_ARGS="-d dbug -f -s stdio: -b -n ${RTPP_NOTIFY_SOCK_TCP} -m ${MIN_PORT} \
RTPP_ARGS="-d dbug -f -s stdio: -b -m ${MIN_PORT} \
-M ${MAX_PORT} -T1 -W2 --config ${CNAME}"

NC_ARGS="-l 127.0.0.1 ${HEP_PORT}"
Expand Down
19 changes: 11 additions & 8 deletions tests/catch_dtmf/basic
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,12 @@ BASEDIR="$(readlink -f -- $BASEDIR)"

. $(dirname $0)/../functions

RTPP_NOTIFY_SOCK_TCP4_PORT=`${PYINT} -c "from random import random;m=10000;print(m+int(random()*(65536-m)))"`
RTPP_NOTIFY_SOCK_TCP="tcp:${IPV4_LHOST}:${RTPP_NOTIFY_SOCK_TCP4_PORT}"
RTPP_NOTIFY_SOCK_TCP="tcp:${IPV4_LHOST}"

CD_DIR="${BASEDIR}/catch_dtmf"
RTP_PORT=24272
MIN_PORT=$((${RTP_PORT} - 2))
MAX_PORT=$((${RTP_PORT} + 1))
RTPP_ARGS="-d dbug -f -s stdio: -b -n ${RTPP_NOTIFY_SOCK_TCP} -m ${MIN_PORT} \
-M ${MAX_PORT} -T3 -W3 --dso ../modules/catch_dtmf/.libs/rtpp_catch_dtmf_debug.so"

run_udpreplay() {
sleep 2
Expand All @@ -33,18 +30,24 @@ run_catch_dtmf() {
${RTPPROXY} ${RTPP_ARGS} 2>catch_dtmf.rlog || return 1
}

${RTPP_NOTYFY_CLIENT} -s ${RTPP_NOTIFY_SOCK_TCP} \
-S "${TOP_BUILDDIR}/python/sippy_lite" -o catch_dtmf.tlog -t 15&
set -- `${RTPP_NOTYFY_CLIENT} -s "${RTPP_NOTIFY_SOCK_TCP}:0" \
-S "${TOP_BUILDDIR}/python/sippy_lite" -o catch_dtmf.tlog -t 15 -D`
RTPP_NC_RC=${?}
RTPP_NC_PID=${!}
RTPP_NC_PID="${1}"
RTPP_NOTIFY_SOCK_TCP4_PORT="${2}"
RTPP_NOTIFY_SOCK_TCP="${RTPP_NOTIFY_SOCK_TCP}:${RTPP_NOTIFY_SOCK_TCP4_PORT}"
report_rc ${RTPP_NC_RC} "Starting rtpp_notify_client.py"

RTPP_ARGS="-d dbug -f -s stdio: -b -n ${RTPP_NOTIFY_SOCK_TCP} -m ${MIN_PORT} \
-M ${MAX_PORT} -T3 -W3 --dso ../modules/catch_dtmf/.libs/rtpp_catch_dtmf_debug.so"

run_udpreplay &
UDPRPL_RC=${?}
UDPRPL_PID=${!}
report_rc ${UDPRPL_RC} "Starting udpreplay"
run_catch_dtmf > catch_dtmf.rout
report "wait for the rtproxy shutdown"
wait ${RTPP_NC_PID}
notify_client_stop ${RTPP_NC_PID}
report "wait for rtpp_notify_client.py shutdown"
wait ${UDPRPL_PID}
report "wait for udpreplay shutdown"
Expand Down
6 changes: 3 additions & 3 deletions tests/functions
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ IPV6_LHOST="::1"

RTPP_NOTIFY_SOCK_UNIX_SHRT="/tmp/rtpp_nc.sock"
RTPP_NOTIFY_SOCK_UNIX="unix:${RTPP_NOTIFY_SOCK_UNIX_SHRT}"
RTPP_NOTIFY_SOCK_TCP="tcp:${IPV4_LHOST}:9642"
RTPP_NOTIFY_SOCK_WILD="tcp:%%CC_SELF%%:9643"
RTPP_NOTIFY_SOCK_WILD_BIND="tcp:${IPV4_LHOST}:9643"
RTPP_NOTIFY_SOCK_TCP="tcp:${IPV4_LHOST}"
RTPP_NOTIFY_SOCK_WILD="tcp:%%CC_SELF%%"
RTPP_NOTIFY_SOCK_WILD_BIND="tcp:${IPV4_LHOST}"

RTPP_TEST_SOCK_UDP4_PORT=${RTPP_TEST_SOCK_UDP4_PORT:-`${PYINT} -c "from random import random;m=10000;print(m+int(random()*(65536-m)))"`}
RTPP_TEST_SOCK_UDP6_PORT=${RTPP_TEST_SOCK_UDP6_PORT:-`${PYINT} -c "from random import random;m=10000;print(m+int(random()*(65536-m)))"`}
Expand Down
8 changes: 5 additions & 3 deletions tests/memdeb/glitch.sub
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
spin_nc()
{
NC_PORT=`${PYINT} -c "from random import random;m=10000;print(m+int(random()*(65536-m)))"`
# NC_PORT=`${PYINT} -c "from random import random;m=10000;print(m+int(random()*(65536-m)))"`
# (nc -k -l 127.0.0.1 ${NC_PORT} > glitch1.ncout)&
# (strace -o glitch1.nctrace -f ${RTPP_NOTYFY_CLIENT} -s tcp:127.0.0.1:${NC_PORT} -o glitch1.ncout -t 600 2>glitch1.nclog 1>glitch1.nclog)&
GNC_LOG="glitch1.nclog"
if [ -e ${GNC_LOG} ]
then
rm "${GNC_LOG}"
fi
NC_PID="`${RTPP_NOTYFY_CLIENT} -D -s tcp:127.0.0.1:${NC_PORT} -o glitch1.ncout -t 600 -l "${GNC_LOG}"`"
set -- `${RTPP_NOTYFY_CLIENT} -D -s tcp:127.0.0.1:0 -o glitch1.ncout -t 600 -l "${GNC_LOG}"`
RTPP_NC_RC=${?}
if [ -z "${NC_PID}" ]
NC_PID="${1}"
NC_PORT="${2}"
if [ -z "${NC_PID}" -o -z "${NC_PORT}" ]
then
RTPP_NC_RC=1
fi
Expand Down
45 changes: 34 additions & 11 deletions tests/session_timeouts/test.sub
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ geninput() {
cat session_timeouts/stats.input
}

RTPP0_ARGS="-d dbug -T10 -b -n ${RTPP_NOTIFY_SOCK_TCP} -n ${RTPP_NOTIFY_SOCK_WILD} -n ${RTPP_NOTIFY_SOCK_UNIX}"
RTPP0_ARGS="-d dbug -T10 -b"
RTPP1_ARGS="${RTPP0_ARGS} -m 12000 -W5"
RTPP2_ARGS="${RTPP0_ARGS} -m 13000"
RTPP3_ARGS="-6 ::1 ${RTPP1_ARGS}"
Expand Down Expand Up @@ -143,15 +143,38 @@ run_test()
else
client_notify_sock="${notify_sock}"
fi
case "$client_notify_sock" in
tcp:*)
client_notify_sock1="${client_notify_sock}:0"
;;
*)
client_notify_sock1="${client_notify_sock}"
;;
esac
NSTESTS=`echo ${RTPP_TEST_SOCKETS} | wc -w`
RTPP_NC_TOUT=$((${NSTESTS} * 34))
RTPP_NC_PID="`${RTPP_NOTYFY_CLIENT} -D -s ${client_notify_sock} -o session_timeouts.tlog \
-t ${RTPP_NC_TOUT} -l session_timeouts.tout`"
set -- `${RTPP_NOTYFY_CLIENT} -D -s "${client_notify_sock1}" -o session_timeouts.tlog \
-t ${RTPP_NC_TOUT} -l session_timeouts.tout`
RTPP_NC_RC=${?}
RTPP_NC_PID="${1}"
RTPP_NC_PORT="${2}"
if [ -z "${RTPP_NC_PID}" ]
then
RTPP_NC_RC=1
fi
case "$client_notify_sock" in
tcp:*)
if [ -z "${RTPP_NC_PORT}" ]
then
RTPP_NC_RC=1
else
client_notify_sock="${client_notify_sock}:${RTPP_NC_PORT}"
notify_sock="${notify_sock}:${RTPP_NC_PORT}"
fi
;;
*)
;;
esac
report_rc ${RTPP_NC_RC} "Starting rtpp_notify_client.py on ${client_notify_sock}"

setup_tstart
Expand All @@ -160,16 +183,16 @@ run_test()
do
if [ "${socket}" = "stdio:" ]
then
run_rtpp_on_stdout "" ${j}.1 ${RTPP1_ARGS}
run_rtpp_on_stdout "" ${j}.1 -n "${notify_sock}" ${RTPP1_ARGS}
report "rtpproxy #${j}.1 start on ${socket}"
RTPP1_PID=${RTPP_PID}
run_rtpp_on_stdout "" ${j}.2 ${RTPP2_ARGS}
run_rtpp_on_stdout "" ${j}.2 -n "${notify_sock}" ${RTPP2_ARGS}
report "rtpproxy #${j}.2 start on ${socket}"
RTPP2_PID=${RTPP_PID}
run_rtpp_on_stdout "6" ${j}.3 ${RTPP3_ARGS}
run_rtpp_on_stdout "6" ${j}.3 -n "${notify_sock}" ${RTPP3_ARGS}
report "rtpproxy #${j}.3 start on ${socket}"
RTPP3_PID=${RTPP_PID}
run_rtpp_on_stdout "6" ${j}.4 ${RTPP4_ARGS}
run_rtpp_on_stdout "6" ${j}.4 -n "${notify_sock}" ${RTPP4_ARGS}
report "rtpproxy #${j}.4 start on ${socket}"
RTPP4_PID=${RTPP_PID}
wait ${RTPP1_PID}
Expand All @@ -192,12 +215,12 @@ run_test()
socket_idx=0
advance_sockidx
RTPP1_LOG=${RTPP_LOGFILE}
RTPP_SOCKFILE="${_socket}" rtpproxy_start ${RTPP1_ARGS}
RTPP_SOCKFILE="${_socket}" rtpproxy_start -n "${notify_sock}" ${RTPP1_ARGS}
report "rtpproxy #${j}.1 start on ${_socket}"
RTPP1_PID="${TMP_PIDFILE}"
advance_sockidx
RTPP2_LOG=${RTPP_LOGFILE}
RTPP_SOCKFILE="${_socket}" rtpproxy_start ${RTPP2_ARGS}
RTPP_SOCKFILE="${_socket}" rtpproxy_start -n "${notify_sock}" ${RTPP2_ARGS}
RTPP2_START_RC=${?}
if [ ${RTPP2_START_RC} -ne 0 ]
then
Expand All @@ -207,7 +230,7 @@ run_test()
RTPP2_PID="${TMP_PIDFILE}"
advance_sockidx
RTPP3_LOG=${RTPP_LOGFILE}
RTPP_SOCKFILE="${_socket}" rtpproxy_start ${RTPP3_ARGS}
RTPP_SOCKFILE="${_socket}" rtpproxy_start -n "${notify_sock}" ${RTPP3_ARGS}
RTPP3_START_RC=${?}
if [ ${RTPP3_START_RC} -ne 0 ]
then
Expand All @@ -218,7 +241,7 @@ run_test()
RTPP3_PID="${TMP_PIDFILE}"
advance_sockidx
RTPP4_LOG=${RTPP_LOGFILE}
RTPP_SOCKFILE="${_socket}" rtpproxy_start ${RTPP4_ARGS}
RTPP_SOCKFILE="${_socket}" rtpproxy_start -n "${notify_sock}" ${RTPP4_ARGS}
RTPP4_START_RC=${?}
if [ ${RTPP4_START_RC} -ne 0 ]
then
Expand Down

0 comments on commit 2b7e45f

Please sign in to comment.