[Asterisk-code-review] Add test for pjsip transfer with 481 (testsuite[18])
Friendly Automation
asteriskteam at digium.com
Tue Mar 23 09:33:24 CDT 2021
Friendly Automation has submitted this change. ( https://gerrit.asterisk.org/c/testsuite/+/15669 )
Change subject: Add test for pjsip transfer with 481
......................................................................
Add test for pjsip transfer with 481
Change-Id: Iee0e5c4fd31b4d4f4bc833391d972ef87ecd902e
---
A tests/channels/pjsip/transfers/blind_transfer/caller_with_hold_481/configs/ast1/extensions.conf
A tests/channels/pjsip/transfers/blind_transfer/caller_with_hold_481/configs/ast1/pjsip.conf
A tests/channels/pjsip/transfers/blind_transfer/caller_with_hold_481/sipp/alice.xml
A tests/channels/pjsip/transfers/blind_transfer/caller_with_hold_481/sipp/bob.xml
A tests/channels/pjsip/transfers/blind_transfer/caller_with_hold_481/sipp/charlie.xml
A tests/channels/pjsip/transfers/blind_transfer/caller_with_hold_481/test-config.yaml
M tests/channels/pjsip/transfers/blind_transfer/tests.yaml
7 files changed, 603 insertions(+), 0 deletions(-)
Approvals:
Joshua Colp: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved
Friendly Automation: Approved for Submit
diff --git a/tests/channels/pjsip/transfers/blind_transfer/caller_with_hold_481/configs/ast1/extensions.conf b/tests/channels/pjsip/transfers/blind_transfer/caller_with_hold_481/configs/ast1/extensions.conf
new file mode 100644
index 0000000..8cc124e
--- /dev/null
+++ b/tests/channels/pjsip/transfers/blind_transfer/caller_with_hold_481/configs/ast1/extensions.conf
@@ -0,0 +1,16 @@
+[general]
+
+[globals]
+
+[transfertest]
+exten => bob,1,NoOp()
+ same => n,Dial(PJSIP/bob)
+ same => n,Hangup()
+
+exten => charlie,1,NoOp()
+ same => n,Wait(1)
+ same => n,Progress()
+ same => n,Wait(1)
+ same => n,Dial(PJSIP/charlie)
+ same => n,Hangup()
+
diff --git a/tests/channels/pjsip/transfers/blind_transfer/caller_with_hold_481/configs/ast1/pjsip.conf b/tests/channels/pjsip/transfers/blind_transfer/caller_with_hold_481/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..bb3e07c
--- /dev/null
+++ b/tests/channels/pjsip/transfers/blind_transfer/caller_with_hold_481/configs/ast1/pjsip.conf
@@ -0,0 +1,66 @@
+[system]
+type=system
+timer_t1=100
+timer_b=6400
+
+[global]
+type=global
+debug=yes
+
+[local-transport]
+type=transport
+bind=127.0.0.1
+protocol=udp
+
+[alice]
+type=endpoint
+allow=g722,ulaw,alaw
+context=transfertest
+direct_media=no
+media_address=127.0.0.1
+aors=alice
+
+[alice]
+type=aor
+max_contacts=1
+contact=sip:alice at 127.0.0.2:5060\;transport=udp
+
+[bob]
+type=endpoint
+allow=g722,ulaw,alaw
+context=transfertest
+direct_media=no
+media_address=127.0.0.1
+aors=bob
+
+[bob]
+type=aor
+max_contacts=1
+contact=sip:bob at 127.0.0.3:5060\;transport=udp
+
+[bob_two]
+type=endpoint
+allow=ulaw
+context=transfertest
+direct_media=no
+media_address=127.0.0.1
+aors=bob_two
+
+[bob_two]
+type=aor
+max_contacts=1
+contact=sip:bob_two at 127.0.0.3:5060\;transport=udp
+
+[charlie]
+type=endpoint
+allow=g722,ulaw,alaw
+context=transfertest
+direct_media=no
+media_address=127.0.0.1
+aors=charlie
+
+[charlie]
+type=aor
+max_contacts=1
+contact=sip:charlie at 127.0.0.4:5060\;transport=udp
+
diff --git a/tests/channels/pjsip/transfers/blind_transfer/caller_with_hold_481/sipp/alice.xml b/tests/channels/pjsip/transfers/blind_transfer/caller_with_hold_481/sipp/alice.xml
new file mode 100644
index 0000000..acd98f8
--- /dev/null
+++ b/tests/channels/pjsip/transfers/blind_transfer/caller_with_hold_481/sipp/alice.xml
@@ -0,0 +1,232 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+
+<scenario name="Send Call">
+
+ <send retrans="500">
+ <![CDATA[
+
+ INVITE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: <sip:alice@[local_ip]:[local_port]>;tag=[pid]SIPpTag[call_number]
+ To: <sip:[service]@[remote_ip]:[remote_port]>
+ Call-ID: [call_id]
+ CSeq: [cseq] INVITE
+ Contact: <sip:alice@[local_ip]:[local_port];transport=[transport]>
+ Max-Forwards: 70
+ Content-Type: application/sdp
+ Content-Length: [len]
+
+ v=0
+ o=- 53655765 2353687637 IN IP[local_ip_type] [local_ip]
+ s=-
+ c=IN IP[media_ip_type] [media_ip]
+ t=0 0
+ m=audio [custom_media_port] RTP/AVP 0
+ a=rtpmap:0 PCMU/8000
+
+ ]]>
+ </send>
+
+ <recv response="100" optional="true" />
+ <recv response="180" optional="true" />
+ <recv response="183" optional="true" />
+
+ <recv response="200" rtd="true">
+ <!-- Save the To tag. We'll need it when we send REFER -->
+ <action>
+ <ereg regexp="(;tag=.*)"
+ header="To:"
+ search_in="hdr"
+ check_it="true"
+ assign_to="remote_tag"/>
+ </action>
+ </recv>
+
+ <send>
+ <![CDATA[
+
+ ACK sip:[service]@[remote_ip]:[remote_port] SIP/2.0
+ [last_Via:]
+ [last_From:]
+ [last_To:]
+ Call-ID: [call_id]
+ CSeq: [cseq] ACK
+ Contact: <sip:alice@[local_ip]:[local_port];transport=[transport]>
+ Max-Forwards: 70
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+ <!-- Send audio -->
+ <nop>
+ <action>
+ <exec rtp_stream="lib/python/asterisk/audio.ulaw,1,0"/>
+ </action>
+ </nop>
+
+ <pause milliseconds="1000" crlf="true" />
+ <nop>
+ <action>
+ <exec rtp_stream="pause" />
+ </action>
+ </nop>
+
+ <!-- Put call on hold -->
+ <send retrans="500">
+ <![CDATA[
+
+ INVITE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
+ [last_Via:]2
+ [last_From:]
+ [last_To:]
+ [last_Call-ID:]
+ CSeq: [cseq+2] INVITE
+ Contact: <sip:alice@[local_ip]:[local_port];transport=[transport]>
+ Max-Forwards: 70
+ Content-Type: application/sdp
+ Content-Length: [len]
+
+ v=0
+ o=- 53655765 2353687637 IN IP[local_ip_type] [local_ip]
+ s=-
+ c=IN IP[media_ip_type] [media_ip]
+ t=0 0
+ m=audio [custom_media_port] RTP/AVP 0
+ a=rtpmap:0 PCMU/8000
+ a=sendonly
+
+ ]]>
+ </send>
+
+ <recv response="100" optional="true" />
+
+ <recv response="200" rtd="true">
+ </recv>
+
+ <send>
+ <![CDATA[
+
+ ACK sip:[service]@[remote_ip]:[remote_port] SIP/2.0
+ [last_Via:]2
+ [last_From:]
+ [last_To:]
+ Call-ID: [call_id]
+ CSeq: [cseq+2] ACK
+ Contact: <sip:alice@[local_ip]:[local_port];transport=[transport]>
+ Max-Forwards: 70
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+ <pause milliseconds="1000" crlf="true"/>
+
+ <!-- Blind transfer bob to charlie -->
+ <send retrans="500">
+ <![CDATA[
+
+ REFER sip:[service]@[remote_ip]:[remote_port] SIP/2.0
+ [last_Via:]3
+ From: <sip:alice@[local_ip]:[local_port]>;tag=[pid]SIPpTag[call_number]
+ To: <sip:[service]@[remote_ip]:[remote_port]>[$remote_tag]
+ Call-ID: [call_id]
+ CSeq: [cseq+4] REFER
+ Contact: sip:alice@[local_ip]:[local_port];transport=[transport]
+ Max-Forwards: 70
+ Subject: Performance Test
+ Refer-To: sip:charlie@[remote_ip]:[remote_port];user=phone
+ Referred-By: sip:alice@[local_ip]:[local_port]
+ Content-Length: 0
+
+ ]]>
+
+ </send>
+
+ <recv response="202" rtd="true">
+ </recv>
+
+ <!-- We should receive a NOTIFY from Asterisk with a 100 trying sipfrag -->
+ <recv request="NOTIFY">
+ </recv>
+
+ <send crlf="true">
+ <![CDATA[
+
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:]
+ [last_Call-ID:]
+ [last_CSeq:]
+ [last_Event:]
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+ ]]>
+ </send>
+
+
+ <!-- We should receive a NOTIFY from Asterisk with a '183 Session Progress' sipfrag -->
+ <recv request="NOTIFY" crlf="true">
+ <action>
+ <ereg regexp="(SIP/2.0 183 Session Progress)"
+ search_in="msg"
+ check_it="true"
+ assign_to="sip_frag_ok"/>
+ <ereg regexp="([0-9]+)"
+ header="CSeq:"
+ search_in="hdr"
+ check_it="true"
+ assign_to="progress_cseq"/>
+ <ereg regexp=" (.*)"
+ header="Via:"
+ search_in="hdr"
+ check_it="true"
+ assign_to="progress_via"/>
+ <ereg regexp=" (.*)"
+ header="To:"
+ search_in="hdr"
+ check_it="true"
+ assign_to="progress_to"/>
+ </action>
+ </recv>
+
+ <!-- Transfer should have successfully occurred so now we need to hang up -->
+ <send start_txn="bye">
+ <![CDATA[
+
+ BYE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
+ [last_Via:]4
+ From: <sip:alice@[local_ip]:[local_port]>;tag=[pid]SIPpTag[call_number]
+ To: <sip:[service]@[remote_ip]:[remote_port]>[$remote_tag]
+ Call-ID: [call_id]
+ CSeq: [cseq+5] BYE
+ Contact: sip:alice@[local_ip]:[local_port]
+ Max-Forwards: 70
+ Subject: Performance Test
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+ <recv response="200" response_txn="bye">
+ </recv>
+
+ <send>
+ <![CDATA[
+
+ SIP/2.0 481 Subscription Does Not Exist
+ Via: [$progress_via]
+ [last_From:]
+ To: [$progress_to]
+ [last_Call-ID:]
+ CSeq: [$progress_cseq] NOTIFY
+ [last_Event:]
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+ ]]>
+ </send>
+
+ <Reference variables="sip_frag_ok" />
+
+</scenario>
diff --git a/tests/channels/pjsip/transfers/blind_transfer/caller_with_hold_481/sipp/bob.xml b/tests/channels/pjsip/transfers/blind_transfer/caller_with_hold_481/sipp/bob.xml
new file mode 100644
index 0000000..3870eac
--- /dev/null
+++ b/tests/channels/pjsip/transfers/blind_transfer/caller_with_hold_481/sipp/bob.xml
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="Basic UAS responder">
+
+ <recv request="INVITE" crlf="true" />
+
+ <send>
+ <![CDATA[
+
+ SIP/2.0 180 Ringing
+ [last_Via:]
+ [last_From:]
+ [last_To:];tag=[pid]SIPpTag[call_number]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: <sip:bob@[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+ <send retrans="500">
+ <![CDATA[
+
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:];tag=[pid]SIPpTag[call_number]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: <sip:bob@[local_ip]:[local_port];transport=[transport]>
+ Content-Type: application/sdp
+ Content-Length: [len]
+
+ v=0
+ o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
+ s=-
+ c=IN IP[media_ip_type] [media_ip]
+ t=0 0
+ m=audio [custom_media_port] RTP/AVP 0
+ a=rtpmap:0 PCMU/8000
+
+ ]]>
+ </send>
+
+ <recv request="ACK"
+ rtd="true"
+ crlf="true">
+ </recv>
+
+ <!-- Send audio -->
+ <nop>
+ <action>
+ <exec rtp_stream="lib/python/asterisk/audio.ulaw,3,0"/>
+ </action>
+ </nop>
+
+ <recv request="BYE" />
+
+ <send>
+ <![CDATA[
+
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+ <ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>
+
+ <CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>
+
+</scenario>
+
diff --git a/tests/channels/pjsip/transfers/blind_transfer/caller_with_hold_481/sipp/charlie.xml b/tests/channels/pjsip/transfers/blind_transfer/caller_with_hold_481/sipp/charlie.xml
new file mode 100644
index 0000000..d14fb7a
--- /dev/null
+++ b/tests/channels/pjsip/transfers/blind_transfer/caller_with_hold_481/sipp/charlie.xml
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+
+<scenario name="Basic UAS responder">
+
+ <recv request="INVITE" crlf="true">
+ <action>
+ <!-- Save the From tag. We'll need it when we send our BYE -->
+ <ereg regexp="(;tag=.*)"
+ header="From:"
+ search_in="hdr"
+ check_it="true"
+ assign_to="remote_tag"/>
+ <!-- Save the From user portion of URI. We'll need it when we send our BYE -->
+ <ereg regexp="(sip:bob)"
+ header="From:"
+ search_in="hdr"
+ check_it="true"
+ assign_to="remote_user"/>
+ <!-- Check the Referred-By header. -->
+ <ereg regexp="sip:alice at 127.0.0.2:5060"
+ header="Referred-By"
+ search_in="hdr"
+ check_it="true"
+ assign_to="referred_by"/>
+ </action>
+ </recv>
+
+ <!-- Answer inbound call -->
+ <send retrans="500">
+ <![CDATA[
+
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:];tag=[pid]SIPpTag[call_number]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: <sip:charlie@[local_ip]:[local_port];transport=[transport]>
+ Content-Type: application/sdp
+ Content-Length: [len]
+
+ v=0
+ o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
+ s=-
+ c=IN IP[media_ip_type] [media_ip]
+ t=0 0
+ m=audio [custom_media_port] RTP/AVP 0
+ a=rtpmap:0 PCMU/8000
+
+ ]]>
+ </send>
+
+ <recv request="ACK"
+ rtd="true"
+ crlf="true">
+ </recv>
+
+ <!-- Send audio -->
+ <nop>
+ <action>
+ <exec rtp_stream="lib/python/asterisk/audio.ulaw,1,0"/>
+ </action>
+ </nop>
+
+ <!-- Allow 5s of audio to be sent to bob -->
+ <pause milliseconds="1000" />
+ <nop>
+ <action>
+ <exec rtp_stream="pause" />
+ </action>
+ </nop>
+
+ <send retrans="0">
+ <![CDATA[
+
+ BYE [$remote_user]@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: <sip:charlie@[local_ip]:[local_port]>;tag=[pid]SIPpTag[call_number]
+ To: <[$remote_user]@[remote_ip]:[remote_port]>[$remote_tag]
+ Call-ID: [call_id]
+ CSeq: [cseq] BYE
+ Contact: sip:charlie@[local_ip]:[local_port]
+ Max-Forwards: 70
+ Subject: Performance Test
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+ <recv response="200" timeout="2000" crlf="true">
+ </recv>
+
+ <ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>
+
+ <CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>
+
+ <Reference variables="referred_by" />
+
+</scenario>
+
diff --git a/tests/channels/pjsip/transfers/blind_transfer/caller_with_hold_481/test-config.yaml b/tests/channels/pjsip/transfers/blind_transfer/caller_with_hold_481/test-config.yaml
new file mode 100644
index 0000000..903272a
--- /dev/null
+++ b/tests/channels/pjsip/transfers/blind_transfer/caller_with_hold_481/test-config.yaml
@@ -0,0 +1,108 @@
+testinfo:
+ summary: 'Test SIP Blind Transfer (caller transfers with hold and a 481)'
+ description: |
+ 'This test verifies a SIP Blind transfer with putting the callee on
+ hold before the transfer occurs. This uses a SIPp instance each for
+ "Alice", "Bob", and "Charlie". Alice calls Bob through Asterisk. Alice
+ puts Bob on hold and Alice then blind transfers Bob to Charlie.
+ Charlie's dialplan sends a Progress to Alice but Alice sends a BYE
+ then a 481 reponse to the NOTIFY 183 sipfrag because the subscription
+ no longer exists.'
+
+properties:
+ dependencies:
+ - python : 'twisted'
+ - python : 'starpy'
+ - asterisk : 'app_dial'
+ - asterisk : 'res_pjsip'
+ - sipp :
+ version : 'v3.4.1'
+ tags:
+ - pjsip
+ - transfer
+
+test-modules:
+ add-test-to-search-path: 'True'
+ test-object:
+ config-section: test-case-config
+ typename: 'sipp.SIPpTestCase'
+ modules:
+ -
+ config-section: 'ami-config'
+ typename: 'ami.AMIEventModule'
+
+test-case-config:
+ memcheck-delay-stop: 7
+ connect-ami: 'True'
+ fail-on-any: False
+ test-iterations:
+ # First iteration
+ -
+ scenarios:
+ # Charlie receives transfered call and sends audio to Bob.
+ - { 'key-args': {'scenario': 'charlie.xml', '-p': '5060', '-i': '127.0.0.4', '-timeout': '20s', '-mi': '127.0.0.4'},
+ 'ordered-args': ['-nd', '-timeout_error', '-key', 'custom_media_port', '6004'] }
+ # Bob receives call from Alice and sends audio.
+ - { 'key-args': {'scenario': 'bob.xml', '-p': '5060', '-i': '127.0.0.3', '-s': 'alice', '-timeout': '20s', '-mi': '127.0.0.3'},
+ 'ordered-args': ['-nd', '-timeout_error', '-key', 'custom_media_port', '6004'] }
+ # Alice calls Bob and sends audio. Alice then attempts to blind transfer Bob to Charlie.
+ - { 'key-args': {'scenario': 'alice.xml', '-p': '5060', '-i': '127.0.0.2', '-s': 'bob', '-timeout': '20s', '-mi': '127.0.0.2'},
+ 'ordered-args': ['-nd', '-timeout_error', '-key', 'custom_media_port', '6004'] }
+
+ami-config:
+ -
+ type: 'headermatch'
+ conditions:
+ match:
+ Event: 'MusicOnHoldStart'
+ Channel: 'PJSIP/bob-.{8}'
+ count: 1
+ -
+ type: 'headermatch'
+ conditions:
+ match:
+ Event: 'MusicOnHoldStop'
+ Channel: 'PJSIP/bob-.{8}'
+ count: 1
+ -
+ type: 'headermatch'
+ conditions:
+ match:
+ Event: 'VarSet'
+ Variable: 'SIPTRANSFER'
+ Value: 'yes'
+ count: 1
+ -
+ type: 'headermatch'
+ conditions:
+ match:
+ Event: 'VarSet'
+ Channel: 'PJSIP/bob-.{8}'
+ Variable: 'SIPREFERRINGCONTEXT'
+ Value: 'transfertest'
+ count: 1
+ -
+ type: 'headermatch'
+ conditions:
+ match:
+ Event: 'VarSet'
+ Channel: 'PJSIP/bob-.{8}'
+ Variable: '_{0,2}SIPREFERREDBYHDR'
+ Value: 'sip:alice at 127.0.0.2:5060'
+ count: 1
+ -
+ type: 'headermatch'
+ conditions:
+ match:
+ Event: 'VarSet'
+ Variable: 'SIPREFERTOHDR'
+ Value: 'sip:charlie at 127.0.0.1'
+ count: 1
+ -
+ type: 'headermatch'
+ conditions:
+ match:
+ Event: 'BlindTransfer'
+ TransfererChannel: 'PJSIP/alice-.{8}'
+ count: 1
+
diff --git a/tests/channels/pjsip/transfers/blind_transfer/tests.yaml b/tests/channels/pjsip/transfers/blind_transfer/tests.yaml
index 2c24a89..39a3cca 100644
--- a/tests/channels/pjsip/transfers/blind_transfer/tests.yaml
+++ b/tests/channels/pjsip/transfers/blind_transfer/tests.yaml
@@ -7,6 +7,7 @@
- test: 'caller_direct_media'
- test: 'caller_refer_only'
- test: 'caller_with_hold'
+ - test: 'caller_with_hold_481'
- test: 'caller_with_hold_drop_options'
- test: 'disallow'
- test: 'goto_on_blindxfr'
--
To view, visit https://gerrit.asterisk.org/c/testsuite/+/15669
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: testsuite
Gerrit-Branch: 18
Gerrit-Change-Id: Iee0e5c4fd31b4d4f4bc833391d972ef87ecd902e
Gerrit-Change-Number: 15669
Gerrit-PatchSet: 2
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210323/bea6ba1f/attachment-0001.html>
More information about the asterisk-code-review
mailing list