[asterisk-commits] mjordan: testsuite/asterisk/trunk r4408 - /asterisk/trunk/tests/channels/pjsi...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Dec 8 22:37:42 CST 2013


Author: mjordan
Date: Sun Dec  8 22:37:40 2013
New Revision: 4408

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=4408
Log:
show_subscriptions: Update test to not terminate on SIPp Scenario

The test object for the show_subscriptions test was inheriting from
the SIPpTestCase class. This class can only be used for tests that terminate
when the SIPp scenarios terminate, as the class will automatically stop the
reactor when the last SIPp scenario finishes. In the case of this test, the
SIPp scenario is merely used to create a subscription so that a subsequent
AMI action will successfully query for the subscriptions. Since the
scenario stops the reactor and kills Asterisk, this was unlikely to succeed
unless the AMI action ran at exactly the right time.

This patch changes the test object so that it inherits from TestCase. The
test object now manages the SIPp Scenario itself.

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=4408&r1=4407&r2=4408
==============================================================================
--- asterisk/trunk/tests/channels/pjsip/ami/show_subscriptions/AMISendTest.py (original)
+++ asterisk/trunk/tests/channels/pjsip/ami/show_subscriptions/AMISendTest.py Sun Dec  8 22:37:40 2013
@@ -8,25 +8,40 @@
 '''
 
 import sys
-import time
+import logging
 
 sys.path.append("lib/python/asterisk")
 
-from sipp import SIPpTestCase
+from sipp import SIPpScenario
+from TestCase import TestCase
+
+from twisted.internet import reactor
+
+logger = logging.getLogger(__name__)
 
 ACTION = {
     "Action":"PJSIPShowSubscriptionsInbound"
 }
 
-class AMISendTest(SIPpTestCase):
+class AMISendTest(TestCase):
     def __init__(self, path=None, config=None):
         super(AMISendTest, self).__init__(path, config)
+        self.create_asterisk()
 
     def run(self):
         super(AMISendTest, self).run()
+        self.create_ami_factory()
 
     def ami_connect(self, ami):
         super(AMISendTest, self).ami_connect(ami)
-        # give some time for everything to subscribe
-        time.sleep(3)
-        ami.sendDeferred(ACTION).addCallback(ami.errorUnlessResponse)
+
+        def _send_show_subscriptions(obj):
+            logger.info('Getting inbound subscriptions...')
+            ami.sendDeferred(ACTION).addCallback(ami.errorUnlessResponse)
+            reactor.callLater(2, self.stop_reactor)
+            return obj
+
+        logger.info('Starting subscription scenario')
+        sipp = SIPpScenario(self.test_name,
+            {'scenario':'subscribe.xml', '-p':'5061' })
+        sipp.run(self).addCallback(_send_show_subscriptions)




More information about the asterisk-commits mailing list