[asterisk-commits] res pjsip: Add base rtp keepalive test (testsuite[master])
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Jul 22 06:56:44 CDT 2015
Joshua Colp has submitted this change and it was merged.
Change subject: res_pjsip: Add base rtp_keepalive test
......................................................................
res_pjsip: Add base rtp_keepalive test
A call arrives from SIPp into Asterisk. The rtp_keepalive for the
endpoint is set to 3 seconds. The call stays alive for 10 seconds and is
then hung up. Since there is no audio exchanged during the call,
Asterisk should send keepalive packets every 3 seconds.
ASTERISK-25242
Reported by Mark Michelson
Change-Id: Ifd8ea7e980fed140bde337bd6b5462bdc251c3a9
---
A tests/channels/pjsip/rtp/rtp_keepalive/base/configs/ast1/extensions.conf
A tests/channels/pjsip/rtp/rtp_keepalive/base/configs/ast1/pjsip.conf
A tests/channels/pjsip/rtp/rtp_keepalive/base/rtp.py
A tests/channels/pjsip/rtp/rtp_keepalive/base/sipp/uac.xml
A tests/channels/pjsip/rtp/rtp_keepalive/base/test-config.yaml
A tests/channels/pjsip/rtp/rtp_keepalive/tests.yaml
A tests/channels/pjsip/rtp/tests.yaml
M tests/channels/pjsip/tests.yaml
8 files changed, 218 insertions(+), 0 deletions(-)
Approvals:
Matt Jordan: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, approved; Verified
diff --git a/tests/channels/pjsip/rtp/rtp_keepalive/base/configs/ast1/extensions.conf b/tests/channels/pjsip/rtp/rtp_keepalive/base/configs/ast1/extensions.conf
new file mode 100644
index 0000000..7b75b3e
--- /dev/null
+++ b/tests/channels/pjsip/rtp/rtp_keepalive/base/configs/ast1/extensions.conf
@@ -0,0 +1,5 @@
+[default]
+exten => echo,1,NoOp()
+same => n,Answer()
+same => n,Echo()
+same => n,Hangup()
diff --git a/tests/channels/pjsip/rtp/rtp_keepalive/base/configs/ast1/pjsip.conf b/tests/channels/pjsip/rtp/rtp_keepalive/base/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..fc5874f
--- /dev/null
+++ b/tests/channels/pjsip/rtp/rtp_keepalive/base/configs/ast1/pjsip.conf
@@ -0,0 +1,10 @@
+[local-transport]
+type = transport
+bind = 127.0.0.1
+protocol = udp
+
+[sipp]
+type = endpoint
+allow = ulaw
+rtp_keepalive = 3
+context = default
diff --git a/tests/channels/pjsip/rtp/rtp_keepalive/base/rtp.py b/tests/channels/pjsip/rtp/rtp_keepalive/base/rtp.py
new file mode 100644
index 0000000..38ff430
--- /dev/null
+++ b/tests/channels/pjsip/rtp/rtp_keepalive/base/rtp.py
@@ -0,0 +1,68 @@
+'''
+Copyright (C) 2015, Digium, Inc.
+Mark Michelson <mmichelson at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+
+import logging
+import sys
+import time
+
+from twisted.internet.protocol import DatagramProtocol
+from twisted.internet import reactor
+
+from construct import *
+
+sys.path.append('lib/python')
+
+LOGGER = logging.getLogger(__name__)
+
+
+class RTP(DatagramProtocol):
+ def __init__(self, test_object):
+ self.last_rx_time = None
+ self.test_object = test_object
+ self.test_object.register_stop_observer(self.asterisk_stopped)
+
+ def datagramReceived(self, data, (host, port)):
+ header = Struct('rtp_packet',
+ BitStruct('header',
+ BitField('version', 2),
+ Bit('padding'),
+ Bit('extension'),
+ Nibble('csrc_count'),
+ Bit('marker'),
+ BitField('payload', 7)
+ ),
+ UBInt16('sequence_number'),
+ UBInt32('timestamp'),
+ UBInt32('ssrc')
+ )
+ rtp_header = header.parse(data)
+ LOGGER.debug("Parsed RTP packet is {0}".format(rtp_header))
+ if rtp_header.header.payload == 13:
+ current_time = time.time()
+ # Don't compare intervals on the first received CNG
+ if self.last_rx_time:
+ interval = current_time - self.last_rx_time
+ if interval < 2.5 or interval > 3.5:
+ LOGGER.error(
+ "Interval of CNG packets not in tolerance {0}".format(
+ interval))
+ self.test_object.set_passed(False)
+ self.test_object.stop_reactor()
+ self.last_rx_time = current_time
+
+ def asterisk_stopped(self, result):
+ LOGGER.debug("Asterisk is stopped")
+ if self.last_rx_time is None:
+ LOGGER.error("Never received any CNG packets during test")
+ self.test_object.set_passed(False)
+ self.test_object.set_passed(True)
+
+
+class KeepaliveCheck(object):
+ def __init__(self, module_config, test_object):
+ reactor.listenUDP(33623, RTP(test_object))
diff --git a/tests/channels/pjsip/rtp/rtp_keepalive/base/sipp/uac.xml b/tests/channels/pjsip/rtp/rtp_keepalive/base/sipp/uac.xml
new file mode 100644
index 0000000..71d61e4
--- /dev/null
+++ b/tests/channels/pjsip/rtp/rtp_keepalive/base/sipp/uac.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="Basic Sipstone UAC">
+ <!-- In client mode (sipp placing calls), the Call-ID MUST be -->
+ <!-- generated by sipp. To do so, use [call_id] keyword. -->
+ <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: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
+ To: sut <sip:[service]@[remote_ip]>
+ Call-ID: [call_id]
+ CSeq: 1 INVITE
+ Contact: sip:sipp@[local_ip]:[local_port]
+ Max-Forwards: 70
+ Subject: Performance Test
+ 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 33623 RTP/AVP 0
+ a=rtpmap:8 PCMA/8000
+ a=rtpmap:0 PCMU/8000
+ a=ptime:20
+
+ ]]>
+ </send>
+
+ <recv response="100"
+ optional="true">
+ </recv>
+
+ <recv response="181"
+ optional="true">
+ </recv>
+
+ <recv response="180" optional="true">
+ </recv>
+
+ <recv response="183" optional="true">
+ </recv>
+
+ <recv response="200" rtd="true">
+ </recv>
+
+ <send>
+ <![CDATA[
+
+ ACK sip:[service]@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
+ To: sut <sip:[service]@[remote_ip]>[peer_tag_param]
+ Call-ID: [call_id]
+ CSeq: 1 ACK
+ Contact: sip:sipp@[local_ip]:[local_port]
+ Max-Forwards: 70
+ Subject: Performance Test
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+ <pause/>
+
+ <send retrans="500">
+ <![CDATA[
+
+ BYE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
+ To: sut <sip:[service]@[remote_ip]>[peer_tag_param]
+ Call-ID: [call_id]
+ CSeq: 2 BYE
+ Contact: sip:sipp@[local_ip]:[local_port]
+ Max-Forwards: 70
+ Subject: Performance Test
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+ <recv response="200" crlf="true">
+ </recv>
+
+</scenario>
+
diff --git a/tests/channels/pjsip/rtp/rtp_keepalive/base/test-config.yaml b/tests/channels/pjsip/rtp/rtp_keepalive/base/test-config.yaml
new file mode 100644
index 0000000..97cd0cb
--- /dev/null
+++ b/tests/channels/pjsip/rtp/rtp_keepalive/base/test-config.yaml
@@ -0,0 +1,36 @@
+testinfo:
+ summary: 'Ensure that Asterisk sends RTP CNG packets'
+ description: |
+ 'A SIPp test scenario calls into Asterisk and lands in an extension that
+ runs the "Echo" application. The SIPp endpoint is configured to have RTP
+ keepalives sent every three seconds. Since the SIPp scenario sends no RTP
+ to Asterisk, Asterisk should send RTP keepalives to the SIPp scenario. This
+ test ensures that the RTP keepalive packets are received and that they are
+ spaced out approximately according to the specified interval.'
+
+test-modules:
+ add-test-to-search-path: True
+ test-object:
+ config-section: sipp-config
+ typename: 'sipp.SIPpTestCase'
+ modules:
+ -
+ typename: 'rtp.KeepaliveCheck'
+
+sipp-config:
+ fail-on-any: True
+ test-iterations:
+ -
+ scenarios:
+ - { 'key-args': {'scenario': 'uac.xml', '-s': 'echo', '-d': '10000'} }
+
+properties:
+ minversion: '13.6.0'
+ dependencies:
+ - sipp:
+ version: 'v3.0'
+ - asterisk: 'res_pjsip'
+ - asterisk: 'res_pjsip_session'
+ - asterisk: 'res_pjsip_sdp_rtp'
+ tags:
+ - pjsip
diff --git a/tests/channels/pjsip/rtp/rtp_keepalive/tests.yaml b/tests/channels/pjsip/rtp/rtp_keepalive/tests.yaml
new file mode 100644
index 0000000..978b809
--- /dev/null
+++ b/tests/channels/pjsip/rtp/rtp_keepalive/tests.yaml
@@ -0,0 +1,3 @@
+# Enter tests here in the order they should be considered for execution:
+tests:
+ - test: 'base'
diff --git a/tests/channels/pjsip/rtp/tests.yaml b/tests/channels/pjsip/rtp/tests.yaml
new file mode 100644
index 0000000..6757b6a
--- /dev/null
+++ b/tests/channels/pjsip/rtp/tests.yaml
@@ -0,0 +1,3 @@
+# Enter tests here in the order they should be considered for execution:
+tests:
+ - dir: 'rtp_keepalive'
diff --git a/tests/channels/pjsip/tests.yaml b/tests/channels/pjsip/tests.yaml
index 6351df0..cc4e1f8 100644
--- a/tests/channels/pjsip/tests.yaml
+++ b/tests/channels/pjsip/tests.yaml
@@ -40,3 +40,4 @@
- test: 'forward_loop'
- dir: 'configuration'
- dir: 'nat'
+ - dir: 'rtp'
--
To view, visit https://gerrit.asterisk.org/899
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ifd8ea7e980fed140bde337bd6b5462bdc251c3a9
Gerrit-PatchSet: 1
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: Mark Michelson <mmichelson at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>
More information about the asterisk-commits
mailing list