[asterisk-commits] espiceland: testsuite/asterisk/trunk r612 - in /asterisk/trunk/tests/fastagi:...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Jul 28 11:21:37 CDT 2010
Author: espiceland
Date: Wed Jul 28 11:21:34 2010
New Revision: 612
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=612
Log:
FastAGI tests now have own directories in /tmp/asterisk-testsuite/.
Modified:
asterisk/trunk/tests/fastagi/channel-status/run-test
asterisk/trunk/tests/fastagi/channel-status/test-config.yaml
asterisk/trunk/tests/fastagi/configs/extensions.conf
asterisk/trunk/tests/fastagi/connect/run-test
asterisk/trunk/tests/fastagi/connect/test-config.yaml
asterisk/trunk/tests/fastagi/hangup/run-test
asterisk/trunk/tests/fastagi/hangup/test-config.yaml
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=612&r1=611&r2=612
==============================================================================
--- asterisk/trunk/tests/fastagi/channel-status/run-test (original)
+++ asterisk/trunk/tests/fastagi/channel-status/run-test Wed Jul 28 11:21:34 2010
@@ -9,9 +9,7 @@
import sys
import os
-import math
from optparse import OptionParser
-from twisted.application import service, internet
from twisted.internet import reactor
from starpy import fastagi
@@ -21,7 +19,7 @@
class FastAGIChannelStatusTest:
def __init__(self, argv):
- self.passed = {}
+ self.passed = {'4': False, '6':False}
self.timeout = 45
self.test = 4
@@ -37,7 +35,8 @@
reactor.callWhenRunning(self.run)
print self.ast_version
- self.asterisk = Asterisk(base=os.path.join(os.getcwd(), "/tmp/asterisk-testsuite/fastagi"))
+ self.asterisk = Asterisk(base=os.path.join(os.getcwd(),
+ "/tmp/asterisk-testsuite/fastagi/channel-status"))
self.asterisk.install_config("tests/fastagi/configs/extensions.conf")
self.asterisk.install_config("tests/fastagi/configs/manager.conf")
self.asterisk.install_config("tests/fastagi/configs/logger.conf")
@@ -46,37 +45,41 @@
print 'Could not answer the call:', reason.getTraceback()
def on_failure(self, reason):
- print 'Could not run deferred for', self.test, '::', reason.getTraceback()
+ print 'Could not run deferred for', self.test
+ print reason.getTraceback()
def on_answer(self, status):
self.do_test(self.agi)
def get_deferred(self, agi):
return agi.channelStatus(agi.variables['agi_channel'])
-
+
def finish_test(self, status):
print "status is", status
self.passed[status] = (self.test == status)
if self.test == 4:
print "Answering call"
self.test = 6
- self.agi.answer().addCallback(self.on_answer).addErrback(self.on_answer_failure)
+ self.agi.answer().addCallback(self.on_answer).addErrback(
+ self.on_answer_failure
+ )
elif self.test == 6:
self.result_changed()
# This gets invoked by the dialplan when the call is answered
# Disconnect agi and set test result values
-
def do_test(self, agi):
self.agi = agi
if self.test == 4:
print "Connection established. Testing for channel status code 4."
elif self.test == 6:
print "Testing for channel status code 6."
-
- return self.get_deferred(agi).addCallback(self.finish_test).addErrback(self.on_failure)
-
+ return self.get_deferred(agi).addCallback(
+ self.finish_test
+ ).addErrback(
+ self.on_failure
+ )
# Read test results and dialplan globals
def read_result(self):
@@ -90,8 +93,9 @@
self.asterisk.cli_exec("core show globals")
else:
self.asterisk.cli_exec("dialplan show globals")
-
- print "FAIL - View result of 'core show globals' in log for more detailed failure results."
+
+ 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)."
@@ -101,17 +105,16 @@
print "Stopping Reactor ..."
reactor.stop()
-
def launch_test(self):
self.asterisk.cli_exec("core set verbose 10")
self.asterisk.cli_exec("agi set debug on")
- # Set blocking=False so that we can test channel status before call is answered.
+ # Set blocking=False so that we can test channel
+ # status before call is answered.
print "Originating call to begin test."
- if self.ast_version < AsteriskVersion("1.6.2"):
- self.asterisk.cli_exec("originate Local/c_exten at agitest extension echo at agitest",blocking=False)
- else:
- self.asterisk.cli_exec("channel originate Local/c_exten at agitest extension echo at agitest", blocking=False)
+ self.asterisk.cli_originate(
+ "Local/c_exten at agitest extension echo at agitest", blocking=False
+ )
def start_asterisk(self):
@@ -121,7 +124,6 @@
def stop_asterisk(self):
print "Stopping Asterisk"
self.asterisk.stop()
-
# Read result before timeout
def result_changed(self):
@@ -133,7 +135,7 @@
reactor.callLater(2, self.launch_test)
reactor.callLater(self.timeout, self.read_result)
-def run(argv=None):
+def main(argv=None):
if argv is None:
argv = sys.argv
@@ -145,4 +147,4 @@
return 0
if __name__ == "__main__":
- sys.exit(run() or 0)
+ sys.exit(main() or 0)
Modified: asterisk/trunk/tests/fastagi/channel-status/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/channel-status/test-config.yaml?view=diff&rev=612&r1=611&r2=612
==============================================================================
--- asterisk/trunk/tests/fastagi/channel-status/test-config.yaml (original)
+++ asterisk/trunk/tests/fastagi/channel-status/test-config.yaml Wed Jul 28 11:21:34 2010
@@ -10,5 +10,5 @@
minversion: '1.4'
dependencies:
- app : 'python'
- - app : 'twisted'
- - app : 'starpy'
+ - python : 'twisted'
+ - python : 'starpy'
Modified: asterisk/trunk/tests/fastagi/configs/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/configs/extensions.conf?view=diff&rev=612&r1=611&r2=612
==============================================================================
--- asterisk/trunk/tests/fastagi/configs/extensions.conf (original)
+++ asterisk/trunk/tests/fastagi/configs/extensions.conf Wed Jul 28 11:21:34 2010
@@ -7,7 +7,7 @@
exten => echo,1,Answer()
exten => echo,n,Echo()
-; Used in connect, hangup
+; Used in connect, hangup, control-stream-file, stream-file, database
exten => b_exten,1,Answer()
exten => b_exten,n,Set(GLOBAL(DEBUG)=FAIL-before agi)
exten => b_exten,n,AGI(agi://127.0.0.1:4573)
@@ -21,4 +21,3 @@
exten => c_exten,n,Set(GLOBAL(DEBUG)=${AGISTATUS})
exten => c_exten,n,Wait(10)
exten => c_exten,n,HangUp()
-
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=612&r1=611&r2=612
==============================================================================
--- asterisk/trunk/tests/fastagi/connect/run-test (original)
+++ asterisk/trunk/tests/fastagi/connect/run-test Wed Jul 28 11:21:34 2010
@@ -9,9 +9,7 @@
import sys
import os
-import math
from optparse import OptionParser
-from twisted.application import service, internet
from twisted.internet import reactor
from starpy import fastagi
@@ -36,31 +34,31 @@
reactor.callWhenRunning(self.run)
print self.ast_version
- self.asterisk = Asterisk(base=os.path.join(os.getcwd(), "/tmp/asterisk-testsuite/fastagi"))
+ self.asterisk = Asterisk(base=os.path.join(os.getcwd(),
+ "/tmp/asterisk-testsuite/fastagi/connect"))
self.asterisk.install_config("tests/fastagi/configs/extensions.conf")
self.asterisk.install_config("tests/fastagi/configs/manager.conf")
def on_failure(self, reason):
- print 'Could not run sequence to close connection: ', reason.getTraceback()
+ print 'Could not run sequence to close connection.'
+ print reason.getTraceback()
def get_deferred(self, agi):
sequence = fastagi.InSequence()
sequence.append(agi.finish)
return sequence()
-
def finish_test(self, agi):
self.passed = True
self.result_changed()
-
+
# This gets invoked by the dialplan when the call is answered
# Disconnect agi and set test result values
def do_test(self, agi):
print "Connection established."
- return self.get_deferred(agi).addCallback(self.finish_test).addErrback(self.on_failure)
-
-
-
+ return self.get_deferred(agi).addCallback(
+ self.finish_test
+ ).addErrback(self.on_failure)
# Read test results and dialplan globals
def read_result(self):
@@ -74,7 +72,9 @@
self.asterisk.cli_exec("core show globals")
else:
self.asterisk.cli_exec("dialplan show globals")
- print "FAIL - FastAGI Connection test failed. View result of 'core show globals' in log for more detailed failure results."
+ print "FAIL - FastAGI Connection test failed. View result of\
+ 'core show globals' in log for more detailed failure\
+ results."
self.stop_asterisk()
@@ -82,16 +82,13 @@
print "Stopping Reactor ..."
reactor.stop()
-
def launch_test(self):
self.asterisk.cli_exec("core set verbose 10")
print "Originating call to begin test."
- if self.ast_version < AsteriskVersion("1.6.2"):
- self.asterisk.cli_exec("originate Local/b_exten at agitest extension echo at agitest")
- else:
- self.asterisk.cli_exec("channel originate Local/b_exten at agitest extension echo at agitest")
-
+ self.asterisk.cli_originate(
+ "Local/b_exten at agitest extension echo at agitest"
+ )
def start_asterisk(self):
print "Starting Asterisk"
@@ -100,7 +97,6 @@
def stop_asterisk(self):
print "Stopping Asterisk"
self.asterisk.stop()
-
# Read result before timeout
def result_changed(self):
@@ -112,7 +108,7 @@
reactor.callLater(2, self.launch_test)
reactor.callLater(self.timeout, self.read_result)
-def run(argv=None):
+def main(argv=None):
if argv is None:
argv = sys.argv
@@ -124,4 +120,4 @@
return 0
if __name__ == "__main__":
- sys.exit(run() or 0)
+ sys.exit(main() or 0)
Modified: asterisk/trunk/tests/fastagi/connect/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/connect/test-config.yaml?view=diff&rev=612&r1=611&r2=612
==============================================================================
--- asterisk/trunk/tests/fastagi/connect/test-config.yaml (original)
+++ asterisk/trunk/tests/fastagi/connect/test-config.yaml Wed Jul 28 11:21:34 2010
@@ -8,5 +8,5 @@
minversion: '1.4'
dependencies:
- app : 'python'
- - app : 'twisted'
- - app : 'starpy'
+ - python : 'twisted'
+ - python : 'starpy'
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=612&r1=611&r2=612
==============================================================================
--- asterisk/trunk/tests/fastagi/hangup/run-test (original)
+++ asterisk/trunk/tests/fastagi/hangup/run-test Wed Jul 28 11:21:34 2010
@@ -9,9 +9,7 @@
import sys
import os
-import math
from optparse import OptionParser
-from twisted.application import service, internet
from twisted.internet import reactor
from starpy import fastagi
@@ -19,7 +17,7 @@
from asterisk.asterisk import Asterisk
from asterisk.version import AsteriskVersion
-class FastAGIChannelStatusTest:
+class FastAGIHangupTest:
def __init__(self, argv):
self.passed = False
self.timeout = 45
@@ -37,7 +35,8 @@
reactor.callWhenRunning(self.run)
print self.ast_version
- self.asterisk = Asterisk(base=os.path.join(os.getcwd(), "/tmp/asterisk-testsuite/fastagi"))
+ self.asterisk = Asterisk(base=os.path.join(os.getcwd(),
+ "/tmp/asterisk-testsuite/fastagi/channel-status"))
self.asterisk.install_config("tests/fastagi/configs/extensions.conf")
self.asterisk.install_config("tests/fastagi/configs/manager.conf")
self.asterisk.install_config("tests/fastagi/configs/logger.conf")
@@ -54,7 +53,6 @@
self.test = 2
self.do_test(self.agi)
-
def finish_test(self, status):
print "Channel is still up! Status is", status
self.passed = False
@@ -66,13 +64,18 @@
self.agi = agi
if self.test == 1:
print "Connection established."
- return agi.hangup().addCallback(self.on_hangup).addErrback(self.on_hangup_failure)
+ return agi.hangup().addCallback(self.on_hangup).addErrback(
+ 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)
-
-
+ # 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)
# Read test results and dialplan globals
def read_result(self):
@@ -87,7 +90,8 @@
else:
self.asterisk.cli_exec("dialplan show globals")
- print "FAIL - View result of 'core show globals' in log for more detailed failure results."
+ print "FAIL - View result of 'core show globals' in log for more\
+ detailed failure results."
self.stop_asterisk()
@@ -95,17 +99,14 @@
print "Stopping Reactor ..."
reactor.stop()
-
def launch_test(self):
self.asterisk.cli_exec("core set verbose 10")
self.asterisk.cli_exec("agi set debug on")
print "Originating call to begin test."
- if self.ast_version < AsteriskVersion("1.6.2"):
- self.asterisk.cli_exec("originate Local/b_exten at agitest extension echo at agitest")
- else:
- self.asterisk.cli_exec("channel originate Local/b_exten at agitest extension echo at agitest")
-
+ self.asterisk.cli_originate(
+ "Local/b_exten at agitest extension echo at agitest"
+ )
def start_asterisk(self):
print "Starting Asterisk"
@@ -114,7 +115,6 @@
def stop_asterisk(self):
print "Stopping Asterisk"
self.asterisk.stop()
-
# Read result before timeout
def result_changed(self):
@@ -126,11 +126,11 @@
reactor.callLater(2, self.launch_test)
reactor.callLater(self.timeout, self.read_result)
-def run(argv=None):
+def main(argv=None):
if argv is None:
argv = sys.argv
- agi_test = FastAGIChannelStatusTest(argv)
+ agi_test = FastAGIHangupTest(argv)
reactor.run()
if agi_test.passed is not True:
return 1
@@ -138,4 +138,4 @@
return 0
if __name__ == "__main__":
- sys.exit(run() or 0)
+ sys.exit(main() or 0)
Modified: asterisk/trunk/tests/fastagi/hangup/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/hangup/test-config.yaml?view=diff&rev=612&r1=611&r2=612
==============================================================================
--- asterisk/trunk/tests/fastagi/hangup/test-config.yaml (original)
+++ asterisk/trunk/tests/fastagi/hangup/test-config.yaml Wed Jul 28 11:21:34 2010
@@ -10,5 +10,5 @@
minversion: '1.4'
dependencies:
- app : 'python'
- - app : 'twisted'
- - app : 'starpy'
+ - python : 'twisted'
+ - python : 'starpy'
More information about the asterisk-commits
mailing list