-
Notifications
You must be signed in to change notification settings - Fork 16
/
test_run.sh
executable file
·284 lines (256 loc) · 7.83 KB
/
test_run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
#!/bin/sh
set -e
uname -a
echo "/proc/sys/kernel/core_pattern: "`cat /proc/sys/kernel/core_pattern`
ulimit -c
. $(dirname $0)/functions
${CC} --version
PYTHON_CMD="${PYTHON_CMD:-"python"}"
rtpproxy_cmds_gen() {
if [ x"${RTPP_PRE_STAT_TIMEOUT}" != x"" ]
then
sleep ${RTPP_PRE_STAT_TIMEOUT}
cat "${BUILDDIR}/rtpproxy.stats.input"
RTPP_STAT_TIMEOUT=$((${RTPP_STAT_TIMEOUT} - ${RTPP_PRE_STAT_TIMEOUT}))
fi
sleep ${RTPP_STAT_TIMEOUT}
cat "${BUILDDIR}/rtpproxy.stats.input"
}
pp_file() {
file="${1}"
fname="`basename ${file}`"
shift
${PP_CMD} "${@}" "${file}" -o "${fname%.in}.pp"
grep -v '^#' "${fname%.in}.pp" | cat -s > "${fname%.in}${PP_SUF}"
}
start_mm() {
if [ -e "${MM_PIDF}" ]
then
rm "${MM_PIDF}"
fi
MM_CFG=""
case "${MM_TYPE}" in
go-b2bua)
MM_LOG="${BUILDDIR}/b2bua.log"
test -e ${MM_LOG} && rm ${MM_LOG}
${MM_ROOT}/b2bua_radius -L ${MM_LOG} \
-static_route="localhost:5062;ash=SIP-Hello1%3A%20World%21;ash=SIP-Hello2%3A%20World%21" \
-rtp_proxy_clients="${RTPP_SOCK_TEST}" -b2bua_socket="${MM_SOCK}" -rtpp_hrtb_ival=120 \
--allowed_pts="18,0,2,4,8,96,98,98,101" \
-rtpp_hrtb_retr_ival=120 -u -acct_enable=0 -f >${MM_LOG} 2>&1 &
MM_PID=${!}
;;
b2bua)
MM_LOG="${BUILDDIR}/b2bua.log"
if [ -e ${MM_LOG} ]
then
rm ${MM_LOG}
fi
SIPLOG_LOGFILE_FILE="${MM_LOG}" SIPLOG_BEND="file" \
${PYTHON_CMD} ${MM_ROOT}/sippy/b2bua_test.py --sip_address='*' \
--sip_port=5060 --foreground=on --acct_enable=off --auth_enable=off \
--static_route="localhost:5062;ash=SIP-Hello1%3A%20World%21;ash=SIP-Hello2%3A%20World%21" \
--b2bua_socket="${MM_SOCK}" --rtp_proxy_clients="${RTPP_SOCK_TEST}" \
--allowed_pts="18,0,2,4,8,[G726-40/8000],[G726-24/8000],[G726-16/8000],[telephone-event/8000]" \
--logfile="${MM_LOG}" &
MM_PID=${!}
;;
opensips)
MM_CFG="opensips.cfg"
MM_BIN="${MM_ROOT}/opensips"
pp_file "scenarios/${MM_AUTH}/${MM_CFG}.in" -DRTPP_SOCK_TEST=\"${RTPP_SOCK_TEST}\" -DOPENSIPS_VER=${MM_VER} \
-DOPENSIPS_VER_FULL=${MM_VER_FULL} -DMM_AUTH="${MM_AUTH}" -DMM_ROOT="${MM_ROOT}" \
-DRTPPC_TYPE="${RTPPC_TYPE}" -DRTPP_LISTEN="${RTPP_LISTEN}"
for nret in 0 1 2
do
PP_SUF=".nr${nret}" pp_file scenarios/${MM_AUTH}/rtpproxy.opensips.output.in -DOPENSIPS_VER=${MM_VER} \
-DOPENSIPS_VER_FULL=${MM_VER_FULL} -DNRET=${nret}
done
set +e
${MM_BIN} -f "${MM_CFG}" -C
MM_DRUN_RC="${?}"
if [ ${MM_DRUN_RC} -gt 127 ]
then
apt install -y gdb
gdb --batch -ex "run" -ex "bt" --args ${MM_BIN} -f "${MM_CFG}" -C
fi
report_rc_log "${MM_DRUN_RC}" "${MM_CFG}" "Checking ${MM_TYPE} config"
set -e
echo "--- Config Begins ---"
cat -n "${MM_CFG}"
echo "--- Config Ends ---"
_MM_ARGS="-f ${MM_CFG} ${MM_ARGS} -F -n 1"
if [ "${MM_BRANCH}" != "master" -a "${MM_VER}" -lt 30 ]
then
_MM_ARGS="${_MM_ARGS} -E"
fi
${MM_BIN} ${_MM_ARGS} &
MM_PID=${!}
;;
kamailio)
MM_CFG="kamailio.cfg"
if [ "${MM_BRANCH}" != "master" -a ${MM_VER_FULL} -lt 50 ]
then
KROOT="${MM_ROOT}"
else
KROOT="${MM_ROOT}/src"
KOPTS="-Y /tmp"
fi
KBIN="${KROOT}/kamailio"
KAM_MPATH="${KROOT}/modules/"
pp_file "${MM_CFG}.in" -DRTPP_SOCK_TEST=\"${RTPP_SOCK_TEST}\" -DKAMAILIO_VER=${MM_VER} \
-DKAMAILIO_VER_FULL=${MM_VER_FULL} -DKAM_MPATH=\"${KAM_MPATH}\"
for nret in 0 1 2
do
PP_SUF=".nr${nret}" pp_file scenarios/${MM_AUTH}/rtpproxy.kamailio.output.in -DKAMAILIO_VER=${MM_VER} \
-DKAMAILIO_VER_FULL=${MM_VER_FULL} -DNRET=${nret}
done
#sed "s|%%RTPP_SOCK_TEST%%|${RTPP_SOCK_TEST}|" < kamailio.cfg.in > kamailio.cfg
set +e
"${KBIN}" ${KOPTS} -f "${MM_CFG}" -c
MM_DRUN_RC="${?}"
report_rc_log "${MM_DRUN_RC}" "${MM_CFG}" "Checking ${MM_TYPE} config"
set -e
"${KBIN}" ${KOPTS} -f "${MM_CFG}" -DD -E -n 1 &
MM_PID=${!}
;;
*)
echo "Unknown MM_TYPE: ${MM_TYPE}" 1>&2
return 1
esac
ALICE_ARGS="${ALICE_ARGS:-"-46"}"
echo ${MM_PID} > "${MM_PIDF}"
sleep ${MM_INIT_DELAY}
return 0
}
#"${BUILDDIR}/install_depends/opensips.sh"
RTPP_PIDF="${BUILDDIR}/rtpproxy.pid"
MM_PIDF="${BUILDDIR}/opensips.pid"
ALICE_PIDF="${BUILDDIR}/alice.pid"
BOB_PIDF="${BUILDDIR}/bob.pid"
cd ${BUILDDIR}
for pidf in "${RTPP_PIDF}" "${MM_PIDF}" "${ALICE_PIDF}" "${BOB_PIDF}"
do
if [ ! -e "${pidf}" ]
then
continue
fi
pid=`cat ${pidf}`
kill -TERM "${pid}" || true
done
if [ x"${MM_SOCK}" != x"" ]
then
RTPP_NOTIFY_ARG="-n ${MM_SOCK} -W 45"
fi
if [ -e "${RTPP_SOCK_BARE}" ]
then
rm "${RTPP_SOCK_BARE}"
fi
MR_TIME="`${PYTHON_CMD} ${RTPPROXY_DIST}/python/sippy_lite/sippy/tools/getmonotime.py -S ${RTPPROXY_DIST}/python/sippy_lite -r`"
SIPLOG_TSTART="`echo ${MR_TIME} | awk '{print $2}'`"
export SIPLOG_TSTART
SIPLOG_TFORM="rel"
export SIPLOG_TFORM
RTPP_LOG_TSTART="`echo ${MR_TIME} | awk '{print $1}'`"
export RTPP_LOG_TSTART
RTPP_LOG_TFORM="rel"
export RTPP_LOG_TFORM
RTPP_LISTEN="-l 0.0.0.0"
if [ "${ALICE_ARGS}" != "-4" ]
then
RTPP_LISTEN="${RTPP_LISTEN} -6 /::"
fi
if [ "${RTPPC_TYPE}" != "rtp.io" ]
then
rtpproxy_cmds_gen | ${RTPPROXY} -p "${RTPP_PIDF}" -d dbug -F -f -s stdio: -s "${RTPP_SOCK_UDP}" \
-s "${RTPP_SOCK_CUNIX}" -s "${RTPP_SOCK_UNIX}" -s "${RTPP_SOCK_UDP6}" -s "${RTPP_SOCK_TCP}" \
-s "${RTPP_SOCK_TCP6}" -m 12000 -M 15000 ${RTPP_LISTEN} ${RTPP_NOTIFY_ARG} > rtpproxy.rout 2>rtpproxy.log &
RTPP_PID=${!}
sleep 1
i=0
while [ ! -e "${RTPP_SOCK_BARE}" ]
do
if [ ${i} -gt 4 ]
then
report_rc_log 1 "rtpproxy.rout rtpproxy.log" "Waiting for the RTPproxy to become ready"
fi
sleep 1
i=$((${i} + 1))
done
sleep 1
fi
MM_AUTH="${MM_AUTH}" ${PYTHON_CMD} bob.py -l '*' -P 5062 -T ${BOB_TIMEOUT} 2>bob.log &
BOB_PID=${!}
echo "${BOB_PID}" > "${BOB_PIDF}"
start_mm
MM_AUTH="${MM_AUTH}" ${PYTHON_CMD} alice.py "${ALICE_ARGS}" -t "${TEST_SET}" -l '*' -P 5061 \
-T ${ALICE_TIMEOUT} 2>alice.log &
ALICE_PID=${!}
echo "${ALICE_PID}" > "${ALICE_PIDF}"
set +e
wait ${ALICE_PID}
ALICE_RC="${?}"
wait ${BOB_PID}
BOB_RC="${?}"
if ! kill -TERM ${MM_PID}
then
for corefile in `sudo find /tmp/ -type f -name core\*`
do
gdb -batch --command=${BUILDDIR}/gdb.gettrace ${MM_BIN} ${corefile} >&2
done
fi
echo "MM_PID: ${MM_PID}"
wait ${MM_PID}
MM_RC="${?}"
if [ ${ALICE_RC} -eq 0 -a ${BOB_RC} -eq 0 -a ${MM_RC} -eq 0 ]
then
# Always give the RTPproxy enough time to execute final stats command,
# before we SIGHUP it
${PYTHON_CMD} -c "from time import time, sleep; tleft=${SIPLOG_TSTART} + ${RTPP_STAT_TIMEOUT} + 5 - time(); sleep(tleft) if tleft > 0 else False;"
fi
if [ "${RTPPC_TYPE}" != "rtp.io" ]
then
kill -HUP ${RTPP_PID}
echo "RTPP_PID: ${RTPP_PID}"
wait ${RTPP_PID}
RTPP_RC="${?}"
else
RTPP_RC=0
fi
rm -f "${ALICE_PIDF}" "${BOB_PIDF}"
if [ "${RTPPC_TYPE}" != "rtp.io" ]
then
if [ "${MM_TYPE}" != "opensips" -a "${MM_TYPE}" != "kamailio" ]
then
diff -uB rtpproxy.${MM_TYPE}.output rtpproxy.rout
RTPP_CHECK_RC="${?}"
else
for nret in 0 1 2
do
diff -uB rtpproxy.${MM_TYPE}.output.nr${nret} rtpproxy.rout
RTPP_CHECK_RC="${?}"
if [ ${RTPP_CHECK_RC} -eq 0 ]
then
break
fi
done
fi
fi
report_rc_log "${ALICE_RC}" "${MM_CFG} alice.log bob.log rtpproxy.log ${MM_LOG}" "Checking if Alice is happy"
report_rc_log "${BOB_RC}" "${MM_CFG} bob.log alice.log rtpproxy.log ${MM_LOG}" "Checking if Bob is happy"
if [ "${RTPPC_TYPE}" != "rtp.io" ]
then
report_rc_log "${RTPP_RC}" "${MM_CFG} rtpproxy.log ${MM_LOG}" "Checking RTPproxy exit code"
if [ x"${MM_LOG}" != x"" ]
then
report_rc_log "${RTPP_CHECK_RC}" "rtpproxy.log ${MM_LOG}" "Checking RTPproxy stdout"
else
report_rc_log "${RTPP_CHECK_RC}" rtpproxy.log "Checking RTPproxy stdout"
fi
fi
if [ x"${MM_LOG}" != x"" ]
then
report_rc_log "${MM_RC}" "${MM_LOG}" "Checking ${MM_TYPE} exit code"
else
report_rc "${MM_RC}" "Checking ${MM_TYPE} exit code"
fi