[Asterisk-code-review] pjsip/rtp: Add test for bind rtp to media address (testsuite[master])

George Joseph asteriskteam at digium.com
Thu Jan 7 21:27:30 CST 2016


George Joseph has uploaded a new change for review.

  https://gerrit.asterisk.org/1934

Change subject: pjsip/rtp: Add test for bind_rtp_to_media_address
......................................................................

pjsip/rtp: Add test for bind_rtp_to_media_address

Tests that RTP packets originate from the media_address
when bind_rtp_to_media_address is set on the endpoint

ASTERISK-25632

Change-Id: If25d93339abc3ba8f6b141be9ed15932a918f637
---
A tests/channels/pjsip/rtp/bind_rtp_to_media_address/configs/ast1/extensions.conf
A tests/channels/pjsip/rtp/bind_rtp_to_media_address/configs/ast1/pjsip.conf
A tests/channels/pjsip/rtp/bind_rtp_to_media_address/configs/ast1/rtp.conf
A tests/channels/pjsip/rtp/bind_rtp_to_media_address/rtp.py
A tests/channels/pjsip/rtp/bind_rtp_to_media_address/sipp/bob.xml
A tests/channels/pjsip/rtp/bind_rtp_to_media_address/test-config.yaml
M tests/channels/pjsip/rtp/tests.yaml
7 files changed, 174 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/34/1934/1

