Skip to content

Commit 2b7e45f

Browse files
committed
Allocate rtpp_notify_client port dynamically. The random
allocation fails once in a while.
1 parent d3818f3 commit 2b7e45f

File tree

5 files changed

+55
-28
lines changed

5 files changed

+55
-28
lines changed

tests/acct_rtcp_hep/basic

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ run_rtpproxy() {
3434
then
3535
rm "${rname}" || return 1
3636
fi
37-
(sed "s|%%RTPP_NOTIFY_SOCK_TCP%%|${RTPP_NOTIFY_SOCK_TCP}|g ; \
38-
s|%%CALLID%%|${CALL_ID}|g" "${CD_DIR}/basic.input" | \
37+
(sed "s|%%CALLID%%|${CALL_ID}|g" "${CD_DIR}/basic.input" | \
3938
${RTPPROXY} ${RTPP_ARGS} ${RTPP_REC_ARGS}) | sed \
4039
"s|^${rtp_porta}$|%%PORT_A%%|g ; s|^${rtp_porto}$|%%PORT_O%%|g"
4140
(env RTPP_GLITCH_ACT="" ${EXTRACTAUDIO} -S -A "${rname}" || return 1) | \
@@ -64,7 +63,7 @@ run_acct_rtcp_hep() {
6463
LNAME="acct_rtcp_hep.${HEP_PROTO}.rlog"
6564
sed "s|%%HEP_PORT%%|${HEP_PORT}|g ; s|%%HEP_PROTO%%|${HEP_PROTO}|g" < \
6665
${CD_DIR}/basic.conf > "${CNAME}"
67-
RTPP_ARGS="-d dbug -f -s stdio: -b -n ${RTPP_NOTIFY_SOCK_TCP} -m ${MIN_PORT} \
66+
RTPP_ARGS="-d dbug -f -s stdio: -b -m ${MIN_PORT} \
6867
-M ${MAX_PORT} -T1 -W2 --config ${CNAME}"
6968

7069
NC_ARGS="-l 127.0.0.1 ${HEP_PORT}"

tests/catch_dtmf/basic

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,12 @@ BASEDIR="$(readlink -f -- $BASEDIR)"
1010

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

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

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

2320
run_udpreplay() {
2421
sleep 2
@@ -33,18 +30,24 @@ run_catch_dtmf() {
3330
${RTPPROXY} ${RTPP_ARGS} 2>catch_dtmf.rlog || return 1
3431
}
3532

36-
${RTPP_NOTYFY_CLIENT} -s ${RTPP_NOTIFY_SOCK_TCP} \
37-
-S "${TOP_BUILDDIR}/python/sippy_lite" -o catch_dtmf.tlog -t 15&
33+
set -- `${RTPP_NOTYFY_CLIENT} -s "${RTPP_NOTIFY_SOCK_TCP}:0" \
34+
-S "${TOP_BUILDDIR}/python/sippy_lite" -o catch_dtmf.tlog -t 15 -D`
3835
RTPP_NC_RC=${?}
39-
RTPP_NC_PID=${!}
36+
RTPP_NC_PID="${1}"
37+
RTPP_NOTIFY_SOCK_TCP4_PORT="${2}"
38+
RTPP_NOTIFY_SOCK_TCP="${RTPP_NOTIFY_SOCK_TCP}:${RTPP_NOTIFY_SOCK_TCP4_PORT}"
4039
report_rc ${RTPP_NC_RC} "Starting rtpp_notify_client.py"
40+
41+
RTPP_ARGS="-d dbug -f -s stdio: -b -n ${RTPP_NOTIFY_SOCK_TCP} -m ${MIN_PORT} \
42+
-M ${MAX_PORT} -T3 -W3 --dso ../modules/catch_dtmf/.libs/rtpp_catch_dtmf_debug.so"
43+
4144
run_udpreplay &
4245
UDPRPL_RC=${?}
4346
UDPRPL_PID=${!}
4447
report_rc ${UDPRPL_RC} "Starting udpreplay"
4548
run_catch_dtmf > catch_dtmf.rout
4649
report "wait for the rtproxy shutdown"
47-
wait ${RTPP_NC_PID}
50+
notify_client_stop ${RTPP_NC_PID}
4851
report "wait for rtpp_notify_client.py shutdown"
4952
wait ${UDPRPL_PID}
5053
report "wait for udpreplay shutdown"

tests/functions

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ IPV6_LHOST="::1"
7373

7474
RTPP_NOTIFY_SOCK_UNIX_SHRT="/tmp/rtpp_nc.sock"
7575
RTPP_NOTIFY_SOCK_UNIX="unix:${RTPP_NOTIFY_SOCK_UNIX_SHRT}"
76-
RTPP_NOTIFY_SOCK_TCP="tcp:${IPV4_LHOST}:9642"
77-
RTPP_NOTIFY_SOCK_WILD="tcp:%%CC_SELF%%:9643"
78-
RTPP_NOTIFY_SOCK_WILD_BIND="tcp:${IPV4_LHOST}:9643"
76+
RTPP_NOTIFY_SOCK_TCP="tcp:${IPV4_LHOST}"
77+
RTPP_NOTIFY_SOCK_WILD="tcp:%%CC_SELF%%"
78+
RTPP_NOTIFY_SOCK_WILD_BIND="tcp:${IPV4_LHOST}"
7979

8080
RTPP_TEST_SOCK_UDP4_PORT=${RTPP_TEST_SOCK_UDP4_PORT:-`${PYINT} -c "from random import random;m=10000;print(m+int(random()*(65536-m)))"`}
8181
RTPP_TEST_SOCK_UDP6_PORT=${RTPP_TEST_SOCK_UDP6_PORT:-`${PYINT} -c "from random import random;m=10000;print(m+int(random()*(65536-m)))"`}

tests/memdeb/glitch.sub

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
spin_nc()
22
{
3-
NC_PORT=`${PYINT} -c "from random import random;m=10000;print(m+int(random()*(65536-m)))"`
3+
# NC_PORT=`${PYINT} -c "from random import random;m=10000;print(m+int(random()*(65536-m)))"`
44
# (nc -k -l 127.0.0.1 ${NC_PORT} > glitch1.ncout)&
55
# (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)&
66
GNC_LOG="glitch1.nclog"
77
if [ -e ${GNC_LOG} ]
88
then
99
rm "${GNC_LOG}"
1010
fi
11-
NC_PID="`${RTPP_NOTYFY_CLIENT} -D -s tcp:127.0.0.1:${NC_PORT} -o glitch1.ncout -t 600 -l "${GNC_LOG}"`"
11+
set -- `${RTPP_NOTYFY_CLIENT} -D -s tcp:127.0.0.1:0 -o glitch1.ncout -t 600 -l "${GNC_LOG}"`
1212
RTPP_NC_RC=${?}
13-
if [ -z "${NC_PID}" ]
13+
NC_PID="${1}"
14+
NC_PORT="${2}"
15+
if [ -z "${NC_PID}" -o -z "${NC_PORT}" ]
1416
then
1517
RTPP_NC_RC=1
1618
fi

tests/session_timeouts/test.sub

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ geninput() {
7979
cat session_timeouts/stats.input
8080
}
8181

82-
RTPP0_ARGS="-d dbug -T10 -b -n ${RTPP_NOTIFY_SOCK_TCP} -n ${RTPP_NOTIFY_SOCK_WILD} -n ${RTPP_NOTIFY_SOCK_UNIX}"
82+
RTPP0_ARGS="-d dbug -T10 -b"
8383
RTPP1_ARGS="${RTPP0_ARGS} -m 12000 -W5"
8484
RTPP2_ARGS="${RTPP0_ARGS} -m 13000"
8585
RTPP3_ARGS="-6 ::1 ${RTPP1_ARGS}"
@@ -143,15 +143,38 @@ run_test()
143143
else
144144
client_notify_sock="${notify_sock}"
145145
fi
146+
case "$client_notify_sock" in
147+
tcp:*)
148+
client_notify_sock1="${client_notify_sock}:0"
149+
;;
150+
*)
151+
client_notify_sock1="${client_notify_sock}"
152+
;;
153+
esac
146154
NSTESTS=`echo ${RTPP_TEST_SOCKETS} | wc -w`
147155
RTPP_NC_TOUT=$((${NSTESTS} * 34))
148-
RTPP_NC_PID="`${RTPP_NOTYFY_CLIENT} -D -s ${client_notify_sock} -o session_timeouts.tlog \
149-
-t ${RTPP_NC_TOUT} -l session_timeouts.tout`"
156+
set -- `${RTPP_NOTYFY_CLIENT} -D -s "${client_notify_sock1}" -o session_timeouts.tlog \
157+
-t ${RTPP_NC_TOUT} -l session_timeouts.tout`
150158
RTPP_NC_RC=${?}
159+
RTPP_NC_PID="${1}"
160+
RTPP_NC_PORT="${2}"
151161
if [ -z "${RTPP_NC_PID}" ]
152162
then
153163
RTPP_NC_RC=1
154164
fi
165+
case "$client_notify_sock" in
166+
tcp:*)
167+
if [ -z "${RTPP_NC_PORT}" ]
168+
then
169+
RTPP_NC_RC=1
170+
else
171+
client_notify_sock="${client_notify_sock}:${RTPP_NC_PORT}"
172+
notify_sock="${notify_sock}:${RTPP_NC_PORT}"
173+
fi
174+
;;
175+
*)
176+
;;
177+
esac
155178
report_rc ${RTPP_NC_RC} "Starting rtpp_notify_client.py on ${client_notify_sock}"
156179

157180
setup_tstart
@@ -160,16 +183,16 @@ run_test()
160183
do
161184
if [ "${socket}" = "stdio:" ]
162185
then
163-
run_rtpp_on_stdout "" ${j}.1 ${RTPP1_ARGS}
186+
run_rtpp_on_stdout "" ${j}.1 -n "${notify_sock}" ${RTPP1_ARGS}
164187
report "rtpproxy #${j}.1 start on ${socket}"
165188
RTPP1_PID=${RTPP_PID}
166-
run_rtpp_on_stdout "" ${j}.2 ${RTPP2_ARGS}
189+
run_rtpp_on_stdout "" ${j}.2 -n "${notify_sock}" ${RTPP2_ARGS}
167190
report "rtpproxy #${j}.2 start on ${socket}"
168191
RTPP2_PID=${RTPP_PID}
169-
run_rtpp_on_stdout "6" ${j}.3 ${RTPP3_ARGS}
192+
run_rtpp_on_stdout "6" ${j}.3 -n "${notify_sock}" ${RTPP3_ARGS}
170193
report "rtpproxy #${j}.3 start on ${socket}"
171194
RTPP3_PID=${RTPP_PID}
172-
run_rtpp_on_stdout "6" ${j}.4 ${RTPP4_ARGS}
195+
run_rtpp_on_stdout "6" ${j}.4 -n "${notify_sock}" ${RTPP4_ARGS}
173196
report "rtpproxy #${j}.4 start on ${socket}"
174197
RTPP4_PID=${RTPP_PID}
175198
wait ${RTPP1_PID}
@@ -192,12 +215,12 @@ run_test()
192215
socket_idx=0
193216
advance_sockidx
194217
RTPP1_LOG=${RTPP_LOGFILE}
195-
RTPP_SOCKFILE="${_socket}" rtpproxy_start ${RTPP1_ARGS}
218+
RTPP_SOCKFILE="${_socket}" rtpproxy_start -n "${notify_sock}" ${RTPP1_ARGS}
196219
report "rtpproxy #${j}.1 start on ${_socket}"
197220
RTPP1_PID="${TMP_PIDFILE}"
198221
advance_sockidx
199222
RTPP2_LOG=${RTPP_LOGFILE}
200-
RTPP_SOCKFILE="${_socket}" rtpproxy_start ${RTPP2_ARGS}
223+
RTPP_SOCKFILE="${_socket}" rtpproxy_start -n "${notify_sock}" ${RTPP2_ARGS}
201224
RTPP2_START_RC=${?}
202225
if [ ${RTPP2_START_RC} -ne 0 ]
203226
then
@@ -207,7 +230,7 @@ run_test()
207230
RTPP2_PID="${TMP_PIDFILE}"
208231
advance_sockidx
209232
RTPP3_LOG=${RTPP_LOGFILE}
210-
RTPP_SOCKFILE="${_socket}" rtpproxy_start ${RTPP3_ARGS}
233+
RTPP_SOCKFILE="${_socket}" rtpproxy_start -n "${notify_sock}" ${RTPP3_ARGS}
211234
RTPP3_START_RC=${?}
212235
if [ ${RTPP3_START_RC} -ne 0 ]
213236
then
@@ -218,7 +241,7 @@ run_test()
218241
RTPP3_PID="${TMP_PIDFILE}"
219242
advance_sockidx
220243
RTPP4_LOG=${RTPP_LOGFILE}
221-
RTPP_SOCKFILE="${_socket}" rtpproxy_start ${RTPP4_ARGS}
244+
RTPP_SOCKFILE="${_socket}" rtpproxy_start -n "${notify_sock}" ${RTPP4_ARGS}
222245
RTPP4_START_RC=${?}
223246
if [ ${RTPP4_START_RC} -ne 0 ]
224247
then

0 commit comments

Comments
 (0)