You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by gi...@apache.org on 2014/05/07 13:10:37 UTC

git commit: updated refs/heads/4.4-forward to 7a0fa6b

Repository: cloudstack
Updated Branches:
  refs/heads/4.4-forward 99f75db1e -> 7a0fa6b45


Added few exception changes,test suite name generation for information collected post run, fixed pep8 issues

Signed-off-by: santhoshe <sa...@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/7a0fa6b4
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/7a0fa6b4
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/7a0fa6b4

Branch: refs/heads/4.4-forward
Commit: 7a0fa6b4581dda692ad276d21ce4c7bb106381cb
Parents: 99f75db
Author: santhoshe <sa...@gmail.com>
Authored: Mon May 5 16:40:58 2014 +1000
Committer: Gaurav Aradhye <ga...@clogeny.com>
Committed: Wed May 7 00:23:06 2014 -0400

----------------------------------------------------------------------
 tools/marvin/marvin/cloudstackConnection.py | 52 +++++++++++++++---------
 tools/marvin/marvin/cloudstackTestClient.py |  4 +-
 tools/marvin/marvin/configGenerator.py      |  3 +-
 tools/marvin/marvin/marvinInit.py           | 15 ++++---
 tools/marvin/marvin/marvinLog.py            |  2 +-
 tools/marvin/marvin/marvinPlugin.py         | 26 ++++++------
 6 files changed, 59 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7a0fa6b4/tools/marvin/marvin/cloudstackConnection.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/cloudstackConnection.py b/tools/marvin/marvin/cloudstackConnection.py
index caa8609..8044da7 100644
--- a/tools/marvin/marvin/cloudstackConnection.py
+++ b/tools/marvin/marvin/cloudstackConnection.py
@@ -38,7 +38,9 @@ from requests import (
     Timeout,
     RequestException
 )
-from marvin.cloudstackException import GetDetailExceptionInfo
+from marvin.cloudstackException import (
+    InvalidParameterException,
+    GetDetailExceptionInfo)
 
 
 class CSConnection(object):
@@ -235,6 +237,7 @@ class CSConnection(object):
                 self.logger.exception("__sendCmdToCS: Invalid Protocol")
                 return FAILED
         except Exception as e:
+            self.__lastError = e
             self.logger.exception("__sendCmdToCS: Exception:%s" %
                                   GetDetailExceptionInfo(e))
             return FAILED
@@ -265,6 +268,8 @@ class CSConnection(object):
                 if payload[required_param] is None:
                     self.logger.debug("CmdName: %s Parameter : %s is Required"
                                       % (cmd_name, required_param))
+                    self.__lastError = InvalidParameterException(
+                        "Invalid Parameters")
                     return FAILED
             for param, value in payload.items():
                 if value is None:
@@ -284,6 +289,7 @@ class CSConnection(object):
                                 i += 1
             return cmd_name.strip(), isAsync, payload
         except Exception as e:
