[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
Mon Jun 6 07:41:40 CDT 2011


branch "review" has been updated
       via  614647a86ea1b0467d9d5cc0325d8fc65adc2859 (commit)
      from  6e01aa75b336219cde43f84debc30edad547ed75 (commit)

Summary of changes:
 plugins/asteriskscf_icebox.py |    2 +-
 plugins/build.py              |    8 ++++----
 plugins/failover.py           |    6 +++---
 plugins/sipp.py               |    2 +-
 remote.py                     |   30 +++++++++++++++++++++---------
 testsuite.py                  |    8 ++++----
 6 files changed, 34 insertions(+), 22 deletions(-)


- Log -----------------------------------------------------------------
commit 614647a86ea1b0467d9d5cc0325d8fc65adc2859
Author: Darren Sessions <dsessions at digium.com>
Date:   Mon Jun 6 07:41:06 2011 -0500

    Added support for logging the stdout and stderr to a log file from the remotes when they are executing system calls. The globalVars variable is used to pass the test information through the rpc connection to the remotes which in turn use that data to create directories reflecting the test category, name, and subtest. This will allow the directory to be archived and sent back to the testsuite server and as multiple tar files are unpacked, data from multiple remotes for a particular test will end up in the same spot.

diff --git a/plugins/asteriskscf_icebox.py b/plugins/asteriskscf_icebox.py
index 4ab4615..f384200 100644
--- a/plugins/asteriskscf_icebox.py
+++ b/plugins/asteriskscf_icebox.py
@@ -26,7 +26,7 @@ class plugin(TestSuite.RemoteBaseClass):
                     results = rpc.setEnvVar('libpath', '!!TMP!!/gitall/build/lib')
                     if results['success'] == False:
                         return results
-                    results = rpc.run('asteriskscf_icebox', component, [iceBoxCmd[0], "%s%s.conf" % (iceBoxCmd[1], component)])
+                    results = rpc.run(globalVars, 'asteriskscf_icebox', component, [iceBoxCmd[0], "%s%s.conf" % (iceBoxCmd[1], component)])
                     if results['success'] == False:
                         return results
             elif cmd == 'stop':
diff --git a/plugins/build.py b/plugins/build.py
index fdda9a2..7b1a963 100644
--- a/plugins/build.py
+++ b/plugins/build.py
@@ -56,7 +56,7 @@ class plugin(TestSuite.RemoteBaseClass):
                     if results['success'] == False:
                         return results
 
-                results = rpc.run('build', cmds, cmds.split(' '), True)
+                results = rpc.run(globalVars, 'build', cmds, cmds.split(' '), True)
                 if results['success'] == False:
                     return results
             
@@ -69,7 +69,7 @@ class plugin(TestSuite.RemoteBaseClass):
                 except:
                     pass
 
-                results = rpc.archiveDir(testData['cmd']['redistribute']['send_dir'])
+                results = rpc.archiveDir(globalVars, testData['cmd']['redistribute']['send_dir'])
                 if results['success'] == False:
                     return results
                
@@ -82,12 +82,12 @@ class plugin(TestSuite.RemoteBaseClass):
                         if results['success'] == False:
                             return results
                     else:
-                        results = rpc.serverSideSendFile(testData['testsuite_remote_host'], remote, 'tmp.tar.gz', testData['cmd']['redistribute']['install_dir'])
+                        results = rpc.serverSideSendFile(globalVars, testData['testsuite_remote_host'], remote, 'tmp.tar.gz', testData['cmd']['redistribute']['install_dir'])
                         if results['success'] == False:
                             return results
         
         return {'success':True,'shutdownExempt':True}
 
     def _scratchBuild(self, rpc, name, type, getCmd, repo):
-        results = rpc.run('build', name, [type, getCmd, repo], True)
+        results = rpc.run(globalVars, 'build', name, [type, getCmd, repo], True)
         return results
diff --git a/plugins/failover.py b/plugins/failover.py
index f506839..c65ebd7 100644
--- a/plugins/failover.py
+++ b/plugins/failover.py
@@ -72,14 +72,14 @@ class plugin(TestSuite.BaseClass):
         results = activeNode['rpc'].wFile('/etc/corosync/corosync.conf', '\n'.join(self._corosyncConfig(activeNode[ipv], standbyNode[ipv], activeNode['nodeID'], activeNode['nAddr'])))
         if not results['success'] == True:
             return self._addShutdownList(results, shutdownList)
-        results = activeNode['rpc'].run('failover', 'corosync', ['service', 'corosync', 'start'], True)
+        results = activeNode['rpc'].run(globalVars, 'failover', 'corosync', ['service', 'corosync', 'start'], True)
         if not results['success'] == True:
             return self._addShutdownList(results, shutdownList)
         
         standbyNode['rpc'].wFile('/etc/corosync/corosync.conf', '\n'.join(self._corosyncConfig(activeNode[ipv], standbyNode[ipv], standbyNode['nodeID'], standbyNode['nAddr'])))
         if not results['success'] == True:
             return self._addShutdownList(results, shutdownList)
-        results = standbyNode['rpc'].run('failover', 'corosync', ['service', 'corosync', 'start'], True)
+        results = standbyNode['rpc'].run(globalVars, 'failover', 'corosync', ['service', 'corosync', 'start'], True)
         if not results['success'] == True:
             return self._addShutdownList(results, shutdownList)
 
@@ -88,7 +88,7 @@ class plugin(TestSuite.BaseClass):
         activeNode['rpc'].writeFile('pacemaker.cli', '\n'.join(self._pacemakerConfig(sharedIP, testData['cmd']['testsuite_remote_active'])))
         if not results['success'] == True:
             return self._addShutdownList(results, shutdownList)
-        results = activeNode['rpc'].run('failover', 'crm', ['crm', '-f', '!!TMP!!/pacemaker.cli'], True)
+        results = activeNode['rpc'].run(globalVars, 'failover', 'crm', ['crm', '-f', '!!TMP!!/pacemaker.cli'], True)
 
         if not self.ping(sharedIP):
             return {'success':False, 'msg':'The %s shared ip address is failing to respond.' % sharedIP, 'shutdownList':shutdownList}
diff --git a/plugins/sipp.py b/plugins/sipp.py
index b4b8f5b..f9e9d33 100644
--- a/plugins/sipp.py
+++ b/plugins/sipp.py
@@ -34,7 +34,7 @@ class plugin(TestSuite.RemoteBaseClass):
                 if mode == 'uac':
                     waitForPidToFinish = True
                 #print ' '.join(self._componentConfig(mode, config[mode], testPath, rpc, testData['testsuite_remote_host']))
-                results = rpc.run('sipp', mode, self._componentConfig(mode, config[mode], testPath, rpc, testData['testsuite_remote_host']), waitForPidToFinish)
+                results = rpc.run(globalVars, 'sipp', mode, self._componentConfig(mode, config[mode], testPath, rpc, testData['testsuite_remote_host']), waitForPidToFinish)
                 if results['success'] == False:
                     return results
 
diff --git a/remote.py b/remote.py
index e43fc2b..057a04f 100755
--- a/remote.py
+++ b/remote.py
@@ -46,7 +46,7 @@ class RemoteManagement(object):
             return {'success':True,'msg':list} 
         return {'success':True,'msg':'Nothing running.'}
 
-    def run(self, plugin, label, execCmd, wait=False):
+    def run(self, globalVars, plugin, label, execCmd, wait=False):
         if plugin in processList:
             if label in processList[plugin]:
                 return {'success':False,'msg':'%s executed by the %s plugin is already running.' % (label, plugin)}
@@ -57,12 +57,19 @@ class RemoteManagement(object):
             except:
                 pass
 
+        if not os.path.exists('%s/tmp/artifacts/%s' % (cwd, globalVars['testInfo']['testPath'])):
+            os.makedirs('%s/tmp/artifacts/%s' % (cwd, globalVars['testInfo']['testCategory']))
+            os.makedirs('%s/tmp/artifacts/%s/%s' % (cwd, globalVars['testInfo']['testCategory'], self.globalVars['testInfo']['testCase']))
+            os.makedirs('%s/tmp/artifacts/%s/%s/%s' % (cwd, globalVars['testInfo']['testCategory'], self.globalVars['testInfo']['testCase'], self.globalVars['testInfo']['testName']))
+            if not os.path.exists('%s/tmp/artifacts/%s' % (cwd, globalVars['testInfo']['testPath'])):
+                return {'success':False,'msg':'Unable to create artifact test path on remotes. %s' %s globalVars['testInfo']['testPath']}
+
         time.sleep(1)
 
         execCmd[0] = self._which(execCmd[0])
 
         try:
-            logArtifactFile = open('%s/tmp/artifacts/%s_%s.log' % (cwd, plugin, label), 'w')
+            logArtifactFile = open('%s/tmp/artifacts/%s_%s.log' % (cwd, _artifactNameCheck(plugin), _artifactNameCheck(label)), 'w')
         except:
             return {'success':False,'msg':"Unable to open '%s/tmp/artifacts/%s_%s.log' for writing." % (cwd, plugin, label)}
 
@@ -179,16 +186,16 @@ class RemoteManagement(object):
         os.remove(fn)
         return {'success':True}
 
-    def archiveDir(self, dn):
+    def archiveDir(self, globalVars, dn):
         dn = self._filePathCheck(dn)
         if not os.path.exists("%s" % dn):
             return {'success':False,'msg':'The %s path does not exist.' % dn}
         os.chdir('%s/tmp' % cwd)
-        results = self.run('remote', 'archiveDir', [self._which('tar'), '-cvf', 'tmp.tar', '%s' % dn], True)
+        results = self.run(globalVars, 'remote', 'archiveDir', [self._which('tar'), '-cvf', 'tmp.tar', '%s' % dn], True)
         if results['success'] == False:
             return results
         os.chdir('%s/tmp' % cwd)
-        results = self.run('remote', 'archiveDir', [self._which('gzip'), 'tmp.tar'], True)
+        results = self.run(globalVars, 'remote', 'archiveDir', [self._which('gzip'), 'tmp.tar'], True)
         return results
     
     def readFile(self, fn):
@@ -219,17 +226,17 @@ class RemoteManagement(object):
         f.close()
         return {'success':True}
 
-    def remoteSideRecvFile(self, fn, fd, installPath):
+    def remoteSideRecvFile(self, globalVars, fn, fd, installPath):
         w = open('%s/tmp/%s' % (cwd, fn), "wb")
         w.write(fd.data)
         w.close()
         installPath = installPath.replace('!!TMP!!', '%s/tmp' % cwd)
-        results = self.run('remoteSideRecvFile', 'tar', ['tar', '-xvf', '%s/tmp/%s' % (cwd, fn), '-C', '%s' % installPath], True)
+        results = self.run(globalVars, 'remoteSideRecvFile', 'tar', ['tar', '-xvf', '%s/tmp/%s' % (cwd, fn), '-C', '%s' % installPath], True)
         if results['success'] == False:
             return results
         return {'success':'True'}
 
-    def serverSideSendFile(self, server, remote, fn, installPath):
+    def serverSideSendFile(self, globalVars, server, remote, fn, installPath):
         rpc = xmlrpclib.ServerProxy('http://%s:8000/' % remote)
         try:
             rpc.reset()
@@ -240,7 +247,7 @@ class RemoteManagement(object):
         except:
             pass
         f = open('%s/tmp/%s' % (cwd, fn), "rb")
-        results = rpc.remoteSideRecvFile(fn, xmlrpclib.Binary(f.read()), installPath)
+        results = rpc.remoteSideRecvFile(globalVars, fn, xmlrpclib.Binary(f.read()), installPath)
         f.close()
         return results
    
@@ -251,6 +258,11 @@ class RemoteManagement(object):
         os.chdir('%s/tmp' % cwd)
         return 1
 
+    def _artifactNameCheck(self, name):
+        name = name.replace(' ', '_')
+        name = name.replace('.', '_')
+        return name
+
     def _filePathCheck(self, fp):
         fp = fp.replace('..', '/invalid')
         fp = fp.replace(';', '/invalid')
diff --git a/testsuite.py b/testsuite.py
index 562d6a4..8ff95e6 100755
--- a/testsuite.py
+++ b/testsuite.py
@@ -56,17 +56,17 @@ class __main__:
 
         for list in self.yamlData:
             for testCategory in list:
-                self.globalVars['testInfo']['testCategory'] = testCategory
                 x, categoryElement = xml().addTestSuite(x, testCategory)
                 print >> sys.stderr, "\n Starting '%s' tests . . \n ---------------------------------" % testCategory
-            
                 for testData in list[testCategory]:
-                    self.globalVars['testInfo']['testCase'] = testData['name']
                     categoryElement, testElement = xml().addTestSuite(categoryElement, testData['name'])
                     print >> sys.stderr, ' |- Testcase "%s" ' % testData['name']
                     for subTestCase in testData['tests']:
                         for testName in subTestCase:
+                            self.globalVars['testInfo']['testCategory'] = testCategory
+                            self.globalVars['testInfo']['testCase'] = testData['name']
                             self.globalVars['testInfo']['testName'] = testName
+                            self.globalVars['testInfo']['testPath'] = "%s/%s/%s" % (testCategory, testData['name'], testName)
                             testElement, subTestElement = xml().addTestCase(testElement, testName)
                             if subTestCase[testName]:
                                 success = True
@@ -236,7 +236,7 @@ class cleanup:
     def dirs(self):
         if not os.path.exists('%s/tmp' % cwd):
             return {'success':False,'msg':'The %s path does not exist.' % dir}
-        shutil.rmtree('%s/tmp' % cwd)
+        #shutil.rmtree('%s/tmp' % cwd)
         return {'success':True}
 
 def sigHandler(signum, frame):

-----------------------------------------------------------------------


-- 
asterisk-scf/integration/testsuite.git



More information about the asterisk-scf-commits mailing list