diff --git a/tests/channels/pjsip/rtp/bind_rtp_to_media_address/configs/ast1/extensions.conf b/tests/channels/pjsip/rtp/bind_rtp_to_media_address/configs/ast1/extensions.conf
new file mode 100644
index 0000000..6121b9f
--- /dev/null
+++ b/tests/channels/pjsip/rtp/bind_rtp_to_media_address/configs/ast1/extensions.conf
@@ -0,0 +1,5 @@
+[default]
+exten => playtone,1,Answer()
+same => n,Playback(descending-2tone)
+same => n,Hangup()
+
diff --git a/tests/channels/pjsip/rtp/bind_rtp_to_media_address/configs/ast1/pjsip.conf b/tests/channels/pjsip/rtp/bind_rtp_to_media_address/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..1156c59
--- /dev/null
+++ b/tests/channels/pjsip/rtp/bind_rtp_to_media_address/configs/ast1/pjsip.conf
@@ -0,0 +1,23 @@
+[local-transport-template](!)
+type=transport
+bind=127.0.0.3:5060
+
+[local-transport-udp](local-transport-template)
+protocol=udp
+
+[endpoint-template-ipv4](!)
+type=endpoint
+context=default
+allow=!all,ulaw,alaw
+media_address=127.0.0.3
+bind_rtp_to_media_address=yes
+direct_media=no
+
+;== IPv4 & UDP ==
+[bob-ipv4-udp](endpoint-template-ipv4)
+aors=bob-ipv4-udp
+from_user=uut-ipv4-udp
+
+[bob-ipv4-udp]
+type=aor
+contact=sip:bob-ipv4-udp at 127.0.0.1:5062\;transport=udp
diff --git a/tests/channels/pjsip/rtp/bind_rtp_to_media_address/configs/ast1/rtp.conf b/tests/channels/pjsip/rtp/bind_rtp_to_media_address/configs/ast1/rtp.conf
new file mode 100644
index 0000000..c62eb86
--- /dev/null
+++ b/tests/channels/pjsip/rtp/bind_rtp_to_media_address/configs/ast1/rtp.conf
@@ -0,0 +1,4 @@
+[general]
+rtpstart=55220
+rtpend=55221
+;
diff --git a/tests/channels/pjsip/rtp/bind_rtp_to_media_address/rtp.py b/tests/channels/pjsip/rtp/bind_rtp_to_media_address/rtp.py
new file mode 100644
index 0000000..2c79e5c
--- /dev/null
+++ b/tests/channels/pjsip/rtp/bind_rtp_to_media_address/rtp.py
@@ -0,0 +1,29 @@
+'''
+Copyright (C) 2015, Fairview 5 Engineering, LLC
+George Joseph <george.joseph at fairview5.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+import logging
+
+from twisted.internet.protocol import DatagramProtocol
+from twisted.internet import reactor
+
+LOGGER = logging.getLogger(__name__)
+
+class RTP(DatagramProtocol):
+    packet_count = 0
+
+    def __init__(self, test_object):
+        self.test_object = test_object
+
+    def datagramReceived(self, data, (host, port)):
+        if self.packet_count == 0 and host != "127.0.0.3":
+            LOGGER.error("Received RTP from wrong ip address: %s %s" % (host,port))
+            self.test_object.set_passed(False)
+        self.packet_count += 1
+
+class PacketSourceCheck(object):
+    def __init__(self, module_config, test_object):
+        reactor.listenUDP(55225, RTP(test_object))
diff --git a/tests/channels/pjsip/rtp/bind_rtp_to_media_address/sipp/bob.xml b/tests/channels/pjsip/rtp/bind_rtp_to_media_address/sipp/bob.xml
new file mode 100644
index 0000000..52cb9e3
--- /dev/null
+++ b/tests/channels/pjsip/rtp/bind_rtp_to_media_address/sipp/bob.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="Just answer and wait for BYE">
+  <recv request="INVITE" crlf="true">
+  </recv>
+
+  <send>
+    <![CDATA[
+
+      SIP/2.0 180 Ringing
+      [last_Via:]
+      [last_From:]
+      [last_To:];tag=[pid]SIPpTag01[call_number]
+      [last_Call-ID:]
+      [last_CSeq:]
+      Contact: <sip:[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]SIPpTag01[call_number]
+      [last_Call-ID:]
+      [last_CSeq:]
+      Contact: <sip:[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 55225 RTP/AVP 0
+      a=rtpmap:0 PCMU/8000
+
+    ]]>
+  </send>
+
+  <recv request="ACK">
+  </recv>
+
+  <recv request="BYE">
+  </recv>
+
+  <send retrans="500">
+    <![CDATA[
+
+      SIP/2.0 200 OK
+      [last_Via:]
+      [last_From:]
+      [last_To:];tag=[pid]SIPpTag01[call_number]
+      [last_Call-ID:]
+      [last_CSeq:]
+      Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+      Content-Type: application/sdp
+      Content-Length: [len]
+
+    ]]>
+  </send>
+
+</scenario>
+
diff --git a/tests/channels/pjsip/rtp/bind_rtp_to_media_address/test-config.yaml b/tests/channels/pjsip/rtp/bind_rtp_to_media_address/test-config.yaml
new file mode 100644
index 0000000..e939705
--- /dev/null
+++ b/tests/channels/pjsip/rtp/bind_rtp_to_media_address/test-config.yaml
@@ -0,0 +1,42 @@
+testinfo:
+    summary:     'Tests bind_rtp_to_media_address'
+    description: |
+        'Asterisk calls bob with media_address set to 127.0.0.3 and
+         bind_rtp_to_media_address=yes.  PacketSourceCheck verifies that
+         the packets are coming from 127.0.0.3.'
+
+test-modules:
+    add-test-to-search-path: True
+    test-object:
+        config-section: sipp-config
+        typename: 'sipp.SIPpTestCase'
+    modules:
+        -
+            config-section: originator-config-ipv4-udp
+            typename: 'pluggable_modules.Originator'
+        -
+            typename: 'rtp.PacketSourceCheck'
+
+sipp-config:
+    fail-on-any: True
+    test-iterations:
+        -
+            scenarios:
+                - { 'key-args': {'scenario': 'bob.xml', '-i': '127.0.0.1', '-p': '5062'}}
+
+originator-config-ipv4-udp:
+    trigger: 'scenario_start'
+    ignore-originate-failure: 'no'
+    id: '0'
+    channel: 'PJSIP/bob-ipv4-udp'
+    context: 'default'
+    exten: 'playtone'
+    priority: '1'
+    async: 'True'
+
+properties:
+    minversion: '13.8.0'
+    dependencies:
+        - asterisk : 'res_pjsip'
+    tags:
+        - pjsip
diff --git a/tests/channels/pjsip/rtp/tests.yaml b/tests/channels/pjsip/rtp/tests.yaml
index 5d77214..872daa9 100644
--- a/tests/channels/pjsip/rtp/tests.yaml
+++ b/tests/channels/pjsip/rtp/tests.yaml
@@ -3,3 +3,4 @@
     - dir: 'rtp_keepalive'
     - test: 'timeout'
     - test: 'timeout_hold'
+    - test: 'bind_rtp_to_media_address'

-- 
To view, visit https://gerrit.asterisk.org/1934
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If25d93339abc3ba8f6b141be9ed15932a918f637
Gerrit-PatchSet: 1
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: George Joseph <george.joseph at fairview5.com>



More information about the asterisk-code-review mailing list