[asterisk-commits] wdoekes: testsuite/asterisk/trunk r3261 - in /asterisk/trunk/tests/channels/S...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jun 7 16:24:13 CDT 2012


Author: wdoekes
Date: Thu Jun  7 16:24:07 2012
New Revision: 3261

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=3261
Log:
Add test for correct HANGUPCAUSE after SIP 404.

Review: https://reviewboard.asterisk.org/r/1951/
Reviewed by: Paul Belanger, Mark Michelson, Kinsey Moore

Added:
    asterisk/trunk/tests/channels/SIP/sip2cause/
    asterisk/trunk/tests/channels/SIP/sip2cause/configs/
    asterisk/trunk/tests/channels/SIP/sip2cause/configs/ast1/
    asterisk/trunk/tests/channels/SIP/sip2cause/configs/ast1/extensions.conf   (with props)
    asterisk/trunk/tests/channels/SIP/sip2cause/configs/ast1/sip.conf   (with props)
    asterisk/trunk/tests/channels/SIP/sip2cause/run-test   (with props)
    asterisk/trunk/tests/channels/SIP/sip2cause/sipp/
    asterisk/trunk/tests/channels/SIP/sip2cause/sipp/invite_recv_do_404.xml   (with props)
    asterisk/trunk/tests/channels/SIP/sip2cause/test-config.yaml   (with props)
Modified:
    asterisk/trunk/tests/channels/SIP/tests.yaml

Added: asterisk/trunk/tests/channels/SIP/sip2cause/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/SIP/sip2cause/configs/ast1/extensions.conf?view=auto&rev=3261
==============================================================================
--- asterisk/trunk/tests/channels/SIP/sip2cause/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/channels/SIP/sip2cause/configs/ast1/extensions.conf Thu Jun  7 16:24:07 2012
@@ -1,0 +1,31 @@
+[dpwait]
+;; Won't be reached but should exist.
+exten => 1234,1,NoOp()
+    same => n,Answer()
+    same => n,Echo()
+
+[dial-alice]
+exten => _XXXX,1,Dial(SIP/alice/${EXTEN})
+    same => n,Log(WARNING, Expecting HANGUPCAUSE to be 1, it is ${HANGUPCAUSE})
+    ;;
+    ;; Note that we still require a Hangup() below. Auto fallthrough
+    ;; behaviour will set hangupcause to 0 resulting in this:
+    ;;
+    ;; [May 29 10:42:44] WARNING[14396]: Ext. 333:2 @ dial-alice:  Expecting HANGUPCAUSE to be 1, it is 1
+    ;;    -- Auto fallthrough, channel 'SIP/sipsak-00000002' status is 'CHANUNAVAIL'
+    ;;
+    ;;    <--- Reliably Transmitting (NAT) to 127.0.0.1:37615 --->
+    ;;    SIP/2.0 503 Service Unavailable
+    ;;    Via: SIP/2.0/UDP 127.0.1.1:5063;branch=z9hG4bK.2de67657;alias;received=127.0.0.1;rport=37615
+    ;;    From: sip:sipsak at 127.0.1.1:5063;tag=26147b47
+    ;;    To: sip:333 at 127.0.0.1;tag=as2caed653
+    ;;    Call-ID: 638876487 at 127.0.1.1
+    ;;    CSeq: 1 INVITE
+    ;;    Server: Asterisk PBX SVN-branch-1.8-r367781M
+    ;;    Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
+    ;;    Supported: replaces, timer
+    ;;    X-Asterisk-HangupCause: Unallocated (unassigned) number
+    ;;    X-Asterisk-HangupCauseCode: 1
+    ;;    Content-Length: 0
+    ;;
+    same => n,Hangup(${HANGUPCAUSE})

Propchange: asterisk/trunk/tests/channels/SIP/sip2cause/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/channels/SIP/sip2cause/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/channels/SIP/sip2cause/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/channels/SIP/sip2cause/configs/ast1/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/SIP/sip2cause/configs/ast1/sip.conf?view=auto&rev=3261
==============================================================================
--- asterisk/trunk/tests/channels/SIP/sip2cause/configs/ast1/sip.conf (added)
+++ asterisk/trunk/tests/channels/SIP/sip2cause/configs/ast1/sip.conf Thu Jun  7 16:24:07 2012
@@ -1,0 +1,8 @@
+[general]
+udpbindaddr=127.0.0.1:5060
+
+[alice]
+type=friend
+fromuser=alice
+host=127.0.0.1
+port=5062

