[asterisk-commits] kmoore: testsuite/asterisk/trunk r3263 - in /asterisk/trunk/tests/iax2: ./ ha...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Jun 15 11:19:48 CDT 2012
Author: kmoore
Date: Fri Jun 15 11:19:42 2012
New Revision: 3263
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=3263
Log:
Add tests for IAX2 HANGUPCAUSE hash functionality
Review: https://reviewboard.asterisk.org/r/1942/
(issue SWP-4223)
Added:
asterisk/trunk/tests/iax2/hangupcause/
asterisk/trunk/tests/iax2/hangupcause/configs/
asterisk/trunk/tests/iax2/hangupcause/configs/ast1/
asterisk/trunk/tests/iax2/hangupcause/configs/ast1/extensions.conf (with props)
asterisk/trunk/tests/iax2/hangupcause/configs/ast1/iax.conf (with props)
asterisk/trunk/tests/iax2/hangupcause/configs/ast2/
asterisk/trunk/tests/iax2/hangupcause/configs/ast2/extensions.conf (with props)
asterisk/trunk/tests/iax2/hangupcause/configs/ast2/iax.conf (with props)
asterisk/trunk/tests/iax2/hangupcause/run-test (with props)
asterisk/trunk/tests/iax2/hangupcause/test-config.yaml (with props)
Modified:
asterisk/trunk/tests/iax2/tests.yaml
Added: asterisk/trunk/tests/iax2/hangupcause/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/iax2/hangupcause/configs/ast1/extensions.conf?view=auto&rev=3263
==============================================================================
--- asterisk/trunk/tests/iax2/hangupcause/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/iax2/hangupcause/configs/ast1/extensions.conf Fri Jun 15 11:19:42 2012
@@ -1,0 +1,17 @@
+[alice-incoming]
+exten => s,1,NoOp()
+same => n,Hangup(NORMAL_CIRCUIT_CONGESTION)
+
+[dpwait]
+exten => 1234,1,Noop()
+same => n,Answer()
+same => n,Echo()
+
+[bob-incoming]
+exten => s,1,NoOp()
+same => n,Wait(1)
+same => n,Hangup(USER_BUSY)
+
+[dial-alice]
+exten => _X.,1,Answer()
+same => n,Dial(iax2/alice/${EXTEN})
Propchange: asterisk/trunk/tests/iax2/hangupcause/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/iax2/hangupcause/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/iax2/hangupcause/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/iax2/hangupcause/configs/ast1/iax.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/iax2/hangupcause/configs/ast1/iax.conf?view=auto&rev=3263
==============================================================================
--- asterisk/trunk/tests/iax2/hangupcause/configs/ast1/iax.conf (added)
+++ asterisk/trunk/tests/iax2/hangupcause/configs/ast1/iax.conf Fri Jun 15 11:19:42 2012
@@ -1,0 +1,17 @@
+[general]
+bindaddr = 127.0.0.1
+
+[alice]
+type = friend
+username = alice
+secret = alice
+host = 127.0.0.2
+context = alice-incoming
+
+[bob]
+type = friend
+username = bob
+secret = bob
+host = 127.0.0.2
+context = bob-incoming
+
Propchange: asterisk/trunk/tests/iax2/hangupcause/configs/ast1/iax.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/iax2/hangupcause/configs/ast1/iax.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/iax2/hangupcause/configs/ast1/iax.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/iax2/hangupcause/configs/ast2/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/iax2/hangupcause/configs/ast2/extensions.conf?view=auto&rev=3263
==============================================================================
--- asterisk/trunk/tests/iax2/hangupcause/configs/ast2/extensions.conf (added)
+++ asterisk/trunk/tests/iax2/hangupcause/configs/ast2/extensions.conf Fri Jun 15 11:19:42 2012
@@ -1,0 +1,19 @@
+[to-bob]
+exten => 1111,1,Set(TEST=single)
+same => n,Dial(iax2/alice)
+
+exten => 2222,1,Set(TEST=double)
+same => n,Dial(iax2/bob&iax2/alice)
+
+exten => 3333,1,Set(TEST=local)
+same => n,Dial(local/3333 at isolated)
+
+exten => h,1,Set(ARRAY(C1,C2)=${HASHKEYS(HANGUPCAUSE)})
+same => n,UserEvent(HUCStatus,status: ${TEST},chan1: ${C1},chan2: ${C2},res1: ${HASH(HANGUPCAUSE,${C1})},res2: ${HASH(HANGUPCAUSE,${C2})},hangupcause: ${HANGUPCAUSE})
+
+[isolated]
+exten => 3333,1,Dial(iax2/bob&iax2/alice)
+
+[dpwait]
+exten => 1234,1,Answer()
+same => n,Echo()
Propchange: asterisk/trunk/tests/iax2/hangupcause/configs/ast2/extensions.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/iax2/hangupcause/configs/ast2/extensions.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/iax2/hangupcause/configs/ast2/extensions.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/iax2/hangupcause/configs/ast2/iax.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/iax2/hangupcause/configs/ast2/iax.conf?view=auto&rev=3263
==============================================================================
--- asterisk/trunk/tests/iax2/hangupcause/configs/ast2/iax.conf (added)
+++ asterisk/trunk/tests/iax2/hangupcause/configs/ast2/iax.conf Fri Jun 15 11:19:42 2012
@@ -1,0 +1,17 @@
+[general]
+bindaddr = 127.0.0.2
+
+[alice]
+type = friend
+username = alice
+secret = alice
+context = to-bob
+host = 127.0.0.1
+
+[bob]
+type = friend
+username = bob
+secret = bob
+context = to-bob
+host = 127.0.0.1
+
Propchange: asterisk/trunk/tests/iax2/hangupcause/configs/ast2/iax.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/iax2/hangupcause/configs/ast2/iax.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/iax2/hangupcause/configs/ast2/iax.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/iax2/hangupcause/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/iax2/hangupcause/run-test?view=auto&rev=3263
==============================================================================
--- asterisk/trunk/tests/iax2/hangupcause/run-test (added)
+++ asterisk/trunk/tests/iax2/hangupcause/run-test Fri Jun 15 11:19:42 2012
@@ -1,0 +1,101 @@
+#!/usr/bin/env python
+'''
+Copyright (C) 2012, Digium, Inc.
+Kinsey Moore <kmoore at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+
+import sys
+import logging
+
+from twisted.internet import reactor
+
+sys.path.append("lib/python")
+from asterisk.asterisk import Asterisk
+from asterisk.TestCase import TestCase
+
+logger = logging.getLogger(__name__)
+
+class HUCTest(TestCase):
+ def __init__(self):
+ TestCase.__init__(self)
+ self.create_asterisk(2)
+ self.event_count = 0
+ self.success_count = 0
+
+ def ami_connect(self, ami):
+ if ami.id == 0:
+ logger.info("Initiating three test calls for single, branched, and local with branched")
+ self.ami[0].originate("local/1111 at dial-alice", "dpwait", "1234", 1).addErrback(self.handleOriginateFailure)
+ self.ami[0].originate("local/2222 at dial-alice", "dpwait", "1234", 1).addErrback(self.handleOriginateFailure)
+ self.ami[0].originate("local/3333 at dial-alice", "dpwait", "1234", 1).addErrback(self.handleOriginateFailure)
+ else:
+ self.ami[1].registerEvent('UserEvent', self.huc_callback)
+
+ def huc_callback(self, ami, event):
+ if event['userevent'] != 'HUCStatus':
+ return
+
+ self.event_count += 1
+ error = 0
+
+ def res_good(chan, res):
+ if event['chan1'].find("alice") != -1:
+ if event['res1'].find('IAX2 HANGUP (34)') == -1:
+ return False
+ else:
+ if event['res1'].find('IAX2 HANGUP (17)') == -1:
+ return False
+ return True
+
+ if res_good(event['chan1'], event['res1']):
+ if event['status'] == "single":
+ logger.info("got result for single channel call")
+ if event['hangupcause'] == '34':
+ self.success_count += 1
+ else:
+ logger.error("Received 'single' event with bad HANGUPCAUSE code")
+ elif event ['status'] == "double":
+ logger.info("got result for branched call")
+ if event['hangupcause'] == '17' and\
+ res_good(event['chan2'], event['res2']):
+ self.success_count += 1
+ else:
+ logger.error("Received 'double' event with bad cause information (%s) for channel %s: %s" % (event['hangupcause'], event['chan2'], event['res2']))
+ elif event ['status'] == "local":
+ logger.info("got result for local-indirected branched call")
+ if event['hangupcause'] == '17' and\
+ res_good(event['chan2'], event['res2']):
+ self.success_count += 1
+ else:
+ logger.error("Received 'local' event with bad cause information (%s) for channel %s: %s" % (event['hangupcause'], event['chan2'], event['res2']))
+ else:
+ logger.error("Received '%s' event with bad cause information for channel %s: %s" % (event['status'], event['chan1'], event['res1']))
+
+ self.are_we_there_yet()
+
+ def are_we_there_yet(self):
+ if self.event_count >= 3:
+ if self.success_count == 3:
+ self.passed = True
+ self.stop_reactor()
+
+ def run(self):
+ TestCase.run(self)
+ self.create_ami_factory(2)
+
+
+def main():
+ test = HUCTest()
+ reactor.run()
+
+ if not test.passed:
+ return 1
+
+ return 0
+
+if __name__ == "__main__":
+ sys.exit(main() or 0)
+
Propchange: asterisk/trunk/tests/iax2/hangupcause/run-test
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/iax2/hangupcause/run-test
------------------------------------------------------------------------------
svn:executable = *
Propchange: asterisk/trunk/tests/iax2/hangupcause/run-test
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/iax2/hangupcause/run-test
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/iax2/hangupcause/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/iax2/hangupcause/test-config.yaml?view=auto&rev=3263
==============================================================================
--- asterisk/trunk/tests/iax2/hangupcause/test-config.yaml (added)
+++ asterisk/trunk/tests/iax2/hangupcause/test-config.yaml Fri Jun 15 11:19:42 2012
@@ -1,0 +1,12 @@
+testinfo:
+ summary: 'Test IAX2 support for HANGUPCAUSE.'
+ description: 'Test generation of informational frames for usage by the HANGUPCAUSE hash feature.'
+
+properties:
+ minversion: '11'
+ dependencies:
+ - python : 'starpy'
+ - asterisk : 'chan_iax2'
+ tags:
+ - iax2
+ - hangupcause
Propchange: asterisk/trunk/tests/iax2/hangupcause/test-config.yaml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/iax2/hangupcause/test-config.yaml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/iax2/hangupcause/test-config.yaml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: asterisk/trunk/tests/iax2/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/iax2/tests.yaml?view=diff&rev=3263&r1=3262&r2=3263
==============================================================================
--- asterisk/trunk/tests/iax2/tests.yaml (original)
+++ asterisk/trunk/tests/iax2/tests.yaml Fri Jun 15 11:19:42 2012
@@ -1,3 +1,4 @@
# Enter tests here in the order they should be considered for execution:
tests:
- test: 'basic-call'
+ - test: 'hangupcause'
More information about the asterisk-commits
mailing list