Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
dwilkie committed Mar 28, 2024
1 parent b0f335b commit 4821c91
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 30 deletions.
6 changes: 5 additions & 1 deletion components/app/lib/call_platform/fake_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def twiml_response
<Parameter name=\"aCustomParameter\" value=\"aCustomValue that was set in TwiML\" />
</Stream>
</Connect>
<Play>https://www2.cs.uic.edu/~i101/SoundFiles/taunt.wav</Play>
<Play>#{audio_file_url}</Play>
</Response>
TWIML
end
Expand All @@ -27,6 +27,10 @@ def twiml_response
def connect_ws_server_url
ENV.fetch("CONNECT_WS_SERVER_URL", "wss://example.com")
end

def audio_file_url
ENV.fetch("AUDIO_FILE_URL", "https://api.twilio.com/cowbell.mp3")
end
end

TEST_NUMBERS = [
Expand Down
2 changes: 1 addition & 1 deletion components/testing/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM public.ecr.aws/docker/library/alpine:latest

RUN apk update && apk upgrade && apk add --update --no-cache sipp curl postgresql-client bind-tools nodejs npm tshark sox ffmpeg tcpdump
RUN apk update && apk upgrade && apk add --update --no-cache python3 sipp curl postgresql-client bind-tools nodejs npm tshark sox ffmpeg tcpdump

WORKDIR /testing

Expand Down
2 changes: 2 additions & 0 deletions components/testing/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

if [ "$1" = 'start' ]; then
WS_SERVER_PORT="${WS_SERVER_PORT:="3001"}"
HTTP_SERVER_PORT="${HTTP_SERVER_PORT:="8000"}"

sipp -sf ./scenarios/uas.xml -bg -trace_msg
nohup node ./support/ws_server/test_server.js --port "$WS_SERVER_PORT" > test-server.log &
nohup python3 -m http.server $HTTP_SERVER_PORT > http-server.log &
tail -f /dev/null
fi

Expand Down
34 changes: 17 additions & 17 deletions components/testing/scenarios/uac_connect.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
</action>
</nop>

<!-- Wait for caller audio to be recevied by callee -->
<pause milliseconds="3000"/>

<!-- Play an out of band DTMF '1' -->
Expand All @@ -97,33 +98,32 @@
</action>
</nop>

<!-- Wait for audio from websockets server to be played back to callee -->
<pause milliseconds="3000"/>

<!-- The 'crlf' option inserts a blank line in the statistics report. -->
<send retrans="500">
<![CDATA[
<!-- Wait for play audio from the <Play> verb -->
<!-- Play>https://www2.cs.uic.edu/~i101/SoundFiles/taunt.wav</Play> -->
<!-- Give it enough time to download and play -->

BYE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: sipp <sip:+85512234567@[local_ip]:[local_port]>;tag=[pid]SIPpTag09[call_number]
To: [service] <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]
Call-ID: [call_id]
CSeq: 2 BYE
Contact: sip:+85512234567@[local_ip]:[local_port]
Max-Forwards: 70
Subject: Performance Test
<recv request="BYE" timeout="30000">
</recv>

<send>
<![CDATA[
SIP/2.0 200 OK
[last_Via:]
[last_From:]
[last_To:];tag=[call_number]
[last_Call-ID:]
[last_CSeq:]
Contact: <sip:+85512234567@[local_ip]:[local_port];transport=udp>
Content-Length: 0
[routes]
]]>
</send>

<recv response="200" crlf="true">
</recv>

<!-- definition of the response time repartition table (unit is ms) -->
<ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>

<!-- definition of the call length repartition table (unit is ms) -->
<CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>

</scenario>
38 changes: 27 additions & 11 deletions components/testing/tests/public_gateway/connect_stream_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,39 @@ reset_db
# kill tcpdump
kill $tcpdump_pid

# extract audio
# extract RTP from PCAP
tshark -n -r $artifacts_dir/uac_connect.pcap -2 -R rtp -T fields -e rtp.payload | tr -d '\n',':' | xxd -r -p > $artifacts_dir/uac_connect.rtp
# Convert RTP to wav
sox -t al -r 8000 -c 1 $artifacts_dir/uac_connect.rtp $artifacts_dir/uac_connect_full_audio.wav
ffmpeg -y -i $artifacts_dir/uac_connect_full_audio.wav -ss 6.3 $artifacts_dir/uac_connect_callee_audio.wav 2> /dev/null
ffmpeg -y -i $artifacts_dir/uac_connect_callee_audio.wav -af silenceremove=1:0:-40dB,areverse,silenceremove=1:0:-50dB,areverse $artifacts_dir/uac_connect_trimmed_callee_audio.wav 2> /dev/null

actual_md5=$(md5sum $artifacts_dir/uac_connect_trimmed_callee_audio.wav | head -c 32)
expected_md5="328489d203813f6e216a1d77c41b3ad9"

echo "Act MD5: $actual_md5"
echo "Exp MD5: $expected_md5"
# Cut the audio from the ws server
ffmpeg -y -i $artifacts_dir/uac_connect_full_audio.wav -ss 6.3 -to 9 $artifacts_dir/uac_connect_ws_server_audio.wav 2> /dev/null
# Remove silence
ffmpeg -y -i $artifacts_dir/uac_connect_ws_server_audio.wav -af silenceremove=1:0:-40dB,areverse,silenceremove=1:0:-50dB,areverse $artifacts_dir/uac_connect_trimmed_ws_server_audio.wav 2> /dev/null
# Cut the play verb audio
ffmpeg -y -i $artifacts_dir/uac_connect_full_audio.wav -ss 9 $artifacts_dir/uac_connect_play_verb_audio.wav 2> /dev/null
# Remove silence
ffmpeg -y -i $artifacts_dir/uac_connect_play_verb_audio.wav -af silenceremove=1:0:-40dB,areverse,silenceremove=1:0:-50dB,areverse $artifacts_dir/uac_connect_trimmed_play_verb_audio.wav 2> /dev/null

ws_server_audio_md5=$(md5sum $artifacts_dir/uac_connect_trimmed_ws_server_audio.wav | head -c 32)
expected_ws_server_audio_md5="328489d203813f6e216a1d77c41b3ad9"

play_verb_audio_md5=$(md5sum $artifacts_dir/uac_connect_trimmed_play_verb_audio.wav | head -c 32)
expected_play_verb_audio_md5="1876af04af732feae7f5fac634314187"

echo "Actual ws_server_audio_md5: $ws_server_audio_md5"
echo "Expected ws_server_audio_md5: $expected_ws_server_audio_md5"
echo "Actual play_verb_audio_md5: $play_verb_audio_md5"
echo "Expected play_verb_audio_md5: $expected_play_verb_audio_md5"

if [[ "$ws_server_audio_md5" != "$expected_ws_server_audio_md5" ]]; then
exit 1
fi

if [[ "$actual_md5" != "$expected_md5" ]]; then
if [[ "$play_verb_audio_md5" != "$expected_play_verb_audio_md5" ]]; then
exit 1
fi
# Assert correct IP in SDP

# Assert correct IP in SDP
if ! assert_in_file $log_file "c=IN IP4 $media_server"; then
exit 1
fi
Binary file added components/testing/tests/support/files/taunt.wav
Binary file not shown.
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ services:
AHN_CORE_HOST: freeswitch
CALL_PLATFORM_STUB_RESPONSES: "true"
CONNECT_WS_SERVER_URL: "ws://testing:3001"
AUDIO_FILE_URL: "http://testing:8000/tests/support/files/taunt.wav"
AHN_CORE_HTTP_PORT: "8080"
AWS_DEFAULT_REGION: "ap-southeast-1"
REDIS_URL: "redis://redis:6379/1"
Expand All @@ -162,6 +163,7 @@ services:
DATABASE_USERNAME: postgres
FIFO_DIR: /opensips/fifo
WS_SERVER_PORT: 3001
HTTP_SERVER_PORT: 8000
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
Expand Down

0 comments on commit 4821c91

Please sign in to comment.