[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
Tue May 24 13:46:35 CDT 2011


branch "review" has been updated
       via  b464215fd8609c06e6a35f7fc408bc129d0d1f72 (commit)
       via  7255348272ba75df7e9d9ee90e4f46929bbb49a3 (commit)
      from  47b269ea1efb00faad6f845d2eae8d4d293c5176 (commit)

Summary of changes:
 lib/python/util.py                          |    2 -
 plugins/build.py                            |   10 +++++
 remote.py                                   |   55 +++++++++++++++++++++++++-
 tests/build/Build_AsteriskSCF/testcase.yaml |   12 ++---
 4 files changed, 67 insertions(+), 12 deletions(-)


- Log -----------------------------------------------------------------
commit b464215fd8609c06e6a35f7fc408bc129d0d1f72
Author: Darren Sessions <dsessions at digium.com>
Date:   Tue May 24 13:43:52 2011 -0500

    updates to the remote build system

diff --git a/plugins/build.py b/plugins/build.py
index 352bc9e..7a44552 100644
--- a/plugins/build.py
+++ b/plugins/build.py
@@ -52,14 +52,16 @@ class testsuite(util.TestSuiteRemoteBaseClass):
                     results = rpc.changeDir(testData['cmd']['cd'])
                     if results['success'] == False:
                         return results
+
                 results = rpc.run('build', cmds, cmds.split(' '), True)
                 if results['success'] == False:
                     return results
-
+            
         if 'redistribute' in testData['cmd']:
-            if not 'remotes' in testData['cmd']['redistribute'] and if not 'send_dir' in testData['cmd']['redistribute']:
+            if not 'remotes' in testData['cmd']['redistribute'] and not 'send_dir' in testData['cmd']['redistribute']:
                 return {'success':False,'msg':'The restribute element requires the remotes and send_dir options.'}
             else:
+                print 'done'
                 results = rpc.archiveDir(testData['cmd']['redistribute']['send_dir'])
                 if results['success'] == False:
                     return results
diff --git a/remote.py b/remote.py
index 9d11b3f..1f300b5 100755
--- a/remote.py
+++ b/remote.py
@@ -14,7 +14,6 @@
 
 import os
 import time
-import tarfile
 import platform
 import subprocess
 import SimpleXMLRPCServer
@@ -144,34 +143,55 @@ class RemoteManagement(object):
         return {'success':True}
 
     def changeDir(self, dir):
-        dir = dir.replace('..', '/')
+        dir = self._filePathCheck(dir)
         if not os.path.exists('%s/tmp/%s' % (cwd, dir)):
             return {'success':False,'msg':'The %s path does not exist.' % dir}
         os.chdir('%s/tmp/%s' % (cwd, dir))
         return {'success':True,'cwd':os.getcwd()}
 
     def removeDir(self, dir):
-        dir = dir.replace('..', '/invalid')
-        dir = dir.replace('.', '/invalid')
+        dir = self._filePathCheck(dir)
         dir = dir.replace('/', '/invalid')
         if not os.path.exists('%s/tmp/%s' % (cwd, dir)):
             return {'success':False,'msg':'The %s path does not exist.' % dir}
         os.removedirs('%s/tmp/%s' % (cwd, dir))
         return {'success':True}
 
+    def moveFile(self, fp, dp):
+        fp = self._filePathCheck(fp)
+        dp = self._filePathCheck(dp)
+        if not os.path.exists('%s/tmp/build/%s' % (cwd, fp)):
+            return {'success':False,'msg':'The %s path does not exist.' % fp} 
+        if not os.path.exists('%s/tmp/build/%s' % (cwd, dp)):
+            return {'success':False,'msg':'The %s path does not exist.' % dp}
+        try:
+            returncode = call('mv %s/tmp/build/%s %s/tmp/build/%s' % (cwd, fp, cwd, dp))
+            if returncode != 0:
+                return {'success':False,'msg':'The move command failed. (return code %d)' % returncode}
+        except OSError, e:
+            return {'success':False,'msg':'Execution failed: %s' % e}
+        return {'success':True}
+
     def removeFile(self, fn):
         os.chdir('%s/tmp' % cwd)
-        fn = fn.replace('..', '/invalid')
-        fn = fn.replace('.', '/invalid')
+        fn = self._filePathCheck(fn)
         fn = fn.replace('/', '/invalid')
         os.remove(fn)
         return {'success':True}
 
     def archiveDir(self, dn):
+        print dn
         os.chdir('%s/tmp' % cwd)
-        tarball = tarfile.open('%s.tar', 'w:gz')
-        tarball.add('%s' % dn)
-        tarball.close
+        dn = self._filePathCheck(dn)
+        if not os.path.exists(dn):
+            return {'success':False,'msg':'The %s path does not exist.' % dn}
+        try:
+            returncode = call('tar -cvf %s.tar %s' % (dn.replace('/', ''), dn))
+            if returncode != 0:
+                return {'success':False,'msg':'The move command failed. (return code %d)' % returncode}
+        except OSError, e:
+            return {'success':False,'msg':'Execution failed: %s' % e}
+        return {'success':True,'tarfile':'%s.tar' % dn.replace('/', '')}
 
     def writeFile(self, fn, fd):
         try:
@@ -197,6 +217,11 @@ class RemoteManagement(object):
         os.chdir('%s/tmp' % cwd)
         return 1
 
+    def _filePathCheck(self, fp):
+        fp = fp.replace('..', '/invalid')
+        fp = fp.replace(';', '/invalid')
+        return fp
+
     def _which(self, app):
         def if_exists(fp):
             return os.path.exists(fp) and os.access(fp, os.X_OK)
diff --git a/tests/build/Build_AsteriskSCF/testcase.yaml b/tests/build/Build_AsteriskSCF/testcase.yaml
index 542f3f1..7512ea2 100644
--- a/tests/build/Build_AsteriskSCF/testcase.yaml
+++ b/tests/build/Build_AsteriskSCF/testcase.yaml
@@ -11,13 +11,6 @@ tests :
                     make_cmd : 
                         - make
                         - make install
-                    redistribute :
-                        remotes :
-                            - testsuite-remote-1.digium.internal
-                            - testsuite-remote-2.digium.internal
-                        send_dir : ice
-                        make_cmd :
-                            - make install
     - ice_python :
         timeline :
             - build :
@@ -41,6 +34,11 @@ tests :
                         - cmake .
                         - make
                         - make install
+                    redistribute :
+                        remotes :
+                            - testsuite-remote-1.digium.internal
+                            - testsuite-remote-2.digium.internal
+                        send_dir : /opt/Ice-3.4.1
     - asterisk_scf :
         timeline:
             - build :

commit 7255348272ba75df7e9d9ee90e4f46929bbb49a3
Author: Darren Sessions <dsessions at digium.com>
Date:   Tue May 24 10:35:24 2011 -0500

    working on the redistribute capability within the build plugin.

diff --git a/lib/python/util.py b/lib/python/util.py
index f3b7379..1580b00 100644
--- a/lib/python/util.py
+++ b/lib/python/util.py
@@ -35,12 +35,10 @@ class TestSuiteRemoteBaseClass:
         if not 'testsuite_remote' in testData:
             return {'success':False,'msg':'No testsuite remote specified.'}
         rpc = xmlrpclib.Server('http://%s:8000' % testData['testsuite_remote'])
-        rpc.reset()
         try:
             rpc.reset()
         except:
             return {'success':False,'msg':'Connection to %s was refused.' % testData['testsuite_remote']}
-
         return self.main(testData, testPath, rpc)
 
 class url:
diff --git a/plugins/build.py b/plugins/build.py
index c321929..352bc9e 100644
--- a/plugins/build.py
+++ b/plugins/build.py
@@ -55,6 +55,14 @@ class testsuite(util.TestSuiteRemoteBaseClass):
                 results = rpc.run('build', cmds, cmds.split(' '), True)
                 if results['success'] == False:
                     return results
+
+        if 'redistribute' in testData['cmd']:
+            if not 'remotes' in testData['cmd']['redistribute'] and if not 'send_dir' in testData['cmd']['redistribute']:
+                return {'success':False,'msg':'The restribute element requires the remotes and send_dir options.'}
+            else:
+                results = rpc.archiveDir(testData['cmd']['redistribute']['send_dir'])
+                if results['success'] == False:
+                    return results
         
         return {'success':True,'shutdownExempt':True}
 
diff --git a/remote.py b/remote.py
index 7f69675..9d11b3f 100755
--- a/remote.py
+++ b/remote.py
@@ -14,6 +14,7 @@
 
 import os
 import time
+import tarfile
 import platform
 import subprocess
 import SimpleXMLRPCServer
@@ -158,6 +159,20 @@ class RemoteManagement(object):
         os.removedirs('%s/tmp/%s' % (cwd, dir))
         return {'success':True}
 
+    def removeFile(self, fn):
+        os.chdir('%s/tmp' % cwd)
+        fn = fn.replace('..', '/invalid')
+        fn = fn.replace('.', '/invalid')
+        fn = fn.replace('/', '/invalid')
+        os.remove(fn)
+        return {'success':True}
+
+    def archiveDir(self, dn):
+        os.chdir('%s/tmp' % cwd)
+        tarball = tarfile.open('%s.tar', 'w:gz')
+        tarball.add('%s' % dn)
+        tarball.close
+
     def writeFile(self, fn, fd):
         try:
             f = open("%s/tmp/%s" % (cwd, fn), "w")
@@ -169,6 +184,15 @@ class RemoteManagement(object):
         f.close()
         return {'success':True}
 
+    def sendFileToRemote(self, fn):
+        with open('%s/tmp/%s' % (cwd, fn), "rb") as fh:
+            return xmlrpclib.Binary(fh.read())
+
+    def getFileFromRemote(self, remote, fn):
+        rpc = xmlrpclib.ServerProxy('http://%s:8000/' % remote)
+        with open('%s/tmp/%s' % (cwd, fn), "wb") as fh:
+            fh.write(rpc.sendFileToRemote().data)
+
     def reset(self):
         os.chdir('%s/tmp' % cwd)
         return 1

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


-- 
asterisk-scf/integration/testsuite.git



More information about the asterisk-scf-commits mailing list