[asterisk-commits] kharwell: testsuite/asterisk/trunk r4490 - /asterisk/trunk/tests/rest_api/app...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Dec 19 16:44:32 CST 2013
Author: kharwell
Date: Thu Dec 19 16:44:29 2013
New Revision: 4490
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=4490
Log:
rest_api: applications/subscribe bridge test was failing
There was a race condition on the ChannelEnteredBrdige event handlers between
the two subscribed apps. Now only one of the apps listens for the event and
handles the test dynamics appropriately.
(closes issue ASTERISK-22996)
Reported by: Matt Jordan
Modified:
asterisk/trunk/tests/rest_api/applications/subscribe-bridge/subscribe_bridge.py
asterisk/trunk/tests/rest_api/applications/subscribe-bridge/test-config.yaml
Modified: asterisk/trunk/tests/rest_api/applications/subscribe-bridge/subscribe_bridge.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/applications/subscribe-bridge/subscribe_bridge.py?view=diff&rev=4490&r1=4489&r2=4490
==============================================================================
--- asterisk/trunk/tests/rest_api/applications/subscribe-bridge/subscribe_bridge.py (original)
+++ asterisk/trunk/tests/rest_api/applications/subscribe-bridge/subscribe_bridge.py Thu Dec 19 16:44:29 2013
@@ -18,35 +18,38 @@
TEST = SubscribeBridge()
-
def on_start(ari, event, test_object):
TEST.channel_id = event['channel']['id']
TEST.bridge_id = ari.post('bridges').json()['id']
+
+ # at this point the 'testsuite' app is subscribed to the bridge
+ # subscribe another app 'bridge-watching-app' to receive events
ari.post('applications', 'bridge-watching-app', 'subscription',
eventSource='bridge:%s' % TEST.bridge_id)
+
+ # both applications should receive a ChannelEnteredBridge
+ # event upon adding a channel
ari.post('bridges', TEST.bridge_id, 'addChannel',
channel=TEST.channel_id)
return True
-
def on_enter_testsuite(ari, event, test_object):
+ # the testsuite application received a ChannelEnteredBridge event
assert TEST.bridge_id == event['bridge']['id']
assert TEST.channel_id == event['channel']['id']
- # Unsubscribe testsuite from the bridge
+
+ # now unsubscribe testsuite from the bridge.
ari.delete('applications', 'testsuite', 'subscription',
eventSource='bridge:%s' % TEST.bridge_id)
- return True
-
-def on_enter_watcher(ari, event, test_object):
- assert TEST.bridge_id == event['bridge']['id']
- assert TEST.channel_id == event['channel']['id']
+ # upon removing the channel testsuite should receive no event, but
+ # the still subscribed bridge-watching-app should
ari.post('bridges', TEST.bridge_id, 'removeChannel',
channel=TEST.channel_id)
return True
-
def on_channel_left_bridge(ari, event, test_object):
+ # bridge-watching-app received a ChannelLeftBridge event
assert TEST.bridge_id == event['bridge']['id']
assert TEST.channel_id == event['channel']['id']
ari.delete('channels', TEST.channel_id);
Modified: asterisk/trunk/tests/rest_api/applications/subscribe-bridge/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/applications/subscribe-bridge/test-config.yaml?view=diff&rev=4490&r1=4489&r2=4490
==============================================================================
--- asterisk/trunk/tests/rest_api/applications/subscribe-bridge/test-config.yaml (original)
+++ asterisk/trunk/tests/rest_api/applications/subscribe-bridge/test-config.yaml Thu Dec 19 16:44:29 2013
@@ -38,21 +38,12 @@
method: on_enter_testsuite
- conditions:
match:
- type: ChannelEnteredBridge
- application: bridge-watching-app
- bridge:
- channel:
- count: 1
- callback:
- module: subscribe_bridge
- method: on_enter_watcher
- - conditions:
- match:
type: ChannelLeftBridge
application: testsuite
bridge:
channel:
- count: 0 # should not happen
+ count: 0 # event should not happen since the 'testsuite'
+ # application won't be subscribed by raise time
- conditions:
match:
type: ChannelLeftBridge
More information about the asterisk-commits
mailing list