[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 May 23 20:50:04 CDT 2011


branch "review" has been updated
       via  a8232a8ff436505ca0700262f41bd80602743ab7 (commit)
      from  8c96df01fb9027464a23ded1c78a6770517d5474 (commit)

Summary of changes:
 lib/python/util.py                          |    5 +-
 plugins/build.py                            |   80 +++++++++++++--------------
 remote.py                                   |   16 +++++-
 tests/build/Build_AsteriskSCF/testcase.yaml |    2 +-
 4 files changed, 57 insertions(+), 46 deletions(-)


- Log -----------------------------------------------------------------
commit a8232a8ff436505ca0700262f41bd80602743ab7
Author: Darren Sessions <dsessions at digium.com>
Date:   Mon May 23 20:50:00 2011 -0500

    loads of work getting the build plugin operational.

diff --git a/lib/python/util.py b/lib/python/util.py
index 8bf1605..f3b7379 100644
--- a/lib/python/util.py
+++ b/lib/python/util.py
@@ -35,6 +35,7 @@ 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:
@@ -43,14 +44,14 @@ class TestSuiteRemoteBaseClass:
         return self.main(testData, testPath, rpc)
 
 class url:
-    def fetchRepoName(self, url):
+    def fetchRepoInfo(self, url):
         repoName = ''
         url = urlparse(url)
         if not url[0] == 'git' and not url[0] == 'svn':
             return {'success':False,'msg':'The URL must be a properly formatted git or svn url.'}
         for part in url[2].split('/'):
             repoName = part
-        return {'success':True,'repoName':repoName}
+        return {'success':True, 'repoName':repoName, 'repoType':'%s' % url[0]}
 
 class plugins:
     def execute(self, name, module, testData, testPath):
diff --git a/plugins/build.py b/plugins/build.py
index 7df9c11..cdf9fd5 100644
--- a/plugins/build.py
+++ b/plugins/build.py
@@ -17,52 +17,50 @@ class testsuite(util.TestSuiteRemoteBaseClass):
         if not 'repo' in testData['cmd']:
             return {'success':False,'msg':'No repo specified.'}
 
-        results = util.url().fetchRepoName(testData['cmd']['repo'])
-        if results['success'] == False:
-            return results
-        else:
-            repoName = results['repoName']
+        repoInfo = util.url().fetchRepoInfo(testData['cmd']['repo'])
+        if repoInfo['success'] == False:
+            return repoInfo
 
-        print repoName
-
-        results = rpc.changeDir('tmp')
-        if results['success'] == False:
-            return results
+        if 'pull_update' in testData['cmd']:
+            if testData['cmd']['pull_update'] == True:
+                update = True
+            else:
+                update = False
+        else:   
+            update = False
 
+        if repoInfo['repoType'] == 'git':
+            repoInfo['repoGetCmd'] = 'clone'
+            repoInfo['repoRefreshCmd'] = 'pull'
+        elif repoInfo['repoType'] == 'svn':
+            repoInfo['repoGetCmd'] = 'checkout'
+            repoInfo['repoRefreshCmd'] = 'update'
 
-#        if 'git_repo' in testData['cmd']:
-#            repoType = 'git'
-#            results = rpc.run('build', repoName, ['git','clone', '%s' % testData['cmd']['git_repo']])
-#              
-#        elif 'svn_repo' in testData['cmd']:
-#            repoType = 'svn'
-#            repo = testData['cmd']['svn_repo']
+        if update == True:
+            results = rpc.changeDir(repoInfo['repoName'])
+            if results['success'] == False:
+                results = self._scratchBuild(rpc, repoInfo['repoName'], repoInfo['repoType'], repoInfo['repoGetCmd'], testData['cmd']['repo'])
+                if results['success'] == False:
+                    return results
+        else:
+            results = self._scratchBuild(rpc, repoInfo['repoName'], repoInfo['repoType'], repoInfo['repoGetCmd'], testData['cmd']['repo'])
+            if results['success'] == False:
+                return results
 
-#        print results
-#        print repoName
+        if 'cd' in testData['cmd']:
+            results = rpc.changeDir(testData['cmd']['cd'])
+            if results['success'] == False:
+                return results
 
+        if 'make_cmd' in testData['cmd']:
+            for cmds in testData['cmd']['make_cmd']:
+                results = rpc.run('build', 'make', cmds.split(' '), True)
+                if results['success'] == False:
+                    return results
         
-       
-        ''' 
-        for cmd in testData['cmd']:
-            if cmd == 'start':
-                for component in testData['cmd']['start']:
-                    print component
-                    #results = rpc.writeFile('%s.conf' % component, '\n'.join(self._componentConfig(component)))
-                    #if results['success'] == False:
-                    #    return results
-                    #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)])
-                    #if results['success'] == False:
-                    #    return results
-            elif cmd == 'stop':
-                print 'stop'
-            else:
-                return {'success':False,'msg':'The %s command is invalid.' % cmd}
-        '''
-
         return {'success':True}
 
-    #def _componentConfig(self, mode, config, testPath):
+    def _scratchBuild(self, rpc, name, type, getCmd, repo):
+        results = rpc.run('build', name, [type, getCmd, repo], True)
+        if results['success'] == False:
+            return results
diff --git a/remote.py b/remote.py
index f957053..5cd41f0 100755
--- a/remote.py
+++ b/remote.py
@@ -41,7 +41,7 @@ class RemoteManagement(object):
 
         return {'success':True,'msg':'Nothing running.'}
 
-    def run(self, plugin, label, execCmd, wait = False):
+    def run(self, 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)}
@@ -67,6 +67,7 @@ class RemoteManagement(object):
             p.poll()
             if wait == True:
                 p.wait()
+            os.chdir('%s' % cwd)
             if p.returncode:
                 return {'success':False,"msg":"Could not execute '%s'." % ' '.join(execCmd)}
         else:
@@ -144,9 +145,19 @@ class RemoteManagement(object):
         return {'success':True}
 
     def changeDir(self, dir):
+        dir = dir.replace('..', '/')
         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 = 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 writeFile(self, fn, fd):
@@ -161,7 +172,8 @@ class RemoteManagement(object):
         return {'success':True}
 
     def reset(self):
-        os.chdir('%s' % cwd)
+        os.chdir('%s/tmp' % cwd)
+        return 1
 
     def _which(self, app):
         def if_exists(fp):
diff --git a/tests/build/Build_AsteriskSCF/testcase.yaml b/tests/build/Build_AsteriskSCF/testcase.yaml
index 40d03a2..e21c490 100644
--- a/tests/build/Build_AsteriskSCF/testcase.yaml
+++ b/tests/build/Build_AsteriskSCF/testcase.yaml
@@ -40,7 +40,7 @@ tests :
                 testsuite_remote : testsuite-server.digium.internal
                 cmd :
                     pull_update : True
-                    repo : 'git://git.asterisk.org/asterisk-scf/release/gitall'
+                    repo : 'git://git.asterisk.org/asterisk-scf/integration/gitall'
                     cd : gitall
                     make_cmd :
                         - ./gitall-asterisk-scf.sh

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


-- 
asterisk-scf/integration/testsuite.git



More information about the asterisk-scf-commits mailing list