[asterisk-commits] kmoore: testsuite/asterisk/trunk r4225 - in /asterisk/trunk/tests/fax/local_c...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Sep 27 08:10:26 CDT 2013


Author: kmoore
Date: Fri Sep 27 08:10:17 2013
New Revision: 4225

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=4225
Log:
Update the local channel t38 queryoption test

This converts the local channel t38 queryoption test from lua to python
and gets it working again on 11, 12, and trunk.

(closes issue ASTERISK-22318)
Review: https://reviewboard.asterisk.org/r/2867/

Added:
    asterisk/trunk/tests/fax/local_channel_t38_queryoption/configs/
    asterisk/trunk/tests/fax/local_channel_t38_queryoption/configs/ast1/
    asterisk/trunk/tests/fax/local_channel_t38_queryoption/configs/ast1/extensions.conf   (with props)
    asterisk/trunk/tests/fax/local_channel_t38_queryoption/configs/ast1/sip.conf   (with props)
    asterisk/trunk/tests/fax/local_channel_t38_queryoption/configs/ast2/
    asterisk/trunk/tests/fax/local_channel_t38_queryoption/configs/ast2/extensions.conf   (with props)
    asterisk/trunk/tests/fax/local_channel_t38_queryoption/configs/ast2/sip.conf   (with props)
Removed:
    asterisk/trunk/tests/fax/local_channel_t38_queryoption/test.lua
Modified:
    asterisk/trunk/tests/fax/local_channel_t38_queryoption/run-test

Added: asterisk/trunk/tests/fax/local_channel_t38_queryoption/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fax/local_channel_t38_queryoption/configs/ast1/extensions.conf?view=auto&rev=4225
==============================================================================
--- asterisk/trunk/tests/fax/local_channel_t38_queryoption/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/fax/local_channel_t38_queryoption/configs/ast1/extensions.conf Fri Sep 27 08:10:17 2013
@@ -1,0 +1,10 @@
+[sendfax]
+exten = 1234,1,NoOp()
+exten = 1234,n,SendFax(/tmp/send.tiff)
+exten = h,1,NoOp()
+exten = h,n,UserEvent(FaxStatus,application: SendFax,status: ${FAXOPT(status)},statusstr: ${FAXOPT(statusstr)},error: ${FAXOPT(error)})
+
+[local-sendfax]
+exten = 1234,1,NoOp()
+exten = 1234,n,Dial(local/1234 at sendfax)
+

Propchange: asterisk/trunk/tests/fax/local_channel_t38_queryoption/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/fax/local_channel_t38_queryoption/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/fax/local_channel_t38_queryoption/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/fax/local_channel_t38_queryoption/configs/ast1/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fax/local_channel_t38_queryoption/configs/ast1/sip.conf?view=auto&rev=4225
==============================================================================
--- asterisk/trunk/tests/fax/local_channel_t38_queryoption/configs/ast1/sip.conf (added)
+++ asterisk/trunk/tests/fax/local_channel_t38_queryoption/configs/ast1/sip.conf Fri Sep 27 08:10:17 2013
@@ -1,0 +1,16 @@
+[general]
+bindaddr = 127.0.0.1
+t38pt_udptl = yes,none
+disallow = all
+allow = gsm
+
+[fax]
+type = peer
+context = local-receivefax
+host = 127.0.0.2
+t38pt_udptl = yes,none
+disallow = all
+allow = gsm
+insecure = invite
+qualify = no
+

Propchange: asterisk/trunk/tests/fax/local_channel_t38_queryoption/configs/ast1/sip.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/fax/local_channel_t38_queryoption/configs/ast1/sip.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/fax/local_channel_t38_queryoption/configs/ast1/sip.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/fax/local_channel_t38_queryoption/configs/ast2/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fax/local_channel_t38_queryoption/configs/ast2/extensions.conf?view=auto&rev=4225
==============================================================================
--- asterisk/trunk/tests/fax/local_channel_t38_queryoption/configs/ast2/extensions.conf (added)
+++ asterisk/trunk/tests/fax/local_channel_t38_queryoption/configs/ast2/extensions.conf Fri Sep 27 08:10:17 2013
@@ -1,0 +1,9 @@
+[receivefax]
+exten = 1234,1,NoOp
+exten = 1234,n,ReceiveFax(receive.tiff)
+exten = h,1,NoOp
+exten = h,n,UserEvent(FaxStatus,application: ReceiveFax,status: ${FAXOPT(status)},statusstr: ${FAXOPT(statusstr)},error: ${FAXOPT(error)})
+
+[local-receivefax]
+exten = 1234,1,NoOp
+exten = 1234,n,Dial(local/1234 at receivefax)

