[asterisk-commits] mjordan: testsuite/asterisk/trunk r2128 - in /asterisk/trunk: lib/python/aste...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Sep 9 09:41:55 CDT 2011
Author: mjordan
Date: Fri Sep 9 09:41:52 2011
New Revision: 2128
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=2128
Log:
Added reactor timeout reset. Implemented in voicemail tests.
Modified:
asterisk/trunk/lib/python/asterisk/TestCase.py
asterisk/trunk/lib/python/asterisk/TestState.py
asterisk/trunk/tests/apps/voicemail/authenticate_nominal/run-test
asterisk/trunk/tests/apps/voicemail/check_voicemail_new_user/run-test
asterisk/trunk/tests/apps/voicemail/check_voicemail_nominal/run-test
asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/run-test
Modified: asterisk/trunk/lib/python/asterisk/TestCase.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/TestCase.py?view=diff&rev=2128&r1=2127&r2=2128
==============================================================================
--- asterisk/trunk/lib/python/asterisk/TestCase.py (original)
+++ asterisk/trunk/lib/python/asterisk/TestCase.py Fri Sep 9 09:41:52 2011
@@ -11,6 +11,7 @@
import logging
import logging.config
import os
+import datetime
from twisted.internet import reactor
from starpy import manager, fastagi
@@ -30,7 +31,7 @@
def __init__(self):
self.test_name = os.path.dirname(sys.argv[0])
self.base = self.test_name.lstrip("tests/")
-
+ self.timeoutId = None
self.testStateController = None
""" Set up logging """
@@ -127,7 +128,7 @@
"""
if (self.reactor_timeout > 0):
- reactor.callLater(self.reactor_timeout, self.__reactor_timeout)
+ self.timeoutId = reactor.callLater(self.reactor_timeout, self.__reactor_timeout)
def ami_login_error(self, ami):
logger.error("Error logging into AMI")
@@ -143,3 +144,13 @@
logger.error(reason.getTraceback())
self.stop_reactor()
return reason
+
+ def reset_timeout(self):
+ """
+ Resets the reactor timeout
+ """
+ if (self.timeoutId != None):
+ originalTime = datetime.datetime.fromtimestamp(self.timeoutId.getTime())
+ self.timeoutId.reset(self.reactor_timeout)
+ newTime = datetime.datetime.fromtimestamp(self.timeoutId.getTime())
+ logger.info("Reactor timeout originally scheduled for %s, rescheduled for %s" % (str(originalTime), str(newTime)))
Modified: asterisk/trunk/lib/python/asterisk/TestState.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/TestState.py?view=diff&rev=2128&r1=2127&r2=2128
==============================================================================
--- asterisk/trunk/lib/python/asterisk/TestState.py (original)
+++ asterisk/trunk/lib/python/asterisk/TestState.py Fri Sep 9 09:41:52 2011
@@ -146,7 +146,7 @@
def __init__(self, controller):
TestState(controller)
- self.controller.failTest()
+ controller.failTest()
def handleStateChange(self, ami, event):
pass
Modified: asterisk/trunk/tests/apps/voicemail/authenticate_nominal/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/voicemail/authenticate_nominal/run-test?view=diff&rev=2128&r1=2127&r2=2128
==============================================================================
--- asterisk/trunk/tests/apps/voicemail/authenticate_nominal/run-test (original)
+++ asterisk/trunk/tests/apps/voicemail/authenticate_nominal/run-test Fri Sep 9 09:41:52 2011
@@ -90,6 +90,7 @@
else:
""" If this is the caller, simply execute the next test """
if self.testCounter < 3:
+ super(AuthenticateNominal, self).reset_timeout()
self.executeTest(ami)
def run(self):
Modified: asterisk/trunk/tests/apps/voicemail/check_voicemail_new_user/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/voicemail/check_voicemail_new_user/run-test?view=diff&rev=2128&r1=2127&r2=2128
==============================================================================
--- asterisk/trunk/tests/apps/voicemail/check_voicemail_new_user/run-test (original)
+++ asterisk/trunk/tests/apps/voicemail/check_voicemail_new_user/run-test Fri Sep 9 09:41:52 2011
@@ -50,6 +50,7 @@
elif message == 'vm-password':
self.voiceMailTest.sendDTMF(self.userPassword)
elif state == 'AUTHENTICATED':
+ self.voiceMailTest.reset_timeout()
self.changeState(AuthenticatedTestState(self.controller, self.voiceMailTest))
else:
self.handleDefaultState(event)
@@ -136,10 +137,13 @@
""" If we review a message, tell it to save the message """
self.voiceMailTest.sendDTMF("1")
elif message == 'vm-rec-name':
+ self.voiceMailTest.reset_timeout()
self.voiceMailTest.setTestCondition('recordName', True)
elif message == 'vm-rec-unv':
+ self.voiceMailTest.reset_timeout()
self.voiceMailTest.setTestCondition('recordUnavailable', True)
elif message == 'vm-rec-busy':
+ self.voiceMailTest.reset_timeout()
self.voiceMailTest.setTestCondition('recordBusy', True)
elif message == 'beep':
""" A beep indicates we need to stream some sound file over - use the same sound file for everything """
@@ -266,6 +270,7 @@
if event['result'] == "pass":
self.passed = True
+ super(CheckVoicemailNewUser, self).hangup()
logger.info("VoiceMail successfully exited")
else:
logger.warn("VoiceMail did not successfully exit:")
Modified: asterisk/trunk/tests/apps/voicemail/check_voicemail_nominal/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/voicemail/check_voicemail_nominal/run-test?view=diff&rev=2128&r1=2127&r2=2128
==============================================================================
--- asterisk/trunk/tests/apps/voicemail/check_voicemail_nominal/run-test (original)
+++ asterisk/trunk/tests/apps/voicemail/check_voicemail_nominal/run-test Fri Sep 9 09:41:52 2011
@@ -116,6 +116,7 @@
"""
Tell it to play the first message
"""
+ self.voiceMailTest.reset_timeout()
self.voiceMailTest.sendDTMF("1")
else:
self.handleDefaultState(event)
@@ -218,6 +219,7 @@
self.voiceMailTest.sendDTMF('1')
elif message == 'vm-savedto':
""" Notify the test that we saved a message """
+ self.voiceMailTest.reset_timeout()
self.voiceMailTest.setTestCondition("savedMessages", 1)
self.changeState(PlayNextMessageTestState(self.controller, self.voiceMailTest))
else:
@@ -295,8 +297,7 @@
return False
self.addTestCondition("savedMessages", TestCondition(checkSavedMessages, 0))
- """ Force this test not to timeout. On bamboo, this test can take a *very* long time """
- self.reactor_timeout = 0
+ self.reactor_timeout = 120
self.create_asterisk(2)
def ami_connect(self, ami):
@@ -359,6 +360,7 @@
if event['result'] == "pass":
self.passed = True
+ super(CheckVoicemailNominal, self).hangup()
logger.info("VoiceMail successfully exited")
else:
logger.warn("VoiceMail did not successfully exit:")
Modified: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/run-test?view=diff&rev=2128&r1=2127&r2=2128
==============================================================================
--- asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/run-test (original)
+++ asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/run-test Fri Sep 9 09:41:52 2011
@@ -56,6 +56,7 @@
return
self.testResultsReceived += 1
+ super(LeaveVoicemailNominal, self).reset_timeout()
if event['result'] == "pass":
self.passed = True
logger.info("VoiceMail successfully exited")
More information about the asterisk-commits
mailing list