Propchange: asterisk/trunk/tests/channels/SIP/sip2cause/configs/ast1/sip.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/channels/SIP/sip2cause/configs/ast1/sip.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/channels/SIP/sip2cause/configs/ast1/sip.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/channels/SIP/sip2cause/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/SIP/sip2cause/run-test?view=auto&rev=3261
==============================================================================
--- asterisk/trunk/tests/channels/SIP/sip2cause/run-test (added)
+++ asterisk/trunk/tests/channels/SIP/sip2cause/run-test Thu Jun  7 16:24:07 2012
@@ -1,0 +1,93 @@
+#!/usr/bin/env python
+'''
+Copyright (C) 2012, Digium, Inc.
+Walter Doekes <walter+asterisk at wjd.nu>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+
+import sys
+import os
+import logging
+
+sys.path.append("lib/python")
+
+from asterisk.TestCase import TestCase
+from asterisk.sipp import SIPpScenario
+from twisted.internet import reactor
+
+CAUSE_UNALLOCATED = 1 # SIP/404
+TEST_DIR = os.path.dirname(os.path.realpath(__file__))
+logger = logging.getLogger(__name__)
+
+class SIP2HangupCauseTest(TestCase):
+    def __init__(self):
+        super(SIP2HangupCauseTest, self).__init__()
+        self.expect_hangups = 3
+        self.create_asterisk()
+
+    def run(self):
+        super(SIP2HangupCauseTest, self).run()
+        self.create_ami_factory()
+
+    def ami_connect(self, ami):
+        self.start_listening()
+        self.ami[0].registerEvent('Hangup', self.on_hangup)
+
+        logger.info("Setting up call that should receive 404")
+        self.ami[0].originate("Local/1111 at dial-alice", "dpwait", "1234",
+                              1).addErrback(self.on_originate_fail)
+
+    def on_originate_fail(self, ami):
+        # We don't mind that it fails. In fact, it should fail.
+        pass
+
+    def start_listening(self):
+        logger.info("Listening for request to respond with 404")
+
+        self.scenario = SIPpScenario(TEST_DIR, {
+            'scenario': 'invite_recv_do_404.xml',
+            '-p': '5062',
+            '-timeout': '8s',
+        })
+        self.scenario.run(self)
+
+    def on_hangup(self, ami, event):
+        assert event['event'] == 'Hangup'
+        logger.info('Got event: %r' % (event,))
+
+        # We expect 3 channels here, and they should all have cause code 1.
+        #   SIP/alice -> world
+        #   Local/1111 at dial-alice;2 -> SIP/alice
+        #   Local/1111 at dial-alice;1 -> Local/1111 at dial-alice;2
+        # For that, we require and test these things:
+        #   - Hangup event generation
+        #   - hangup_sip2cause (404 -> 1)
+        #   - propagation of HANGUPCAUSE over local channels
+        cause = int(event['cause'])
+        if cause != CAUSE_UNALLOCATED:
+            logger.error('Unexpected HANGUPCAUSE %d (not %d) for channel %s' %
+                         (cause, CAUSE_UNALLOCATED, event['channel']))
+            self.stop_reactor()
+            return
+
+        self.expect_hangups -= 1
+        if not self.expect_hangups:
+            self.passed = True
+            self.stop_reactor()
+
+
+def main():
+    test = SIP2HangupCauseTest()
+    reactor.run()
+    if test.passed:
+        return 0
+    return 1
+
+
+if __name__ == "__main__":
+    sys.exit(main())
+
+
+# vim:ts=8:sw=4:sts=4:expandtab:textwidth=79

Propchange: asterisk/trunk/tests/channels/SIP/sip2cause/run-test
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/channels/SIP/sip2cause/run-test
------------------------------------------------------------------------------
    svn:executable = *

Propchange: asterisk/trunk/tests/channels/SIP/sip2cause/run-test
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/channels/SIP/sip2cause/run-test
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/channels/SIP/sip2cause/sipp/invite_recv_do_404.xml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/SIP/sip2cause/sipp/invite_recv_do_404.xml?view=auto&rev=3261
==============================================================================
--- asterisk/trunk/tests/channels/SIP/sip2cause/sipp/invite_recv_do_404.xml (added)
+++ asterisk/trunk/tests/channels/SIP/sip2cause/sipp/invite_recv_do_404.xml Thu Jun  7 16:24:07 2012
@@ -1,0 +1,37 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+
+<scenario name="Wait for invite and send 404, Walter Doekes 2012">
+  <recv request="INVITE" rrs="true"/>
+
+  <send>
+    <![CDATA[
+
+      SIP/2.0 100 Trying
+      [last_Via:]
+      [last_From:]
+      [last_To:]
+      [last_Call-ID:]
+      [last_CSeq:]
+      Content-Length: 0
+
+    ]]>
+  </send>
+
+  <send>
+    <![CDATA[
+
+      SIP/2.0 404 Not Found
+      [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>
+
+  <recv request="ACK" rrs="true"/>
+
+</scenario><!-- vim: set ts=8 sw=2 sts=2 et ai: -->

Propchange: asterisk/trunk/tests/channels/SIP/sip2cause/sipp/invite_recv_do_404.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/channels/SIP/sip2cause/sipp/invite_recv_do_404.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/channels/SIP/sip2cause/sipp/invite_recv_do_404.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/channels/SIP/sip2cause/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/SIP/sip2cause/test-config.yaml?view=auto&rev=3261
==============================================================================
--- asterisk/trunk/tests/channels/SIP/sip2cause/test-config.yaml (added)
+++ asterisk/trunk/tests/channels/SIP/sip2cause/test-config.yaml Thu Jun  7 16:24:07 2012
@@ -1,0 +1,15 @@
+testinfo:
+    summary: 'Test SIP failure code to internal cause code conversion (hangup_sip2cause).'
+    description: |
+        'Test whether certain SIP response codes (404) are mapped to
+        the Q.850 equivalent (1/UNALLOCATED).'
+
+properties:
+    minversion: '1.8'
+    dependencies:
+        - python: 'starpy'
+        - sipp:
+            version: 'v3.1'
+    tags:
+        - sip
+        - sip_cause

Propchange: asterisk/trunk/tests/channels/SIP/sip2cause/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/channels/SIP/sip2cause/test-config.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/channels/SIP/sip2cause/test-config.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: asterisk/trunk/tests/channels/SIP/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/SIP/tests.yaml?view=diff&rev=3261&r1=3260&r2=3261
==============================================================================
--- asterisk/trunk/tests/channels/SIP/tests.yaml (original)
+++ asterisk/trunk/tests/channels/SIP/tests.yaml Thu Jun  7 16:24:07 2012
@@ -46,3 +46,4 @@
     - test: 'hangupcause'
     - test: 'sip_cause'
     - test: 'invite_no_totag'
+    - test: 'sip2cause'




More information about the asterisk-commits mailing list