[asterisk-commits] kmoore: testsuite/asterisk/trunk r4020 - in /asterisk/trunk/tests/channels/SI...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Aug 15 07:21:40 CDT 2013
Author: kmoore
Date: Thu Aug 15 07:21:37 2013
New Revision: 4020
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=4020
Log:
Fix the chan_sip blind transfer tests
This modifies the SIP blind transfer tests that run against chan_sip to
function properly on Asterisk 12 by handling the new bridging and
transfer events instead of the older ones.
Review: https://reviewboard.asterisk.org/r/2758/
(closes issue ASTERISK-22215)
Modified:
asterisk/trunk/tests/channels/SIP/sip_blind_transfer/callee_refer_only/run-test
asterisk/trunk/tests/channels/SIP/sip_blind_transfer/callee_with_reinvite/run-test
asterisk/trunk/tests/channels/SIP/sip_blind_transfer/caller_refer_only/run-test
asterisk/trunk/tests/channels/SIP/sip_blind_transfer/caller_with_reinvite/run-test
Modified: asterisk/trunk/tests/channels/SIP/sip_blind_transfer/callee_refer_only/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/SIP/sip_blind_transfer/callee_refer_only/run-test?view=diff&rev=4020&r1=4019&r2=4020
==============================================================================
--- asterisk/trunk/tests/channels/SIP/sip_blind_transfer/callee_refer_only/run-test (original)
+++ asterisk/trunk/tests/channels/SIP/sip_blind_transfer/callee_refer_only/run-test Thu Aug 15 07:21:37 2013
@@ -20,6 +20,7 @@
sys.path.append("lib/python")
from asterisk.asterisk import Asterisk
from asterisk.TestCase import TestCase
+from asterisk.version import AsteriskVersion
logger = logging.getLogger(__name__)
@@ -36,6 +37,8 @@
def __init__(self):
TestCase.__init__(self)
self.passed = False
+ self.channel1 = None
+ self.transfer_event_received = False
self.create_asterisk()
def read_result(self):
@@ -55,11 +58,35 @@
# start up the processes
self.start_processes()
- ami.registerEvent('Bridge', self.bridge_event_handler)
- ami.registerEvent('Transfer', self.transfer_event_handler)
+ if AsteriskVersion() >= AsteriskVersion("12"):
+ ami.registerEvent('BridgeEnter', self.bridge_enter_event_handler)
+ ami.registerEvent('BlindTransfer', self.blind_transfer_event_handler)
+ else:
+ ami.registerEvent('Bridge', self.bridge_event_handler)
+ ami.registerEvent('Transfer', self.transfer_event_handler)
ami.registerEvent('Hangup', self.hangup_event_handler)
self.a_call_b()
+
+ def bridge_enter_event_handler(self, ami, event):
+ if not self.channel1:
+ self.channel1 = event['channel']
+ logger.debug("Received bridge enter for channel %s" % self.channel1)
+ return
+
+ channel2 = event['channel']
+ logger.debug("Received bridge enter for channel %s" % channel2)
+
+ if (self.channel1 == BlindTransfer.phone_a_channel and channel2 == BlindTransfer.phone_b_channel) or \
+ (self.channel1 == BlindTransfer.phone_b_channel and channel2 == BlindTransfer.phone_a_channel):
+ logger.debug("Starting transfer of Phone B to Phone C")
+ self.b_transfer_a_to_c()
+ self.channel1 = None
+ elif (self.channel1 == BlindTransfer.phone_a_channel and channel2 == BlindTransfer.phone_c_channel) or \
+ (self.channel1 == BlindTransfer.phone_c_channel and channel2 == BlindTransfer.phone_a_channel):
+ self.ami_check_bridge()
+ else:
+ logger.warning("Unexpected bridge (%s and %s) received!" % (self.channel1, channel2))
def bridge_event_handler(self, ami, event):
bridgetype = event['bridgetype'].lower()
@@ -78,6 +105,13 @@
elif bridgetype != 'core' or bridgestate != 'unlink':
logger.warning("Unexpected bridgetype %s or bridgestate %s received!" % (bridgetype, bridgestate))
+ def blind_transfer_event_handler(self, ami, event):
+ if event['isexternal'].lower() != 'yes':
+ logger.warn("Unexpected transfer type: Internal")
+ else:
+ logger.debug("Received blind external transfer initiated by %(transfererchannel)s to %(extension)s@%(context)s" % event)
+ self.transfer_event_received = True
+
def transfer_event_handler(self, ami, event):
transfertype = event['transfertype'].lower()
transfermethod = event['transfermethod'].lower()
@@ -102,6 +136,12 @@
logger.warn("Transfer event failed or contained incorrect data; not checking bridge results")
self.passed = False
self.read_result()
+ return
+
+ if AsteriskVersion() >= AsteriskVersion('12'):
+ # the following has already been verified using bridgeenter messages so exit early
+ self.passed = True
+ self.hangup_channel_c()
return
logger.debug('Results %s' % str(results))
Modified: asterisk/trunk/tests/channels/SIP/sip_blind_transfer/callee_with_reinvite/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/SIP/sip_blind_transfer/callee_with_reinvite/run-test?view=diff&rev=4020&r1=4019&r2=4020
==============================================================================
--- asterisk/trunk/tests/channels/SIP/sip_blind_transfer/callee_with_reinvite/run-test (original)
+++ asterisk/trunk/tests/channels/SIP/sip_blind_transfer/callee_with_reinvite/run-test Thu Aug 15 07:21:37 2013
@@ -20,6 +20,7 @@
sys.path.append("lib/python")
from asterisk.asterisk import Asterisk
from asterisk.TestCase import TestCase
+from asterisk.version import AsteriskVersion
logger = logging.getLogger(__name__)
@@ -36,6 +37,8 @@
def __init__(self):
TestCase.__init__(self)
self.passed = False
+ self.channel1 = None
+ self.transfer_event_received = False
self.create_asterisk()
def read_result(self):
@@ -55,11 +58,35 @@
# start up the processes
self.start_processes()
- ami.registerEvent('Bridge', self.bridge_event_handler)
- ami.registerEvent('Transfer', self.transfer_event_handler)
+ if AsteriskVersion() >= AsteriskVersion("12"):
+ ami.registerEvent('BridgeEnter', self.bridge_enter_event_handler)
+ ami.registerEvent('BlindTransfer', self.blind_transfer_event_handler)
+ else:
+ ami.registerEvent('Bridge', self.bridge_event_handler)
+ ami.registerEvent('Transfer', self.transfer_event_handler)
ami.registerEvent('Hangup', self.hangup_event_handler)
self.a_call_b()
+
+ def bridge_enter_event_handler(self, ami, event):
+ if not self.channel1:
+ self.channel1 = event['channel']
+ logger.debug("Received bridge enter for channel %s" % self.channel1)
+ return
+
+ channel2 = event['channel']
+ logger.debug("Received bridge enter for channel %s" % channel2)
+
+ if (self.channel1 == BlindTransfer.phone_a_channel and channel2 == BlindTransfer.phone_b_channel) or \
+ (self.channel1 == BlindTransfer.phone_b_channel and channel2 == BlindTransfer.phone_a_channel):
+ logger.debug("Starting transfer of Phone B to Phone C")
+ self.b_transfer_a_to_c()
+ self.channel1 = None
+ elif (self.channel1 == BlindTransfer.phone_a_channel and channel2 == BlindTransfer.phone_c_channel) or \
+ (self.channel1 == BlindTransfer.phone_c_channel and channel2 == BlindTransfer.phone_a_channel):
+ self.ami_check_bridge()
+ else:
+ logger.warning("Unexpected bridge (%s and %s) received!" % (self.channel1, channel2))
def bridge_event_handler(self, ami, event):
bridgetype = event['bridgetype'].lower()
@@ -78,6 +105,13 @@
elif bridgetype != 'core' or bridgestate != 'unlink':
logger.warning("Unexpected bridgetype %s or bridgestate %s received!" % (bridgetype, bridgestate))
+ def blind_transfer_event_handler(self, ami, event):
+ if event['isexternal'].lower() != 'yes':
+ logger.warn("Unexpected transfer type: Internal")
+ else:
+ logger.debug("Received blind external transfer initiated by %(transfererchannel)s to %(extension)s@%(context)s" % event)
+ self.transfer_event_received = True
+
def transfer_event_handler(self, ami, event):
transfertype = event['transfertype'].lower()
transfermethod = event['transfermethod'].lower()
@@ -102,6 +136,12 @@
logger.warn("Transfer event failed or contained incorrect data; not checking bridge results")
self.passed = False
self.read_result()
+ return
+
+ if AsteriskVersion() >= AsteriskVersion('12'):
+ # the following has already been verified using bridgeenter messages so exit early
+ self.passed = True
+ self.hangup_channel_c()
return
logger.debug('Results %s' % str(results))
Modified: asterisk/trunk/tests/channels/SIP/sip_blind_transfer/caller_refer_only/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/SIP/sip_blind_transfer/caller_refer_only/run-test?view=diff&rev=4020&r1=4019&r2=4020
==============================================================================
--- asterisk/trunk/tests/channels/SIP/sip_blind_transfer/caller_refer_only/run-test (original)
+++ asterisk/trunk/tests/channels/SIP/sip_blind_transfer/caller_refer_only/run-test Thu Aug 15 07:21:37 2013
@@ -20,6 +20,7 @@
sys.path.append("lib/python")
from asterisk.asterisk import Asterisk
from asterisk.TestCase import TestCase
+from asterisk.version import AsteriskVersion
logger = logging.getLogger(__name__)
@@ -36,6 +37,7 @@
def __init__(self):
TestCase.__init__(self)
self.passed = False
+ self.channel1 = None
self.transfer_event_received = False
self.create_asterisk()
@@ -56,11 +58,35 @@
# start up the processes
self.start_processes()
- ami.registerEvent('Bridge', self.bridge_event_handler)
- ami.registerEvent('Transfer', self.transfer_event_handler)
+ if AsteriskVersion() >= AsteriskVersion("12"):
+ ami.registerEvent('BridgeEnter', self.bridge_enter_event_handler)
+ ami.registerEvent('BlindTransfer', self.blind_transfer_event_handler)
+ else:
+ ami.registerEvent('Bridge', self.bridge_event_handler)
+ ami.registerEvent('Transfer', self.transfer_event_handler)
ami.registerEvent('Hangup', self.hangup_event_handler)
self.a_call_b()
+
+ def bridge_enter_event_handler(self, ami, event):
+ if not self.channel1:
+ self.channel1 = event['channel']
+ logger.debug("Received bridge enter for channel %s" % self.channel1)
+ return
+
+ channel2 = event['channel']
+ logger.debug("Received bridge enter for channel %s" % channel2)
+
+ if (self.channel1 == BlindTransfer.phone_a_channel and channel2 == BlindTransfer.phone_b_channel) or \
+ (self.channel1 == BlindTransfer.phone_b_channel and channel2 == BlindTransfer.phone_a_channel):
+ logger.debug("Starting transfer of Phone B to Phone C")
+ self.a_transfer_b_to_c()
+ self.channel1 = None
+ elif (self.channel1 == BlindTransfer.phone_b_channel and channel2 == BlindTransfer.phone_c_channel) or \
+ (self.channel1 == BlindTransfer.phone_c_channel and channel2 == BlindTransfer.phone_b_channel):
+ self.ami_check_bridge()
+ else:
+ logger.warning("Unexpected bridge (%s and %s) received!" % (self.channel1, channel2))
def bridge_event_handler(self, ami, event):
bridgetype = event['bridgetype'].lower()
@@ -79,6 +105,13 @@
elif bridgetype != 'core' or bridgestate != 'unlink':
logger.warning("Unexpected bridgetype %s or bridgestate %s received!" % (bridgetype, bridgestate))
+ def blind_transfer_event_handler(self, ami, event):
+ if event['isexternal'].lower() != 'yes':
+ logger.warn("Unexpected transfer type: Internal")
+ else:
+ logger.debug("Received blind external transfer initiated by %(transfererchannel)s to %(extension)s@%(context)s" % event)
+ self.transfer_event_received = True
+
def transfer_event_handler(self, ami, event):
transfertype = event['transfertype'].lower()
transfermethod = event['transfermethod'].lower()
@@ -103,6 +136,12 @@
logger.warn("Transfer event failed or contained incorrect data; not checking bridge results")
self.passed = False
self.read_result()
+ return
+
+ if AsteriskVersion() >= AsteriskVersion('12'):
+ # the following has already been verified using bridgeenter messages so exit early
+ self.passed = True
+ self.hangup_channel_c()
return
logger.debug('Results %s' % str(results))
Modified: asterisk/trunk/tests/channels/SIP/sip_blind_transfer/caller_with_reinvite/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/SIP/sip_blind_transfer/caller_with_reinvite/run-test?view=diff&rev=4020&r1=4019&r2=4020
==============================================================================
--- asterisk/trunk/tests/channels/SIP/sip_blind_transfer/caller_with_reinvite/run-test (original)
+++ asterisk/trunk/tests/channels/SIP/sip_blind_transfer/caller_with_reinvite/run-test Thu Aug 15 07:21:37 2013
@@ -20,6 +20,7 @@
sys.path.append("lib/python")
from asterisk.asterisk import Asterisk
from asterisk.TestCase import TestCase
+from asterisk.version import AsteriskVersion
logger = logging.getLogger(__name__)
@@ -36,6 +37,8 @@
def __init__(self):
TestCase.__init__(self)
self.passed = False
+ self.channel1 = None
+ self.transfer_event_received = False
self.create_asterisk()
def read_result(self):
@@ -62,11 +65,35 @@
# start up the processes
self.start_processes()
- ami.registerEvent('Bridge', self.bridge_event_handler)
- ami.registerEvent('Transfer', self.transfer_event_handler)
+ if AsteriskVersion() >= AsteriskVersion("12"):
+ ami.registerEvent('BridgeEnter', self.bridge_enter_event_handler)
+ ami.registerEvent('BlindTransfer', self.blind_transfer_event_handler)
+ else:
+ ami.registerEvent('Bridge', self.bridge_event_handler)
+ ami.registerEvent('Transfer', self.transfer_event_handler)
ami.registerEvent('Hangup', self.hangup_event_handler)
self.a_call_b()
+
+ def bridge_enter_event_handler(self, ami, event):
+ if not self.channel1:
+ self.channel1 = event['channel']
+ logger.debug("Received bridge enter for channel %s" % self.channel1)
+ return
+
+ channel2 = event['channel']
+ logger.debug("Received bridge enter for channel %s" % channel2)
+
+ if (self.channel1 == BlindTransfer.phone_a_channel and channel2 == BlindTransfer.phone_b_channel) or \
+ (self.channel1 == BlindTransfer.phone_b_channel and channel2 == BlindTransfer.phone_a_channel):
+ logger.debug("Starting transfer of Phone B to Phone C")
+ self.a_transfer_b_to_c()
+ self.channel1 = None
+ elif (self.channel1 == BlindTransfer.phone_b_channel and channel2 == BlindTransfer.phone_c_channel) or \
+ (self.channel1 == BlindTransfer.phone_c_channel and channel2 == BlindTransfer.phone_b_channel):
+ self.ami_check_bridge()
+ else:
+ logger.warning("Unexpected bridge (%s and %s) received!" % (self.channel1, channel2))
def bridge_event_handler(self, ami, event):
bridgetype = event['bridgetype'].lower()
@@ -85,6 +112,13 @@
elif bridgetype != 'core' or bridgestate != 'unlink':
logger.warning("Unexpected bridgetype %s or bridgestate %s received!" % (bridgetype, bridgestate))
+ def blind_transfer_event_handler(self, ami, event):
+ if event['isexternal'].lower() != 'yes':
+ logger.warn("Unexpected transfer type: Internal")
+ else:
+ logger.debug("Received blind external transfer initiated by %(transfererchannel)s to %(extension)s@%(context)s" % event)
+ self.transfer_event_received = True
+
def transfer_event_handler(self, ami, event):
transfertype = event['transfertype'].lower()
transfermethod = event['transfermethod'].lower()
@@ -109,6 +143,12 @@
logger.warn("Transfer event failed or contained incorrect data; not checking bridge results")
self.passed = False
self.read_result()
+ return
+
+ if AsteriskVersion() >= AsteriskVersion('12'):
+ # the following has already been verified using bridgeenter messages so exit early
+ self.passed = True
+ self.hangup_channel_c()
return
logger.debug('Results %s' % str(results))
More information about the asterisk-commits
mailing list