[asterisk-commits] kmoore: testsuite/asterisk/trunk r4192 - in /asterisk/trunk/tests: apps/bridg...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Sep 16 07:57:09 CDT 2013
Author: kmoore
Date: Mon Sep 16 07:57:06 2013
New Revision: 4192
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=4192
Log:
Fix the bridge transfer tests
This fixes the following tests in the testsuite:
* blonde_nominal (updated for new asterisk-12+ AMI events)
* atxfer_nominal (updated for new asterisk-12+ AMI events)
* transfer_failure (updated for new asterisk-12+ CEL events)
* bridge_transfer_callee (updated for new asterisk-12+ AMI events)
Review: https://reviewboard.asterisk.org/r/2856/
(closes issue ASTERISK-22327)
Reported by: Matt Jordan
Modified:
asterisk/trunk/tests/apps/bridge/bridge_transfer_callee/run-test
asterisk/trunk/tests/bridge/atxfer_nominal/transfer.py
asterisk/trunk/tests/bridge/blonde_nominal/transfer.py
asterisk/trunk/tests/bridge/transfer_failure/test-config.yaml
Modified: asterisk/trunk/tests/apps/bridge/bridge_transfer_callee/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/bridge/bridge_transfer_callee/run-test?view=diff&rev=4192&r1=4191&r2=4192
==============================================================================
--- asterisk/trunk/tests/apps/bridge/bridge_transfer_callee/run-test (original)
+++ asterisk/trunk/tests/apps/bridge/bridge_transfer_callee/run-test Mon Sep 16 07:57:06 2013
@@ -17,8 +17,9 @@
sys.path.append("lib/python")
from asterisk.TestCase import TestCase
+from asterisk.version import AsteriskVersion
-logger = logging.getLogger(__name__)
+LOGGER = logging.getLogger(__name__)
class BridgeTransferTest(TestCase):
@@ -27,6 +28,7 @@
self.current_test = 0
self.total_tests = 4
self.create_asterisk()
+ self.channel1 = None
def run(self):
TestCase.run(self)
@@ -37,7 +39,10 @@
""" Register for all events we care about """
ami.registerEvent("UserEvent", self.user_event)
- ami.registerEvent("BridgeExec", self.bridge_event)
+ if AsteriskVersion() >= AsteriskVersion('12'):
+ ami.registerEvent("BridgeEnter", self.bridge_enter_event)
+ else:
+ ami.registerEvent("BridgeExec", self.bridge_event)
#originate the bridgee
df = ami.originate(channel = "Local/local at call1", exten = "call", context = "test_context", priority = 1)
df.addErrback(self.handleOriginateFailure)
@@ -54,26 +59,26 @@
def process_test_event(self, ami, event):
#evaluate pass/failure
- logger.info("event: %s" % event)
+ LOGGER.info("event: %s" % event)
if (event.get('test') != "%d" % self.current_test):
- logger.error("test %d event didn't match expected test number. Test Failed." % self.current_test)
+ LOGGER.error("test %d event didn't match expected test number. Test Failed." % self.current_test)
self.stop_reactor()
return
if (event.get('status') != "SUCCESS"):
- logger.error("test %d event did not specify SUCCESS. Test Failed." % self.current_test)
+ LOGGER.error("test %d event did not specify SUCCESS. Test Failed." % self.current_test)
self.stop_reactor()
return
channel = event.get('channel')
if channel is None:
- logger.error("test %d did not include a channel in test event.")
+ LOGGER.error("test %d did not include a channel in test event.")
self.stop_reactor()
return
if not self.match_starts("Local/local at call1-", channel):
- logger.error("test %d SUCCESS was placed on the wrong channel. Test Failed." % self.current_test)
+ LOGGER.error("test %d SUCCESS was placed on the wrong channel. Test Failed." % self.current_test)
self.stop_reactor()
return
@@ -83,7 +88,7 @@
df = ami.originate(channel = "Local/local at call1", exten = "call", context = "test_context", priority = 1)
df.addErrback(self.handleOriginateFailure)
else:
- logger.info("All Bridge Transfer tests complete. Test Successful.")
+ LOGGER.info("All Bridge Transfer tests complete. Test Successful.")
self.passed = True
self.stop_reactor()
@@ -93,9 +98,20 @@
if channel is not None:
ami.hangup(channel)
else:
- logger.error("bridge event didn't include a channel1. That's not supposed to happen.")
+ LOGGER.error("bridge event didn't include a channel1. That's not supposed to happen.")
else:
- logger.error("A bridge failed. That's rather abnormal.")
+ LOGGER.error("A bridge failed. That's rather abnormal.")
+
+ def bridge_enter_event(self, ami, event):
+ if self.channel1 is None:
+ self.channel1 = event['channel']
+ LOGGER.info("Got first channel %s in bridge %s" % (self.channel1, event['bridgeuniqueid']))
+ return
+
+ LOGGER.info("Got second channel %s in bridge %s, hanging up %s" %
+ (event['channel'], event['bridgeuniqueid'], self.channel1))
+ ami.hangup(self.channel1)
+ self.channel1 = None
def match_starts(self, string1, string2):
pattern = re.compile(string1)
Modified: asterisk/trunk/tests/bridge/atxfer_nominal/transfer.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/bridge/atxfer_nominal/transfer.py?view=diff&rev=4192&r1=4191&r2=4192
==============================================================================
--- asterisk/trunk/tests/bridge/atxfer_nominal/transfer.py (original)
+++ asterisk/trunk/tests/bridge/atxfer_nominal/transfer.py Mon Sep 16 07:57:06 2013
@@ -11,6 +11,7 @@
import logging
sys.path.append("lib/python")
+from version import AsteriskVersion
LOGGER = logging.getLogger(__name__)
@@ -46,10 +47,19 @@
self._current_feature = None
self.test_object.register_feature_start_observer(self._handle_feature_start)
- self.test_object.register_feature_end_observer(self._handle_feature_end)
+ if AsteriskVersion() >= AsteriskVersion('12'):
+ self.test_object.register_ami_observer(self._handle_ami_connect)
+ else:
+ self.test_object.register_feature_end_observer(self._handle_feature_end)
if (Transfer.__singleton_instance == None):
Transfer.__singleton_instance = self
+
+ def _handle_ami_connect(self, ami):
+ ''' Handle AMI connect events '''
+ if (ami.id != 0):
+ return
+ ami.registerEvent('AttendedTransfer', self._handle_attended_transfer)
def _handle_feature_start(self, test_object, feature):
''' Callback for the BridgeTestCase feature detected event
@@ -80,6 +90,11 @@
raise Exception()
LOGGER.info('Hanging up channel %s' % channel)
ami.hangup(channel)
+
+ def _handle_attended_transfer(self, ami, event):
+ ''' Handle the AttendedTransfer event. Once the event has
+ triggered, the call can be torn down. '''
+ self._handle_feature_end(None, None)
def complete_attended_transfer(self):
'''
Modified: asterisk/trunk/tests/bridge/blonde_nominal/transfer.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/bridge/blonde_nominal/transfer.py?view=diff&rev=4192&r1=4191&r2=4192
==============================================================================
--- asterisk/trunk/tests/bridge/blonde_nominal/transfer.py (original)
+++ asterisk/trunk/tests/bridge/blonde_nominal/transfer.py Mon Sep 16 07:57:06 2013
@@ -11,6 +11,7 @@
import logging
sys.path.append("lib/python")
+from version import AsteriskVersion
LOGGER = logging.getLogger(__name__)
@@ -46,7 +47,8 @@
self._current_feature = None
self.test_object.register_feature_start_observer(self._handle_feature_start)
- self.test_object.register_feature_end_observer(self._handle_feature_end)
+ if AsteriskVersion() < AsteriskVersion('12'):
+ self.test_object.register_feature_end_observer(self._handle_feature_end)
self.test_object.register_ami_observer(self._handle_ami_connect)
if (Transfer.__singleton_instance == None):
@@ -57,6 +59,8 @@
if (ami.id != 0):
return
ami.registerEvent('Newstate', self._handle_new_state)
+ if AsteriskVersion() >= AsteriskVersion('12'):
+ ami.registerEvent('AttendedTransfer', self._handle_attended_transfer)
def _handle_new_state(self, ami, event):
''' Handle a new state change. When we get a ringing back on the
@@ -103,4 +107,8 @@
LOGGER.info('Hanging up channel %s' % channel)
ami.hangup(channel)
+ def _handle_attended_transfer(self, ami, event):
+ ''' Handle the AttendedTransfer event. Once the event has
+ triggered, the call can be torn down. '''
+ self._handle_feature_end(None, None)
Modified: asterisk/trunk/tests/bridge/transfer_failure/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/bridge/transfer_failure/test-config.yaml?view=diff&rev=4192&r1=4191&r2=4192
==============================================================================
--- asterisk/trunk/tests/bridge/transfer_failure/test-config.yaml (original)
+++ asterisk/trunk/tests/bridge/transfer_failure/test-config.yaml Mon Sep 16 07:57:06 2013
@@ -27,8 +27,13 @@
typename: 'ami.AMIEventModule'
minversion: '12'
-
- config-section: 'cel-config'
+ config-section: 'cel-config-11'
typename: 'cel.CELModule'
+ maxversion: '12'
+ -
+ config-section: 'ami-cel-config-12'
+ typename: 'ami.AMIEventModule'
+ minversion: '12'
-
config-section: 'cdr-config'
typename: 'cdr.CDRModule'
@@ -107,7 +112,7 @@
Direction: 'Received'
count: '8'
-cel-config:
+cel-config-11:
-
file: 'Master'
lines:
@@ -535,6 +540,483 @@
exten: 'bob_attended'
context: 'default'
channel: '.*/alice-.*'
+
+ami-cel-config-12:
+ -
+ type: 'cel'
+ conditions:
+ match:
+ Channel: 'SIP/alice-.*'
+ requirements:
+ -
+ match:
+ EventName: 'CHAN_START'
+ CallerIDname: 'Alice'
+ CallerIDnum: '1234'
+ Exten: 'alice_blind'
+ Context: 'default'
+ -
+ partialorder:
+ before: 'bob-start-one'
+ match:
+ EventName: 'APP_START'
+ CallerIDname: 'Alice'
+ CallerIDnum: '1234'
+ CallerIDdnid: 'alice_blind'
+ Exten: 'alice_blind'
+ Context: 'default'
+ Application: 'Dial'
+ -
+ partialorder:
+ after: 'bob-answer-one'
+ match:
+ EventName: 'ANSWER'
+ CallerIDname: 'Alice'
+ CallerIDnum: '1234'
+ CallerIDdnid: 'alice_blind'
+ Exten: 'alice_blind'
+ Context: 'default'
+ Application: 'Dial'
+ -
+ match:
+ EventName: 'BRIDGE_ENTER'
+ CallerIDname: 'Alice'
+ CallerIDnum: '1234'
+ CallerIDdnid: 'alice_blind'
+ Exten: 'alice_blind'
+ Context: 'default'
+ Application: 'Dial'
+ -
+ match:
+ EventName: 'BRIDGE_EXIT'
+ CallerIDname: 'Alice'
+ CallerIDnum: '1234'
+ CallerIDdnid: 'alice_blind'
+ Exten: 'alice_blind'
+ Context: 'default'
+ Application: 'Dial'
+ -
+ match:
+ EventName: 'APP_END'
+ CallerIDname: 'Alice'
+ CallerIDnum: '1234'
+ CallerIDdnid: 'alice_blind'
+ Exten: 'alice_blind'
+ Context: 'default'
+ Application: 'Dial'
+ -
+ match:
+ EventName: 'HANGUP'
+ CallerIDname: 'Alice'
+ CallerIDnum: '1234'
+ CallerIDdnid: 'alice_blind'
+ Exten: 'alice_blind'
+ Context: 'default'
+ Extra: '.*16.*ANSWER.*/alice-.*'
+ -
+ match:
+ EventName: 'CHAN_END'
+ CallerIDname: 'Alice'
+ CallerIDnum: '1234'
+ CallerIDdnid: 'alice_blind'
+ Exten: 'alice_blind'
+ Context: 'default'
+ -
+ match:
+ EventName: 'CHAN_START'
+ CallerIDname: 'Alice'
+ CallerIDnum: '1234'
+ Exten: 'alice_attended'
+ Context: 'default'
+ -
+ partialorder:
+ before: 'bob-start-two'
+ match:
+ EventName: 'APP_START'
+ CallerIDname: 'Alice'
+ CallerIDnum: '1234'
+ CallerIDdnid: 'alice_attended'
+ Exten: 'alice_attended'
+ Context: 'default'
+ Application: 'Dial'
+ -
+ partialorder:
+ after: 'bob-answer-two'
+ match:
+ EventName: 'ANSWER'
+ CallerIDname: 'Alice'
+ CallerIDnum: '1234'
+ CallerIDdnid: 'alice_attended'
+ Exten: 'alice_attended'
+ Context: 'default'
+ Application: 'Dial'
+ -
+ match:
+ EventName: 'BRIDGE_ENTER'
+ CallerIDname: 'Alice'
+ CallerIDnum: '1234'
+ CallerIDdnid: 'alice_attended'
+ Exten: 'alice_attended'
+ Context: 'default'
+ Application: 'Dial'
+ -
+ match:
+ EventName: 'BRIDGE_EXIT'
+ CallerIDname: 'Alice'
+ CallerIDnum: '1234'
+ CallerIDdnid: 'alice_attended'
+ Exten: 'alice_attended'
+ Context: 'default'
+ Application: 'Dial'
+ -
+ match:
+ EventName: 'APP_END'
+ CallerIDname: 'Alice'
+ CallerIDnum: '1234'
+ CallerIDdnid: 'alice_attended'
+ Exten: 'alice_attended'
+ Context: 'default'
+ Application: 'Dial'
+ -
+ match:
+ EventName: 'HANGUP'
+ CallerIDname: 'Alice'
+ CallerIDnum: '1234'
+ CallerIDdnid: 'alice_attended'
+ Exten: 'alice_attended'
+ Context: 'default'
+ Extra: '.*16.*ANSWER.*/alice-.*'
+ -
+ match:
+ EventName: 'CHAN_END'
+ CallerIDname: 'Alice'
+ CallerIDnum: '1234'
+ CallerIDdnid: 'alice_attended'
+ Exten: 'alice_attended'
+ Context: 'default'
+ -
+ match:
+ EventName: 'CHAN_START'
+ CallerIDname: 'Alice'
+ CallerIDnum: '1234'
+ Exten: 'bob_blind'
+ Context: 'default'
+ -
+ partialorder:
+ before: 'bob-start-three'
+ match:
+ EventName: 'APP_START'
+ CallerIDname: 'Alice'
+ CallerIDnum: '1234'
+ CallerIDdnid: 'bob_blind'
+ Exten: 'bob_blind'
+ Context: 'default'
+ Application: 'Dial'
+ -
+ partialorder:
+ after: 'bob-answer-three'
+ match:
+ EventName: 'ANSWER'
+ CallerIDname: 'Alice'
+ CallerIDnum: '1234'
+ CallerIDdnid: 'bob_blind'
+ Exten: 'bob_blind'
+ Context: 'default'
+ Application: 'Dial'
+ -
+ match:
+ EventName: 'BRIDGE_ENTER'
+ CallerIDname: 'Alice'
+ CallerIDnum: '1234'
+ CallerIDdnid: 'bob_blind'
+ Exten: 'bob_blind'
+ Context: 'default'
+ Application: 'Dial'
+ -
+ match:
+ EventName: 'BRIDGE_EXIT'
+ CallerIDname: 'Alice'
+ CallerIDnum: '1234'
+ CallerIDdnid: 'bob_blind'
+ Exten: 'bob_blind'
+ Context: 'default'
+ Application: 'Dial'
+ -
+ match:
+ EventName: 'APP_END'
+ CallerIDname: 'Alice'
+ CallerIDnum: '1234'
+ CallerIDdnid: 'bob_blind'
+ Exten: 'bob_blind'
+ Context: 'default'
+ Application: 'Dial'
+ -
+ match:
+ EventName: 'HANGUP'
+ CallerIDname: 'Alice'
+ CallerIDnum: '1234'
+ CallerIDdnid: 'bob_blind'
+ Exten: 'bob_blind'
+ Context: 'default'
+ Extra: '.*16.*ANSWER.*'
+ -
+ match:
+ EventName: 'CHAN_END'
+ CallerIDname: 'Alice'
+ CallerIDnum: '1234'
+ CallerIDdnid: 'bob_blind'
+ Exten: 'bob_blind'
+ Context: 'default'
+ -
+ match:
+ EventName: 'CHAN_START'
+ CallerIDname: 'Alice'
+ CallerIDnum: '1234'
+ Exten: 'bob_attended'
+ Context: 'default'
+ -
+ partialorder:
+ before: 'bob-start-four'
+ match:
+ EventName: 'APP_START'
+ CallerIDname: 'Alice'
+ CallerIDnum: '1234'
+ CallerIDdnid: 'bob_attended'
+ Exten: 'bob_attended'
+ Context: 'default'
+ Application: 'Dial'
+ -
+ partialorder:
+ after: 'bob-answer-four'
+ match:
+ EventName: 'ANSWER'
+ CallerIDname: 'Alice'
+ CallerIDnum: '1234'
+ CallerIDdnid: 'bob_attended'
+ Exten: 'bob_attended'
+ Context: 'default'
+ Application: 'Dial'
+ -
+ match:
+ EventName: 'BRIDGE_ENTER'
+ CallerIDname: 'Alice'
+ CallerIDnum: '1234'
+ CallerIDdnid: 'bob_attended'
+ Exten: 'bob_attended'
+ Context: 'default'
+ Application: 'Dial'
+ -
+ match:
+ EventName: 'BRIDGE_EXIT'
+ CallerIDname: 'Alice'
+ CallerIDnum: '1234'
+ CallerIDdnid: 'bob_attended'
+ Exten: 'bob_attended'
+ Context: 'default'
+ Application: 'Dial'
+ -
+ match:
+ EventName: 'APP_END'
+ CallerIDname: 'Alice'
+ CallerIDnum: '1234'
+ CallerIDdnid: 'bob_attended'
+ Exten: 'bob_attended'
+ Context: 'default'
+ Application: 'Dial'
+ -
+ match:
+ EventName: 'HANGUP'
+ CallerIDname: 'Alice'
+ CallerIDnum: '1234'
+ CallerIDdnid: 'bob_attended'
+ Exten: 'bob_attended'
+ Context: 'default'
+ Extra: '.*16.*ANSWER.*'
+ -
+ match:
+ EventName: 'CHAN_END'
+ CallerIDname: 'Alice'
+ CallerIDnum: '1234'
+ CallerIDdnid: 'bob_attended'
+ Exten: 'bob_attended'
+ Context: 'default'
+ -
+ type: 'cel'
+ conditions:
+ match:
+ requirements:
+ -
+ id: 'bob-start-one'
+ match:
+ EventName: 'CHAN_START'
+ CallerIDname: 'Bob'
+ CallerIDnum: '4321'
+ -
+ id: 'bob-answer-one'
+ match:
+ EventName: 'ANSWER'
+ CallerIDname: 'Bob'
+ CallerIDnum: '4321'
+ Application: 'AppDial'
+ AppData: '\(Outgoing Line\)'
+ -
+ match:
+ EventName: 'BRIDGE_ENTER'
+ CallerIDname: 'Bob'
+ CallerIDnum: '4321'
+ Context: 'default'
+ Application: 'AppDial'
+ -
+ match:
+ EventName: 'BRIDGE_EXIT'
+ CallerIDname: 'Bob'
+ CallerIDnum: '4321'
+ Context: 'default'
+ Application: 'AppDial'
+ -
+ match:
+ EventName: 'HANGUP'
+ CallerIDname: 'Bob'
+ CallerIDnum: '4321'
+ Application: 'AppDial'
+ AppData: '\(Outgoing Line\)'
+ Extra: '.*16.*/alice-.*'
+ -
+ match:
+ EventName: 'CHAN_END'
+ CallerIDname: 'Bob'
+ CallerIDnum: '4321'
+ Application: 'AppDial'
+ AppData: '\(Outgoing Line\)'
+ -
+ id: 'bob-start-two'
+ match:
+ EventName: 'CHAN_START'
+ CallerIDname: 'Bob'
+ CallerIDnum: '4321'
+ -
+ id: 'bob-answer-two'
+ match:
+ EventName: 'ANSWER'
+ CallerIDname: 'Bob'
+ CallerIDnum: '4321'
+ Application: 'AppDial'
+ AppData: '\(Outgoing Line\)'
+ -
+ match:
+ EventName: 'BRIDGE_ENTER'
+ CallerIDname: 'Bob'
+ CallerIDnum: '4321'
+ Context: 'default'
+ Application: 'AppDial'
+ -
+ match:
+ EventName: 'BRIDGE_EXIT'
+ CallerIDname: 'Bob'
+ CallerIDnum: '4321'
+ Context: 'default'
+ Application: 'AppDial'
+ -
+ match:
+ EventName: 'HANGUP'
+ CallerIDname: 'Bob'
+ CallerIDnum: '4321'
+ Application: 'AppDial'
+ AppData: '\(Outgoing Line\)'
+ Extra: '.*16.*/alice-.*'
+ -
+ match:
+ EventName: 'CHAN_END'
+ CallerIDname: 'Bob'
+ CallerIDnum: '4321'
+ Application: 'AppDial'
+ AppData: '\(Outgoing Line\)'
+ -
+ id: 'bob-start-three'
+ match:
+ EventName: 'CHAN_START'
+ CallerIDname: 'Bob'
+ CallerIDnum: '4321'
+ -
+ id: 'bob-answer-three'
+ match:
+ EventName: 'ANSWER'
+ CallerIDname: 'Bob'
+ CallerIDnum: '4321'
+ Application: 'AppDial'
+ AppData: '\(Outgoing Line\)'
+ -
+ match:
+ EventName: 'BRIDGE_ENTER'
+ CallerIDname: 'Bob'
+ CallerIDnum: '4321'
+ Context: 'default'
+ Application: 'AppDial'
+ -
+ match:
+ EventName: 'BRIDGE_EXIT'
+ CallerIDname: 'Bob'
+ CallerIDnum: '4321'
+ Context: 'default'
+ Application: 'AppDial'
+ -
+ match:
+ EventName: 'HANGUP'
+ CallerIDname: 'Bob'
+ CallerIDnum: '4321'
+ Application: 'AppDial'
+ AppData: '\(Outgoing Line\)'
+ Extra: '.*16.*'
+ -
+ match:
+ EventName: 'CHAN_END'
+ CallerIDname: 'Bob'
+ CallerIDnum: '4321'
+ Application: 'AppDial'
+ AppData: '\(Outgoing Line\)'
+ -
+ id: 'bob-start-four'
+ match:
+ EventName: 'CHAN_START'
+ CallerIDname: 'Bob'
+ CallerIDnum: '4321'
+ -
+ id: 'bob-answer-four'
+ match:
+ EventName: 'ANSWER'
+ CallerIDname: 'Bob'
+ CallerIDnum: '4321'
+ Application: 'AppDial'
+ AppData: '\(Outgoing Line\)'
+ -
+ match:
+ EventName: 'BRIDGE_ENTER'
+ CallerIDname: 'Bob'
+ CallerIDnum: '4321'
+ Context: 'default'
+ Application: 'AppDial'
+ -
+ match:
+ EventName: 'BRIDGE_EXIT'
+ CallerIDname: 'Bob'
+ CallerIDnum: '4321'
+ Context: 'default'
+ Application: 'AppDial'
+ -
+ match:
+ EventName: 'HANGUP'
+ CallerIDname: 'Bob'
+ CallerIDnum: '4321'
+ Application: 'AppDial'
+ AppData: '\(Outgoing Line\)'
+ Extra: '.*16.*'
+ -
+ match:
+ EventName: 'CHAN_END'
+ CallerIDname: 'Bob'
+ CallerIDnum: '4321'
+ Application: 'AppDial'
+ AppData: '\(Outgoing Line\)'
cdr-config:
-
More information about the asterisk-commits
mailing list