[asterisk-commits] kmoore: testsuite/asterisk/trunk r4927 - /asterisk/trunk/tests/channels/pjsip...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Apr 3 07:01:18 CDT 2014
Author: kmoore
Date: Thu Apr 3 07:01:12 2014
New Revision: 4927
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=4927
Log:
TestSuite: Fix bouncing show_subscriptions test
This fixes a race condition in the PJSIP AMI show_subscriptions test
where the PJSIPShowSubscriptionsInbound AMI command would be issued
before states had finished transitioning resulting in the response
containing "NULL" instead of "ACTIVE".
Review: https://reviewboard.asterisk.org/r/3383/
Modified:
asterisk/trunk/tests/channels/pjsip/ami/show_subscriptions/AMISendTest.py
Modified: asterisk/trunk/tests/channels/pjsip/ami/show_subscriptions/AMISendTest.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/pjsip/ami/show_subscriptions/AMISendTest.py?view=diff&rev=4927&r1=4926&r2=4927
==============================================================================
--- asterisk/trunk/tests/channels/pjsip/ami/show_subscriptions/AMISendTest.py (original)
+++ asterisk/trunk/tests/channels/pjsip/ami/show_subscriptions/AMISendTest.py Thu Apr 3 07:01:12 2014
@@ -25,6 +25,7 @@
class AMISendTest(TestCase):
def __init__(self, path=None, config=None):
+ self.updates_received = 0
super(AMISendTest, self).__init__(path, config)
self.create_asterisk()
@@ -35,13 +36,22 @@
def ami_connect(self, ami):
super(AMISendTest, self).ami_connect(ami)
- def _send_show_subscriptions(obj):
- LOGGER.info('Getting inbound subscriptions...')
- ami.sendDeferred(ACTION).addCallback(ami.errorUnlessResponse)
- reactor.callLater(2, self.stop_reactor)
- return obj
-
+ ami.registerEvent("TestEvent", self.test_event)
LOGGER.info('Starting subscription scenario')
sipp = SIPpScenario(self.test_name,
{'scenario':'subscribe.xml', '-p':'5061' })
- sipp.run(self).addCallback(_send_show_subscriptions)
+ sipp.run(self)
+
+ def test_event(self, ami, event):
+ if event['state'] != "SUBSCRIPTION_STATE_SET" \
+ or event['statetext'] != "ACTIVE" \
+ or event['endpoint'] != "user1":
+ return
+
+ self.updates_received += 1
+ if self.updates_received != 2:
+ return
+
+ LOGGER.info('Getting inbound subscriptions...')
+ ami.sendDeferred(ACTION).addCallback(ami.errorUnlessResponse)
+ reactor.callLater(2, self.stop_reactor)
More information about the asterisk-commits
mailing list