[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 14:59:00 CDT 2011


branch "review" has been updated
       via  b9f5aeefa5257a374cfabe8911eba744305ac8b6 (commit)
      from  0f66f456ca42a1b5911576a67314c342fa12ca7f (commit)

Summary of changes:
 lib/python/util.py                  |    9 +++-
 lib/python/yaml_parser.py           |   26 +++++----
 plugins/asteriskscf_configurator.py |   17 +++--
 plugins/build.py                    |    9 ++-
 remote.py                           |    3 +
 tests/sip/tests.yaml                |    5 +-
 tests/tests.yaml                    |    5 +-
 testsuite.py                        |  111 ++++++++++++++++++-----------------
 8 files changed, 104 insertions(+), 81 deletions(-)


- Log -----------------------------------------------------------------
commit b9f5aeefa5257a374cfabe8911eba744305ac8b6
Author: Darren Sessions <dsessions at digium.com>
Date:   Mon May 23 14:58:57 2011 -0500

    Converted the parsed yaml results to be encapsulated within a list instead of a dict to preserve order.

diff --git a/lib/python/util.py b/lib/python/util.py
index af4341c..28be839 100644
--- a/lib/python/util.py
+++ b/lib/python/util.py
@@ -35,6 +35,13 @@ 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.testRPC()
+        try:
+            rpc.testRPC()
+        except:
+            return {'success':False,'msg':'Connection to %s was refused.' % testData['testsuite_remote']}
+
         return self.main(testData, testPath, rpc)
 
 class url:
@@ -54,7 +61,7 @@ class plugins:
         except AttributeError:
             return {'success':False,'msg':"Unable to execute module '%s'. %s" % (name, sys.exc_info()[1])}
         else:
-            results = func().run(testData, testPath, testData['testsuite_remote'])
+            results = func().run(testData, testPath)
         if not type(results) == dict:
             return {'success':False,'msg':"The '%s' module return invalid or missing data." % name}
         return results
diff --git a/lib/python/yaml_parser.py b/lib/python/yaml_parser.py
index 31ffc04..eb15160 100755
--- a/lib/python/yaml_parser.py
+++ b/lib/python/yaml_parser.py
@@ -2,6 +2,7 @@
 
 import sys
 import yaml
+import dumper
 
 class yamlBase:
     def __init__(self):
@@ -9,26 +10,29 @@ class yamlBase:
         self.testsYaml = 'tests.yaml'
         self.testDocYaml = 'testdoc.yaml'
         self.testCaseYaml = 'testcase.yaml'
-        self.returnData = {}
+        self.returnData = []
+        self.indResults = {}
         self.load()
 
     def parse(self, searchPath, yamlFile, test=None):
         testData = self.loadFiles(searchPath, self.testsYaml)
-        for list in testData['tests']:
-            for recursiveSearch in list:
-                path = "%s/%s" % (searchPath, list[recursiveSearch])
-                if recursiveSearch == 'tests':
-                    test = list[recursiveSearch]
-                    self.returnData[test] = []
+        for list in testData:
+            for items in testData[list]:
+                path = "%s/%s" % (searchPath, items)
+                if list == 'tests':
+                    self.indResults = {}
+                    self.indResults[items] = []
+                    self.parse(path, yamlFile, items)
+                    self.returnData.append(self.indResults)
+                elif list == 'dir':
                     self.parse(path, yamlFile, test)
-                elif recursiveSearch == 'dir':
-                    self.parse(path, yamlFile, test)
-                elif recursiveSearch == 'testcase':
+                elif list == 'testcase':
                     results = self.loadFiles(path, yamlFile)
                     results['path'] = path
-                    self.returnData[test].append(results)
+                    self.indResults[test].append(results)
 
     def loadFiles(self, path, yaml_file):
+        f = open("%s/%s" % (path, yaml_file), "r") 
         try:
             f = open("%s/%s" % (path, yaml_file), "r")
         except IOError:
diff --git a/plugins/asteriskscf_configurator.py b/plugins/asteriskscf_configurator.py
index dc76b83..5efc4f8 100644
--- a/plugins/asteriskscf_configurator.py
+++ b/plugins/asteriskscf_configurator.py
@@ -18,21 +18,24 @@ sys.path.append('/opt/Ice-3.4.1/python')
 
 import Ice
 
-Ice.loadSlice('-I. -I/opt/Ice-3.4.1/slice -I./tmp/gitall/slice --all ./tmp/gitall/sip/local-slice/SipConfigurationIf.ice')
-Ice.loadSlice('-I. --all ./tmp/gitall/slice/AsteriskSCF/System/Component/ConfigurationIf.ice')
-
-import AsteriskSCF.SIP.V1
-import AsteriskSCF.System.Configuration.V1
-
 class testsuite(util.TestSuiteBaseClass):
     def main(self, testData, testPath):
         if not 'configuration_wipe' in testData:
             testData['configuration_wipe'] = None
 
+        try:
+            Ice.loadSlice('-I. -I/opt/Ice-3.4.1/slice -I./tmp/gitall/slice --all ./tmp/gitall/sip/local-slice/SipConfigurationIf.ice')
+            Ice.loadSlice('-I. --all ./tmp/gitall/slice/AsteriskSCF/System/Component/ConfigurationIf.ice')
+        except:
+            return {'success':False,'shutdownExempt':'True','msg':'Slice preprocessing failed. Unable to locate slice files.'}
+
+        import AsteriskSCF.SIP.V1
+        import AsteriskSCF.System.Configuration.V1
+
         ''' The configurator doesn't implement a start or stop function as it's just pushing config '''
         for cmd in testData['cmd']:
             if not cmd == 'sip':
-                return {'success':False,'msg':'The %s command is invalid.' % cmd}
+                return {'success':False,'shutdownExempt':'True','msg':'The %s command is invalid.' % cmd}
             return ConfiguratorApp(cmd, testData['testsuite_remote'], testData['cmd'][cmd], testData['configuration_wipe']).main([''])
 
 # Exception class used within the configurator application
diff --git a/plugins/build.py b/plugins/build.py
index 1179288..5974563 100644
--- a/plugins/build.py
+++ b/plugins/build.py
@@ -13,6 +13,7 @@ import util
 
 class testsuite(util.TestSuiteRemoteBaseClass):
     def main(self, testData, testPath, rpc):
+        return {'success':True,'shutdownExempt':'True'}
 
         ''' start and stop individual components. shutdown is implemented in the main testsuite code ''' 
     
@@ -26,12 +27,14 @@ class testsuite(util.TestSuiteRemoteBaseClass):
                 repoType = 'svn'
                 repo = testData['cmd']['svn_repo']
 
-        results = fetchRepoName(repo)
+        results = util.url().fetchRepoName(repo)
         if results['success'] == False:
             return results
         else:
             repoName = results['repoName']
 
+        print results
+        print repoName
        
         ''' 
         for cmd in testData['cmd']:
@@ -53,8 +56,6 @@ class testsuite(util.TestSuiteRemoteBaseClass):
                 return {'success':False,'msg':'The %s command is invalid.' % cmd}
         '''
 
-        return {'success':False}
-
         return {'success':True}
 
-    def _componentConfig(self, mode, config, testPath):
+    #def _componentConfig(self, mode, config, testPath):
diff --git a/remote.py b/remote.py
index a57c9cc..ed950b1 100755
--- a/remote.py
+++ b/remote.py
@@ -161,6 +161,9 @@ class RemoteManagement(object):
         f.close()
         return {'success':True}
 
+    def testRPC(self):
+        return 1
+
     def _which(self, app):
         def if_exists(fp):
             return os.path.exists(fp) and os.access(fp, os.X_OK)
diff --git a/tests/sip/tests.yaml b/tests/sip/tests.yaml
index ab1dbb1..758ea86 100644
--- a/tests/sip/tests.yaml
+++ b/tests/sip/tests.yaml
@@ -1,2 +1,3 @@
-tests :
-    - testcase : SysTest_Functional_Basic_CallSetup
+testcase :
+    - SysTest_Functional_Basic_CallSetup
+    - SysTest_Functional_Phones_PolycomIP430
diff --git a/tests/tests.yaml b/tests/tests.yaml
index a865e43..6e94f4c 100644
--- a/tests/tests.yaml
+++ b/tests/tests.yaml
@@ -1,4 +1,3 @@
 tests :
-    - tests : build
-    - tests : sip
-#    - tests : failover
+    - build
+    - sip
diff --git a/testsuite.py b/testsuite.py
index adb5fca..f939693 100755
--- a/testsuite.py
+++ b/testsuite.py
@@ -22,6 +22,8 @@ sys.path.append("%s/plugins" % homeDir)
 import util
 import yaml_parser
 
+import dumper
+
 class __main__:
     def __init__(self):
         self.yamlData = yaml_parser.testcases().returnData
@@ -34,65 +36,68 @@ class __main__:
 
         x = util.xml().initTestSuite()
 
-        for testCategory in self.yamlData:  
-            x, categoryElement = util.xml().addTestSuite(x, testCategory)
-            print "\n Starting '%s' tests . . \n ---------------------------------" % testCategory
+        for list in self.yamlData:
+            for testCategory in list:
+                x, categoryElement = util.xml().addTestSuite(x, testCategory)
+                print "\n Starting '%s' tests . . \n ---------------------------------" % testCategory
             
-            for testData in self.yamlData[testCategory]:
-                categoryElement, testElement = util.xml().addTestSuite(categoryElement, testData['name'])
-                print ' |- Testcase "%s" ' % testData['name']
-                #print testData['options']
-                for subTestCase in testData['tests']:
-                    for testName in subTestCase:
-                        testElement, subTestElement = util.xml().addTestCase(testElement, testName)
-                        if subTestCase[testName]:
-                            success = True
-
-                            if subTestCase[testName]['expected_failure']:
-                                subTestElement = util.xml().setProperty(subTestElement, 'expected_failure', subTestCase[testName]['expected_failure'])
-
-                            #print subTestCase[testName]['expected_failure']
-
-                            ''' import plugins '''
-                            for plugin in [plugin for timeLine in subTestCase[testName]['timeline'] for plugin in timeLine]:
-                                pluginData[plugin] = util.plugins().init(plugin)
-                                if not pluginData[plugin]['success'] == True:
-                                    errorMsgs.append(pluginData[plugin]['msg'])
-                                    success = False
-
-                            if success == False:
-                                print '   |- Test "' + testName + '" - FAILED!\n    \- ' + '\n'.join(errorMsgs)
-                                subTestElement, errorMsgs = util.xml().addFailure(subTestElement, errorMsgs)
-                                break
+                for testData in list[testCategory]:
+                    categoryElement, testElement = util.xml().addTestSuite(categoryElement, testData['name'])
+                    print ' |- Testcase "%s" ' % testData['name']
+                    #print testData['options']
+                    for subTestCase in testData['tests']:
+                        for testName in subTestCase:
+                            testElement, subTestElement = util.xml().addTestCase(testElement, testName)
+                            if subTestCase[testName]:
+                                success = True
+                
+                                if 'expected_failure' in subTestCase[testName]:
+                                    if subTestCase[testName]['expected_failure']:
+                                       subTestElement = util.xml().setProperty(subTestElement, 'expected_failure', subTestCase[testName]['expected_failure'])
+
+                                #print subTestCase[testName]['expected_failure']
+
+                                ''' import plugins '''
+                                for plugin in [plugin for timeLine in subTestCase[testName]['timeline'] for plugin in timeLine]:
+                                    pluginData[plugin] = util.plugins().init(plugin)
+                                    if not pluginData[plugin]['success'] == True:
+                                        errorMsgs.append(pluginData[plugin]['msg'])
+                                        success = False
+
+                                if success == False:
+                                    print '   |- Test "' + testName + '" - FAILED!\n    \- ' + '\n'.join(errorMsgs)
+                                    subTestElement, errorMsgs = util.xml().addFailure(subTestElement, errorMsgs)
+                                    break
 
-                            ''' execute testcase timeline '''
-                            for timeLine in subTestCase[testName]['timeline']:
-                                for plugin in timeLine:
-                                    runResults = util.plugins().execute(plugin, pluginData[plugin]['module'], timeLine[plugin], testData['path'])
-                                    if runResults['success'] == True:
-                                        if not 'shutdownExempt' in runResults:
-                                            shutdownList.append({timeLine[plugin]['testsuite_remote']:plugin})
-                                    else:
+                                ''' execute testcase timeline '''
+                                for timeLine in subTestCase[testName]['timeline']:
+                                    for plugin in timeLine:
+                                        runResults = util.plugins().execute(plugin, pluginData[plugin]['module'], timeLine[plugin], testData['path'])
+                                        if runResults['success'] == True:
+                                            if not 'shutdownExempt' in runResults:
+                                                shutdownList.append({timeLine[plugin]['testsuite_remote']:plugin})
+                                        else:
+                                            break
+                                    if runResults['success'] == False:
+                                        runResults['msg'] = '%s: %s' % (plugin, runResults['msg'])
                                         break
-                                if runResults['success'] == False:
-                                    runResults['msg'] = '%s: %s' % (plugin, runResults['msg'])
-                                    break
 
-                            if runResults['success'] == False:
-                                print '   |- Test "' + testName + '" - FAILED!\n    \- ' + runResults['msg']
-                                subTestElement, errorMsgs = util.xml().addFailure(subTestElement, ['%s' % runResults['msg']])
+                                ''' shutdown if 'restart_persistant_plugins_between_tests' is true or not specified '''
+                                for host in [host for d in shutdownList for host in d]:
+                                    remote = xmlrpclib.Server('http://%s:8000' % host)
+                                    remote.shutdown(d[host]) 
 
-                            ''' shutdown if 'restart_persistant_plugins_between_tests' is true or not specified '''
-                            for host in [host for d in shutdownList for host in d]:
-                                remote = xmlrpclib.Server('http://%s:8000' % host)
-                                remote.shutdown(d[host]) 
+                                if runResults['success'] == False:
+                                    print '   |- Test "' + testName + '" - FAILED!\n    \- ' + runResults['msg']
+                                    subTestElement, errorMsgs = util.xml().addFailure(subTestElement, ['%s' % runResults['msg']])
+                                    break
                 
-                            print '   |- Test "' + testName + '" - PASSED!'
-                            # setProperty(self, element, key, val): for xml results
-                        else:
-                            print '   |- Test "' + testName + '" - FAILED!\n    \- No test data defined!'
-                            subTestElement, errorMsgs = util.xml().addFailure(subTestElement, ['No test data defined!'])
-                            break
+                                print '   |- Test "' + testName + '" - PASSED!'
+                                # setProperty(self, element, key, val): for xml results
+                            else:
+                                print '   |- Test "' + testName + '" - FAILED!\n    \- No test data defined!'
+                                subTestElement, errorMsgs = util.xml().addFailure(subTestElement, ['No test data defined!'])
+                                break
         #print xml().convToString(x)
         print "\n\n" + util.xml().prettyXml(x)
         return

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


-- 
asterisk-scf/integration/testsuite.git



More information about the asterisk-scf-commits mailing list