<p>Jenkins2 <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/6956">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Jenkins2: Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">channels/pjsip/transport/reuse: Tests for reuse of TCP transports.<br><br>These tests check to see if the TCP transport that was used to register<br>the endpoint is reused.  The tests depend upon the rewrite_contact option<br>because the REGISTERed contact points to a nonexistent location.  If the<br>transport isn't reused then any SIP request sent by Asterisk will fail and<br>cause the test to fail.<br><br>Change-Id: Id89af15fb3e7a63bd58d6115d923cb30a07d99ae<br>---<br>A tests/channels/pjsip/transport/reuse/invite/configs/ast1/extensions.conf<br>A tests/channels/pjsip/transport/reuse/invite/configs/ast1/pjsip.conf<br>A tests/channels/pjsip/transport/reuse/invite/sipp/invite.xml<br>A tests/channels/pjsip/transport/reuse/invite/sipp/register.xml<br>A tests/channels/pjsip/transport/reuse/invite/test-config.yaml<br>A tests/channels/pjsip/transport/reuse/notify/configs/ast1/extensions.conf<br>A tests/channels/pjsip/transport/reuse/notify/configs/ast1/pjsip.conf<br>A tests/channels/pjsip/transport/reuse/notify/configs/ast1/voicemail.conf<br>A tests/channels/pjsip/transport/reuse/notify/sipp/initial_notify.xml<br>A tests/channels/pjsip/transport/reuse/notify/sipp/reg_sub.xml<br>A tests/channels/pjsip/transport/reuse/notify/test-config.yaml<br>A tests/channels/pjsip/transport/reuse/options/configs/ast1/pjsip.conf<br>A tests/channels/pjsip/transport/reuse/options/sipp/options.xml<br>A tests/channels/pjsip/transport/reuse/options/sipp/register.xml<br>A tests/channels/pjsip/transport/reuse/options/test-config.yaml<br>A tests/channels/pjsip/transport/reuse/tests.yaml<br>M tests/channels/pjsip/transport/tests.yaml<br>17 files changed, 793 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/tests/channels/pjsip/transport/reuse/invite/configs/ast1/extensions.conf b/tests/channels/pjsip/transport/reuse/invite/configs/ast1/extensions.conf<br>new file mode 100644<br>index 0000000..950774c<br>--- /dev/null<br>+++ b/tests/channels/pjsip/transport/reuse/invite/configs/ast1/extensions.conf<br>@@ -0,0 +1,20 @@<br>+[answered_routine]<br>+exten = s,1,NoOp()<br>+same = n,UserEvent(CallAnswered)<br>+same = n,SoftHangup(${CHANNEL(name)})<br>+same = n,Return()<br>+<br>+[default]<br>+; Wait for alice to register before we try to call alice.<br>+exten = registration_wait,1,NoOp()<br>+same = n(loop),GotoIf($["${DEVICE_STATE(PJSIP/alice)}"="NOT_INUSE"]?registered)<br>+same = n,Wait(0.25)<br>+same = n,Goto(loop)<br>+same = n(registered),Answer()<br>+same = n,Echo()<br>+same = n,Hangup()<br>+<br>+exten = alice,1,NoOp()<br>+same = n,Dial(PJSIP/alice,,U(answered_routine))<br>+same = n,Hangup()<br>+<br>diff --git a/tests/channels/pjsip/transport/reuse/invite/configs/ast1/pjsip.conf b/tests/channels/pjsip/transport/reuse/invite/configs/ast1/pjsip.conf<br>new file mode 100644<br>index 0000000..cbfd5b7<br>--- /dev/null<br>+++ b/tests/channels/pjsip/transport/reuse/invite/configs/ast1/pjsip.conf<br>@@ -0,0 +1,24 @@<br>+[global]<br>+type=global<br>+debug=yes<br>+<br>+[local-transport-5066]<br>+type=transport<br>+bind=127.0.0.1:5066<br>+protocol=tcp<br>+<br>+[local-transport]<br>+type=transport<br>+bind=127.0.0.1<br>+protocol=tcp<br>+<br>+[alice]<br>+type=endpoint<br>+allow=g722,ulaw,alaw<br>+context=default<br>+aors=alice<br>+rewrite_contact=yes<br>+<br>+[alice]<br>+type=aor<br>+max_contacts=5<br>diff --git a/tests/channels/pjsip/transport/reuse/invite/sipp/invite.xml b/tests/channels/pjsip/transport/reuse/invite/sipp/invite.xml<br>new file mode 100644<br>index 0000000..31f985d<br>--- /dev/null<br>+++ b/tests/channels/pjsip/transport/reuse/invite/sipp/invite.xml<br>@@ -0,0 +1,62 @@<br>+<?xml version="1.0" encoding="ISO-8859-1" ?><br>+<!DOCTYPE scenario SYSTEM "sipp.dtd"><br>+<br>+<scenario name="UAS Test transport"><br>+       <recv request="INVITE"><br>+              <action><br>+                       <ereg regexp="127.0.0.1:5066;rport" search_in="hdr" header="Via"<br>+                            check_it="true" assign_to="1" /><br>+              </action><br>+      </recv><br>+<br>+     <send retrans="500"><br>+         <![CDATA[<br>+                 SIP/2.0 200 OK<br>+                       [last_Via:]<br>+                  [last_From:]<br>+                 [last_To:];tag=[call_number]<br>+                 [last_Call-ID:]<br>+                      [last_CSeq:]<br>+                 Contact: <sip:[local_ip]:5062;transport=[transport]><br>+                   Content-Type: application/sdp<br>+                        Content-Length: [len]<br>+<br>+                     v=0<br>+                  o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]<br>+                  s=-<br>+                  c=IN IP[media_ip_type] [media_ip]<br>+                    t=0 0<br>+                        m=audio [media_port] RTP/AVP 0<br>+                       a=rtpmap:0 PCMU/8000<br>+         ]]><br>+       </send><br>+<br>+     <recv request="ACK"><br>+         <action><br>+                       <ereg regexp="127.0.0.1:5066;rport" search_in="hdr" header="Via"<br>+                            check_it="true" assign_to="2" /><br>+              </action><br>+      </recv><br>+<br>+     <recv request="BYE" crlf="true"><br>+           <action><br>+                       <ereg regexp="127.0.0.1:5066;rport" search_in="hdr" header="Via"<br>+                            check_it="true" assign_to="3" /><br>+              </action><br>+      </recv><br>+<br>+     <send retrans="500"><br>+         <![CDATA[<br>+                 SIP/2.0 200 OK<br>+                       [last_Via:]<br>+                  [last_From:]<br>+                 [last_To:];tag=[call_number]<br>+                 [last_Call-ID:]<br>+                      [last_CSeq:]<br>+                 Contact: <sip:[local_ip]:5062;transport=[transport]><br>+                   Content-Length: 0<br>+            ]]><br>+       </send><br>+<br>+     <Reference variables="1,2,3" /><br>+</scenario><br>diff --git a/tests/channels/pjsip/transport/reuse/invite/sipp/register.xml b/tests/channels/pjsip/transport/reuse/invite/sipp/register.xml<br>new file mode 100644<br>index 0000000..c1c2d2a<br>--- /dev/null<br>+++ b/tests/channels/pjsip/transport/reuse/invite/sipp/register.xml<br>@@ -0,0 +1,43 @@<br>+<?xml version="1.0" encoding="ISO-8859-1" ?><br>+<!DOCTYPE scenario SYSTEM "sipp.dtd"><br>+<br>+<scenario name="UAS Test transport"><br>+       <send><br>+         <![CDATA[<br>+                 REGISTER sip:[remote_ip]:[remote_port] SIP/2.0<br>+                       Via: SIP/2.0/[transport] [local_ip]:5062;rport;branch=[branch]<br>+                       From: "[service]" <sip:[service]@[local_ip]:5062>;tag=[pid]SIPpTag00[call_number]<br>+                    To: "[service]" <sip:[service]@[remote_ip]:[remote_port]><br>+                    Call-ID: [call_id]<br>+                   CSeq: [cseq] REGISTER<br>+                        Max-Forwards: 70<br>+                     Expires: 60<br>+                  Contact: <sip:[service]@[local_ip]:5062>;transport=[transport]<br>+                 Subject: Transport reuse Test<br>+                        Content-Length: 0<br>+            ]]><br>+       </send><br>+<br>+     <recv response="200" crlf="true" /><br>+<br>+     <pause milliseconds="4000"/><br>+<br>+      <send><br>+         <![CDATA[<br>+                 REGISTER sip:[remote_ip]:[remote_port] SIP/2.0<br>+                       Via: SIP/2.0/[transport] [local_ip]:5062;rport;branch=[branch]<br>+                       From: "[service]" <sip:[service]@[local_ip]:5062>;tag=[pid]SIPpTag00[call_number]<br>+                    To: "[service]" <sip:[service]@[remote_ip]:[remote_port]><br>+                    Call-ID: [call_id]<br>+                   CSeq: [cseq] REGISTER<br>+                        Max-Forwards: 70<br>+                     Expires: 0<br>+                   Contact: <sip:[service]@[local_ip]:5062>;transport=[transport]<br>+                 Subject: Transport reuse Test<br>+                        Content-Length: 0<br>+            ]]><br>+       </send><br>+<br>+     <recv response="200" crlf="true" /><br>+</scenario><br>+<br>diff --git a/tests/channels/pjsip/transport/reuse/invite/test-config.yaml b/tests/channels/pjsip/transport/reuse/invite/test-config.yaml<br>new file mode 100644<br>index 0000000..77f4d2c<br>--- /dev/null<br>+++ b/tests/channels/pjsip/transport/reuse/invite/test-config.yaml<br>@@ -0,0 +1,96 @@<br>+testinfo:<br>+    summary:     'Tests reusing transport on INVITE'<br>+    description: |<br>+        "Two transports are defined, the first on port 5066 and the other<br>+        (the default) on 5060.  The aor it registers with sends the INVITE.<br>+        The outgoing call waits for the endpoint to register before placing<br>+        the call to the endpoint.  If the call gets answered then the<br>+        transport was reused as nothing will be listening for a new transport<br>+        connection.<br>+<br>+        * Send REGISTER<br>+        * In the out-of-call scenario file, check the INVITE Via<br>+          specifies 5066 as the port.<br>+        * Send unREGISTER<br>+        "<br>+<br>+properties:<br>+    minversion: ['13.18.0', '14.7.0', '15.1.0']<br>+    dependencies:<br>+        - buildoption: 'TEST_FRAMEWORK'<br>+        - sipp :<br>+            version : 'v3.0'<br>+        - python: 'twisted'<br>+        - python: 'starpy'<br>+        - asterisk: 'app_dial'<br>+        - asterisk: 'app_echo'<br>+        - asterisk: 'app_stack'<br>+        - asterisk: 'app_softhangup'<br>+        - asterisk: 'app_userevent'<br>+        - asterisk: 'func_channel'<br>+        - asterisk: 'res_pjsip'<br>+    tags:<br>+        - pjsip<br>+<br>+test-modules:<br>+    test-object:<br>+        -<br>+            config-section: sipp-config<br>+            typename: 'sipp.SIPpTestCase'<br>+    modules:<br>+        -<br>+            config-section: originator-config<br>+            typename: 'pluggable_modules.Originator'<br>+        -<br>+            config-section: 'ami-config'<br>+            typename: 'ami.AMIEventModule'<br>+<br>+sipp-config:<br>+    reactor-timeout: 15<br>+    fail-on-any: True<br>+    test-iterations:<br>+        -<br>+            scenarios:<br>+                - { 'key-args': {'scenario': 'register.xml',<br>+                '-oocsf': 'invite.xml',<br>+                '-p': '5061', '-s': 'alice', '-t': 't1'},<br>+                'target': '127.0.0.1:5066'}<br>+<br>+originator-config:<br>+    trigger: 'ami_connect'<br>+    ignore-originate-failure: 'no'<br>+    id: '0'<br>+    channel: 'Local/registration_wait@default'<br>+    context: 'default'<br>+    exten: 'alice'<br>+    priority: '1'<br>+    async: 'True'<br>+<br>+ami-config:<br>+    -<br>+        type: 'headermatch'<br>+        id: '0'<br>+        conditions:<br>+            match:<br>+                Event: 'TestEvent'<br>+                State: 'AOR_CONTACT_ADDED'<br>+                AOR: 'alice'<br>+        count: '1'<br>+    -<br>+        type: 'headermatch'<br>+        id: '0'<br>+        conditions:<br>+            match:<br>+                Event: 'UserEvent'<br>+                UserEvent: 'CallAnswered'<br>+        count: '1'<br>+    -<br>+        type: 'headermatch'<br>+        id: '0'<br>+        conditions:<br>+            match:<br>+                Event: 'TestEvent'<br>+                State: 'AOR_CONTACT_REMOVED'<br>+                AOR: 'alice'<br>+        count: '1'<br>+<br>diff --git a/tests/channels/pjsip/transport/reuse/notify/configs/ast1/extensions.conf b/tests/channels/pjsip/transport/reuse/notify/configs/ast1/extensions.conf<br>new file mode 100644<br>index 0000000..6f22648<br>--- /dev/null<br>+++ b/tests/channels/pjsip/transport/reuse/notify/configs/ast1/extensions.conf<br>@@ -0,0 +1,5 @@<br>+[default]<br>+exten = 1000,hint,PJSIP/1000<br>+exten = 1000,1,NoOp()<br>+same = n,Hangup()<br>+<br>diff --git a/tests/channels/pjsip/transport/reuse/notify/configs/ast1/pjsip.conf b/tests/channels/pjsip/transport/reuse/notify/configs/ast1/pjsip.conf<br>new file mode 100644<br>index 0000000..cce5c32<br>--- /dev/null<br>+++ b/tests/channels/pjsip/transport/reuse/notify/configs/ast1/pjsip.conf<br>@@ -0,0 +1,34 @@<br>+[global]<br>+type=global<br>+debug=yes<br>+<br>+[local-transport-5066]<br>+type=transport<br>+bind=127.0.0.1:5066<br>+protocol=tcp<br>+<br>+[local-transport]<br>+type=transport<br>+bind=127.0.0.1<br>+protocol=tcp<br>+<br>+[alice]<br>+type=endpoint<br>+allow=g722,ulaw,alaw<br>+context=default<br>+aors=alice<br>+auth=alice<br>+mailboxes=1000@default<br>+mwi_subscribe_replaces_unsolicited=no<br>+rewrite_contact=yes<br>+<br>+[alice]<br>+type=aor<br>+max_contacts=5<br>+mailboxes=1000e@default<br>+<br>+[alice]<br>+type=auth<br>+auth_type=userpass<br>+username=alice<br>+password=password<br>diff --git a/tests/channels/pjsip/transport/reuse/notify/configs/ast1/voicemail.conf b/tests/channels/pjsip/transport/reuse/notify/configs/ast1/voicemail.conf<br>new file mode 100644<br>index 0000000..253c745<br>--- /dev/null<br>+++ b/tests/channels/pjsip/transport/reuse/notify/configs/ast1/voicemail.conf<br>@@ -0,0 +1,2 @@<br>+[default]<br>+1000 => 4242,Example Mailbox<br>diff --git a/tests/channels/pjsip/transport/reuse/notify/sipp/initial_notify.xml b/tests/channels/pjsip/transport/reuse/notify/sipp/initial_notify.xml<br>new file mode 100644<br>index 0000000..e497c1e<br>--- /dev/null<br>+++ b/tests/channels/pjsip/transport/reuse/notify/sipp/initial_notify.xml<br>@@ -0,0 +1,34 @@<br>+<?xml version="1.0" encoding="ISO-8859-1" ?><br>+<!DOCTYPE scenario SYSTEM "sipp.dtd"><br>+<br>+<scenario name="Out-of-Call NOTIFY after REGISTER"><br>+        <recv request="NOTIFY"><br>+              <action><br>+                       <ereg regexp="127.0.0.1:5066;rport" search_in="hdr" header="Via"<br>+                            assign_to="1" /><br>+                </action><br>+      </recv><br>+<br>+     <!-- ereg 'check_it' doesn't work in an out-of-call scenario file because there's<br>+         no call to mark as failed so we have to explicitly kill sipp if the regex<br>+            didn't match. --><br>+<br>+  <nop condexec="1" condexec_inverse="true"><br>+         <action><br>+                       <exec int_cmd="stop_now" /><br>+          </action><br>+      </nop><br>+<br>+      <send><br>+         <![CDATA[<br>+                 SIP/2.0 200 OK<br>+                       [last_Via:]<br>+                  [last_From:]<br>+                 [last_To:]<br>+                   [last_Call-ID:]<br>+                      [last_CSeq:]<br>+                 Contact: <sip:[local_ip]:5062;transport=[transport]><br>+                   Content-Length: 0<br>+            ]]><br>+       </send><br>+</scenario><br>diff --git a/tests/channels/pjsip/transport/reuse/notify/sipp/reg_sub.xml b/tests/channels/pjsip/transport/reuse/notify/sipp/reg_sub.xml<br>new file mode 100644<br>index 0000000..7211e02<br>--- /dev/null<br>+++ b/tests/channels/pjsip/transport/reuse/notify/sipp/reg_sub.xml<br>@@ -0,0 +1,191 @@<br>+<?xml version="1.0" encoding="ISO-8859-1" ?><br>+<!DOCTYPE scenario SYSTEM "sipp.dtd"><br>+<br>+<scenario name="REGISTER, SUBSCRIBE, unSUBSCRIBE, unREGISTER"><br>+ <send><br>+         <![CDATA[<br>+                 REGISTER sip:[remote_ip]:[remote_port] SIP/2.0<br>+                       Via: SIP/2.0/[transport] [local_ip]:5062;rport;branch=[branch]<br>+                       From: "[service]" <sip:[service]@[local_ip]:5062>;tag=[pid]SIPpTag00[call_number]<br>+                    To: "[service]" <sip:[service]@[remote_ip]:[remote_port]><br>+                    Call-ID: [call_id]<br>+                   CSeq: 1 REGISTER<br>+                     Max-Forwards: 70<br>+                     Expires: 60<br>+                  Contact: <sip:[service]@[local_ip]:5062>;transport=[transport]<br>+                 Subject: Performance Test<br>+                    Content-Length: 0<br>+            ]]><br>+       </send><br>+<br>+     <recv response="401" auth="true" /><br>+<br>+     <send><br>+         <![CDATA[<br>+                 REGISTER sip:[remote_ip]:[remote_port] SIP/2.0<br>+                       Via: SIP/2.0/[transport] [local_ip]:5062;rport;branch=[branch]<br>+                       From: "[service]" <sip:[service]@[local_ip]:5062>;tag=[pid]SIPpTag00[call_number]<br>+                    To: "[service]" <sip:[service]@[remote_ip]:[remote_port]><br>+                    Call-ID: [call_id]<br>+                   CSeq: [cseq] REGISTER<br>+                        Max-Forwards: 70<br>+                     Expires: 60<br>+                  Contact: <sip:[service]@[local_ip]:5062>;transport=[transport]<br>+                 Subject: Performance Test<br>+                    [authentication]<br>+                     Content-Length: 0<br>+            ]]><br>+       </send><br>+<br>+     <recv response="200" crlf="true" /><br>+        <pause milliseconds="500" /><br>+<br>+      <send retrans="500"><br>+         <![CDATA[<br>+                 SUBSCRIBE sip:[mbx]@[remote_ip]:[remote_port] SIP/2.0<br>+                        Via: SIP/2.0/[transport] [local_ip]:5062;rport;branch=[branch]<br>+                       From: "[service]" <sip:[service]@[local_ip]:5062>;tag=[pid]SIPpTag00[call_number]<br>+                    To: <sip:[service]@[remote_ip]:[remote_port]><br>+                  Contact: <sip:[service]@[local_ip]:5062><br>+                       Call-ID: [call_id]<br>+                   CSeq: [cseq] SUBSCRIBE<br>+                       Max-Forwards: 70<br>+                     Event: presence<br>+                      Expires: 10<br>+                  Supported: replaces, 100rel, timer, norefersub<br>+                       Accept: application/pidf+xml, application/xpidf+xml, application/simple-message-summary<br>+                      Allow-Events: presence, message-summary, refer<br>+                       Content-Length: 0<br>+            ]]><br>+       </send><br>+<br>+     <recv response="401" auth="true" /><br>+<br>+     <send retrans="500"><br>+         <![CDATA[<br>+                 SUBSCRIBE sip:[mbx]@[remote_ip]:[remote_port] SIP/2.0<br>+                        Via: SIP/2.0/[transport] [local_ip]:5062;rport;branch=[branch]<br>+                       From: "[service]" <sip:[service]@[local_ip]:5062>;tag=[pid]SIPpTag00[call_number]<br>+                    To: <sip:[service]@[remote_ip]:[remote_port]><br>+                  Contact: <sip:[service]@[local_ip]:5062><br>+                       Call-ID: [call_id]<br>+                   CSeq: [cseq] SUBSCRIBE<br>+                       Max-Forwards: 70<br>+                     Event: presence<br>+                      Expires: 10<br>+                  Supported: replaces, 100rel, timer, norefersub<br>+                       Accept: application/pidf+xml, application/xpidf+xml, application/simple-message-summary<br>+                      Allow-Events: presence, message-summary, refer<br>+                       [authentication]<br>+                     Content-Length: 0<br>+            ]]><br>+       </send><br>+<br>+     <recv response="200" crlf="true" /><br>+<br>+     <recv request="NOTIFY"><br>+              <action><br>+                       <ereg regexp="127.0.0.1:5066;rport" search_in="hdr" header="Via"<br>+                            check_it="true" assign_to="1" /><br>+              </action><br>+      </recv><br>+        <Reference variables="1" /><br>+<br>+       <send crlf="true"><br>+           <![CDATA[<br>+                 SIP/2.0 200 OK<br>+                       [last_Via:]<br>+                  [last_From:]<br>+                 [last_To:]<br>+                   [last_Call-ID:]<br>+                      [last_CSeq:]<br>+                 Contact: <sip:[local_ip]:5062;transport=[transport]><br>+                   Content-Length: 0<br>+            ]]><br>+       </send><br>+<br>+     <pause milliseconds="500" /><br>+<br>+      <send retrans="500"><br>+         <![CDATA[<br>+                 SUBSCRIBE sip:[mbx]@[remote_ip]:[remote_port] SIP/2.0<br>+                        Via: SIP/2.0/[transport] [local_ip]:5062;rport;branch=[branch]<br>+                       From: "[service]" <sip:[service]@[local_ip]:5062>;tag=[pid]SIPpTag00[call_number]<br>+                    To: <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]<br>+                  Contact: <sip:[service]@[local_ip]:5062><br>+                       Call-ID: [call_id]<br>+                   CSeq: [cseq] SUBSCRIBE<br>+                       Max-Forwards: 70<br>+                     Event: presence<br>+                      Expires: 0<br>+                   Supported: replaces, 100rel, timer, norefersub<br>+                       Accept: application/pidf+xml, application/xpidf+xml, application/simple-message-summary<br>+                      Allow-Events: presence, message-summary, refer<br>+                       Content-Length: 0<br>+            ]]><br>+       </send><br>+<br>+     <recv response="200" /><br>+<br>+   <recv request="NOTIFY"><br>+              <action><br>+                       <ereg regexp="127.0.0.1:5066;rport" search_in="hdr" header="Via"<br>+                            check_it="true" assign_to="2" /><br>+              </action><br>+      </recv><br>+        <Reference variables="2" /><br>+<br>+       <send crlf="true"><br>+           <![CDATA[<br>+                 SIP/2.0 200 OK<br>+                       [last_Via:]<br>+                  [last_From:]<br>+                 [last_To:]<br>+                   [last_Call-ID:]<br>+                      [last_CSeq:]<br>+                 Contact: <sip:[local_ip]:5062;transport=[transport]><br>+                   Content-Length: 0<br>+            ]]><br>+       </send><br>+<br>+     <pause milliseconds="1000" /><br>+<br>+     <send retrans="500"><br>+         <![CDATA[<br>+                 REGISTER sip:[remote_ip]:[remote_port] SIP/2.0<br>+                       Via: SIP/2.0/[transport] [local_ip]:5062;rport;branch=[branch]<br>+                       From: "[service]" <sip:[service]@[local_ip]:5062>;tag=[pid]SIPpTag00[call_number]<br>+                    To: "[service]" <sip:[service]@[remote_ip]:[remote_port]><br>+                    Call-ID: [call_id]<br>+                   CSeq: [cseq] REGISTER<br>+                        Max-Forwards: 70<br>+                     Expires: 0<br>+                   Contact: <sip:[service]@[local_ip]:5062>;transport=[transport]<br>+                 Subject: Performance Test<br>+                    Content-Length: 0<br>+            ]]><br>+       </send><br>+<br>+     <recv response="401" auth="true" /><br>+<br>+     <send><br>+         <![CDATA[<br>+                 REGISTER sip:[remote_ip]:[remote_port] SIP/2.0<br>+                       Via: SIP/2.0/[transport] [local_ip]:5062;rport;branch=[branch]<br>+                       From: "[service]" <sip:[service]@[local_ip]:5062>;tag=[pid]SIPpTag00[call_number]<br>+                    To: "[service]" <sip:[service]@[remote_ip]:[remote_port]><br>+                    Call-ID: [call_id]<br>+                   CSeq: [cseq] REGISTER<br>+                        Max-Forwards: 70<br>+                     Expires: 0<br>+                   Contact: <sip:[service]@[local_ip]:5062>;transport=[transport]<br>+                 Subject: Performance Test<br>+                    [authentication]<br>+                     Content-Length: 0<br>+            ]]><br>+       </send><br>+<br>+     <recv response="200" /><br>+<br>+   <pause milliseconds="1000" /><br>+</scenario><br>diff --git a/tests/channels/pjsip/transport/reuse/notify/test-config.yaml b/tests/channels/pjsip/transport/reuse/notify/test-config.yaml<br>new file mode 100644<br>index 0000000..797313e<br>--- /dev/null<br>+++ b/tests/channels/pjsip/transport/reuse/notify/test-config.yaml<br>@@ -0,0 +1,95 @@<br>+testinfo:<br>+    summary:     'Tests reusing transport on SUBSCRIBE NOTIFY'<br>+    description: |<br>+        "Two transports are defined, the first on port 5066 and the last<br>+        (the default) on 5060.  The endpoint/aor allows MWI subscription<br>+        and unsolicited MWI.<br>+        If the NOTIFY messages get answered then the transport was reused as<br>+        nothing will be listening for a new transport connection.<br>+<br>+        * Send REGISTER/auth<br>+        * In the out-of-call scenario file, check the unsolicited NOTIFY Via<br>+          specifies 5066 as the port.<br>+        * Send SUBSCRIBE/auth<br>+        * check the NOTIFY Via specifies 5066 as the port.<br>+        * Send unSUBSCRIBE/auth<br>+        * check the NOTIFY Via specifies 5066 as the port.<br>+        * Send unREGISTER/auth<br>+        "<br>+<br>+properties:<br>+    minversion: ['13.18.0', '14.7.0', '15.1.0']<br>+    dependencies:<br>+        - buildoption: 'TEST_FRAMEWORK'<br>+        - sipp :<br>+            version : 'v3.0'<br>+        - python: 'twisted'<br>+        - python: 'starpy'<br>+        - asterisk: 'res_pjsip'<br>+        - asterisk: 'res_pjsip_mwi'<br>+    tags:<br>+        - pjsip<br>+<br>+test-modules:<br>+    test-object:<br>+        -<br>+            config-section: sipp-config<br>+            typename: 'sipp.SIPpTestCase'<br>+    modules:<br>+        -<br>+            config-section: 'ami-config'<br>+            typename: 'ami.AMIEventModule'<br>+<br>+sipp-config:<br>+    reactor-timeout: 15<br>+    fail-on-any: True<br>+    test-iterations:<br>+        -<br>+            #<br>+            # The only way to test an unsolicited NOTIFY is in an out-of-call<br>+            # scenario file.<br>+            #<br>+            scenarios:<br>+                - { 'key-args': {'scenario': 'reg_sub.xml',<br>+                '-oocsf': 'initial_notify.xml',<br>+                '-p': '5061', '-s': 'alice', '-au': 'alice', '-ap': 'password', '-t': 't1'},<br>+                'ordered-args': ['-key', 'mbx', '1000'], 'target': '127.0.0.1:5066'}<br>+<br>+ami-config:<br>+    -<br>+        type: 'headermatch'<br>+        id: '0'<br>+        conditions:<br>+            match:<br>+                Event: 'TestEvent'<br>+                State: 'AOR_CONTACT_ADDED'<br>+                AOR: 'alice'<br>+        count: '1'<br>+    -<br>+        type: 'headermatch'<br>+        id: '0'<br>+        conditions:<br>+            match:<br>+                Event: 'TestEvent'<br>+                State: 'SUBSCRIPTION_ESTABLISHED'<br>+                Resource: '1000'<br>+        count: '1'<br>+    -<br>+        type: 'headermatch'<br>+        id: '0'<br>+        conditions:<br>+            match:<br>+                Event: 'TestEvent'<br>+                State: 'SUBSCRIPTION_TERMINATED'<br>+                Resource: '1000'<br>+        count: '1'<br>+    -<br>+        type: 'headermatch'<br>+        id: '0'<br>+        conditions:<br>+            match:<br>+                Event: 'TestEvent'<br>+                State: 'AOR_CONTACT_REMOVED'<br>+                AOR: 'alice'<br>+        count: '1'<br>+<br>diff --git a/tests/channels/pjsip/transport/reuse/options/configs/ast1/pjsip.conf b/tests/channels/pjsip/transport/reuse/options/configs/ast1/pjsip.conf<br>new file mode 100644<br>index 0000000..4223d88<br>--- /dev/null<br>+++ b/tests/channels/pjsip/transport/reuse/options/configs/ast1/pjsip.conf<br>@@ -0,0 +1,26 @@<br>+[global]<br>+type=global<br>+debug=yes<br>+max_initial_qualify_time=1<br>+<br>+[local-transport-5066]<br>+type=transport<br>+bind=127.0.0.1:5066<br>+protocol=tcp<br>+<br>+[local-transport]<br>+type=transport<br>+bind=127.0.0.1<br>+protocol=tcp<br>+<br>+[alice]<br>+type=endpoint<br>+allow=g722,ulaw,alaw<br>+context=default<br>+aors=alice<br>+rewrite_contact=yes<br>+<br>+[alice]<br>+type=aor<br>+max_contacts=5<br>+qualify_frequency=10<br>diff --git a/tests/channels/pjsip/transport/reuse/options/sipp/options.xml b/tests/channels/pjsip/transport/reuse/options/sipp/options.xml<br>new file mode 100644<br>index 0000000..2a866cd<br>--- /dev/null<br>+++ b/tests/channels/pjsip/transport/reuse/options/sipp/options.xml<br>@@ -0,0 +1,33 @@<br>+<?xml version="1.0" encoding="ISO-8859-1" ?><br>+<!DOCTYPE scenario SYSTEM "sipp.dtd"><br>+<br>+<scenario name="UAS Test transport"><br>+ <!-- ereg 'check_it' doesn't work in an out-of-call scenario file because<br>+             there's no call to mark as failed so we have to explicitly kill sipp if the<br>+              regex didn't match. --><br>+<br>+    <recv request="OPTIONS"><br>+             <action><br>+                       <ereg regexp="127.0.0.1:5066;rport" search_in="hdr" header="Via"<br>+                            check_it="true" assign_to="1" /><br>+              </action><br>+      </recv><br>+        <nop condexec="1" condexec_inverse="true"><br>+         <action><br>+                       <exec int_cmd="stop_now" /><br>+          </action><br>+      </nop><br>+<br>+      <send><br>+         <![CDATA[<br>+                 SIP/2.0 200 OK<br>+                       [last_Via:]<br>+                  [last_From:]<br>+                 [last_To:];tag=[call_number]<br>+                 [last_Call-ID:]<br>+                      [last_CSeq:]<br>+                 Contact: <sip:[local_ip]:5062;transport=[transport]><br>+                   Content-Length: 0<br>+            ]]><br>+       </send><br>+</scenario><br>diff --git a/tests/channels/pjsip/transport/reuse/options/sipp/register.xml b/tests/channels/pjsip/transport/reuse/options/sipp/register.xml<br>new file mode 100644<br>index 0000000..c1c2d2a<br>--- /dev/null<br>+++ b/tests/channels/pjsip/transport/reuse/options/sipp/register.xml<br>@@ -0,0 +1,43 @@<br>+<?xml version="1.0" encoding="ISO-8859-1" ?><br>+<!DOCTYPE scenario SYSTEM "sipp.dtd"><br>+<br>+<scenario name="UAS Test transport"><br>+      <send><br>+         <![CDATA[<br>+                 REGISTER sip:[remote_ip]:[remote_port] SIP/2.0<br>+                       Via: SIP/2.0/[transport] [local_ip]:5062;rport;branch=[branch]<br>+                       From: "[service]" <sip:[service]@[local_ip]:5062>;tag=[pid]SIPpTag00[call_number]<br>+                    To: "[service]" <sip:[service]@[remote_ip]:[remote_port]><br>+                    Call-ID: [call_id]<br>+                   CSeq: [cseq] REGISTER<br>+                        Max-Forwards: 70<br>+                     Expires: 60<br>+                  Contact: <sip:[service]@[local_ip]:5062>;transport=[transport]<br>+                 Subject: Transport reuse Test<br>+                        Content-Length: 0<br>+            ]]><br>+       </send><br>+<br>+     <recv response="200" crlf="true" /><br>+<br>+     <pause milliseconds="4000"/><br>+<br>+      <send><br>+         <![CDATA[<br>+                 REGISTER sip:[remote_ip]:[remote_port] SIP/2.0<br>+                       Via: SIP/2.0/[transport] [local_ip]:5062;rport;branch=[branch]<br>+                       From: "[service]" <sip:[service]@[local_ip]:5062>;tag=[pid]SIPpTag00[call_number]<br>+                    To: "[service]" <sip:[service]@[remote_ip]:[remote_port]><br>+                    Call-ID: [call_id]<br>+                   CSeq: [cseq] REGISTER<br>+                        Max-Forwards: 70<br>+                     Expires: 0<br>+                   Contact: <sip:[service]@[local_ip]:5062>;transport=[transport]<br>+                 Subject: Transport reuse Test<br>+                        Content-Length: 0<br>+            ]]><br>+       </send><br>+<br>+     <recv response="200" crlf="true" /><br>+</scenario><br>+<br>diff --git a/tests/channels/pjsip/transport/reuse/options/test-config.yaml b/tests/channels/pjsip/transport/reuse/options/test-config.yaml<br>new file mode 100644<br>index 0000000..284c8d3<br>--- /dev/null<br>+++ b/tests/channels/pjsip/transport/reuse/options/test-config.yaml<br>@@ -0,0 +1,80 @@<br>+testinfo:<br>+    summary:     'Tests reusing transport on OPTIONS'<br>+    description: |<br>+        "Two transports are defined, the first on port 5066 and the other<br>+        (the default) on 5060.  The aor it registers with sends the OPTIONS.<br>+        If the OPTIONS ping gets answered then the transport was reused as<br>+        nothing will be listening for a new transport connection.<br>+<br>+        * Send REGISTER<br>+        * In the out-of-call scenario file, check the OPTIONS Via<br>+          specifies 5066 as the port.<br>+        * Send unREGISTER<br>+        "<br>+<br>+properties:<br>+    minversion: ['13.18.0', '14.7.0', '15.1.0']<br>+    dependencies:<br>+        - buildoption: 'TEST_FRAMEWORK'<br>+        - sipp :<br>+            version : 'v3.0'<br>+        - python: 'twisted'<br>+        - python: 'starpy'<br>+        - asterisk: 'res_pjsip'<br>+    tags:<br>+        - pjsip<br>+<br>+test-modules:<br>+    test-object:<br>+        -<br>+            config-section: sipp-config<br>+            typename: 'sipp.SIPpTestCase'<br>+    modules:<br>+        -<br>+            config-section: 'ami-config'<br>+            typename: 'ami.AMIEventModule'<br>+<br>+sipp-config:<br>+    reactor-timeout: 15<br>+    fail-on-any: True<br>+    test-iterations:<br>+        -<br>+            #<br>+            # The only way to test a REGISTER and an OPTIONS is to put the<br>+            # OPTIONS in an out-of-call scenario file.<br>+            #<br>+            scenarios:<br>+                - { 'key-args': {'scenario': 'register.xml',<br>+                '-oocsf': 'options.xml',<br>+                '-p': '5061', '-s': 'alice', '-t': 't1'},<br>+                'target': '127.0.0.1:5066'}<br>+<br>+ami-config:<br>+    -<br>+        type: 'headermatch'<br>+        id: '0'<br>+        conditions:<br>+            match:<br>+                Event: 'TestEvent'<br>+                State: 'AOR_CONTACT_ADDED'<br>+                AOR: 'alice'<br>+        count: '1'<br>+    -<br>+        type: 'headermatch'<br>+        id: '0'<br>+        conditions:<br>+            match:<br>+                Event: 'TestEvent'<br>+                State: 'AOR_CONTACT_QUALIFY_RESULT'<br>+                Status: 'Reachable'<br>+        count: '1'<br>+    -<br>+        type: 'headermatch'<br>+        id: '0'<br>+        conditions:<br>+            match:<br>+                Event: 'TestEvent'<br>+                State: 'AOR_CONTACT_REMOVED'<br>+                AOR: 'alice'<br>+        count: '1'<br>+<br>diff --git a/tests/channels/pjsip/transport/reuse/tests.yaml b/tests/channels/pjsip/transport/reuse/tests.yaml<br>new file mode 100644<br>index 0000000..cfda588<br>--- /dev/null<br>+++ b/tests/channels/pjsip/transport/reuse/tests.yaml<br>@@ -0,0 +1,4 @@<br>+tests:<br>+    - test: 'invite'<br>+    - test: 'notify'<br>+    - test: 'options'<br>diff --git a/tests/channels/pjsip/transport/tests.yaml b/tests/channels/pjsip/transport/tests.yaml<br>index 811f55e..1fbc0c8 100644<br>--- a/tests/channels/pjsip/transport/tests.yaml<br>+++ b/tests/channels/pjsip/transport/tests.yaml<br>@@ -1,2 +1,3 @@<br> tests:<br>+    - dir: 'reuse'<br>     - dir: 'symmetric'<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/6956">change 6956</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/6956"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: testsuite </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: Id89af15fb3e7a63bd58d6115d923cb30a07d99ae </div>
<div style="display:none"> Gerrit-Change-Number: 6956 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Richard Mudgett <rmudgett@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>