+            self.__lastError = e
             self.logger.\
                 exception("__sanitizeCmd: CmdName : "
                           "%s : Exception:%s" % (cmd_name,
@@ -301,21 +307,29 @@ class CSConnection(object):
         @Output:Response output from CS
         '''
         try:
-            ret = jsonHelper.getResultObj(cmd_response.json(), response_cls)
-        except TypeError:
-            ret = jsonHelper.getResultObj(cmd_response.json, response_cls)
+            try:
+                ret = jsonHelper.getResultObj(
+                    cmd_response.json(),
+                    response_cls)
+            except TypeError:
+                ret = jsonHelper.getResultObj(cmd_response.json, response_cls)
 
-        '''
-        If the response is asynchronous, poll and return response
-        else return response as it is
-        '''
-        if is_async == "false":
-            self.logger.debug("Response : %s" % str(ret))
-            return ret
-        else:
-            response = self.__poll(ret.jobid, response_cls)
-            self.logger.debug("Response : %s" % str(response))
-            return response.jobresult if response != FAILED else FAILED
+            '''
+            If the response is asynchronous, poll and return response
+            else return response as it is
+            '''
+            if is_async == "false":
+                self.logger.debug("Response : %s" % str(ret))
+                return ret
+            else:
+                response = self.__poll(ret.jobid, response_cls)
+                self.logger.debug("Response : %s" % str(response))
+                return response.jobresult if response != FAILED else FAILED
+        except Exception as e:
+            self.__lastError = e
+            self.logger.\
+                exception("Exception:%s" % GetDetailExceptionInfo(e))
+            return FAILED
 
     def marvinRequest(self, cmd, response_type=None, method='GET', data=''):
         """
@@ -325,7 +339,7 @@ class CSConnection(object):
                 response_type: response type of the command in cmd
                 method: HTTP GET/POST, defaults to GET
         @Output: Response received from CS
-                 FAILED In case of Error\Exception
+                 Exception in case of Error\Exception
         """
         try:
             '''
@@ -334,7 +348,7 @@ class CSConnection(object):
             if (cmd is None or cmd == '')or \
                     (response_type is None or response_type == ''):
                 self.logger.exception("marvinRequest : Invalid Command Input")
-                return FAILED
+                raise InvalidParameterException("Invalid Parameter")
 
             '''
             2. Sanitize the Command
@@ -342,7 +356,7 @@ class CSConnection(object):
             sanitize_cmd_out = self.__sanitizeCmd(cmd)
 
             if sanitize_cmd_out == FAILED:
-                return FAILED
+                raise self.__lastError
 
             cmd_name, is_async, payload = sanitize_cmd_out
             '''
@@ -368,4 +382,4 @@ class CSConnection(object):
         except Exception as e:
             self.logger.exception("marvinRequest : CmdName: %s Exception: %s" %
                                   (str(cmd), GetDetailExceptionInfo(e)))
-            return FAILED
+            raise e

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7a0fa6b4/tools/marvin/marvin/cloudstackTestClient.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/cloudstackTestClient.py b/tools/marvin/marvin/cloudstackTestClient.py
index d3a6b94..0e3d3d0 100644
--- a/tools/marvin/marvin/cloudstackTestClient.py
+++ b/tools/marvin/marvin/cloudstackTestClient.py
@@ -26,7 +26,6 @@ from marvin.cloudstackException import GetDetailExceptionInfo
 from marvin.lib.utils import (random_gen, validateList)
 from marvin.cloudstackAPI.cloudstackAPIClient import CloudStackAPIClient
 
-
 class CSTestClient(object):
 
     '''
@@ -83,7 +82,8 @@ class CSTestClient(object):
                 Tests are to Run
         @Output : Returns the Parsed Test Data Dictionary
         '''
-        return self.__parsedTestDataConfig
+        out = self.__parsedTestDataConfig
+        return out
 
     def getZoneForTests(self):
         '''

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7a0fa6b4/tools/marvin/marvin/configGenerator.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/configGenerator.py b/tools/marvin/marvin/configGenerator.py
index 4f03fd0..66609da 100644
--- a/tools/marvin/marvin/configGenerator.py
+++ b/tools/marvin/marvin/configGenerator.py
@@ -431,7 +431,8 @@ class ConfigManager(object):
         @Output: ParsedDict if successful if  cfg file provided is valid
                  None if cfg file is invalid or not able to be parsed
         '''
-        return self.__parsedCfgDict
+        out = self.__parsedCfgDict
+        return out
 
 
 def getDeviceUrl(obj):

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7a0fa6b4/tools/marvin/marvin/marvinInit.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/marvinInit.py b/tools/marvin/marvin/marvinInit.py
index de580ce..ce9b43f 100644
--- a/tools/marvin/marvin/marvinInit.py
+++ b/tools/marvin/marvin/marvinInit.py
@@ -187,14 +187,13 @@ class MarvinInit:
         try:
             mgt_details = self.__parsedConfig.mgtSvr[0]
             dbsvr_details = self.__parsedConfig.dbSvr
-            self.__testClient = CSTestClient(mgt_details,
-                                             dbsvr_details,
-                                             logger=self.__tcRunLogger,
-                                             test_data_filepath=
-                                             self.__testDataFilePath,
-                                             zone=self.__zoneForTests,
-                                             hypervisor_type=
-                                             self.__hypervisorType)
+            self.__testClient = CSTestClient(
+                mgt_details,
+                dbsvr_details,
+                logger=self.__tcRunLogger,
+                test_data_filepath=self.__testDataFilePath,
+                zone=self.__zoneForTests,
+                hypervisor_type=self.__hypervisorType)
             if self.__testClient:
                 return self.__testClient.createTestClient()
             return FAILED

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7a0fa6b4/tools/marvin/marvin/marvinLog.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/marvinLog.py b/tools/marvin/marvin/marvinLog.py
index 65687aa..ea8eaee 100644
--- a/tools/marvin/marvin/marvinLog.py
+++ b/tools/marvin/marvin/marvinLog.py
@@ -152,7 +152,7 @@ class MarvinLog:
                     "__" + str(temp_ts) + "_" + random_gen()
 
             if user_provided_logpath:
-                temp_dir = user_provided_logpath
+                temp_dir = user_provided_logpath + "/MarvinLogs"
             elif ((log_cfg is not None) and
                     ('LogFolderPath' in log_cfg.__dict__.keys()) and
                     (log_cfg.__dict__.get('LogFolderPath') is not None)):

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7a0fa6b4/tools/marvin/marvin/marvinPlugin.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/marvinPlugin.py b/tools/marvin/marvin/marvinPlugin.py
index c817cd6..74b64ef 100644
--- a/tools/marvin/marvin/marvinPlugin.py
+++ b/tools/marvin/marvin/marvinPlugin.py
@@ -287,21 +287,23 @@ class MarvinPlugin(Plugin):
 
     def finalize(self, result):
         try:
+            src = self.__logFolderPath
             if not self.__userLogPath:
-                src = self.__logFolderPath
                 log_cfg = self.__parsedConfig.logger
                 tmp = log_cfg.__dict__.get('LogFolderPath') + "/MarvinLogs"
-                dst = tmp + "//" + random_gen()
-                mod_name = "test_suite"
-                if self.__testModName:
-                    mod_name = self.__testModName.split(".")
-                    if len(mod_name) > 2:
-                        mod_name = mod_name[-2]
-                if mod_name:
-                    dst = tmp + "/" + mod_name + "_" + random_gen()
-                cmd = "mv " + src + " " + dst
-                os.system(cmd)
-                print "===final results are now copied to: %s===" % str(dst)
+            else:
+                tmp = self.__userLogPath + "/MarvinLogs"
+            dst = tmp + "//" + random_gen()
+            mod_name = "test_suite"
+            if self.__testModName:
+                mod_name = self.__testModName.split(".")
+                if len(mod_name) > 2:
+                    mod_name = mod_name[-2]
+            if mod_name:
+                dst = tmp + "/" + mod_name + "_" + random_gen()
+            cmd = "mv " + src + " " + dst
+            os.system(cmd)
+            print "===final results are now copied to: %s===" % str(dst)
         except Exception as e:
             print "=== Exception occurred under finalize :%s ===" % \
                   str(GetDetailExceptionInfo(e))