[asterisk-commits] mjordan: testsuite/asterisk/trunk r1998 - in /asterisk/trunk: ./ asttest/ lib...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Aug 29 10:36:23 CDT 2011
Author: mjordan
Date: Mon Aug 29 10:36:17 2011
New Revision: 1998
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=1998
Log:
Added support for python logging to testsuite
This change adds python logging to the testsuite. This replaces the previous
mechanism for logging test output, which captured stdout and redirected it
to a file. Currently, the logging is managed for each test case by the
python TestCase class.
Reported by: mjordan
Tested by: pabelanger
Review: https://reviewboard.asterisk.org/r/1382
Added:
asterisk/trunk/logger.conf
- copied unchanged from r1997, asterisk/team/group/python_logging/logger.conf
asterisk/trunk/logs/
- copied from r1997, asterisk/team/group/python_logging/logs/
Modified:
asterisk/trunk/ (props changed)
asterisk/trunk/asttest/asttest.c
asterisk/trunk/lib/python/asterisk/TestCase.py
asterisk/trunk/lib/python/asterisk/ami.py
asterisk/trunk/lib/python/asterisk/asterisk.py
asterisk/trunk/lib/python/asterisk/cdr.py
asterisk/trunk/lib/python/asterisk/config.py
asterisk/trunk/lib/python/asterisk/sipp.py
asterisk/trunk/lib/python/asterisk/version.py
asterisk/trunk/lib/python/asterisk/voicemail.py
asterisk/trunk/lib/python/client.py
asterisk/trunk/runtests.py
asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast2/extensions.conf
asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/run-test
asterisk/trunk/tests/apps/voicemail/tests.yaml
Propchange: asterisk/trunk/
------------------------------------------------------------------------------
automerge = *
Propchange: asterisk/trunk/
------------------------------------------------------------------------------
svnmerge-integrated = /asterisk/trunk:1-1987
Modified: asterisk/trunk/asttest/asttest.c
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/asttest/asttest.c?view=diff&rev=1998&r1=1997&r2=1998
==============================================================================
--- asterisk/trunk/asttest/asttest.c (original)
+++ asterisk/trunk/asttest/asttest.c Mon Aug 29 10:36:17 2011
@@ -82,7 +82,7 @@
opts->asterisk_path = "asterisk";
/* parse options */
- while ((c = getopt(argc, argv, "l:a:s:v:n:wh")) != -1) {
+ while ((c = getopt(argc, argv, "l:a:s:v:wh")) != -1) {
switch (c) {
case 'l':
opts->log_filename = optarg;
Modified: asterisk/trunk/lib/python/asterisk/TestCase.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/TestCase.py?view=diff&rev=1998&r1=1997&r2=1998
==============================================================================
--- asterisk/trunk/lib/python/asterisk/TestCase.py (original)
+++ asterisk/trunk/lib/python/asterisk/TestCase.py Mon Aug 29 10:36:17 2011
@@ -8,14 +8,15 @@
'''
import sys
-import logging
+import logging, logging.config
+import logging.config
import os
from twisted.internet import reactor
from starpy import manager, fastagi
from asterisk import Asterisk
-log = logging.getLogger('TestCase')
+logger = logging.getLogger(__name__)
class TestCase(object):
ast = []
@@ -23,11 +24,24 @@
fastagi = []
reactor_timeout = 30
passed = False
+ defaultLogLevel = "WARN"
+ defaultLogFileName = "logger.conf"
def __init__(self):
self.test_name = os.path.dirname(sys.argv[0])
self.base = self.test_name.lstrip("tests/")
+ self.testStateController = None
+
+ """ Set up logging """
+ logConfigFile = os.path.join(os.getcwd(), "%s" % (self.defaultLogFileName))
+ if os.path.exists(logConfigFile):
+ logging.config.fileConfig(logConfigFile, None, False)
+ else:
+ print "WARNING: no logging.conf file found; using default configuration"
+ logging.basicConfig(level=self.defaultLogLevel)
+
+ logger.info("Executing " + self.test_name)
reactor.callWhenRunning(self.run)
def create_asterisk(self, count=1):
@@ -38,7 +52,7 @@
"""
for c in range(count):
- print "Creating Asterisk instance %d ..." % (c + 1)
+ logger.info("Creating Asterisk instance %d" % (c + 1))
self.ast.append(Asterisk(base=self.base))
# Copy shared config files
self.ast[c].install_configs("%s/configs" %
@@ -60,7 +74,7 @@
for c in range(count):
host = "127.0.0.%d" % (c + 1)
self.ami.append(None)
- print "Creating AMIFactory %d ..." % (c + 1)
+ logger.info("Creating AMIFactory %d" % (c + 1))
self.ami_factory = manager.AMIFactory(username, secret, c)
self.ami_factory.login(host).addCallbacks(self.ami_connect,
self.ami_login_error)
@@ -70,7 +84,7 @@
for c in range(count):
host = "127.0.0.%d" % (c + 1)
self.fastagi.append(None)
- print "Creating FastAGI Factory %d ..." % (c + 1)
+ logger.info("Creating FastAGI Factory %d" % (c + 1))
self.fastagi_factory = fastagi.FastAGIFactory(self.fastagi_connect)
reactor.listenTCP(4573, self.fastagi_factory,
self.reactor_timeout, host)
@@ -80,7 +94,7 @@
"""
for index, item in enumerate(self.ast):
- print "Starting Asterisk instance %d ..." % (index + 1)
+ logger.info("Starting Asterisk instance %d" % (index + 1))
self.ast[index].start()
def stop_asterisk(self):
@@ -88,14 +102,14 @@
"""
for index, item in enumerate(self.ast):
- print "Stopping Asterisk instance %d ..." % (index + 1)
+ logger.info("Stopping Asterisk instance %d" % (index + 1))
self.ast[index].stop()
def stop_reactor(self):
"""
"""
- print "Stopping Reactor ..."
+ logger.info("Stopping Reactor")
if reactor.running:
reactor.stop()
@@ -106,10 +120,10 @@
reactor.callLater(self.reactor_timeout, self.stop_reactor)
def ami_login_error(self, ami):
- print "Error logging into AMI"
+ logger.error("Error logging into AMI")
self.stop_reactor()
def ami_connect(self, ami):
- print "AMI Connect instance %s ..." % (ami.id + 1)
+ logger.info("AMI Connect instance %s" % (ami.id + 1))
self.ami[ami.id] = ami
Modified: asterisk/trunk/lib/python/asterisk/ami.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/ami.py?view=diff&rev=1998&r1=1997&r2=1998
==============================================================================
--- asterisk/trunk/lib/python/asterisk/ami.py (original)
+++ asterisk/trunk/lib/python/asterisk/ami.py Mon Aug 29 10:36:17 2011
@@ -2,6 +2,9 @@
from starpy import manager
import datetime
import sys
+import logging
+
+logger = logging.getLogger(__name__)
class AMI:
def __init__(self, on_login, on_error, timeout=60, user="mark", secret="mysecret", host="127.0.0.1", port=5038):
@@ -18,20 +21,20 @@
def login(self):
self.__attempts = self.__attempts + 1
- print "AMI Login attempt #%d" % (self.__attempts)
+ logger.debug("AMI Login attempt #%d" % (self.__attempts))
if not self.__start:
self.__start = datetime.datetime.now()
self.ami_factory.login(self.host, self.port).addCallbacks(self.on_login_success, self.on_login_error)
def on_login_success(self, ami):
self.ami = ami
- print "AMI Login succesful"
+ logger.debug("AMI Login succesful")
return self.on_login(ami)
def on_login_error(self, reason):
runtime = (datetime.datetime.now() - self.__start).seconds
if runtime >= self.login_timeout:
- print "AMI login failed after %d second timeout" % (self.login_timeout)
+ logger.error("AMI login failed after %d second timeout" % (self.login_timeout))
return self.on_error()
delay = 2 ** self.__attempts
if delay + runtime >= self.login_timeout:
Modified: asterisk/trunk/lib/python/asterisk/asterisk.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/asterisk.py?view=diff&rev=1998&r1=1997&r2=1998
==============================================================================
--- asterisk/trunk/lib/python/asterisk/asterisk.py (original)
+++ asterisk/trunk/lib/python/asterisk/asterisk.py Mon Aug 29 10:36:17 2011
@@ -18,10 +18,12 @@
import shutil
import subprocess
import utils
+import logging
from config import ConfigFile
from version import AsteriskVersion
+logger = logging.getLogger(__name__)
class Asterisk:
"""An instance of Asterisk.
@@ -77,7 +79,7 @@
ast_conf = ConfigFile(c)
break
if ast_conf is None:
- print "No asterisk.conf found on the system!"
+ logger.error("No asterisk.conf found on the system!")
return
if base is not None:
@@ -97,7 +99,7 @@
if c.name == "directories":
dir_cat = c
if dir_cat is None:
- print "Unable to discover dir layout from asterisk.conf"
+ logger.error("Unable to discover dir layout from asterisk.conf")
return
self.__gen_ast_conf(ast_conf, dir_cat, ast_conf_options)
for (var, val) in dir_cat.options:
@@ -121,7 +123,7 @@
try:
self.process = subprocess.Popen(cmd)
except OSError:
- print "Failed to execute command: %s" % str(cmd)
+ logger.error("Failed to execute command: %s" % str(cmd))
return False
# Be _really_ sure that Asterisk has started up before returning.
@@ -232,7 +234,7 @@
asterisk.install_config("tests/my-cool-test/configs/manager.conf")
"""
if not os.path.exists(cfg_path):
- print "Config file '%s' does not exist" % cfg_path
+ logger.error("Config file '%s' does not exist" % cfg_path)
return
tmp = "%s/%s/%s" % (os.path.dirname(cfg_path), self.ast_version.branch, os.path.basename(cfg_path))
@@ -244,9 +246,9 @@
try:
shutil.copyfile(cfg_path, target_path)
except shutil.Error:
- print "'%s' and '%s' are the same file" % (cfg_path, target_path)
+ logger.warn("'%s' and '%s' are the same file" % (cfg_path, target_path))
except IOError:
- print "The destination is not writable '%s'" % target_path
+ logger.warn("The destination is not writable '%s'" % target_path)
def cli_originate(self, argstr, blocking=True):
"""Starts a call from the CLI and links it to an application or
@@ -272,13 +274,13 @@
raise_error = False
if len(args) != 3 and len(args) != 4:
raise_error = True
- print "Wrong number of arguments."
+ logger.error("Wrong number of arguments.")
if args[1] != "extension" and args[1] != "application":
raise_error = True
- print '2nd argument must be "extension" or "application"'
+ logger.error('2nd argument must be "extension" or "application"')
if args[0].find("/") == -1:
raise_error = True
- print 'Channel dial string must be in the form "tech/data".'
+ logger.error('Channel dial string must be in the form "tech/data".')
if raise_error is True:
raise Exception, "Cannot originate call!\n\
Argument string must be in one of these forms:\n\
@@ -306,7 +308,7 @@
"-C", "%s" % os.path.join(self.astetcdir, "asterisk.conf"),
"-rx", "%s" % cli_cmd
]
- print "Executing %s ..." % cmd
+ logger.debug("Executing %s ..." % cmd)
if not blocking:
process = subprocess.Popen(cmd)
@@ -316,13 +318,13 @@
process = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
except OSError:
- print "Failed to execute command: %s" % str(cmd)
+ logger.warn("Failed to execute command: %s" % str(cmd))
return ""
output = ""
try:
for l in process.stdout.readlines():
- print l,
+ logger.debug(l),
output += l
except IOError:
pass
@@ -343,10 +345,10 @@
try:
f = open(local_ast_conf_path, "w")
except IOError:
- print "Failed to open %s" % local_ast_conf_path
+ logger.error("Failed to open %s" % local_ast_conf_path)
return
except:
- print "Unexpected error: %s" % sys.exc_info()[0]
+ logger.error("Unexpected error: %s" % sys.exc_info()[0])
return
for c in ast_conf.categories:
Modified: asterisk/trunk/lib/python/asterisk/cdr.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/cdr.py?view=diff&rev=1998&r1=1997&r2=1998
==============================================================================
--- asterisk/trunk/lib/python/asterisk/cdr.py (original)
+++ asterisk/trunk/lib/python/asterisk/cdr.py Mon Aug 29 10:36:17 2011
@@ -14,6 +14,9 @@
import sys
import csv
import re
+import logging
+
+logger = logging.getLogger(__name__)
class AsteriskCSVCDRLine:
"A single Asterisk call detail record"
@@ -46,8 +49,8 @@
for k,v in self.iteritems():
if None not in (v, other.get(k)) and not re.match(
"%s$" % (str(v).lower()), str(other.get(k)).lower()):
- print "CDR MATCH FAILED, Expected: %s:%s Got: %s:%s" % (k, v,
- k, other.get(k))
+ logger.warn("CDR MATCH FAILED, Expected: %s:%s Got: %s:%s" % (k, v,
+ k, other.get(k)))
return False
return True
@@ -86,10 +89,10 @@
try:
cdr = csv.DictReader(open(fn, "r"), AsteriskCSVCDRLine.get_fields(), ",")
except IOError:
- print "Failed to open CDR file '%s'" % (fn)
+ logger.error("Failed to open CDR file '%s'" % (fn))
return
except:
- print "Unexpected error: %s" % (sys.exc_info()[0])
+ logger.error("Unexpected error: %s" % (sys.exc_info()[0]))
return
for r in cdr:
@@ -110,7 +113,7 @@
each record"""
if len(self) != len(other):
- print "CDR MATCH FAILED, different number of records"
+ logger.warn("CDR MATCH FAILED, different number of records")
return False
for i,x in enumerate(self):
if not x.match(other[i]):
@@ -124,7 +127,7 @@
try:
open(self.filename, "w").close()
except:
- print "Unable to empty CDR file %s" % (self.filename)
+ logger.warn("Unable to empty CDR file %s" % (self.filename))
class AsteriskCSVCDRTests(unittest.TestCase):
Modified: asterisk/trunk/lib/python/asterisk/config.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/config.py?view=diff&rev=1998&r1=1997&r2=1998
==============================================================================
--- asterisk/trunk/lib/python/asterisk/config.py (original)
+++ asterisk/trunk/lib/python/asterisk/config.py Mon Aug 29 10:36:17 2011
@@ -19,7 +19,9 @@
import sys
import re
import unittest
+import logging
+logger = logging.getLogger(__name__)
def is_blank_line(line):
return re.match("\s*(?:;.*)?$", line) is not None
@@ -49,7 +51,7 @@
match = self.varval_re.match(line)
if match is None:
if not is_blank_line(line):
- print "Invalid line: '%s'" % line.strip()
+ logger.warn("Invalid line: '%s'" % line.strip())
return
self.options.append((match.group("name"), match.group("value").strip()))
@@ -80,10 +82,10 @@
config_str = f.read()
f.close()
except IOError:
- print "Failed to open config file '%s'" % fn
+ logger.error("Failed to open config file '%s'" % fn)
return
except:
- print "Unexpected error: %s" % sys.exc_info()[0]
+ logger.error("Unexpected error: %s" % sys.exc_info()[0])
return
config_str = self.strip_mline_comments(config_str)
@@ -103,7 +105,7 @@
)
elif len(self.categories) == 0:
if not is_blank_line(line):
- print "Invalid line: '%s'" % line.strip()
+ logger.warn("Invalid line: '%s'" % line.strip())
else:
self.categories[-1].parse_line(line)
@@ -178,9 +180,9 @@
if len(argv) == 2:
conf = ConfigFile(argv[1])
for c in conf.categories:
- print "[%s]" % c.name
+ logger.debug("[%s]" % c.name)
for (var, val) in c.options:
- print "%s = %s" % (var, val)
+ logger.debug("%s = %s" % (var, val))
else:
return unittest.main()
Modified: asterisk/trunk/lib/python/asterisk/sipp.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/sipp.py?view=diff&rev=1998&r1=1997&r2=1998
==============================================================================
--- asterisk/trunk/lib/python/asterisk/sipp.py (original)
+++ asterisk/trunk/lib/python/asterisk/sipp.py Mon Aug 29 10:36:17 2011
@@ -13,9 +13,11 @@
import sys
import os
import subprocess
+import logging
from asterisk import Asterisk
+logger = logging.getLogger(__name__)
class SIPpTest:
"""
@@ -90,8 +92,8 @@
for (key, val) in default_args.items():
sipp_args.extend([ key, val ])
- print "Executing SIPp scenario: %s" % scenario['scenario']
- print sipp_args
+ logger.debug("Executing SIPp scenario: %s" % scenario['scenario'])
+ logger.debug(sipp_args)
return subprocess.Popen(sipp_args,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
@@ -115,13 +117,13 @@
self.stderr.append(err)
self.result.append(self.sipp[i].wait())
if self.result[i]:
- print "SIPp scenario #%d FAILED" % i
+ logger.warn("SIPp scenario #%d FAILED" % i)
else:
- print "SIPp scenario #%d PASSED" % i
+ logger.info("SIPp scenario #%d PASSED" % i)
if self.result[i]:
passed = False
#print self.stdout[i]
- print self.stderr[i]
+ logger.warn(self.stderr[i])
self.ast1.stop()
Modified: asterisk/trunk/lib/python/asterisk/version.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/version.py?view=diff&rev=1998&r1=1997&r2=1998
==============================================================================
--- asterisk/trunk/lib/python/asterisk/version.py (original)
+++ asterisk/trunk/lib/python/asterisk/version.py Mon Aug 29 10:36:17 2011
@@ -14,6 +14,9 @@
import sys
import re
import unittest
+import logging
+
+logger = logging.getLogger(__name__)
class AsteriskVersion:
"""An Asterisk Version.
@@ -146,10 +149,10 @@
v = match.group(1)
f.close()
except IOError:
- print "I/O Error getting Asterisk version from %s" % path
+ logger.error("I/O Error getting Asterisk version from %s" % path)
except:
- print "Unexpected error getting version from %s: %s" % (path,
- sys.exc_info()[0])
+ logger.error("Unexpected error getting version from %s: %s" % (path,
+ sys.exc_info()[0]))
return v
Modified: asterisk/trunk/lib/python/asterisk/voicemail.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/voicemail.py?view=diff&rev=1998&r1=1997&r2=1998
==============================================================================
--- asterisk/trunk/lib/python/asterisk/voicemail.py (original)
+++ asterisk/trunk/lib/python/asterisk/voicemail.py Mon Aug 29 10:36:17 2011
@@ -12,12 +12,20 @@
import os
import glob
import shutil
-
+import logging
+
+from datetime import datetime
from asterisk import Asterisk
from config import Category
from config import ConfigFile
+from TestCase import TestCase
+from TestState import TestState
+from TestState import TestStateController
sys.path.append("lib/python")
+
+logger = logging.getLogger(__name__)
+
"""
Class that manages creation of, verification of, and teardown of Asterisk mailboxes on the local filesystem
@@ -72,7 +80,6 @@
self.__ast = ast
self.voicemailDirectory = self.__ast.directories['astspooldir'] + '/voicemail'
-
"""
Creates the basic set of folders needed for a mailbox on the file system
context The context that the mailbox will exist under
@@ -116,7 +123,7 @@
except IOError as e:
if e.errno == errno.EACCESS:
- print "You do not have sufficient permissions to perform the necessary directory manipulations"
+ logger.error( "You do not have sufficient permissions to perform the necessary directory manipulations")
return False
return True
@@ -154,14 +161,15 @@
f.write('rdnis=unknown\n')
f.write('priority=2\n')
f.write('callerchan=SIP/ast1-00000000\n')
- f.write('callerid=\"Anonymous\"<ast1>\n')
+ f.write('callerid=\"Anonymous\"<555-5555>\n')
f.write('origdate=Tue Aug 9 10:05:13 PM UTC 2011\n')
f.write('origtime=1312927513\n')
if (folder == self.urgentFolderName):
f.write('flag=Urgent\n')
else:
f.write('flag=\n')
- f.write('duration=1\n')
+ f.write('category=tt-monkeys\n')
+ f.write('duration=6\n')
f.close()
for format in formats:
@@ -215,6 +223,24 @@
"""
fileName = msgName + ".txt"
retVal = retVal & self.checkVoiceFileExists(context, mailbox, fileName, folder)
+
+ return retVal
+
+ """
+ Check if a voicemail greeting exists on the filesystem
+ context The context of the mailbox
+ mailbox The mailbox
+ msgname The name of the greeting to find
+ lstFormats The formats we expect to be recorded for us
+
+ true if the greeting exists, false otherwise
+ """
+ def checkGreetingExists(self, context, mailbox, msgname, lstFormats):
+ retVal = True
+
+ for format in lstFormats:
+ fileName = msgname + "." + format
+ retVal = retVal & self.checkVoiceFileExists(context, mailbox, fileName, "")
return retVal
@@ -248,6 +274,53 @@
return False
"""
+ An object that holds voicemail user information
+ """
+ class UserObject(object):
+ def __init__(self):
+ self.password = ""
+ self.fullname = ""
+ self.emailaddress = ""
+ self.pageraddress = ""
+
+ """
+ Gets user information from the voicemail configuration file
+
+ context The context of the mailbox
+ mailbox The mailbox
+ sourceFile The file containing the user information to pull from. Defaults
+ to voicemail.conf
+
+ returns A VoiceMailMailboxManagement.UserObject object, populated with the user's values,
+ or an empty object
+ """
+ def getUserObject(self, context, mailbox, sourceFile="voicemail.conf"):
+
+ filePath = self.__ast.baseDirectory + self.__ast.directories['astetcdir'] + "/" + sourceFile
+
+ configFile = ConfigFile(filePath)
+ userObject = VoiceMailMailboxManagement.UserObject()
+ for cat in configFile.categories:
+ if cat.name == context:
+ for kvp in cat.options:
+ if kvp[0] == mailbox:
+ tokens = kvp[1].split(',')
+ i = 0
+ for token in tokens:
+ if i == 0:
+ userObject.password = token
+ elif i == 1:
+ userObject.fullname = token
+ elif i == 2:
+ userObject.emailaddress = token
+ elif i == 3:
+ userObject.pageraddress = token
+ i += 1
+ return userObject
+
+ return userObject
+
+ """
Checks if a file exists under the voicemail file structure
context The context of the mailbox
mailbox The mailbox
@@ -266,7 +339,6 @@
return True
else:
return False
-
def __removeItemsFromFolder__(self, mailboxPath, folder):
folderPath = os.path.join(self.__ast.baseDirectory, "%(mp)s/%(f)s" % {'mp':mailboxPath, 'f':folder})
Modified: asterisk/trunk/lib/python/client.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/client.py?view=diff&rev=1998&r1=1997&r2=1998
==============================================================================
--- asterisk/trunk/lib/python/client.py (original)
+++ asterisk/trunk/lib/python/client.py Mon Aug 29 10:36:17 2011
@@ -106,8 +106,7 @@
self.ordered = False
def __init__(self, myargv, myasterisk, mytester, mytimeout = 5):
- self.log = logging.getLogger('TestAMI')
- self.log.setLevel(logging.INFO)
+ self.log = logging.getLogger(__name__)
self.ami = None
self.testcount = 0
self.passed = True
Modified: asterisk/trunk/runtests.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/runtests.py?view=diff&rev=1998&r1=1997&r2=1998
==============================================================================
--- asterisk/trunk/runtests.py (original)
+++ asterisk/trunk/runtests.py Mon Aug 29 10:36:17 2011
@@ -158,23 +158,17 @@
cmd = [
"%s/run-test" % self.test_name,
]
+
if os.path.exists(cmd[0]) and os.access(cmd[0], os.X_OK):
print "Running %s ..." % cmd
- try:
- f = open("%s/test-output.txt" % self.test_name, "w")
- except IOError:
- print "FAILURE: Failed to open file for test output"
- return
p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
try:
for l in p.stdout.readlines():
- f.write(l)
print l,
except IOError:
pass
p.wait()
- f.close()
self.passed = (p.returncode == 0 and self.expectPass) or (p.returncode and not self.expectPass)
else:
Modified: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast2/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast2/extensions.conf?view=diff&rev=1998&r1=1997&r2=1998
==============================================================================
--- asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast2/extensions.conf (original)
+++ asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast2/extensions.conf Mon Aug 29 10:36:17 2011
@@ -29,4 +29,3 @@
same => n,SendDTMF(#)
same => n,Wait(1)
same => n,Hangup()
-
Modified: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/run-test?view=diff&rev=1998&r1=1997&r2=1998
==============================================================================
--- asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/run-test (original)
+++ asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/run-test Mon Aug 29 10:36:17 2011
@@ -11,6 +11,7 @@
import sys
import os
import datetime
+import logging
from datetime import datetime
from twisted.internet import reactor
@@ -22,6 +23,7 @@
from asterisk.TestCase import TestCase
from asterisk.voicemail import VoiceMailMailboxManagement
+logger = logging.getLogger(__name__)
class LeaveVoicemailNominal(TestCase):
@@ -35,7 +37,7 @@
self.create_asterisk(2)
def ami_connect(self, ami):
- print str(datetime.now()) + " Got AMI Connect for instance " + str(ami.id)
+ logger.info("Got AMI Connect for instance " + str(ami.id))
TestCase.ami_connect(self, ami)
self.audioFile = os.path.join(os.getcwd(), "%s/sounds/talking" % (self.testParentDir))
@@ -47,13 +49,13 @@
extensions = [1234,1234,5678,5678,9000]
for extension in extensions:
- print str(datetime.now()) + " Originating call to sip/ast1/" + str(extension)
+ logger.debug("Originating call to sip/ast1/" + str(extension))
df = ami.originate("sip/ast1/" + str(extension), "sendvoicemail", str(extension), 1, None, "CallId-" + str(extension), None, None, None, {}, True )
df.addErrback(self.handleOriginateFailure)
def handleOriginateFailure(self, reason):
- print str(datetime.now()) + " error sending originate:"
- print reason.getTraceback()
+ logger.error("Error sending originate:")
+ logger.error(reason.getTraceback())
self.stop_reactor()
return reason
@@ -64,11 +66,11 @@
if event['result'] == "pass":
self.passed = True
- print str(datetime.now()) + " VoiceMail successfully exited"
+ logger.info("VoiceMail successfully exited")
else:
- print str(datetime.now()) + " VoiceMail did not successfully exit:"
- print str(datetime.now()) + " result: %s" % (event['result'],)
- print str(datetime.now()) + " error: %s" % (event['error'],)
+ logger.warn("VoiceMail did not successfully exit:")
+ logger.warn("result: %s" % (event['result'],))
+ logger.warn("error: %s" % (event['error'],))
self.stop_reactor()
@@ -98,23 +100,23 @@
if test.passed:
formats = ["ulaw","wav","WAV"]
if not voicemailManager.checkVoicemailExists("default","1234",0,formats):
- print str(datetime.now()) + " Failed to find voicemail 0 for default/1234"
+ logger.warn("Failed to find voicemail 0 for default/1234")
test.passed = 0
if not voicemailManager.checkVoicemailExists("default","1234",1,formats):
- print str(datetime.now()) + " Failed to find voicemail 1 for default/1234"
+ logger.warn("Failed to find voicemail 1 for default/1234")
test.passed = 0
if not voicemailManager.checkVoicemailExists("default","5678",0,formats):
- print str(datetime.now()) + " Failed to find voicemail 0 for default/5678"
+ logger.warn("Failed to find voicemail 0 for default/5678")
test.passed = 0
if not voicemailManager.checkVoicemailExists("default","5678",1,formats):
- print str(datetime.now()) + " Failed to find voicemail 0 for default/5678"
+ logger.warn("Failed to find voicemail 0 for default/5678")
test.passed = 0
if not voicemailManager.checkVoicemailExists("notdefault","1234",0,formats):
- print str(datetime.now()) + " Failed to find voicemail 0 for notdefault/1234"
+ logger.warn("Failed to find voicemail 0 for notdefault/1234")
test.passed = 0
if not test.passed:
Modified: asterisk/trunk/tests/apps/voicemail/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/voicemail/tests.yaml?view=diff&rev=1998&r1=1997&r2=1998
==============================================================================
--- asterisk/trunk/tests/apps/voicemail/tests.yaml (original)
+++ asterisk/trunk/tests/apps/voicemail/tests.yaml Mon Aug 29 10:36:17 2011
@@ -10,4 +10,21 @@
# - test: 'authenticate_nominal'
# - test: 'authenticate_invalid_mailbox'
# - test: 'authenticate_invalid_password'
-# - test: 'authenticate_extensions'
+# - test: 'authenticate_extensions'
+# - test: 'check_voicemail_nominal'
+# - test: 'check_voicemail_envelope'
+# - test: 'check_voicemail_delete'
+# - test: 'check_voicemail_new_user'
+# - test: 'check_voicemail_new_user_hangup'
+# - test: 'check_voicemail_options_record_busy'
+# - test: 'check_voicemail_options_record_unavail'
+# - test: 'check_voicemail_options_record_name'
+# - test: 'check_voicemail_options_record_temp'
+# - test: 'check_voicemail_options_change_password'
+# - test: 'check_voicemail_forward'
+# - test: 'check_voicemail_forward_hangup'
+# - test: 'check_voicemail_forward_with_prepend'
+# - test: 'check_voicemail_callback'
+# - test: 'check_voicemail_dialout'
+# - test: 'check_voicemail_reply'
+# - test: 'check_voicemail_while_leaving_msg'
More information about the asterisk-commits
mailing list