Propchange: asterisk/trunk/tests/fax/local_channel_t38_queryoption/configs/ast2/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/fax/local_channel_t38_queryoption/configs/ast2/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/fax/local_channel_t38_queryoption/configs/ast2/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/fax/local_channel_t38_queryoption/configs/ast2/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fax/local_channel_t38_queryoption/configs/ast2/sip.conf?view=auto&rev=4225
==============================================================================
--- asterisk/trunk/tests/fax/local_channel_t38_queryoption/configs/ast2/sip.conf (added)
+++ asterisk/trunk/tests/fax/local_channel_t38_queryoption/configs/ast2/sip.conf Fri Sep 27 08:10:17 2013
@@ -1,0 +1,16 @@
+[general]
+bindaddr = 127.0.0.2
+t38pt_udptl = yes,none
+disallow = all
+allow = gsm
+
+[fax]
+type = peer
+context = local-receivefax
+host = 127.0.0.1
+t38pt_udptl = yes,none
+disallow = all
+allow = gsm
+insecure = invite
+qualify = no
+

Propchange: asterisk/trunk/tests/fax/local_channel_t38_queryoption/configs/ast2/sip.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/fax/local_channel_t38_queryoption/configs/ast2/sip.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/fax/local_channel_t38_queryoption/configs/ast2/sip.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: asterisk/trunk/tests/fax/local_channel_t38_queryoption/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fax/local_channel_t38_queryoption/run-test?view=diff&rev=4225&r1=4224&r2=4225
==============================================================================
--- asterisk/trunk/tests/fax/local_channel_t38_queryoption/run-test (original)
+++ asterisk/trunk/tests/fax/local_channel_t38_queryoption/run-test Fri Sep 27 08:10:17 2013
@@ -1,4 +1,103 @@
-#!/usr/bin/env bash
-set -e
-. lib/sh/lua.sh
-asttest -a /$AST_TEST_ROOT -s `dirname $0` $@
+#!/usr/bin/env python
+'''
+Copyright (C) 2013, Digium, Inc.
+Kinsey Moore <kmoore at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+
+import sys
+import os
+import logging
+import shutil
+
+from twisted.internet import reactor
+
+sys.path.append("lib/python")
+from asterisk.TestCase import TestCase
+
+LOGGER = logging.getLogger(__name__)
+
+class FaxLocalQueryOptionTest(TestCase):
+    '''This class sets up and manages the Local channel fax queryoptions
+    passthrough test.'''
+
+    def __init__(self):
+        '''Initialize the class and copy the tiff to an accessible place.'''
+        TestCase.__init__(self)
+        self.reactor_timeout = 120
+
+
+        self.connections_established = 0
+        self.success_received = 0
+        self.create_asterisk(count=2)
+
+        # copy the tiff file we are going to send to a good known location
+        tiff_path = os.path.dirname(os.path.realpath(__file__))
+        shutil.copy("%s/send.tiff" % (tiff_path), "/tmp")
+
+    def ami_connect(self, ami):
+        '''Setup AMI listeners and start the test.'''
+        self.connections_established += 1
+
+        ami.registerEvent('UserEvent', self.fax_result)
+
+        if self.connections_established != 2:
+            return
+
+        LOGGER.info("Originating fax call")
+        self.ami[0].originate(
+            channel="sip/1234 at fax",
+            exten="1234",
+            context="local-sendfax",
+            priority=1
+        ).addErrback(self.handleOriginateFailure)
+
+    def run(self):
+        '''Setup debugging on the asterisk instances and create AMI
+        connections.'''
+        TestCase.run(self)
+        self.ast[0].cli_exec("sip set debug on")
+        self.ast[0].cli_exec("fax set debug on")
+        self.ast[0].cli_exec("udptl set debug on")
+        self.ast[1].cli_exec("sip set debug on")
+        self.ast[1].cli_exec("fax set debug on")
+        self.ast[1].cli_exec("udptl set debug on")
+        self.create_ami_factory(2)
+
+    def fax_result(self, ami, event):
+        '''Handle receipt of user-defined events, looking for indications of
+        success or failure.'''
+        if event['userevent'] != 'FaxStatus':
+            return
+
+        if event['status'] != 'SUCCESS':
+            LOGGER.error("Received a FaxStatus event that indicated failure")
+            self.stop_reactor()
+            return
+
+        self.success_received += 1
+
+        if self.success_received == 2:
+            self.passed = True
+            self.stop_reactor()
+
+def main():
+    '''Run the fax queryoption test.'''
+    test = FaxLocalQueryOptionTest()
+    reactor.run()
+    if test.passed != True:
+        if test.connections_established != 2:
+            LOGGER.error("Established %d AMI connections instead of 2"
+                % test.connections_established)
+        if test.success_received != 2:
+            LOGGER.error("Received %d success events instead of 2"
+                % test.success_received)
+        return 1
+    return 0
+
+if __name__ == "__main__":
+    sys.exit(main() or 0)
+
+# vim:sw=4:ts=4:expandtab:textwidth=79




More information about the asterisk-commits mailing list