[asterisk-dev] Change in testsuite[master]: Address review feedback
Jonathan Rose (Code Review)
asteriskteam at digium.com
Fri Apr 3 13:49:29 CDT 2015
Jonathan Rose has uploaded a new change for review.
https://gerrit.asterisk.org/28
Change subject: Address review feedback
......................................................................
Address review feedback
Change-Id: If37cf20857ae3c0b35e0637a0a2cb7e7d6226df6
---
M tests/fax/pjsip/t38_with_auth/configs/ast1/extensions.conf
M tests/fax/pjsip/t38_with_auth/configs/ast2/extensions.conf
M tests/fax/pjsip/t38_with_auth/run-test
M tests/fax/pjsip/t38_with_auth/test-config.yaml
4 files changed, 62 insertions(+), 52 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/28/28/1
diff --git a/tests/fax/pjsip/t38_with_auth/configs/ast1/extensions.conf b/tests/fax/pjsip/t38_with_auth/configs/ast1/extensions.conf
index 55a81b4..83e0d5b 100644
--- a/tests/fax/pjsip/t38_with_auth/configs/ast1/extensions.conf
+++ b/tests/fax/pjsip/t38_with_auth/configs/ast1/extensions.conf
@@ -1,7 +1,7 @@
[sendfax]
exten => 1234,1,noop
-exten => 1234,n,SendFax(${ASTDATADIR}/send.tiff)
+ same => n,SendFax(${ASTDATADIR}/send.tiff)
exten => h,1,noop
-exten => h,n,UserEvent(FaxStatus,operation: send,status: ${FAXOPT(status)},statusstr: ${FAXOPT(statusstr)},error: ${FAXOPT(error)})
+ same => n,UserEvent(FaxStatus,operation: send,status: ${FAXOPT(status)},statusstr: ${FAXOPT(statusstr)},error: ${FAXOPT(error)})
diff --git a/tests/fax/pjsip/t38_with_auth/configs/ast2/extensions.conf b/tests/fax/pjsip/t38_with_auth/configs/ast2/extensions.conf
index 03f2714..8d5dc7f 100644
--- a/tests/fax/pjsip/t38_with_auth/configs/ast2/extensions.conf
+++ b/tests/fax/pjsip/t38_with_auth/configs/ast2/extensions.conf
@@ -1,6 +1,6 @@
[receivefax]
exten => 1234,1,noop
-exten => 1234,n,ReceiveFax(${ASTDATADIR}/receive.tiff)
+ same => n,ReceiveFax(${ASTDATADIR}/receive.tiff)
exten => h,1,noop
-exten => h,n,UserEvent(FaxStatus,operation: receive,status: ${FAXOPT(status)},statusstr: ${FAXOPT(statusstr)},error: ${FAXOPT(error)})
+ same => n,UserEvent(FaxStatus,operation: receive,status: ${FAXOPT(status)},statusstr: ${FAXOPT(statusstr)},error: ${FAXOPT(error)})
diff --git a/tests/fax/pjsip/t38_with_auth/run-test b/tests/fax/pjsip/t38_with_auth/run-test
old mode 100644
new mode 100755
index 8af0d4d..30fc635
--- a/tests/fax/pjsip/t38_with_auth/run-test
+++ b/tests/fax/pjsip/t38_with_auth/run-test
@@ -1,8 +1,9 @@
#!/usr/bin/env python
# vim: sw=3 et:
'''
-Copyright (C) 2011, Digium, Inc.
+Copyright (C) 2015, Digium, Inc.
Matthew Nicholson <mnicholson at digium.com>
+Jonathan Rose <jrose at digium.com>
This program is free software, distributed under the terms of
the GNU General Public License Version 2.
@@ -11,73 +12,81 @@
import sys
import logging
import os
-import re
import shutil
-from twisted.internet import reactor
-
sys.path.append("lib/python")
-from asterisk.asterisk import Asterisk
+
+from twisted.internet import reactor
from asterisk.test_case import TestCase
-logger = logging.getLogger(__name__)
+LOGGER = logging.getLogger(__name__)
+
class T38Test(TestCase):
- event_count = 0
- success_count = 0
+ """Test class for performing the test. Manages files, originates FAX call,
+ and monitors a user event to verify that the fax completed successfully on
+ the sender end of the call.
+ """
- def __init__(self):
- TestCase.__init__(self)
- self.reactor_timeout = 120
- self.create_asterisk(2)
+ def __init__(self):
+ """Create Asterisk instances and copy our test fax to where the sender
+ will send it from.
+ """
- # copy the tiff file we are going to send to a good known location
- shutil.copy("%s/send.tiff" % (os.path.dirname(os.path.realpath(__file__)),), "%s%s" % (self.ast[0].base, self.ast[0].directories['astdatadir']))
+ super(T38Test, self).__init__()
+ self.reactor_timeout = 120
+ self.create_asterisk(2)
- def ami_connect(self, ami):
- if ami.id == 0:
+ # copy the tiff file we are going to send to a good known location
+ shutil.copy("%s/send.tiff" % (os.path.dirname(
+ os.path.realpath(__file__)),), "%s%s" %
+ (self.ast[0].base, self.ast[0].directories['astdatadir']))
- ami.registerEvent('UserEvent', self.fax_result)
- df = ami.originate("PJSIP/ast2-t38/sip:1234 at 127.0.0.2", "sendfax", "1234", 1)
+ def ami_connect(self, ami):
+ """Upon connecting to AMI on the first Asterisk instance, originate
+ a call that will send the fax to the second Asterisk instance. Also
+ register for UserEvents.
+ """
- def handle_failure(reason):
- logging.error("error sending originate:")
- logging.error(reason.getTraceback())
- self.stop_reactor()
+ if ami.id == 0:
+ ami.registerEvent('UserEvent', self.fax_result)
+ deferred = ami.originate("PJSIP/ast2-t38/sip:1234 at 127.0.0.2",
+ "sendfax", "1234", 1)
+ deferred.addErrback(self.handle_originate_failure)
- return reason
+ def fax_result(self, ami, event):
+ """Upon receiving a FaxStatus user event, verify whether the fax
+ succeeded or failed.
+ """
- df.addErrback(handle_failure)
+ if event['userevent'] != 'FaxStatus':
+ return
- def fax_result(self, ami, event):
- if event['userevent'] != 'FaxStatus':
- return
+ if event['status'] == "SUCCESS":
+ self.passed = True
+ else:
+ LOGGER.error("error sending fax through t38:")
+ LOGGER.error("operation: %s" % (event['operation'],))
+ LOGGER.error("status: %s" % (event['status'],))
+ LOGGER.error("error: %s" % (event['error'],))
+ LOGGER.error("statusstr: %s" % (event['statusstr'],))
- if event['status'] == "SUCCESS":
- self.passed = True
- else:
- logging.error("error sending fax through t38:")
- logging.error("operation: %s" % (event['operation'],))
- logging.error("status: %s" % (event['status'],))
- logging.error("error: %s" % (event['error'],))
- logging.error("statusstr: %s" % (event['statusstr'],))
+ self.stop_reactor()
- self.stop_reactor()
-
- def run(self):
- TestCase.run(self)
- self.create_ami_factory(2)
+ def run(self):
+ super(T38Test, self).run()
+ self.create_ami_factory(2)
def main():
- test = T38Test()
- reactor.run()
+ test = T38Test()
+ reactor.run()
- if not test.passed:
- return 1
+ if not test.passed:
+ return 1
- return 0
+ return 0
if __name__ == "__main__":
- sys.exit(main() or 0)
+ sys.exit(main() or 0)
diff --git a/tests/fax/pjsip/t38_with_auth/test-config.yaml b/tests/fax/pjsip/t38_with_auth/test-config.yaml
index 43cda18..1e41533 100644
--- a/tests/fax/pjsip/t38_with_auth/test-config.yaml
+++ b/tests/fax/pjsip/t38_with_auth/test-config.yaml
@@ -3,10 +3,11 @@
description: |
"This test starts two Asterisk instances and sends a fax between them
using the PJSIP channel driver - The endpoints use userpass
- authentication."
+ authentication. Addresses a bug that caused a failure in faxes using
+ authentication while sending from a PJSIP endpoint detailed in
+ ASTERISK-24933"
properties:
- minversion: '13.3.1'
dependencies:
- python : 'twisted'
- python : 'starpy'
--
To view, visit https://gerrit.asterisk.org/28
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If37cf20857ae3c0b35e0637a0a2cb7e7d6226df6
Gerrit-PatchSet: 1
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: Jonathan Rose <jrose at digium.com>
More information about the asterisk-dev
mailing list