[asterisk-commits] kmoore: testsuite/asterisk/trunk r3799 - in /asterisk/trunk: lib/python/aster...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu May 23 11:19:51 CDT 2013
Author: kmoore
Date: Thu May 23 11:19:47 2013
New Revision: 3799
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=3799
Log:
Bring in some bridge_construction tests now that bridge_construction is merged
Added:
asterisk/trunk/tests/manager/bridge_actions/
asterisk/trunk/tests/manager/bridge_actions/check_bridge.py (with props)
asterisk/trunk/tests/manager/bridge_actions/configs/
asterisk/trunk/tests/manager/bridge_actions/configs/ast1/
asterisk/trunk/tests/manager/bridge_actions/configs/ast1/extensions.conf (with props)
asterisk/trunk/tests/manager/bridge_actions/test-config.yaml (with props)
Modified:
asterisk/trunk/lib/python/asterisk/BridgeTestCase.py
asterisk/trunk/tests/bridge/simple_bridge/test-config.yaml
asterisk/trunk/tests/manager/tests.yaml
Modified: asterisk/trunk/lib/python/asterisk/BridgeTestCase.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/BridgeTestCase.py?view=diff&rev=3799&r1=3798&r2=3799
==============================================================================
--- asterisk/trunk/lib/python/asterisk/BridgeTestCase.py (original)
+++ asterisk/trunk/lib/python/asterisk/BridgeTestCase.py Thu May 23 11:19:47 2013
@@ -106,6 +106,9 @@
if (ami.id == 0):
self.ami_uut = ami
self.ami_uut.registerEvent('Bridge', self.uut_bridge_callback)
+ self.ami_uut.registerEvent('BridgeCreate', self.uut_bridge_create_callback)
+ self.ami_uut.registerEvent('BridgeEnter', self.uut_bridge_enter_callback)
+ self.ami_uut.registerEvent('BridgeLeave', self.uut_bridge_leave_callback)
self.ami_uut.registerEvent('TestEvent', self.test_callback)
self.ami_uut.registerEvent('Hangup', self.hangup_callback)
LOGGER.info("UUT AMI connected")
@@ -148,6 +151,7 @@
self.bob_channel = None
self.uut_alice_channel = None
self.uut_bob_channel = None
+ self.uut_bridge_id = None
self.alice_hungup = False
self.bob_hungup = False
self.uut_alice_hungup = False
@@ -155,6 +159,7 @@
self.current_feature = 0
self.infeatures = False
self.issue_hangups_on_bridged = False
+ self.bridged = False
# Step 1: Initiate a call from Alice to Bob
LOGGER.info("Originating call")
@@ -210,6 +215,32 @@
self.current_run += 1
self.run_tests()
+ # Callbacks for new bridging architecture
+ def uut_bridge_create_callback(self, ami, event):
+ self.uut_bridge_id = event.get('bridgeuniqueid')
+
+ def uut_bridge_enter_callback(self, ami, event):
+ if self.uut_bridge_id != event.get('bridgeuniqueid'):
+ return
+
+ if self.uut_alice_channel is None:
+ self.uut_alice_channel = event.get('channel')
+ LOGGER.info('UUT Alice Channel: %s' % self.uut_alice_channel)
+ elif self.uut_bob_channel is None:
+ self.uut_bob_channel = event.get('channel')
+ LOGGER.info('UUT Bob Channel: %s' % self.uut_bob_channel)
+ LOGGER.debug("Bridge is up between %s and %s"
+ % (self.uut_alice_channel, self.uut_bob_channel))
+ LOGGER.debug("Type of bridge is %s" % event.get('bridgetype'))
+ self.bridged = True
+ if self.issue_hangups_on_bridged:
+ self.send_hangup()
+
+ def uut_bridge_leave_callback(self, ami, event):
+ LOGGER.debug("Bridge is down")
+ self.bridged = False
+
+ # Callback for old bridging architecture
def uut_bridge_callback(self, ami, event):
if self.uut_alice_channel is None:
self.uut_alice_channel = event.get('channel1')
Modified: asterisk/trunk/tests/bridge/simple_bridge/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/bridge/simple_bridge/test-config.yaml?view=diff&rev=3799&r1=3798&r2=3799
==============================================================================
--- asterisk/trunk/tests/bridge/simple_bridge/test-config.yaml (original)
+++ asterisk/trunk/tests/bridge/simple_bridge/test-config.yaml Thu May 23 11:19:47 2013
@@ -12,10 +12,12 @@
-
config-section: 'cdr-config'
typename: 'cdr.CDRModule'
- modules:
-
config-section: 'cel-config'
typename: 'cel.CELModule'
+ -
+ typename: 'ami.AMIEventModule'
+ config-section: ami-uut
bridge-config:
test-runs:
@@ -25,6 +27,115 @@
-
originate_channel: 'SIP/test_call at uut'
hangup: 'bob'
+
+ami-uut:
+ -
+ type: 'headermatch'
+ id: '0'
+ conditions:
+ match:
+ Event: 'BridgeCreate'
+ requirements:
+ match:
+ BridgeType: 'simple_bridge'
+ count: '2'
+ -
+ type: 'headermatch'
+ id: '0'
+ conditions:
+ match:
+ Event: 'BridgeEnter'
+ Channel: 'SIP/alice-.*'
+ requirements:
+ match:
+ BridgeUniqueid: '.*-.*-.*'
+ BridgeType: 'simple_bridge'
+ ChannelState: '6'
+ ChannelStateDesc: 'Up'
+ CallerIDNum: '1234'
+ CallerIDName: 'Alice'
+ ConnectedLineNum: '4321'
+ ConnectedLineName: 'Bob'
+ Context: 'default'
+ Exten: 'test_call'
+ Priority: '1'
+ Uniqueid: '.*'
+ count: '2'
+ -
+ type: 'headermatch'
+ id: '0'
+ conditions:
+ match:
+ Event: 'BridgeEnter'
+ Channel: 'SIP/bob-.*'
+ requirements:
+ match:
+ BridgeUniqueid: '.*-.*-.*'
+ BridgeType: 'simple_bridge'
+ ChannelState: '6'
+ ChannelStateDesc: 'Up'
+ ConnectedLineNum: '1234'
+ ConnectedLineName: 'Alice'
+ CallerIDNum: '4321'
+ CallerIDName: 'Bob'
+ Context: 'default'
+ Priority: '1'
+ Uniqueid: '.*'
+ count: '2'
+ -
+ type: 'headermatch'
+ id: '0'
+ conditions:
+ match:
+ Event: 'BridgeLeave'
+ Channel: 'SIP/alice-.*'
+ requirements:
+ match:
+ BridgeUniqueid: '.*-.*-.*'
+ BridgeType: 'simple_bridge'
+ ChannelState: '6'
+ ChannelStateDesc: 'Up'
+ CallerIDNum: '1234'
+ CallerIDName: 'Alice'
+ ConnectedLineNum: '4321'
+ ConnectedLineName: 'Bob'
+ Context: 'default'
+ Exten: 'test_call'
+ Priority: '1'
+ Uniqueid: '.*'
+ count: '2'
+ -
+ type: 'headermatch'
+ id: '0'
+ conditions:
+ match:
+ Event: 'BridgeLeave'
+ Channel: 'SIP/bob-.*'
+ requirements:
+ match:
+ BridgeUniqueid: '.*-.*-.*'
+ BridgeType: 'simple_bridge'
+ ChannelState: '6'
+ ChannelStateDesc: 'Up'
+ ConnectedLineNum: '1234'
+ ConnectedLineName: 'Alice'
+ CallerIDNum: '4321'
+ CallerIDName: 'Bob'
+ Context: 'default'
+ Priority: '1'
+ Uniqueid: '.*'
+ count: '2'
+ -
+ type: 'headermatch'
+ id: '0'
+ conditions:
+ match:
+ Event: 'BridgeDestroy'
+ requirements:
+ match:
+ BridgeUniqueid: '.*-.*-.*'
+ BridgeType: 'simple_bridge'
+ count: '2'
cdr-config:
-
Added: asterisk/trunk/tests/manager/bridge_actions/check_bridge.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/manager/bridge_actions/check_bridge.py?view=auto&rev=3799
==============================================================================
--- asterisk/trunk/tests/manager/bridge_actions/check_bridge.py (added)
+++ asterisk/trunk/tests/manager/bridge_actions/check_bridge.py Thu May 23 11:19:47 2013
@@ -1,0 +1,95 @@
+'''
+Copyright (C) 2013, 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 logging
+
+LOGGER = logging.getLogger(__name__)
+
+class bridge_info_callback_container:
+ def __init__(self, ami):
+ self.ami = ami
+
+ def callback(self, result):
+ '''Ensure that only one bridge is listed and get detailed information about it
+ '''
+ channel_count = 0
+ for list_result in result:
+ if 'uniqueid' not in list_result:
+ continue
+
+ channel_count += 1
+
+ if channel_count < 2:
+ self.send_error("Not enough channels in the bridge")
+ elif channel_count > 2:
+ self.send_error("Too many channels in the bridge")
+ else:
+ self.send_success()
+
+ def failed(self, reason):
+ self.send_error("BridgeInfo action failed: %s" % reason)
+ pass
+
+ def send_error(self, message):
+ LOGGER.error(message)
+ self.ami.userEvent('BridgeInfoFailure', message=message})
+
+ def send_success(self):
+ self.ami.userEvent('BridgeInfoSuccess')
+
+class bridge_list_callback_container:
+ def __init__(self, ami):
+ self.ami = ami
+
+ def callback(self, result):
+ '''Ensure that only one bridge is listed and get detailed information about it
+ '''
+ bridge_id = None
+ for list_result in result:
+ if 'bridgeuniqueid' not in list_result:
+ continue
+
+ if bridge_id is None:
+ bridge_id = list_result['bridgeuniqueid']
+ else:
+ self.send_error("More than one bridge returned where there should be only one")
+ return
+
+ if bridge_id is None:
+ self.send_error("No bridges returned where there should be one")
+ return
+
+ self.send_success()
+ message = {
+ 'action' : 'BridgeInfo',
+ 'bridgeuniqueid' : bridge_id
+ }
+ info_callback = bridge_info_callback_container(self.ami)
+ self.ami.collectDeferred(message, 'BridgeInfoComplete').addCallbacks(info_callback.callback, info_callback.failed)
+
+ def failed(self, reason):
+ self.send_error("BridgeList action failed: %s" % reason)
+ pass
+
+ def send_error(self, message):
+ LOGGER.error(message)
+ self.ami.userEvent('BridgeListFailure', message=message})
+
+ def send_success(self):
+ self.ami.userEvent('BridgeListSuccess')
+
+def get_bridge_info(ami, event):
+ ''' Callback called when the second participant entered the bridge.
+ '''
+
+ message = {
+ 'action' : 'BridgeList'
+ }
+ list_callback = bridge_list_callback_container(ami)
+ ami.collectDeferred(message, 'BridgeListComplete').addCallbacks(list_callback.callback, list_callback.failed)
+ return True
Propchange: asterisk/trunk/tests/manager/bridge_actions/check_bridge.py
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/manager/bridge_actions/check_bridge.py
------------------------------------------------------------------------------
svn:executable = *
Propchange: asterisk/trunk/tests/manager/bridge_actions/check_bridge.py
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/manager/bridge_actions/check_bridge.py
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/manager/bridge_actions/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/manager/bridge_actions/configs/ast1/extensions.conf?view=auto&rev=3799
==============================================================================
--- asterisk/trunk/tests/manager/bridge_actions/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/manager/bridge_actions/configs/ast1/extensions.conf Thu May 23 11:19:47 2013
@@ -1,0 +1,4 @@
+[default]
+
+exten => test_call,1,Dial(SIP/test_call at bob,,wW)
+same => n,Hangup()
Propchange: asterisk/trunk/tests/manager/bridge_actions/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/manager/bridge_actions/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/manager/bridge_actions/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/manager/bridge_actions/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/manager/bridge_actions/test-config.yaml?view=auto&rev=3799
==============================================================================
--- asterisk/trunk/tests/manager/bridge_actions/test-config.yaml (added)
+++ asterisk/trunk/tests/manager/bridge_actions/test-config.yaml Thu May 23 11:19:47 2013
@@ -1,0 +1,75 @@
+testinfo:
+ summary: 'Test that BridgeList and BridgeInfo AMI actions works properly'
+ description: |
+ 'Set up a bridge between two endpoints and ensure that BridgeList
+ responds with the correct bridges and that BridgeInfo replies with
+ the correct channel information.'
+
+test-modules:
+ add-test-to-search-path: 'True'
+ test-object:
+ config-section: bridge-config
+ typename: 'BridgeTestCase.BridgeTestCase'
+ modules:
+ -
+ typename: 'ami.AMIEventModule'
+ config-section: ami-uut
+
+bridge-config:
+ test-runs:
+ -
+ originate_channel: 'SIP/test_call at uut'
+ hangup: 'alice'
+
+ami-uut:
+ -
+ type: 'callback'
+ id: '0'
+ conditions:
+ match:
+ Event: 'BridgeEnter'
+ Channel: 'SIP/bob-.*'
+ BridgeType: 'simple_bridge'
+ callbackModule: 'check_bridge'
+ callbackMethod: 'get_bridge_info'
+ count: '1'
+ -
+ type: 'headermatch'
+ id: '0'
+ conditions:
+ match:
+ Event: 'Userevent'
+ UserEvent: 'BridgeListFailure'
+ count: '0'
+ -
+ type: 'headermatch'
+ id: '0'
+ conditions:
+ match:
+ Event: 'Userevent'
+ UserEvent: 'BridgeInfoFailure'
+ count: '0'
+ -
+ type: 'headermatch'
+ id: '0'
+ conditions:
+ match:
+ Event: 'Userevent'
+ UserEvent: 'BridgeListSuccess'
+ count: '1'
+ -
+ type: 'headermatch'
+ id: '0'
+ conditions:
+ match:
+ Event: 'Userevent'
+ UserEvent: 'BridgeInfoSuccess'
+ count: '1'
+
+properties:
+ minversion: '12.0.0'
+ dependencies:
+ - python : 'twisted'
+ - python : 'starpy'
+ tags:
+ - bridge
Propchange: asterisk/trunk/tests/manager/bridge_actions/test-config.yaml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/manager/bridge_actions/test-config.yaml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/manager/bridge_actions/test-config.yaml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: asterisk/trunk/tests/manager/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/manager/tests.yaml?view=diff&rev=3799&r1=3798&r2=3799
==============================================================================
--- asterisk/trunk/tests/manager/tests.yaml (original)
+++ asterisk/trunk/tests/manager/tests.yaml Thu May 23 11:19:47 2013
@@ -5,5 +5,6 @@
- test: 'authlimit'
- test: 'authtimeout'
- test: 'acl-login'
+ - test: 'bridge_actions'
# Temporarily disabled while failures are debugged
#- test: 'response-time'
More information about the asterisk-commits
mailing list