[asterisk-commits] espiceland: testsuite/asterisk/trunk r608 - in /asterisk/trunk/tests: ./ fast...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Jul 28 11:18:04 CDT 2010
Author: espiceland
Date: Wed Jul 28 11:18:00 2010
New Revision: 608
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=608
Log:
Test for FastAGI's controlStreamFile() and add recently committed tests to
tests.yaml.
Added:
asterisk/trunk/tests/fastagi/control-stream-file/
asterisk/trunk/tests/fastagi/control-stream-file/run-test (with props)
asterisk/trunk/tests/fastagi/control-stream-file/test-config.yaml (with props)
Modified:
asterisk/trunk/tests/tests.yaml
Added: 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=auto&rev=608
==============================================================================
--- asterisk/trunk/tests/fastagi/control-stream-file/run-test (added)
+++ asterisk/trunk/tests/fastagi/control-stream-file/run-test Wed Jul 28 11:18:00 2010
@@ -1,0 +1,125 @@
+#!/usr/bin/python
+'''
+Copyright (C) 2010, Digium, Inc.
+Erin Spiceland <espiceland at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+
+import sys
+import os
+from optparse import OptionParser
+from twisted.internet import reactor
+from starpy import fastagi
+
+sys.path.append("lib/python")
+from asterisk.asterisk import Asterisk
+from asterisk.version import AsteriskVersion
+
+class FastAGIControlStreamFileTest:
+ def __init__(self, argv):
+ self.passed = False
+ self.timeout = 45
+
+ parser = OptionParser()
+ parser.add_option("-v", "--version", dest="ast_version",
+ help="Asterisk version string")
+ (options, args) = parser.parse_args(argv)
+ self.ast_version = AsteriskVersion(options.ast_version)
+
+ # Listen for results from dialplan
+ self.agi_factory = fastagi.FastAGIFactory(self.do_test)
+ reactor.listenTCP(4573, self.agi_factory, self.timeout, '127.0.0.1')
+ reactor.callWhenRunning(self.run)
+
+ print self.ast_version
+ self.asterisk = Asterisk(base=os.path.join(os.getcwd(),
+ "/tmp/asterisk-testsuite/fastagi/control-stream-file"))
+ 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")
+
+ def on_failure(self, reason):
+ print 'Could not run controlStreamFile: ', reason.getTraceback()
+ self.agi.finish()
+
+ # result of 0 indicates success
+ def finish_test(self,result):
+ if result is "0":
+ self.passed = True
+
+ self.result_changed()
+
+ # This gets invoked by the dialplan when the call is answered
+ # send CONTROL STREAM FILE command and wait for results
+ def do_test(self, agi):
+ self.agi = agi
+ print "Connection established."
+ return agi.controlStreamFile("beep", "").addCallback(
+ self.finish_test).addErrback(self.on_failure)
+
+ # Read test results and dialplan globals
+ def read_result(self):
+
+ if self.passed is True:
+ print "PASS - FastAGI controlStreamFile() works as expected."
+ else:
+ self.asterisk.cli_exec("core show channels")
+
+ if self.ast_version < AsteriskVersion("1.6.1"):
+ self.asterisk.cli_exec("core show globals")
+ else:
+ self.asterisk.cli_exec("dialplan show globals")
+ print "FAIL - FastAGI Connection 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()
+
+ if reactor.running:
+ 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."
+ self.asterisk.cli_originate(
+ "Local/b_exten at agitest extension echo at agitest"
+ )
+
+ def start_asterisk(self):
+ print "Starting Asterisk"
+ self.asterisk.start()
+
+ def stop_asterisk(self):
+ print "Stopping Asterisk"
+ self.asterisk.stop()
+
+ # Read result before timeout
+ def result_changed(self):
+ if self.passed is True:
+ reactor.callLater(2, self.read_result)
+
+ def run(self):
+ self.start_asterisk()
+ reactor.callLater(2, self.launch_test)
+ reactor.callLater(self.timeout, self.read_result)
+
+def main(argv=None):
+ if argv is None:
+ argv = sys.argv
+
+ agi_test = FastAGIControlStreamFileTest(argv)
+ reactor.run()
+ if agi_test.passed is not True:
+ return 1
+
+ return 0
+
+if __name__ == "__main__":
+ sys.exit(main() or 0)
Propchange: asterisk/trunk/tests/fastagi/control-stream-file/run-test
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/fastagi/control-stream-file/run-test
------------------------------------------------------------------------------
svn:executable = *
Propchange: asterisk/trunk/tests/fastagi/control-stream-file/run-test
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/fastagi/control-stream-file/run-test
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/fastagi/control-stream-file/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/control-stream-file/test-config.yaml?view=auto&rev=608
==============================================================================
--- asterisk/trunk/tests/fastagi/control-stream-file/test-config.yaml (added)
+++ asterisk/trunk/tests/fastagi/control-stream-file/test-config.yaml Wed Jul 28 11:18:00 2010
@@ -1,0 +1,13 @@
+testinfo:
+ summary: 'Test FastAGI controlStreamFile().'
+ description: |
+ "Test FastAGI controlStreamFile(). NOTE: If this test fails, you may
+ need to update StarPy. Due to a bug, StarPy 1.0.0a13 and earlier
+ will always fail this test."
+
+properties:
+ minversion: '1.4'
+ dependencies:
+ - app : 'python'
+ - python : 'twisted'
+ - python : 'starpy'
Propchange: asterisk/trunk/tests/fastagi/control-stream-file/test-config.yaml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/fastagi/control-stream-file/test-config.yaml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/fastagi/control-stream-file/test-config.yaml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: asterisk/trunk/tests/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/tests.yaml?view=diff&rev=608&r1=607&r2=608
==============================================================================
--- asterisk/trunk/tests/tests.yaml (original)
+++ asterisk/trunk/tests/tests.yaml Wed Jul 28 11:18:00 2010
@@ -40,3 +40,5 @@
- test: 'queues/wrapup_time'
- test: 'fastagi/connect'
- test: 'fastagi/channel-status'
+ - test: 'fastagi/hangup'
+ - test: 'fastagi/stream-file'
More information about the asterisk-commits
mailing list