[svn-commits] mjordan: testsuite/asterisk/trunk r5477 - /asterisk/trunk/tests/rest_api/brid...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Sun Aug 17 15:55:59 CDT 2014
Author: mjordan
Date: Sun Aug 17 15:55:56 2014
New Revision: 5477
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=5477
Log:
blind_transfer: Fix race condition when blind transferring party
The blind_transfer REST API test previously initiated the blind transfer
on both channels entering Stasis. It would also place the channels into
the bridge during the same callback, but did not wait for the
ChannelEnteredBridge event. Because of that, at times, the blind transfer
would fail, as one of the channels would not be in the bridge.
This patch triggers the blind transfer when both ChannelEnteredBridge events
have fired.
Modified:
asterisk/trunk/tests/rest_api/bridges/blind_transfer/blind_transfer.py
asterisk/trunk/tests/rest_api/bridges/blind_transfer/test-config.yaml
Modified: asterisk/trunk/tests/rest_api/bridges/blind_transfer/blind_transfer.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/bridges/blind_transfer/blind_transfer.py?view=diff&rev=5477&r1=5476&r2=5477
==============================================================================
--- asterisk/trunk/tests/rest_api/bridges/blind_transfer/blind_transfer.py (original)
+++ asterisk/trunk/tests/rest_api/bridges/blind_transfer/blind_transfer.py Sun Aug 17 15:55:56 2014
@@ -12,29 +12,29 @@
LOGGER = logging.getLogger(__name__)
class TestLogic(object):
- def __init__(self):
- self.channels = 0
- self.bridge_id = None
- self.pja = subprocess.Popen(['pjsua', '--local-port=5065', '--null-audio',
- '--id=sip:bob at 127.0.0.1'],
- stdin=subprocess.PIPE, stdout=subprocess.PIPE)
- self.pjb = subprocess.Popen(['pjsua', '--local-port=5066', '--null-audio',
- '--id=sip:alice at 127.0.0.1'],
- stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+ def __init__(self):
+ self.channels = 0
+ self.bridge_id = None
+ self.pja = subprocess.Popen(['pjsua', '--local-port=5065', '--null-audio',
+ '--id=sip:bob at 127.0.0.1'],
+ stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+ self.pjb = subprocess.Popen(['pjsua', '--local-port=5066', '--null-audio',
+ '--id=sip:alice at 127.0.0.1'],
+ stdin=subprocess.PIPE, stdout=subprocess.PIPE)
TEST = TestLogic()
def a_call_stasis():
- TEST.pja.stdin.write("m\n")
- TEST.pja.stdin.write("sip:stasis at 127.0.0.1:5060\n")
+ TEST.pja.stdin.write("m\n")
+ TEST.pja.stdin.write("sip:stasis at 127.0.0.1:5060\n")
def b_call_stasis():
- TEST.pjb.stdin.write("m\n")
- TEST.pjb.stdin.write("sip:stasis at 127.0.0.1:5060\n")
+ TEST.pjb.stdin.write("m\n")
+ TEST.pjb.stdin.write("sip:stasis at 127.0.0.1:5060\n")
def a_call_transfer():
- TEST.pja.stdin.write("x\n")
- TEST.pja.stdin.write("sip:1000 at 127.0.0.1:5060\n")
+ TEST.pja.stdin.write("x\n")
+ TEST.pja.stdin.write("sip:1000 at 127.0.0.1:5060\n")
def on_kickoff_start(ari, event, test_object):
LOGGER.debug("on_kickoff_start(%r)" % event)
@@ -48,20 +48,29 @@
LOGGER.debug("on_test_start(%r)" % event)
ari.post('bridges', TEST.bridge_id, 'addChannel', channel=event['channel']['id'])
+ return True
+
+def on_channel_entered_bridge(ari, event, test_object):
+
TEST.channels += 1
if TEST.channels == 2:
a_call_transfer()
return True
+
def on_blind_transfer(ari, event, test_object):
- LOGGER.debug("on_blind_transfer(%r)" % event)
- ari.delete('bridges', TEST.bridge_id)
- TEST.pjb.stdin.write("h\n")
+ LOGGER.debug("on_blind_transfer(%r)" % event)
+ ari.delete('bridges', TEST.bridge_id)
+ TEST.pjb.stdin.write("h\n")
- if not event['channel']['name'].startswith('PJSIP/bob-'):
- return False
- elif event['bridge']['id'] != TEST.bridge_id:
- return False
+ if event.get('result') != 'Success':
+ LOGGER.error('Blind transfer failed: %s' % event.get('result'))
+ return False
- return True
+ if not event['channel']['name'].startswith('PJSIP/bob-'):
+ return False
+ elif event['bridge']['id'] != TEST.bridge_id:
+ return False
+
+ return True
Modified: asterisk/trunk/tests/rest_api/bridges/blind_transfer/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/bridges/blind_transfer/test-config.yaml?view=diff&rev=5477&r1=5476&r2=5477
==============================================================================
--- asterisk/trunk/tests/rest_api/bridges/blind_transfer/test-config.yaml (original)
+++ asterisk/trunk/tests/rest_api/bridges/blind_transfer/test-config.yaml Sun Aug 17 15:55:56 2014
@@ -35,6 +35,13 @@
method: on_test_start
- conditions:
match:
+ type: ChannelEnteredBridge
+ count: 2
+ callback:
+ module: blind_transfer
+ method: on_channel_entered_bridge
+ - conditions:
+ match:
type: BridgeBlindTransfer
application: testsuite
count: 1
More information about the svn-commits
mailing list