[asterisk-commits] kmoore: testsuite/asterisk/trunk r3111 - /asterisk/trunk/lib/python/asterisk/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Mar 21 08:42:30 CDT 2012
Author: kmoore
Date: Wed Mar 21 08:42:26 2012
New Revision: 3111
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=3111
Log:
Ensure that SimpleTestCase-based tests complete in a reasonable amount of time
SimpleTestCase was causing test failures because the channels in use were not
torn down when the reactor was stopped. This explicitly hangs up the channels
so that test times are not unreasonably extended. For the 4 tests affected,
test times were reduced from approximately 70 seconds to under 3 seconds.
Modified:
asterisk/trunk/lib/python/asterisk/SimpleTestCase.py
Modified: asterisk/trunk/lib/python/asterisk/SimpleTestCase.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/SimpleTestCase.py?view=diff&rev=3111&r1=3110&r2=3111
==============================================================================
--- asterisk/trunk/lib/python/asterisk/SimpleTestCase.py (original)
+++ asterisk/trunk/lib/python/asterisk/SimpleTestCase.py Wed Mar 21 08:42:26 2012
@@ -44,8 +44,30 @@
if self.verify_event(event):
self.event_count += 1
if self.event_count == self.expected_events:
- self.passed = True
- self.stop_reactor()
+ # get list of channels so hangups can happen
+ df = self.ami[0].status().addCallbacks(self.status_callback,
+ self.status_failed)
+
+ def status_callback(self, result):
+ '''Initiate hangup since no more testing will take place'''
+ for status_result in result:
+ self.ami[0].hangup(status_result['channel']).addCallbacks(
+ self.hangup_success)
+ break
+ else:
+ # no channels to hang up? close it out
+ self.passed = True
+ self.stop_reactor()
+
+ def hangup_success(self, result):
+ '''Now that the channels are hung up, the test can be ended'''
+ self.passed = True
+ self.stop_reactor()
+
+ def status_failed(self, reason):
+ '''If the channel listing failed, we still need to shut down'''
+ self.passed = True
+ self.stop_reactor()
def verify_event(self, event):
"""
More information about the asterisk-commits
mailing list