[asterisk-commits] pabelanger: testsuite/asterisk/trunk r1061 - in /asterisk/trunk/tests/fastagi...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Dec 3 16:22:38 CST 2010
Author: pabelanger
Date: Fri Dec 3 16:22:32 2010
New Revision: 1061
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=1061
Log:
Optimize fastagi tests
This decreased build times the on FreeBSD agent from 22mins to 3mins.
Review: https://reviewboard.asterisk.org/r/1045/
Modified:
asterisk/trunk/tests/fastagi/channel-status/run-test
asterisk/trunk/tests/fastagi/configs/ast1/extensions.conf
asterisk/trunk/tests/fastagi/connect/run-test
asterisk/trunk/tests/fastagi/control-stream-file/run-test
asterisk/trunk/tests/fastagi/database/run-test
asterisk/trunk/tests/fastagi/execute/run-test
asterisk/trunk/tests/fastagi/get-data/run-test
asterisk/trunk/tests/fastagi/hangup/run-test
asterisk/trunk/tests/fastagi/record-file/run-test
asterisk/trunk/tests/fastagi/say-alpha/run-test
asterisk/trunk/tests/fastagi/say-date/run-test
asterisk/trunk/tests/fastagi/say-datetime/run-test
asterisk/trunk/tests/fastagi/say-digits/run-test
asterisk/trunk/tests/fastagi/say-number/run-test
asterisk/trunk/tests/fastagi/say-phonetic/run-test
asterisk/trunk/tests/fastagi/say-time/run-test
asterisk/trunk/tests/fastagi/stream-file/run-test
asterisk/trunk/tests/fastagi/tests.yaml
asterisk/trunk/tests/fastagi/wait-for-digit/run-test
Modified: asterisk/trunk/tests/fastagi/channel-status/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/channel-status/run-test?view=diff&rev=1061&r1=1060&r2=1061
==============================================================================
--- asterisk/trunk/tests/fastagi/channel-status/run-test (original)
+++ asterisk/trunk/tests/fastagi/channel-status/run-test Fri Dec 3 16:22:32 2010
@@ -23,7 +23,7 @@
class FastAGIChannelStatusTest:
def __init__(self, argv):
self.passed = {'4': False, '6':False}
- self.timeout = 45
+ self.timeout = 30
self.test = 4
parser = OptionParser()
@@ -44,8 +44,7 @@
print 'Could not answer the call:', reason.getTraceback()
def on_failure(self, reason):
- print 'Could not run deferred for', self.test
- print reason.getTraceback()
+ print 'Could not run deferred:', reason.getTraceback()
def on_answer(self, status):
self.do_test(self.agi)
@@ -60,8 +59,7 @@
print "Answering call"
self.test = 6
self.agi.answer().addCallback(self.on_answer).addErrback(
- self.on_answer_failure
- )
+ self.on_answer_failure)
elif self.test == 6:
self.result_changed()
@@ -75,45 +73,25 @@
print "Testing for channel status code 6."
return self.get_deferred(agi).addCallback(
- self.finish_test
- ).addErrback(
- self.on_failure
- )
+ self.finish_test).addErrback(self.on_failure)
# Read test results and dialplan globals
def read_result(self):
self.agi.finish()
+ self.stop_reactor()
if self.passed[4] is True and self.passed[6] is True:
- print "PASS - FastAGI CHANNEL STATUS works as expected."
+ print "Success"
else:
- self.ast1.cli_exec("core show channels")
+ print "Failed"
- if self.ast_version < AsteriskVersion("1.6.1"):
- self.ast1.cli_exec("core show globals")
- else:
- self.ast1.cli_exec("dialplan show globals")
-
- print "FAIL - View result of 'core show globals' in log for",\
- "more detailed failure results."
- if self.passed[4] is not True: print "Test 4 failed (ringing)."
- if self.passed[6] is not True: print "Test 6 failed (up)."
-
- self.stop_asterisk()
-
+ def stop_reactor(self):
+ print "Stopping Reactor ..."
if reactor.running:
- print "Stopping Reactor ..."
reactor.stop()
def launch_test(self):
- self.ast1.cli_exec("agi set debug on")
-
- # Set blocking=False so that we can test channel
- # status before call is answered.
print "Originating call to begin test."
- self.ast1.cli_originate(
- "Local/no_answer at agitest extension echo at agitest", blocking=False
- )
-
+ self.ast1.cli_originate("Local/no_answer at agitest extension echo at agitest", blocking=False)
def start_asterisk(self):
print "Starting Asterisk"
@@ -126,20 +104,21 @@
# Read result before timeout
def result_changed(self):
if self.passed[6] is not None:
- reactor.callLater(2, self.read_result)
+ self.read_result()
def run(self):
- self.start_asterisk()
- reactor.callLater(2, self.launch_test)
- reactor.callLater(self.timeout, self.read_result)
+ self.launch_test()
+ reactor.callLater(self.timeout, self.stop_reactor)
def main(argv=None):
if argv is None:
argv = sys.argv
- agi_test = FastAGIChannelStatusTest(argv)
+ test = FastAGIChannelStatusTest(argv)
+ test.start_asterisk()
reactor.run()
- if agi_test.passed[4] is not True or agi_test.passed[6] is not True:
+ test.stop_asterisk()
+ if test.passed[4] is not True or test.passed[6] is not True:
return 1
return 0
Modified: asterisk/trunk/tests/fastagi/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/configs/ast1/extensions.conf?view=diff&rev=1061&r1=1060&r2=1061
==============================================================================
--- asterisk/trunk/tests/fastagi/configs/ast1/extensions.conf (original)
+++ asterisk/trunk/tests/fastagi/configs/ast1/extensions.conf Fri Dec 3 16:22:32 2010
@@ -22,8 +22,6 @@
exten => no_answer,n,AGI(agi://127.0.0.1:4573)
exten => no_answer,n,Set(GLOBAL(DEBUG)=${AGISTATUS})
exten => no_answer,n,HangUp()
-
-
[get-data]
exten => 1,1,Answer()
@@ -65,10 +63,8 @@
exten => 1,n,WaitExten(10)
exten => 1,n,Hangup()
-exten => _5XX,1,Wait(1)
-exten => _5XX,n,Set(TALK_DETECTED=0)
+exten => _5XX,1,Set(TALK_DETECTED=0)
exten => _5xx,n,BackgroundDetect(silence/10,100,10,20000)
-exten => _5XX,n,Wait(15)
exten => _5XX,n,Set(GLOBAL(DEBUG)=FAIL - td_and_agi_notify listening for sounds)
exten => _5XX,n,GoToIf($[${TALK_DETECTED}=0]?fail:pass)
exten => _5XX,n(fail),Set(GLOBAL(DEBUG)=FAIL - talk detect failed with result ${TALK_DETECTED})
Modified: asterisk/trunk/tests/fastagi/connect/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/connect/run-test?view=diff&rev=1061&r1=1060&r2=1061
==============================================================================
--- asterisk/trunk/tests/fastagi/connect/run-test (original)
+++ asterisk/trunk/tests/fastagi/connect/run-test Fri Dec 3 16:22:32 2010
@@ -20,10 +20,11 @@
workingdir = "/tmp/asterisk-testsuite/fastagi/connect"
testdir = "tests/fastagi"
+
class FastAGIConnectTest:
def __init__(self, argv):
self.passed = False
- self.timeout = 45
+ self.timeout = 30
parser = OptionParser()
parser.add_option("-v", "--version", dest="ast_version",
@@ -47,34 +48,22 @@
self.result_changed()
return agi.finish()
- # Read test results and dialplan globals
def read_result(self):
+ self.stop_reactor()
if self.passed is True:
- print "PASS - FastAGI connection works as expected."
+ print "Success"
else:
- self.ast1.cli_exec("core show channels")
+ print "Failed"
- if self.ast_version < AsteriskVersion("1.6.1"):
- self.ast1.cli_exec("core show globals")
- else:
- self.ast1.cli_exec("dialplan show globals")
-
- print "FAIL - FastAGI Connection test failed. View result of\
- 'core show globals' in log for more detailed failure\
- results."
-
- self.stop_asterisk()
-
+ def stop_reactor(self):
+ print "Stopping Reactor ..."
if reactor.running:
- print "Stopping Reactor ..."
reactor.stop()
def launch_test(self):
print "Originating call to begin test."
- self.ast1.cli_originate(
- "Local/501 at agitest extension echo at agitest"
- )
+ self.ast1.cli_originate("Local/501 at agitest extension echo at agitest")
def start_asterisk(self):
print "Starting Asterisk"
@@ -87,20 +76,22 @@
# Read result before timeout
def result_changed(self):
if self.passed is True:
- reactor.callLater(2, self.read_result)
+ self.read_result()
def run(self):
- self.start_asterisk()
- reactor.callLater(2, self.launch_test)
- reactor.callLater(self.timeout, self.read_result)
+ self.launch_test()
+ reactor.callLater(self.timeout, self.stop_reactor)
+
def main(argv=None):
if argv is None:
argv = sys.argv
- agi_test = FastAGIConnectTest(argv)
+ test = FastAGIConnectTest(argv)
+ test.start_asterisk()
reactor.run()
- if agi_test.passed is not True:
+ test.stop_asterisk()
+ if test.passed is not True:
return 1
return 0
Modified: asterisk/trunk/tests/fastagi/control-stream-file/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/control-stream-file/run-test?view=diff&rev=1061&r1=1060&r2=1061
==============================================================================
--- asterisk/trunk/tests/fastagi/control-stream-file/run-test (original)
+++ asterisk/trunk/tests/fastagi/control-stream-file/run-test Fri Dec 3 16:22:32 2010
@@ -20,10 +20,11 @@
workingdir = "/tmp/asterisk-testsuite/fastagi/control-stream-file"
testdir = "tests/fastagi"
+
class FastAGIControlStreamFileTest:
def __init__(self, argv):
self.passed = False
- self.timeout = 45
+ self.timeout = 30
parser = OptionParser()
parser.add_option("-v", "--version", dest="ast_version",
@@ -58,37 +59,21 @@
return agi.controlStreamFile("beep", "").addCallback(
self.finish_test).addErrback(self.on_failure)
- # Read test results and dialplan globals
def read_result(self):
+ self.stop_reactor()
+ if self.passed is True:
+ print "Success"
+ else:
+ print "Failed"
- if self.passed is True:
- print "PASS - FastAGI CONTROL STREAM FILE works as expected."
- else:
- self.ast1.cli_exec("core show channels")
-
- if self.ast_version < AsteriskVersion("1.6.1"):
- self.ast1.cli_exec("core show globals")
- else:
- self.ast1.cli_exec("dialplan show globals")
- print "FAIL - FastAGI CONTROL STREAM FILE test failed. You",\
- "may need to update StarPy. Starpy 1.0.0a13 and older",\
- "will always fail this test."
- print "View result of 'core show globals' in log for more\
- detailed failure results."
-
- self.stop_asterisk()
-
+ def stop_reactor(self):
+ print "Stopping Reactor ..."
if reactor.running:
- print "Stopping Reactor ..."
reactor.stop()
def launch_test(self):
- self.ast1.cli_exec("agi set debug on")
-
print "Originating call to begin test."
- self.ast1.cli_originate(
- "Local/504 at agitest extension echo at agitest"
- )
+ self.ast1.cli_originate("Local/504 at agitest extension echo at agitest")
def start_asterisk(self):
print "Starting Asterisk"
@@ -101,20 +86,21 @@
# Read result before timeout
def result_changed(self):
if self.passed is True:
- reactor.callLater(2, self.read_result)
+ self.read_result()
def run(self):
- self.start_asterisk()
- reactor.callLater(2, self.launch_test)
- reactor.callLater(self.timeout, self.read_result)
+ self.launch_test()
+ reactor.callLater(self.timeout, self.stop_reactor)
def main(argv=None):
if argv is None:
argv = sys.argv
- agi_test = FastAGIControlStreamFileTest(argv)
+ test = FastAGIControlStreamFileTest(argv)
+ test.start_asterisk()
reactor.run()
- if agi_test.passed is not True:
+ test.stop_asterisk()
+ if test.passed is not True:
return 1
return 0
Modified: asterisk/trunk/tests/fastagi/database/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/database/run-test?view=diff&rev=1061&r1=1060&r2=1061
==============================================================================
--- asterisk/trunk/tests/fastagi/database/run-test (original)
+++ asterisk/trunk/tests/fastagi/database/run-test Fri Dec 3 16:22:32 2010
@@ -20,10 +20,11 @@
workingdir = "/tmp/asterisk-testsuite/fastagi/database"
testdir = "tests/fastagi"
+
class FastAGIDatabaseTest:
def __init__(self, argv):
self.passed = {}
- self.timeout = 45
+ self.timeout = 30
self.key = "fastagitest"
self.overall_result = True
self.agi = ""
@@ -61,7 +62,7 @@
# We expect this to get called when we try to select
# the key we've just deleted from the database.
def on_get3_failure(self, reason):
- print "Success. %s is no longer a valid key." % self.key
+ print "%s is no longer a valid key." % self.key
self.passed["Del"] = True
self.result_changed()
@@ -75,9 +76,8 @@
self.passed["Put"] = True
# 2. Retrieve that key from the database
print "Retrieving key from the database."
- self.agi.databaseGet("secret",self.key).addCallback(
- self.get_result_from_get
- ).addErrback(self.on_get_failure)
+ self.agi.databaseGet("secret", self.key).addCallback(
+ self.get_result_from_get).addErrback(self.on_get_failure)
# 2. Retrieve that key from the database
def get_result_from_get(self, result):
@@ -93,9 +93,8 @@
# 3. Update the value of the key in the database
print "Updating value of key."
- self.agi.databaseSet("secret",self.key,"halfwaydone").addCallback(
- self.get_result_from_set
- ).addErrback(self.on_set_failure)
+ self.agi.databaseSet("secret", self.key, "halfwaydone").addCallback(
+ self.get_result_from_set).addErrback(self.on_set_failure)
# 3. Update the value of the key in the database
def get_result_from_set(self, result):
@@ -117,15 +116,14 @@
print 'Value of %s is "%s"' % (self.key, result)
if result != "halfwaydone":
self.passed["Set"] = False
- print "Call to DATABASE SET succeeded,\
+ print "Call to DATABASE SET succeeded, \
but value did not get updated."
print 'Expected value of "halfwaydone" but got "%s"' % result
# 5. Delete that key from the database
print "Deleting key from database."
self.agi.databaseDel("secret",self.key).addCallback(
- self.get_result_from_del
- ).addErrback(self.on_del_failure)
+ self.get_result_from_del).addErrback(self.on_del_failure)
# 5. Delete that key from the database
def get_result_from_del(self, result):
@@ -139,8 +137,7 @@
# 6. Test that key was deleted.
print "Checking that key was deleted."
self.agi.databaseGet("secret",self.key).addCallback(
- self.get_result_from_get3
- ).addErrback(self.on_get3_failure)
+ self.get_result_from_get3).addErrback(self.on_get3_failure)
# 6. Test that key was deleted.
# This should never be called if databaseDel() succeeded.
@@ -164,34 +161,31 @@
def do_test(self, agi):
self.agi = agi
print "Inserting key into database."
- return agi.databaseSet("secret",self.key,"juststarted").addCallback(
- self.get_result_from_put
- ).addErrback(self.on_put_failure)
+ return agi.databaseSet("secret", self.key, "juststarted").addCallback(
+ self.get_result_from_put).addErrback(self.on_put_failure)
# Read test results and dialplan globals
def read_result(self):
self.agi.finish()
+ self.stop_reactor()
for test in self.passed:
- if self.passed[test] is True:
- print "database%s worked as expected." % test
- else:
- print "database%s FAILED." % test
+ if self.passed[test] is False:
self.overall_result = False
- self.stop_asterisk()
-
+ if self.overall_result is True:
+ print "Success"
+ else:
+ print "Failed"
+
+ def stop_reactor(self):
+ print "Stopping Reactor ..."
if reactor.running:
- print "Stopping Reactor ..."
reactor.stop()
def launch_test(self):
- self.ast1.cli_exec("agi set debug on")
-
print "Originating call to begin test."
- self.ast1.cli_originate(
- "Local/506 at agitest extension echo at agitest"
- )
+ self.ast1.cli_originate("Local/506 at agitest extension echo at agitest")
def start_asterisk(self):
print "Starting Asterisk"
@@ -206,21 +200,22 @@
# if self.passed["Put"] is None, not one test has completed yet
# and we should wait for the timeout.
if self.passed["Put"] is not None:
- reactor.callLater(2, self.read_result)
+ self.read_result()
def run(self):
- self.start_asterisk()
- reactor.callLater(2, self.launch_test)
- reactor.callLater(self.timeout, self.read_result)
+ self.launch_test()
+ reactor.callLater(self.timeout, self.stop_reactor)
+
def main(argv=None):
if argv is None:
argv = sys.argv
- agi_test = FastAGIDatabaseTest(argv)
+ test = FastAGIDatabaseTest(argv)
+ test.start_asterisk()
reactor.run()
-
- if agi_test.overall_result is not True:
+ test.stop_asterisk()
+ if test.overall_result is not True:
return 1
return 0
Modified: asterisk/trunk/tests/fastagi/execute/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/execute/run-test?view=diff&rev=1061&r1=1060&r2=1061
==============================================================================
--- asterisk/trunk/tests/fastagi/execute/run-test (original)
+++ asterisk/trunk/tests/fastagi/execute/run-test Fri Dec 3 16:22:32 2010
@@ -28,7 +28,7 @@
'Set [Global]': False,
'Set [Channel]': False
}
- self.timeout = 45
+ self.timeout = 30
self.key = "fastagitest"
self.overall_result = True
self.agi = ""
@@ -70,15 +70,13 @@
def on_Set2_success(self, result):
self.agi.getVariable('LAMB').addCallback(
- self.on_get_variable2
- ).addErrback(self.on_get_variable2_failure)
+ self.on_get_variable2).addErrback(self.on_get_variable2_failure)
self.passed['Set [Channel]'] = True
# 4. Set(DEBUG=${VAR})
def do_Set2(self):
self.agi.execute("Set", "LAMB=sure to go").addCallback(
- self.on_Set2_success
- ).addErrback(self.on_Set2_failure)
+ self.on_Set2_success).addErrback(self.on_Set2_failure)
def on_get_variable_failure(self, reason):
self.passed['Set [Global]'] = False
@@ -102,15 +100,13 @@
def on_Set_success(self, result):
self.agi.getVariable('FLEECE').addCallback(
- self.on_get_variable
- ).addErrback(self.on_get_variable_failure)
+ self.on_get_variable).addErrback(self.on_get_variable_failure)
self.passed['Set [Global]'] = True
# 3. Set(GLOBAL(DEBUG)=${VAR})
def do_Set(self):
self.agi.execute("Set", "GLOBAL(FLEECE)=white as snow").addCallback(
- self.on_Set_success
- ).addErrback(self.on_Set_failure)
+ self.on_Set_success).addErrback(self.on_Set_failure)
def on_System_failure(self, reason):
self.passed['System'] = False
@@ -124,8 +120,7 @@
# 2. System(command arg1 arg2 etc)
def do_System(self):
self.agi.execute("System", "echo little lamb").addCallback(
- self.on_System_success
- ).addErrback(self.on_System_failure)
+ self.on_System_success).addErrback(self.on_System_failure)
def on_SendDTMF_failure(self, reason):
self.passed['SendDTMF'] = False
@@ -152,31 +147,30 @@
self.agi = agi
return agi.execute(
"SendDTMF", "3212333", 300, comma_delimiter=True
- ).addCallback(
- self.on_SendDTMF_success
+ ).addCallback(self.on_SendDTMF_success
).addErrback(self.on_SendDTMF_failure)
# Read test results and dialplan globals
def read_result(self):
self.agi.finish()
+ self.stop_reactor()
for test in self.passed:
- if self.passed[test] is True:
- print "EXECUTE (%s) worked as expected." % test
- else:
- print "EXECUTE (%s) FAILED." % test
+ if self.passed[test] is False:
self.overall_result = False
- self.stop_asterisk()
+ if self.overall_result is True:
+ print "Success"
+ else:
+ print "Failed"
+
+ def stop_reactor(self):
+ print "Stopping Reactor ..."
if reactor.running:
- print "Stopping Reactor ..."
reactor.stop()
def launch_test(self):
- self.ast1.cli_exec("agi set debug on")
print "Originating call to begin test."
- self.ast1.cli_originate(
- "Local/507 at agitest extension echo at agitest"
- )
+ self.ast1.cli_originate("Local/507 at agitest extension echo at agitest")
def start_asterisk(self):
print "Starting Asterisk"
@@ -191,20 +185,21 @@
# If self.passed["SendDTMF"] is False, not one test has completed yet
# and we should wait for the timeout.
if self.passed["SendDTMF"] is not False:
- reactor.callLater(2, self.read_result)
+ self.read_result()
def run(self):
- self.start_asterisk()
- reactor.callLater(2, self.launch_test)
- reactor.callLater(self.timeout, self.read_result)
+ self.launch_test()
+ reactor.callLater(self.timeout, self.stop_reactor)
def main(argv=None):
if argv is None:
argv = sys.argv
- agi_test = FastAGIExecuteTest(argv)
+ test = FastAGIExecuteTest(argv)
+ test.start_asterisk()
reactor.run()
- if agi_test.overall_result is not True:
+ test.stop_asterisk()
+ if test.overall_result is not True:
return 1
return 0
Modified: asterisk/trunk/tests/fastagi/get-data/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/get-data/run-test?view=diff&rev=1061&r1=1060&r2=1061
==============================================================================
--- asterisk/trunk/tests/fastagi/get-data/run-test (original)
+++ asterisk/trunk/tests/fastagi/get-data/run-test Fri Dec 3 16:22:32 2010
@@ -23,7 +23,7 @@
class FastAGIGetDataTest:
def __init__(self, argv):
self.passed = False
- self.timeout = 45
+ self.timeout = 30
parser = OptionParser()
parser.add_option("-v", "--version", dest="ast_version",
@@ -68,34 +68,21 @@
# Read test results and dialplan globals
def read_result(self):
+ self.stop_reactor()
if self.passed is True:
- print "PASS - FastAGI GET DATA works as expected."
+ print "Success"
else:
- self.ast1.cli_exec("core show channels")
+ print "Failed"
- if self.ast_version < AsteriskVersion("1.6.1"):
- self.ast1.cli_exec("core show globals")
- else:
- self.ast1.cli_exec("dialplan show globals")
-
- print "FAIL - FastAGI GET DATA test failed. View result",\
- "of 'core show globals' in log for more detailed",\
- "failure results."
-
- self.stop_asterisk()
-
+ def stop_reactor(self):
+ print "Stopping Reactor ..."
if reactor.running:
- print "Stopping Reactor ..."
reactor.stop()
def launch_test(self):
- self.ast1.cli_exec("agi set debug on")
-
print "Originating call to begin test."
- self.ast1.cli_originate(
- "Local/502 at agitest extension 1 at get-data"
- )
+ self.ast1.cli_originate("Local/502 at agitest extension 1 at get-data")
def start_asterisk(self):
print "Starting Asterisk"
@@ -108,20 +95,21 @@
# Read result before timeout
def result_changed(self):
if self.passed is True:
- reactor.callLater(2, self.read_result)
+ self.read_result()
def run(self):
- self.start_asterisk()
- reactor.callLater(2, self.launch_test)
- reactor.callLater(self.timeout, self.read_result)
+ self.launch_test()
+ reactor.callLater(self.timeout, self.stop_reactor)
def main(argv=None):
if argv is None:
argv = sys.argv
- agi_test = FastAGIGetDataTest(argv)
+ test = FastAGIGetDataTest(argv)
+ test.start_asterisk()
reactor.run()
- if agi_test.passed is not True:
+ test.stop_asterisk()
+ if test.passed is not True:
return 1
return 0
Modified: asterisk/trunk/tests/fastagi/hangup/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/hangup/run-test?view=diff&rev=1061&r1=1060&r2=1061
==============================================================================
--- asterisk/trunk/tests/fastagi/hangup/run-test (original)
+++ asterisk/trunk/tests/fastagi/hangup/run-test Fri Dec 3 16:22:32 2010
@@ -24,7 +24,7 @@
class FastAGIHangupTest:
def __init__(self, argv):
self.passed = False
- self.timeout = 45
+ self.timeout = 30
self.test = 1
parser = OptionParser()
@@ -57,11 +57,8 @@
print "Channel is still up! Status is", status, "Maybe the channel is still attempting to hangup..."
print "Testing for closed channel again."
time.sleep(5)
- self.agi.channelStatus(
- agi.variables['agi_channel']
- ).addCallback(
- self.finish_test2
- ).addErrback(self.on_failure)
+ self.agi.channelStatus(agi.variables['agi_channel']
+ ).addCallback(self.finish_test2).addErrback(self.on_failure)
def finish_test2(self, status):
print "Channel is still up! Status is", status
@@ -75,47 +72,30 @@
if self.test == 1:
print "Connection established."
return agi.hangup().addCallback(self.on_hangup).addErrback(
- self.on_hangup_failure
- )
+ self.on_hangup_failure)
elif self.test == 2:
print "Testing for closed channel."
# We expect this call to fail, as channelStatus()
# cannot query a dead channel
- return agi.channelStatus(
- agi.variables['agi_channel']
- ).addCallback(
- self.finish_test
- ).addErrback(self.on_failure)
+ return agi.channelStatus(agi.variables['agi_channel']
+ ).addCallback(self.finish_test).addErrback(self.on_failure)
- # Read test results and dialplan globals
def read_result(self):
self.agi.finish()
+ self.stop_reactor()
if self.passed is True:
- print "PASS - FastAGI HANGUP works as expected."
+ print "Success"
else:
- self.ast1.cli_exec("core show channels")
+ print "Failed"
- if self.ast_version < AsteriskVersion("1.6.1"):
- self.ast1.cli_exec("core show globals")
- else:
- self.ast1.cli_exec("dialplan show globals")
-
- print "FAIL - View result of 'core show globals' in log for more",\
- "detailed failure results."
-
- self.stop_asterisk()
-
+ def stop_reactor(self):
+ print "Stopping Reactor ..."
if reactor.running:
- print "Stopping Reactor ..."
reactor.stop()
def launch_test(self):
- self.ast1.cli_exec("agi set debug on")
-
print "Originating call to begin test."
- self.ast1.cli_originate(
- "Local/503 at agitest extension echo at agitest"
- )
+ self.ast1.cli_originate("Local/503 at agitest extension echo at agitest")
def start_asterisk(self):
print "Starting Asterisk"
@@ -128,20 +108,21 @@
# Read result before timeout
def result_changed(self):
if self.passed is True:
- reactor.callLater(2, self.read_result)
+ self.read_result()
def run(self):
- self.start_asterisk()
- reactor.callLater(2, self.launch_test)
- reactor.callLater(self.timeout, self.read_result)
+ self.launch_test()
+ reactor.callLater(self.timeout, self.stop_reactor)
def main(argv=None):
if argv is None:
argv = sys.argv
- agi_test = FastAGIHangupTest(argv)
+ test = FastAGIHangupTest(argv)
+ test.start_asterisk()
reactor.run()
- if agi_test.passed is not True:
+ test.stop_asterisk()
+ if test.passed is not True:
return 1
return 0
Modified: asterisk/trunk/tests/fastagi/record-file/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/record-file/run-test?view=diff&rev=1061&r1=1060&r2=1061
==============================================================================
--- asterisk/trunk/tests/fastagi/record-file/run-test (original)
+++ asterisk/trunk/tests/fastagi/record-file/run-test Fri Dec 3 16:22:32 2010
@@ -20,6 +20,7 @@
workingdir = "/tmp/asterisk-testsuite/fastagi/execute"
testdir = "tests/fastagi"
+
class FastAGIRecordFileTest:
def __init__(self, argv):
self.passed = {
@@ -27,7 +28,7 @@
"HANGUP": False
}
self.test = "DTMF"
- self.timeout = 45
+ self.timeout = 30
self.key = "fastagitest"
self.overall_result = True
self.agi = ""
@@ -56,7 +57,7 @@
print 'Could not record file:', reason.getTraceback()
if self.test is "DTMF":
self.test = "HANGUP"
- reactor.callLater(2, self.launch_test())
+ reactor.callLater(0, self.launch_test())
else:
self.result_changed()
@@ -66,7 +67,7 @@
except:
digit = None
- print "Recording terminated by %s (%s) after %s bytes."\
+ print "Recording terminated by %s (%s) after %s bytes." \
% (result[1], digit, result[2])
if os.path.exists(self.audio_file):
file_size = os.path.getsize(self.audio_file)
@@ -74,11 +75,11 @@
print "The file was created, but it is empty."
self.passed[self.test] = False
elif result[2] == file_size:
- print "Data was recorded, and data length matches what was",\
+ print "Data was recorded, and data length matches what was", \
"reported during the %s test." % self.test
self.passed[self.test] = True
else:
- print "Some data was recorded, but the data length does not",\
+ print "Some data was recorded, but the data length does not", \
"match what was reported during the %s test." % self.test
self.passed[self.test] = False
else:
@@ -87,57 +88,40 @@
if self.test is "DTMF":
self.test = "HANGUP"
- reactor.callLater(2, self.launch_test)
+ reactor.callLater(0, self.launch_test)
else:
self.result_changed()
# This gets invoked by the dialplan when the call is answered
def do_test(self, agi):
self.agi = agi
- return agi.recordFile(
- "%s/out" % (workingdir), "ulaw", "#", "3"
- ).addCallback(
- self.on_record_success
- ).addErrback(self.on_record_failure)
+ return agi.recordFile("%s/out" % (workingdir), "ulaw", "#", "3"
+ ).addCallback(self.on_record_success).addErrback(self.on_record_failure)
- # Read test results and dialplan globals
def read_result(self):
self.agi.finish()
+ self.stop_reactor()
for t, r in self.passed.iteritems():
if self.passed[t] is False:
- print "RECORD FILE did NOT work as expected when",\
- "terminated with", t
self.overall_result = False
- if self.overall_result is False:
- self.ast1.cli_exec("core show channels")
+ if self.overall_result is True:
+ print "Success"
+ else:
+ print "Failed"
- if self.ast_version < AsteriskVersion("1.6.1"):
- self.ast1.cli_exec("core show globals")
- else:
- self.ast1.cli_exec("dialplan show globals")
-
- print "FAIL - FastAGI RECORD FILE test failed. View result",\
- "of 'core show globals' in log for more detailed",\
- "failure results."
-
- self.stop_asterisk()
+ def stop_reactor(self):
+ print "Stopping Reactor ..."
if reactor.running:
- print "Stopping Reactor ..."
reactor.stop()
def launch_test(self):
- self.ast1.cli_exec("agi set debug on")
print "Originating call to begin test which terminates recording",\
"with", self.test
if self.test is "DTMF":
- self.ast1.cli_originate(
- "Local/508 at agitest extension 1 at record-file"
- )
+ self.ast1.cli_originate("Local/508 at agitest extension 1 at record-file")
elif self.test is "HANGUP":
- self.ast1.cli_originate(
- "Local/509 at agitest extension 2 at record-file"
- )
+ self.ast1.cli_originate("Local/509 at agitest extension 2 at record-file")
else:
self.result_changed()
@@ -152,20 +136,21 @@
# Read result before timeout
def result_changed(self):
if self.passed['DTMF'] is True and self.passed['HANGUP'] is True:
- reactor.callLater(2, self.read_result)
+ self.read_result()
def run(self):
- self.start_asterisk()
- reactor.callLater(2, self.launch_test)
- reactor.callLater(self.timeout, self.read_result)
+ self.launch_test()
+ reactor.callLater(self.timeout, self.stop_reactor)
def main(argv=None):
if argv is None:
argv = sys.argv
- agi_test = FastAGIRecordFileTest(argv)
+ test = FastAGIRecordFileTest(argv)
+ test.start_asterisk()
reactor.run()
- if agi_test.overall_result is not True:
+ test.stop_asterisk()
+ if test.overall_result is not True:
return 1
return 0
Modified: asterisk/trunk/tests/fastagi/say-alpha/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/say-alpha/run-test?view=diff&rev=1061&r1=1060&r2=1061
==============================================================================
--- asterisk/trunk/tests/fastagi/say-alpha/run-test (original)
+++ asterisk/trunk/tests/fastagi/say-alpha/run-test Fri Dec 3 16:22:32 2010
@@ -20,11 +20,12 @@
workingdir = "/tmp/asterisk-testsuite/fastagi/say-alpha"
testdir = "tests/fastagi"
+
class FastAGISayAlphaTest:
def __init__(self, argv):
self.passed = False
self.notified = False
- self.timeout = 45
+ self.timeout = 30
parser = OptionParser()
parser.add_option("-v", "--version", dest="ast_version",
@@ -47,9 +48,6 @@
def listen_result(self, agi):
print "Got test success confirmation from dialplan."
self.notified = True
- agi.finish()
- self.agi.finish()
- self.result_changed()
def on_failure(self, reason):
print 'SAY ALPHA failed: ', reason.getTraceback()
@@ -58,6 +56,7 @@
def finish_test(self, result):
print "AGI command reports success."
self.passed = True
+ self.result_changed()
# This gets invoked by the dialplan when the call is answered
# send SAY ALPHA command and wait for results
@@ -65,41 +64,24 @@
self.agi = agi
print "Connection established."
return agi.sayAlpha("respect").addCallback(
- self.finish_test
- ).addErrback(self.on_failure)
+ self.finish_test).addErrback(self.on_failure)
- # Read test results and dialplan globals
def read_result(self):
self.agi.finish()
+ self.stop_reactor()
if self.passed is True and self.notified is True:
- print "PASS - FastAGI SAY ALPHA works as expected."
+ print "Success"
else:
- self.ast1.cli_exec("core show channels")
+ print "Failed"
- if self.ast_version < AsteriskVersion("1.6.1"):
- self.ast1.cli_exec("core show globals")
- else:
- self.ast1.cli_exec("dialplan show globals")
- print "AGI reports success: ", self.passed
- print "Diaplan reports success: ", self.notified
-
- print "FAIL - FastAGI SAY ALPHA test failed. View result",\
- "of 'core show globals' in log for more detailed",\
- "failure results."
-
- self.stop_asterisk()
-
+ def stop_reactor(self):
+ print "Stopping Reactor ..."
if reactor.running:
- print "Stopping Reactor ..."
reactor.stop()
def launch_test(self):
- self.ast1.cli_exec("agi set debug on")
-
print "Originating call to begin test."
- self.ast1.cli_originate(
- "Local/510 at agitest extension 1 at td_and_agi_notify"
- )
+ self.ast1.cli_originate("Local/510 at agitest extension 1 at td_and_agi_notify")
def start_asterisk(self):
print "Starting Asterisk"
@@ -112,20 +94,21 @@
# Read result before timeout
def result_changed(self):
if self.passed is True:
- reactor.callLater(2, self.read_result)
+ self.read_result()
def run(self):
- self.start_asterisk()
- reactor.callLater(2, self.launch_test)
- reactor.callLater(self.timeout, self.read_result)
+ self.launch_test()
+ reactor.callLater(self.timeout, self.stop_reactor)
def main(argv=None):
if argv is None:
argv = sys.argv
- agi_test = FastAGISayAlphaTest(argv)
+ test = FastAGISayAlphaTest(argv)
+ test.start_asterisk()
reactor.run()
- if agi_test.passed is not True or agi_test.notified is not True:
+ test.stop_asterisk()
+ if test.passed is not True or test.notified is not True:
return 1
return 0
Modified: asterisk/trunk/tests/fastagi/say-date/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/say-date/run-test?view=diff&rev=1061&r1=1060&r2=1061
==============================================================================
--- asterisk/trunk/tests/fastagi/say-date/run-test (original)
+++ asterisk/trunk/tests/fastagi/say-date/run-test Fri Dec 3 16:22:32 2010
@@ -20,12 +20,13 @@
workingdir = "/tmp/asterisk-testsuite/fastagi/say-date"
testdir = "tests/fastagi"
[... 888 lines stripped ...]
More information about the asterisk-commits
mailing list