From 948d729163126fb555df0c7e95f020ab96cc36cd Mon Sep 17 00:00:00 2001 From: George Joseph Date: Tue, 23 Jun 2026 08:44:13 -0600 Subject: [PATCH] attended_transfer/caller_local_blond: Make more reliable * Trying to figure out how the test actually works took most of the time. To make it easier to understand, instead of using names like referer, referee, etc. the scenarios are now named after our usual actors: alice, bob and charlie. * Numerous naming clarifications were made to the scenario files. * The test description has been re-written to include both a high-level and low-level flow. * Instead of having the 4 sipp scenarios all bind to 127.0.0.1 with different ports, they bind to 127.0.0.2, 3, 4, 5 port 5060. * The usual test failure was in the alice_calls_bob scenario when it's supposed to receive 2 sipfrag NOTIFYs. For some reason, sipp would occasionally just end the scenario after the first NOTIFY with no indication as to why. To get around this, alice_calls_bob.xml no longer explicitly deals with the NOTIFYs and instead lets sipp deal with them by virtue of the `-aa` option. * Also fixed an issue in sipp.py that prevented SIP packets from being output to the Asterisk logs when there was only 1 asterisk instance. --- lib/python/asterisk/sipp.py | 9 ++- .../configs/ast1/extensions.conf | 8 +-- .../configs/ast1/pjsip.conf | 12 ++-- .../sipp/{referer.xml => alice_calls_bob.xml} | 60 +++++------------- .../{referee.xml => alice_calls_charlie.xml} | 14 ++--- .../sipp/{uas.xml => bob.xml} | 6 +- .../sipp/{uas_hangup.xml => charlie.xml} | 10 +-- .../caller_local_blonde/test-config.yaml | 63 +++++++++++++------ 8 files changed, 90 insertions(+), 92 deletions(-) rename tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/sipp/{referer.xml => alice_calls_bob.xml} (81%) rename tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/sipp/{referee.xml => alice_calls_charlie.xml} (88%) rename tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/sipp/{uas.xml => bob.xml} (96%) rename tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/sipp/{uas_hangup.xml => charlie.xml} (95%) diff --git a/lib/python/asterisk/sipp.py b/lib/python/asterisk/sipp.py index a7bf5d539..74700e601 100644 --- a/lib/python/asterisk/sipp.py +++ b/lib/python/asterisk/sipp.py @@ -143,9 +143,9 @@ def run(self): """ super(SIPpTestCase, self).run() - for a in range(1, self.asterisk_instances): - self.ast[a-1].cli_exec('sip set debug on') - self.ast[a-1].cli_exec('pjsip set logger on') + for a in range(0, self.asterisk_instances): + self.ast[a].cli_exec('sip set debug on') + self.ast[a].cli_exec('pjsip set logger on') LOGGER.info("creating ami factory") if not isinstance(self.connect_ami, dict): @@ -556,6 +556,9 @@ def errReceived(self, data): # SIPp will send some 'normal' messages to stderr. Buffer them so we # can output them later if we want self.stderr.append(data) + LOGGER.debug("Received from SIPp scenario %s:\n %s" % (self._name, + data.decode('utf-8', 'ignore'))) + self.output += data.decode('utf-8', 'ignore') def processEnded(self, reason): """Override of ProcessProtocol.processEnded""" diff --git a/tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/configs/ast1/extensions.conf b/tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/configs/ast1/extensions.conf index 0031d35f1..0bc2a51dd 100644 --- a/tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/configs/ast1/extensions.conf +++ b/tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/configs/ast1/extensions.conf @@ -1,9 +1,9 @@ [default] -exten => call_c,1,NoOp() - same => n,Dial(PJSIP/charlie) +exten => bob,1,NoOp() + same => n,Dial(PJSIP/bob) same => n,Hangup() -exten => call_a,1,NoOp() - same => n,Dial(PJSIP/alice) +exten => charlie,1,NoOp() + same => n,Dial(PJSIP/charlie) same => n,Hangup() diff --git a/tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/configs/ast1/pjsip.conf b/tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/configs/ast1/pjsip.conf index 62bc07a36..0d3a97bca 100644 --- a/tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/configs/ast1/pjsip.conf +++ b/tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/configs/ast1/pjsip.conf @@ -9,15 +9,10 @@ context=default disallow=all allow=ulaw direct_media=no -aors=alice send_pai=yes send_rpid=yes callerid=Alice -[alice] -type=aor -contact=sip:alice@127.0.0.1:5068 - [bob] type=endpoint context=default @@ -27,6 +22,11 @@ direct_media=no send_pai=yes send_rpid=yes callerid=Bob +aors=bob + +[bob] +type=aor +contact=sip:bob@127.0.0.4:5060 [charlie] type=endpoint @@ -41,4 +41,4 @@ callerid=Charlie [charlie] type=aor -contact=sip:charlie@127.0.0.1:5067 +contact=sip:charlie@127.0.0.5:5060 diff --git a/tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/sipp/referer.xml b/tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/sipp/alice_calls_bob.xml similarity index 81% rename from tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/sipp/referer.xml rename to tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/sipp/alice_calls_bob.xml index ad6a0d302..c84243a90 100644 --- a/tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/sipp/referer.xml +++ b/tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/sipp/alice_calls_bob.xml @@ -22,13 +22,13 @@ ;tag=[call_number] - To: + From: ;tag=[call_number] + To: Call-ID: [call_id] CSeq: [cseq] INVITE - Contact: + Contact: Content-Type: application/sdp Max-Forwards: 70 Content-Length: [len] @@ -54,30 +54,31 @@ Max-Forwards: 70 Content-Length: 0 ]]> + + Contact: Content-Type: application/sdp Max-Forwards: 70 Content-Length: [len] @@ -103,13 +104,13 @@ Max-Forwards: 70 Content-Length: 0 @@ -152,55 +153,22 @@ + Contact: Max-Forwards: 70 Refer-to: <[$remote_contact]?Replaces=REMOTE[$callid_chunk_1]%40[$callid_chunk_2]%3Bto-tag%3D[$remote_to_tag]%3Bfrom-tag%3D[$remote_from_tag]> - Referred-By: sip:bob@[local_ip] + Referred-By: sip:alice@[local_ip] Content-Length: 0 ]]> - - - - Content-Length:0 - - ]]> - - - - - - - Content-Length:0 - - ]]> - - diff --git a/tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/sipp/referee.xml b/tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/sipp/alice_calls_charlie.xml similarity index 88% rename from tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/sipp/referee.xml rename to tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/sipp/alice_calls_charlie.xml index ad0285c35..38e663929 100644 --- a/tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/sipp/referee.xml +++ b/tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/sipp/alice_calls_charlie.xml @@ -32,13 +32,13 @@ ;tag=[call_number] - To: + From: ;tag=[call_number] + To: Call-ID: [call_id] CSeq: [cseq] INVITE - Contact: + Contact: Max-Forwards: 70 Content-Type: application/sdp Content-Length: [len] @@ -80,7 +80,7 @@ Call-ID: [$original_callid] Remote-To-Tag: [$to_tag] Remote-From-Tag: [$from_tag] - Remote-URI: sip:call_a@[remote_ip]:[remote_port] + Remote-URI: sip:charlie@[remote_ip]:[remote_port] ]]> @@ -89,13 +89,13 @@ Max-Forwards: 70 Content-Length: 0 diff --git a/tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/sipp/uas.xml b/tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/sipp/bob.xml similarity index 96% rename from tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/sipp/uas.xml rename to tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/sipp/bob.xml index b7b295182..0591d793d 100644 --- a/tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/sipp/uas.xml +++ b/tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/sipp/bob.xml @@ -84,12 +84,12 @@ - - - + diff --git a/tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/sipp/uas_hangup.xml b/tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/sipp/charlie.xml similarity index 95% rename from tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/sipp/uas_hangup.xml rename to tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/sipp/charlie.xml index 9f395b60a..68efdf2e5 100644 --- a/tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/sipp/uas_hangup.xml +++ b/tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/sipp/charlie.xml @@ -86,12 +86,12 @@ - - - ;tag=[call_number] + From: ;tag=[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] + Contact: Max-Forwards: 70 Subject: Performance Test Content-Length: 0 diff --git a/tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/test-config.yaml b/tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/test-config.yaml index cd0c6c4ec..1324856e0 100644 --- a/tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/test-config.yaml +++ b/tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_blonde/test-config.yaml @@ -4,20 +4,43 @@ testinfo: "Originate two SIP calls through Asterisk to remote endpoints and then have one originating call transfer the other via REFER with Replaces header. - The four SIPp scenarios involved perform the following actions: - SIPp #1 (referer.xml) calls through Asterisk to SIPp #2 (uas.xml) - SIPp #1 kicks off SIPp #3 (referee.xml) which calls SIPp #4 (uas_hangup.xml). - SIPp #3 passes call information back to SIPp #1. - Before SIPp #4 answers SIPp #1 initiates an attended transfer via REFER with Replaces information from SIPp #3. - SIPp #3 is hung up. - SIPp #1 hangs up. - SIPp #4 continues to ring until it answers. - SIPp #2 receives a connected line update and the values are checked. - SIPp #4 answers. - SIPp #2 and SIPp #4 are bridged. - SIPp #4 receives a connected line update and the values are checked. - SIPp #4 hangs up. - SIPp #2 is hung up." + High-level scenario: + Alice calls Bob. When he answers, Alice puts him on hold. + Alice calls Charlie. Before he answers, Alice does a REFER Bob->Charlie. + When Charlie answers he and Bob are bridged and Alice goes away. + + NOTE: sipp doesn't allow more than one dialog in a scenario file so Alice + is actually implemented in two scenario files: alice_calls_bob and alice_calls_charlie. + The two coordinate using sipp's 3pcc capability. + + Low-level flow: + alice_calls_bob starts by calling bob. + bob answers. + alice_calls_bob waits for a second then sends a reINVITE to put bob on hold. + alice_calls_bob does a sendCmd to start alice_calls_charlie then waits on a recvCmd from alice_calls_charlie. + charlie waits 5 seconds before answering. + alice_calls_charlie waits 1 second then does a sendCmd back to alice_calls_bob. + charlie is still waiting. + alice_calls_bob recvCmd returns. + alice_calls_bob does a REFER bob->charlie. + alice_calls_bob receives a 202 and 2 NOTIFYs. The NOTIFYs are handled automatically by sipp. + alice_calls_bob waits again on a recvCmd from alice_calls_charlie. + alice_calls_charlie gets a 603 and sends an ACK. + alice_calls_charlie does a sendCmd to alice_calls_bob. + alice_calls_charlie.xml ENDS. + alice_calls_bob.xml recvCmd returns. + alice_calls_bob.xml sends a BYE. + alice_calls_bob.xml receives a 481. + alice_calls_bob.xml ENDS. + charlie finally answers. + charlie gets an ACK followed by a reINVITE with Bob's callerID. + charlie sends a 200 and gets an ACK. + bob gets a reINVITE with Charlie's callerID. + bob sends a 200 and gets an ACK. + bob waits on a BYE. + charlie sends a BYE. + bob gets the BYE and ENDS. + charlie ENDS. test-modules: add-test-to-search-path: True @@ -34,10 +57,14 @@ test-object-config: test-iterations: - scenarios: - - { 'key-args': {'scenario':'uas.xml', '-p':'5067', '-m':'2', '-sleep': '2'} } - - { 'key-args': {'scenario':'uas_hangup.xml', '-p':'5068', '-m':'2', '-sleep': '2'} } - - { 'coordinated-sender': {'key-args': {'scenario':'referer.xml', '-p':'5066', '-sleep': '2'} }, - 'coordinated-receiver': {'key-args': {'scenario':'referee.xml', '-p':'5065'} } } + - { 'coordinated-sender': {'key-args': {'scenario':'alice_calls_bob.xml', '-i':'127.0.0.2', '-p':'5060', '-sleep': '2'}, + 'ordered-args': [ '-aa', '-bind_local' ] }, + 'coordinated-receiver': {'key-args': {'scenario':'alice_calls_charlie.xml', '-i':'127.0.0.3', '-p':'5060'}, + 'ordered-args': [ '-bind_local' ] } } + - { 'key-args': {'scenario':'bob.xml', '-i':'127.0.0.4', '-p':'5060', '-m':'2', '-sleep': '2'}, + 'ordered-args': [ '-bind_local' ] } + - { 'key-args': {'scenario':'charlie.xml', '-i':'127.0.0.5', '-p':'5060', '-m':'2', '-sleep': '2'}, + 'ordered-args': [ '-bind_local' ] } ami-config: -