[asterisk-commits] coreyfarrell: testsuite/asterisk/trunk r5138 - in /asterisk/trunk: ./ lib/pyt...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Jun 18 13:14:55 CDT 2014
Author: coreyfarrell
Date: Wed Jun 18 13:14:46 2014
New Revision: 5138
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=5138
Log:
Prevent untracked files from being created in the svn directory
* run-local
install asttest within astroot directory structure
fix the path statement
* lib/python/asterisk.py
add get_path to be used instead of manual path construction involving
asterisk._base, encouraging use of os.path.join style path construction
* chanspy_barge, chanspy_w_mixmonitor
use astspooldir/tmp to write the testaudio1
* sip_tls_call, sip_tls_register
use key files from original location instead of copying them
* fax/sip/local_channel_t38_queryoption, udptl, udptl_v6
store file from ReceiveFax in ${ASTDATADIR}
ASTERISK-23538 #close
Reported by: Corey Farrell
Review: https://reviewboard.asterisk.org/r/3397/
Modified:
asterisk/trunk/lib/python/asterisk/asterisk.py
asterisk/trunk/run-local
asterisk/trunk/tests/apps/chanspy/chanspy_barge/run-test
asterisk/trunk/tests/apps/chanspy/chanspy_w_mixmonitor/run-test
asterisk/trunk/tests/channels/SIP/sip_tls_call/configs/helper1
asterisk/trunk/tests/channels/SIP/sip_tls_call/configs/helper2
asterisk/trunk/tests/channels/SIP/sip_tls_call/run-test
asterisk/trunk/tests/channels/SIP/sip_tls_register/run-test
asterisk/trunk/tests/fax/sip/local_channel_t38_queryoption/configs/ast2/extensions.conf
asterisk/trunk/tests/udptl/configs/ast2/extensions.conf
asterisk/trunk/tests/udptl_v6/configs/ast2/extensions.conf
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=5138&r1=5137&r2=5138
==============================================================================
--- asterisk/trunk/lib/python/asterisk/asterisk.py (original)
+++ asterisk/trunk/lib/python/asterisk/asterisk.py Wed Jun 18 13:14:46 2014
@@ -450,6 +450,24 @@
return self._stop_deferred
+ def get_path(self, astdirkey, *paths):
+ """Join paths using the correct prefix for the current instance.
+
+ Keyword Arguments:
+ astdirkey This argument must match a directory key from asterisk.conf.
+ *paths This is a list of paths to be appended using os.path.join.
+
+ Example Usage:
+ asterisk.get_path("astlogdir", "cdr-csv", "Master.csv")
+ """
+
+ if not astdirkey in self.directories:
+ msg = "Directory '%s' not found in asterisk.conf" % astdirkey
+ LOGGER.error(msg)
+ raise Exception(msg)
+
+ return os.path.join(self.base + self.directories[astdirkey], *paths)
+
def install_configs(self, cfg_path, deps=None):
"""Installs all files located in the configuration directory for this
instance of Asterisk.
Modified: asterisk/trunk/run-local
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/run-local?view=diff&rev=5138&r1=5137&r2=5138
==============================================================================
--- asterisk/trunk/run-local (original)
+++ asterisk/trunk/run-local Wed Jun 18 13:14:46 2014
@@ -17,7 +17,7 @@
lua -e "getfenv()" 2>/dev/null && (
cd asttest
make
- make install DESTDIR="$HERE/root"
+ make install DESTDIR="$HERE/astroot"
)
(
cd ..
@@ -54,7 +54,10 @@
# a unix socket name (asterisk.ctl) has to be no longer than
# UNIX_PATH_MAX (108) characters:
export AST_TEST_ROOT=`mktemp_symlink /tmp/ast_test_XXXXXX $HERE/astroot`
- export PATH="$HERE/asttest/root/usr/local/bin:$HERE/astroot/usr/sbin:$PATH"
+ # Prepend $PATH to include locations populated by ./run-local setup
+ # astroot/usr/local/bin - asttest
+ # astroot/usr/sbin - asterisk
+ export PATH="$HERE/astroot/usr/local/bin:$HERE/astroot/usr/sbin:$PATH"
# Preprend ':' if LD_LIBRARY_PATH is not empty:
LD_LIBRARY_PATH="${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}"
export LD_LIBRARY_PATH="$HERE/astroot/usr/lib${LD_LIBRARY_PATH}"
Modified: asterisk/trunk/tests/apps/chanspy/chanspy_barge/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/chanspy/chanspy_barge/run-test?view=diff&rev=5138&r1=5137&r2=5138
==============================================================================
--- asterisk/trunk/tests/apps/chanspy/chanspy_barge/run-test (original)
+++ asterisk/trunk/tests/apps/chanspy/chanspy_barge/run-test Wed Jun 18 13:14:46 2014
@@ -24,8 +24,6 @@
LOGGER = logging.getLogger(__name__)
-testdir = "tests/apps/chanspy/chanspy_barge"
-
class ChanSpyBarge(TestCase):
def __init__(self):
super(ChanSpyBarge, self).__init__()
@@ -43,8 +41,8 @@
"transmit_silence" : "yes",
}
- self.talkingaudio = os.path.join(os.getcwd(), "%s/sounds/talking" % (testdir))
- self.audiofile1 = os.path.join(os.getcwd(), "%s/testaudio1" % (testdir))
+ self.talkingaudio = os.path.join(os.getcwd(), "%s/sounds/talking" % self.test_name)
+ self.audiofile1 = self.ast[0].get_path("astspooldir", "tmp", "testaudio1")
def fastagi_connect(self, agi):
LOGGER.info("GOT PASS RESULTS!!!")
Modified: asterisk/trunk/tests/apps/chanspy/chanspy_w_mixmonitor/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/chanspy/chanspy_w_mixmonitor/run-test?view=diff&rev=5138&r1=5137&r2=5138
==============================================================================
--- asterisk/trunk/tests/apps/chanspy/chanspy_w_mixmonitor/run-test (original)
+++ asterisk/trunk/tests/apps/chanspy/chanspy_w_mixmonitor/run-test Wed Jun 18 13:14:46 2014
@@ -35,10 +35,10 @@
self.talk_detected = 0
self.chanspy_channel = ""
+ self.create_asterisk()
+
self.talkingaudio = os.path.join(os.getcwd(), "%s/sounds/talking" % self.test_name)
- self.audiofile1 = os.path.join(os.getcwd(), "%s/testaudio1" % self.test_name)
-
- self.create_asterisk()
+ self.audiofile1 = self.ast[0].get_path("astspooldir", "tmp", "testaudio1")
def fastagi_connect(self, agi):
LOGGER.info("Got pass results!")
Modified: asterisk/trunk/tests/channels/SIP/sip_tls_call/configs/helper1
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/SIP/sip_tls_call/configs/helper1?view=diff&rev=5138&r1=5137&r2=5138
==============================================================================
--- asterisk/trunk/tests/channels/SIP/sip_tls_call/configs/helper1 (original)
+++ asterisk/trunk/tests/channels/SIP/sip_tls_call/configs/helper1 Wed Jun 18 13:14:46 2014
@@ -1,3 +1,3 @@
-tlscertfile=<<path>>/keys/serverA.pem
-tlscafile=<<path>>/keys/ca.crt
+tlscertfile=<<path>>/configs/keys/serverA.pem
+tlscafile=<<path>>/configs/keys/ca.crt
Modified: asterisk/trunk/tests/channels/SIP/sip_tls_call/configs/helper2
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/SIP/sip_tls_call/configs/helper2?view=diff&rev=5138&r1=5137&r2=5138
==============================================================================
--- asterisk/trunk/tests/channels/SIP/sip_tls_call/configs/helper2 (original)
+++ asterisk/trunk/tests/channels/SIP/sip_tls_call/configs/helper2 Wed Jun 18 13:14:46 2014
@@ -1,2 +1,2 @@
-tlscertfile=<<path>>/keys/serverB.pem
-tlscafile=<<path>>/keys/ca.crt
+tlscertfile=<<path>>/configs/keys/serverB.pem
+tlscafile=<<path>>/configs/keys/ca.crt
Modified: asterisk/trunk/tests/channels/SIP/sip_tls_call/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/SIP/sip_tls_call/run-test?view=diff&rev=5138&r1=5137&r2=5138
==============================================================================
--- asterisk/trunk/tests/channels/SIP/sip_tls_call/run-test (original)
+++ asterisk/trunk/tests/channels/SIP/sip_tls_call/run-test Wed Jun 18 13:14:46 2014
@@ -43,41 +43,31 @@
def __init__(self):
TestCase.__init__(self)
- workingdir = "channels/SIP/sip_tls_call"
- testdir = "tests/%s" % workingdir
-
# Additional setup for config files and keys
LOGGER.info("Building test resources ...")
- if os.path.exists('%s/configs/ast1/sip_helper.inc' % (testdir)):
- os.remove('%s/configs/ast1/sip_helper.inc' % (testdir))
- shutil.copy('%s/configs/helper1' % (testdir), '%s/configs/ast1/sip_helper.inc' % (testdir))
+ if os.path.exists('%s/configs/ast1/sip_helper.inc' % self.test_name):
+ os.remove('%s/configs/ast1/sip_helper.inc' % self.test_name)
+ shutil.copy('%s/configs/helper1' % self.test_name, '%s/configs/ast1/sip_helper.inc' % self.test_name)
- if os.path.exists('%s/configs/ast2/sip_helper.inc' % (testdir)):
- os.remove('%s/configs/ast2/sip_helper.inc' % (testdir))
- shutil.copy('%s/configs/helper2' % (testdir), '%s/configs/ast2/sip_helper.inc' % (testdir))
- file_replace_string('%s/configs/ast1/sip_helper.inc' % (testdir), '<<path>>', '%s' % (workingdir))
- file_replace_string('%s/configs/ast2/sip_helper.inc' % (testdir), '<<path>>', '%s' % (workingdir))
+ if os.path.exists('%s/configs/ast2/sip_helper.inc' % self.test_name):
+ os.remove('%s/configs/ast2/sip_helper.inc' % self.test_name)
+ shutil.copy('%s/configs/helper2' % self.test_name, '%s/configs/ast2/sip_helper.inc' % self.test_name)
+ file_replace_string('%s/configs/ast1/sip_helper.inc' % self.test_name, '<<path>>', self.test_name)
+ file_replace_string('%s/configs/ast2/sip_helper.inc' % self.test_name, '<<path>>', self.test_name)
self.create_asterisk(2)
#Now that we've created the Asterisk instances, let's go ahead and remove the sip_helper.inc files
- if os.path.exists('%s/configs/ast1/sip_helper.inc' % (testdir)):
- os.remove('%s/configs/ast1/sip_helper.inc' % (testdir))
+ if os.path.exists('%s/configs/ast1/sip_helper.inc' % self.test_name):
+ os.remove('%s/configs/ast1/sip_helper.inc' % self.test_name)
- if os.path.exists('%s/configs/ast2/sip_helper.inc' % (testdir)):
- os.remove('%s/configs/ast2/sip_helper.inc' % (testdir))
+ if os.path.exists('%s/configs/ast2/sip_helper.inc' % self.test_name):
+ os.remove('%s/configs/ast2/sip_helper.inc' % self.test_name)
# initialize test variables
self.passed = False
self.tone1 = False
self.tone2 = False
-
- if not os.path.exists('%s/' % workingdir):
- os.makedirs('%s' % workingdir);
- if os.path.exists('%s/keys' % (workingdir)):
- shutil.rmtree('%s/keys' % (workingdir))
- shutil.copytree('%s/configs/keys' % (testdir), '%s/keys' % (workingdir))
- # End of additional setup for config files and keys
def ami_connect(self, ami):
if (AsteriskVersion() >= AsteriskVersion('12')):
Modified: asterisk/trunk/tests/channels/SIP/sip_tls_register/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/SIP/sip_tls_register/run-test?view=diff&rev=5138&r1=5137&r2=5138
==============================================================================
--- asterisk/trunk/tests/channels/SIP/sip_tls_register/run-test (original)
+++ asterisk/trunk/tests/channels/SIP/sip_tls_register/run-test Wed Jun 18 13:14:46 2014
@@ -31,8 +31,6 @@
def __init__(self):
TestCase.__init__(self)
- self.testdir = "tests/channels/SIP/sip_tls_register"
-
self.pass_sipp = False
self.pass_event = False
@@ -41,34 +39,26 @@
self.create_asterisk()
- self.keysdir = "%s%s" % (self.ast[0].base, self.ast[0].directories['astkeydir'])
- self.etcdir = "%s%s" % (self.ast[0].base, self.ast[0].directories['astetcdir'])
+ self.keysdir = self.ast[0].get_path('astkeydir')
+ self.etcdir = self.ast[0].get_path('astetcdir')
# Additional setup for config files and keys
logger.debug( "Building test resources ...")
- if os.path.exists('%s/configs/ast1/sip_helper.inc' % (self.testdir)):
- os.remove('%s/configs/ast1/sip_helper.inc' % (self.testdir))
- shutil.copy('%s/configs/sip_helper_template.inc' % (self.testdir), '%s/configs/ast1/sip_helper.inc' % (self.testdir))
+ if os.path.exists('%s/configs/ast1/sip_helper.inc' % self.test_name):
+ os.remove('%s/configs/ast1/sip_helper.inc' % self.test_name)
+ shutil.copy('%s/configs/sip_helper_template.inc' % self.test_name, '%s/configs/ast1/sip_helper.inc' % self.test_name)
- file_replace_string('%s/configs/ast1/sip_helper.inc' % (self.testdir), '<<path>>', '%s' % (self.keysdir))
+ file_replace_string('%s/configs/ast1/sip_helper.inc' % self.test_name, '<<path>>', self.keysdir)
#recopy sip_helper.inc since it's been changed. Remove first in case one already exists.
if os.path.exists('%s/sip_helper.inc' % self.etcdir):
os.remove('%s/sip_helper.inc' % self.etcdir)
- shutil.copy('%s/configs/ast1/sip_helper.inc' % (self.testdir), '%s' % (self.etcdir))
-
- #For the registration test, we need to copy some keys for use with sipp.
- #first delete them if they are already in the folder.
- self.cleanup_tls()
-
- #then copy them from the test directory to the working directory that sipp runs from.
- shutil.copy('%s/configs/keys/serverA.key' % (self.testdir), 'cakey.pem')
- shutil.copy('%s/configs/keys/serverA.crt' % (self.testdir), 'cacert.pem')
+ shutil.copy('%s/configs/ast1/sip_helper.inc' % self.test_name, self.etcdir)
#Now that we've created the Asterisk instances, let's go ahead and remove the sip_helper.inc files
- if os.path.exists('%s/configs/ast1/sip_helper.inc' % (self.testdir)):
- os.remove('%s/configs/ast1/sip_helper.inc' % (self.testdir))
+ if os.path.exists('%s/configs/ast1/sip_helper.inc' % self.test_name):
+ os.remove('%s/configs/ast1/sip_helper.inc' % self.test_name)
# initialize test variables
self.passed = False
@@ -77,9 +67,9 @@
if not os.path.exists('%s/' % self.keysdir):
os.makedirs('%s' % self.keysdir);
- if os.path.exists('%s/keys' % (self.keysdir)):
- shutil.rmtree('%s/keys' % (self.keysdir))
- shutil.copytree('%s/configs/keys' % (self.testdir), '%s/keys' % (self.keysdir))
+ if os.path.exists('%s/keys' % self.keysdir):
+ shutil.rmtree('%s/keys' % self.keysdir)
+ shutil.copytree('%s/configs/keys' % self.test_name, '%s/keys' % self.keysdir)
# End of additional setup for config files and keys
# Sets up callback function for PeerStatus events and runs/evaluates SIPp for the necessary scenario with TLS.
@@ -92,7 +82,15 @@
self.ami = ami
self.ami.registerEvent("PeerStatus", self.check_register_result)
- scenario_def = {'scenario': 'register.xml', '-p': '5061', '-recv_timeout': '1000', '-s': 'SIP/v4-in', '-t': 'ln'}
+ scenario_def = {
+ 'scenario': 'register.xml',
+ '-p': '5061',
+ '-recv_timeout': '1000',
+ '-s': 'SIP/v4-in',
+ '-t': 'ln',
+ '-tls_cert': '%s/configs/keys/serverA.crt' % self.test_name,
+ '-tls_key': '%s/configs/keys/serverA.key' % self.test_name,
+ }
scenario = SIPpScenario("tests/channels/SIP/sip_tls_register", scenario_def)
df = scenario.run(self)
@@ -124,13 +122,6 @@
logger.info("Registration for peer %s in state %s" % (peer, status))
return
- # Cleans up TLS cert files used by SIPp
- def cleanup_tls(self):
- if os.path.exists('cacert.pem'):
- os.remove('cacert.pem')
- if os.path.exists('cakey.pem'):
- os.remove('cakey.pem')
-
# Sets up reactor and AMI connection
def run(self):
TestCase.run(self)
Modified: asterisk/trunk/tests/fax/sip/local_channel_t38_queryoption/configs/ast2/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fax/sip/local_channel_t38_queryoption/configs/ast2/extensions.conf?view=diff&rev=5138&r1=5137&r2=5138
==============================================================================
--- asterisk/trunk/tests/fax/sip/local_channel_t38_queryoption/configs/ast2/extensions.conf (original)
+++ asterisk/trunk/tests/fax/sip/local_channel_t38_queryoption/configs/ast2/extensions.conf Wed Jun 18 13:14:46 2014
@@ -1,6 +1,6 @@
[receivefax]
exten = 1234,1,NoOp
-exten = 1234,n,ReceiveFax(receive.tiff)
+exten = 1234,n,ReceiveFax(${ASTDATADIR}/receive.tiff)
exten = h,1,NoOp
exten = h,n,UserEvent(FaxStatus,application: ReceiveFax,status: ${FAXOPT(status)},statusstr: ${FAXOPT(statusstr)},error: ${FAXOPT(error)})
Modified: asterisk/trunk/tests/udptl/configs/ast2/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/udptl/configs/ast2/extensions.conf?view=diff&rev=5138&r1=5137&r2=5138
==============================================================================
--- asterisk/trunk/tests/udptl/configs/ast2/extensions.conf (original)
+++ asterisk/trunk/tests/udptl/configs/ast2/extensions.conf Wed Jun 18 13:14:46 2014
@@ -3,6 +3,6 @@
exten => 666,n,Wait(20)
exten => 666,n,Hangup()
-exten => fax,1,ReceiveFax(recv.tiff)
+exten => fax,1,ReceiveFax(${ASTDATADIR}/recv.tiff)
exten => h,1,UserEvent(recvstatus, status: ${FAXSTATUS})
Modified: asterisk/trunk/tests/udptl_v6/configs/ast2/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/udptl_v6/configs/ast2/extensions.conf?view=diff&rev=5138&r1=5137&r2=5138
==============================================================================
--- asterisk/trunk/tests/udptl_v6/configs/ast2/extensions.conf (original)
+++ asterisk/trunk/tests/udptl_v6/configs/ast2/extensions.conf Wed Jun 18 13:14:46 2014
@@ -3,6 +3,6 @@
exten => 666,n,Wait(20)
exten => 666,n,Hangup()
-exten => fax,1,ReceiveFax(recv.tiff)
+exten => fax,1,ReceiveFax(${ASTDATADIR}/recv.tiff)
exten => h,1,UserEvent(recvstatus, status: ${FAXSTATUS})
More information about the asterisk-commits
mailing list