[asterisk-scf-commits] asterisk-scf/integration/testsuite.git branch "review" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Wed Jun 1 08:51:25 CDT 2011
branch "review" has been updated
via 91fe417899ba31a551224a800138658e06da16d4 (commit)
from 0309113225c092e2ed8b9f3ded494fd0d007b2cb (commit)
Summary of changes:
lib/python/TestSuite.py | 57 ++++++++++++++++++++++----
plugins/build.py | 16 +++++--
remote.py | 4 +-
tests/build/Build_AsteriskSCF/testcase.yaml | 10 +----
testsuite.py | 59 ++++++---------------------
5 files changed, 77 insertions(+), 69 deletions(-)
- Log -----------------------------------------------------------------
commit 91fe417899ba31a551224a800138658e06da16d4
Author: Darren Sessions <dsessions at digium.com>
Date: Wed Jun 1 08:51:23 2011 -0500
added support for the build plugin to replicate back to the test-suite server script.
diff --git a/lib/python/TestSuite.py b/lib/python/TestSuite.py
index bc6b636..e4c06bf 100644
--- a/lib/python/TestSuite.py
+++ b/lib/python/TestSuite.py
@@ -31,6 +31,16 @@ class utils():
else:
return False
+ def installFromRemote(self, cwd, fn, fd, installPath):
+ w = open('%s/tmp/%s' % (cwd, fn), "wb")
+ w.write(fd)
+ w.close()
+ installPath = installPath.replace('!!TMP!!', '%s/tmp' % cwd)
+ results = self.run(['tar', '-xvf', '%s/tmp/%s' % (cwd, fn), '-C', '%s' % installPath], cwd, True)
+ if results['success'] == False:
+ return results
+ return {'success':'True'}
+
def rpc(self, host):
rpc = xmlrpclib.Server('http://%s:8000' % host)
try:
@@ -40,15 +50,44 @@ class utils():
ipv4, ipv6 = rpc.whatAreMyIps()
return {'success':True, 'rpc':rpc, 'ipv4':ipv4, 'ipv6':ipv6}
+ def run(self, cmd, cwd, wait=False):
+ for arg in cmd:
+ try:
+ cmd[cmd.index(arg)] = arg.replace('!!TMP!!', '%s/tmp' % cwd)
+ except:
+ pass
+
+ cmd[0] = self._which(cmd[0])
+ if os.path.exists(cmd[0]) and os.access(cmd[0], os.X_OK):
+ p = subprocess.Popen(
+ cmd,
+ bufsize=-1,
+ shell=False
+ #stdin=subprocess.PIPE,
+ #stdout=subprocess.PIPE,
+ #stderr=subprocess.PIPE
+ )
+ p.poll()
+ if wait == True:
+ p.wait()
+ os.chdir('%s' % cwd)
+ if p.returncode:
+ return {'success':False,"msg":"Could not execute '%s'." % ' '.join(cmd)}
+ else:
+ return {'success':False,"msg":"FAILED TO EXECUTE '%s', it must exist and be executable" % ' '.join(cmd)}
+ return {'success':True}
+
class file:
- def write(self, component):
+ def write(self, fn, fd):
try:
- f = open("%s/temp_config_%s.conf" % (self._cwd, component), "w")
+ f = open('%s' % fn, 'w')
+ except IOError:
+ return {'success':False,'msg':'Failed to open test results output file: %s/tmp/%s' % (cwd, fn)}
except:
- return "Unexpected error: %s" % sys.exc_info()
- f.write(config)
+ return {'success':False,'msg':'Unexpected error: %s' % sys.exc_info()[0]}
+ f.write(fd)
f.close()
- self._results['file_cleanup'].append('%s/temp_config_%s.conf' % (self._cwd, component))
+ return {'success':True}
def read(self, fn):
try:
@@ -73,13 +112,13 @@ class utils():
return {'success':True, 'repoName':repoName, 'repoType':'%s' % url[0]}
class BaseClass(utils):
- def run(self, testData, testPath):
+ def run(self, testData, testPath, globalVars):
if not 'cmd' in testData:
return {'success':False,'msg':'No command specified.'}
- return self.main(testData, testPath)
+ return self.main(testData, testPath, globalVars)
class RemoteBaseClass(utils):
- def run(self, testData, testPath):
+ def run(self, testData, testPath, globalVars):
if not 'cmd' in testData:
return {'success':False,'msg':'No command specified.'}
if not 'testsuite_remote_host' in testData:
@@ -89,4 +128,4 @@ class RemoteBaseClass(utils):
rpc.reset()
except:
return {'success':False,'msg':'Connection to %s was refused.' % testData['testsuite_remote_host']}
- return self.main(testData, testPath, rpc)
+ return self.main(testData, testPath, globalVars, rpc)
diff --git a/plugins/build.py b/plugins/build.py
index 5708574..fdda9a2 100644
--- a/plugins/build.py
+++ b/plugins/build.py
@@ -12,7 +12,7 @@
import TestSuite
class plugin(TestSuite.RemoteBaseClass):
- def main(self, testData, testPath, rpc):
+ def main(self, testData, testPath, globalVars, rpc):
if not 'repo' in testData['cmd']:
return {'success':False,'msg':'No repo specified.'}
@@ -74,9 +74,17 @@ class plugin(TestSuite.RemoteBaseClass):
return results
for remote in testData['cmd']['redistribute']['remotes']:
- results = rpc.serverSideSendFile(testData['testsuite_remote_host'], remote, 'tmp.tar.gz', testData['cmd']['redistribute']['install_dir'])
- if results['success'] == False:
- return results
+ if remote == globalVars['hostname']:
+ results = rpc.readFile('tmp.tar.gz')
+ if results['success'] == False:
+ return results
+ results = self.installFromRemote(globalVars['cwd'], 'tmp.tar.gz', results['data'], testData['cmd']['redistribute']['install_dir'])
+ if results['success'] == False:
+ return results
+ else:
+ results = rpc.serverSideSendFile(testData['testsuite_remote_host'], remote, 'tmp.tar.gz', testData['cmd']['redistribute']['install_dir'])
+ if results['success'] == False:
+ return results
return {'success':True,'shutdownExempt':True}
diff --git a/remote.py b/remote.py
index ade4b7b..57e5860 100755
--- a/remote.py
+++ b/remote.py
@@ -187,7 +187,7 @@ class RemoteManagement(object):
return results
def readFile(self, fn):
- return rFile("%s/tmp/%s" % (cwd, fn))
+ return self.rFile("%s/tmp/%s" % (cwd, fn))
def rFile(self, fn):
try:
@@ -197,7 +197,7 @@ class RemoteManagement(object):
except:
return {'success':False,'msg':'Unexpected error: %s' % sys.exc_info()[0]}
data = xmlrpclib.Binary(f.read())
- r.close()
+ f.close()
return {'success':True, 'data':data}
def writeFile(self, fn, fd):
diff --git a/tests/build/Build_AsteriskSCF/testcase.yaml b/tests/build/Build_AsteriskSCF/testcase.yaml
index d5f36c8..04884fe 100644
--- a/tests/build/Build_AsteriskSCF/testcase.yaml
+++ b/tests/build/Build_AsteriskSCF/testcase.yaml
@@ -36,10 +36,7 @@ tests :
- make install
redistribute :
remotes :
- - testsuite-server.digium.internal
- - testsuite-remote-1.digium.internal
- - testsuite-remote-2.digium.internal
- - testsuite-remote-3.digium.internal
+ - dms.digium.internal
send_dir : '/opt/Ice-3.4.1'
install_dir : /
- asterisk_scf :
@@ -56,9 +53,6 @@ tests :
- cmake --build ./build
redistribute :
remotes :
- - testsuite-server.digium.internal
- - testsuite-remote-1.digium.internal
- - testsuite-remote-2.digium.internal
- - testsuite-remote-3.digium.internal
+ - dms.digium.internal
send_dir : 'gitall'
install_dir : '!!TMP!!'
diff --git a/testsuite.py b/testsuite.py
index 04159b3..4733de5 100755
--- a/testsuite.py
+++ b/testsuite.py
@@ -21,28 +21,22 @@ import subprocess
from xml.dom import minidom
from xml.etree.ElementTree import Element, SubElement, tostring
-homeDir = os.path.dirname(os.path.realpath(__file__))
-sys.path.append("%s/lib/python" % homeDir)
-sys.path.append("%s/plugins" % homeDir)
+cwd = os.path.dirname(os.path.realpath(__file__))
+hostname = platform.node()
+
+sys.path.append("%s/lib/python" % cwd)
+sys.path.append("%s/plugins" % cwd)
import yaml_parser
class __main__:
def __init__(self):
+ if not os.path.exists('%s/tmp' % cwd):
+ os.makedirs('%s/tmp' % cwd)
+ self.globalVars = {'cwd':cwd, 'hostname':hostname}
self.yamlData = yaml_parser.testcases().returnData
-
- remote = remoteClient().start()
- if remote['success'] == False:
- print '\n\nUnable to start the test-suite server remote client. %s\n\n' % remote['msg']
- sys.exit(1)
-
self.testsuite()
- remote = remoteClient().stop(remote['subprocess'])
- if remote['success'] == False:
- print '\n\nUnable to stop the test-suite server remote client.\n\n'
- sys.exit(1)
-
def testsuite(self):
errorMsgs = []
pluginData = {}
@@ -85,7 +79,7 @@ class __main__:
''' execute testcase timeline '''
for timeLine in subTestCase[testName]['timeline']:
for plugin in timeLine:
- runResults = plugins().execute(plugin, pluginData[plugin]['module'], timeLine[plugin], testData['path'])
+ runResults = plugins().execute(plugin, pluginData[plugin]['module'], timeLine[plugin], testData['path'], self.globalVars)
if not 'shutdownList' in runResults:
if not 'shutdownExempt' in runResults:
if 'testsuite_remote_host' in timeLine[plugin]:
@@ -122,41 +116,14 @@ class __main__:
print "\n\n" + xml().prettyXml(x)
return
-class remoteClient:
- def start(self):
- cmd = ['%s/remote.py' % homeDir]
- if os.path.exists(cmd[0]) and os.access(cmd[0], os.X_OK):
- p = subprocess.Popen(
- cmd,
- bufsize=-1,
- shell=False
- #shell=False,
- #stdin=subprocess.PIPE,
- #stdout=subprocess.PIPE,
- #stderr=subprocess.PIPE
- )
- p.poll()
- if p.returncode:
- return {'success':False,"msg":"Could not execute '%s'." % ' '.join(cmd)}
- else:
- return {'success':False,"msg":"FAILED TO EXECUTE '%s'. It must exist and be executable" % ' '.join(cmd)}
- return {'success':True, 'subprocess':p}
-
- def stop(self, subprocess):
- try:
- os.kill(subprocess.pid, 9)
- except:
- return {'success':False, 'msg':"Unable to kill the remote process."}
- return {'success':True}
-
class plugins:
- def execute(self, name, module, testData, testPath):
+ def execute(self, name, module, testData, testPath, globalVars):
try:
func = getattr(module, 'plugin')
except AttributeError:
return {'success':False,'msg':"Unable to execute module '%s'. %s" % (name, sys.exc_info()[1])}
else:
- results = func().run(testData, testPath)
+ results = func().run(testData, testPath, globalVars)
if not type(results) == dict:
return {'success':False,'msg':"The '%s' module return invalid or missing data." % name}
return results
@@ -193,8 +160,8 @@ class plugins:
except:
return {'success':False,'msg':'The "main" method in the "plugin" class in "%s" is not responding properly. %s.' % (name, sys.exc_info())}
argCheck = inspect.getargspec(module.plugin().main)
- if argCheck[0] != ['self','testData', 'testPath'] and argCheck[0] != ['self','testData', 'testPath', 'rpc']:
- return {'success':False,'msg':"The 'main' method in the 'plugin' class within '%s' has improperly labeled args! i.e. def main(self, testData, testPath)." % name}
+ if argCheck[0] != ['self','testData', 'testPath', 'globalVars'] and argCheck[0] != ['self','testData', 'testPath', 'globalVars', 'rpc']:
+ return {'success':False,'msg':"The 'main' method in the 'plugin' class within '%s' has improperly labeled args! i.e. def main(self, testData, testPath, globalVars)." % name}
return {'success':True}
class xml:
-----------------------------------------------------------------------
--
asterisk-scf/integration/testsuite.git
More information about the asterisk-scf-commits
mailing list