Repository: cloudstack Updated Branches: refs/heads/master c42e9036f -> 24bf1c56d
Added few exception changes,test suite name generation for information collected post run, fixed pep8 issues Signed-off-by: santhoshe <santhosh.eduku...@gmail.com> Conflicts: tools/marvin/marvin/marvinInit.py Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/24bf1c56 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/24bf1c56 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/24bf1c56 Branch: refs/heads/master Commit: 24bf1c56dfe437766a716dc8ced6d892782bd6a1 Parents: c42e903 Author: santhoshe <santhosh.eduku...@gmail.com> Authored: Mon May 5 16:40:58 2014 +1000 Committer: SrikanteswaraRao Talluri <tall...@apache.org> Committed: Wed May 14 18:34:27 2014 +0530 ---------------------------------------------------------------------- tools/marvin/marvin/cloudstackConnection.py | 52 +++++++++++++++--------- tools/marvin/marvin/cloudstackTestClient.py | 4 +- tools/marvin/marvin/configGenerator.py | 3 +- tools/marvin/marvin/marvinInit.py | 3 +- tools/marvin/marvin/marvinLog.py | 2 +- tools/marvin/marvin/marvinPlugin.py | 26 ++++++------ 6 files changed, 54 insertions(+), 36 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/24bf1c56/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/24bf1c56/tools/marvin/marvin/cloudstackTestClient.py ---------------------------------------------------------------------- diff --git a/tools/marvin/marvin/cloudstackTestClient.py b/tools/marvin/marvin/cloudstackTestClient.py index 2e9b49a..b554ba1 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/24bf1c56/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/24bf1c56/tools/marvin/marvin/marvinInit.py ---------------------------------------------------------------------- diff --git a/tools/marvin/marvin/marvinInit.py b/tools/marvin/marvin/marvinInit.py index b6b3cec..ce9b43f 100644 --- a/tools/marvin/marvin/marvinInit.py +++ b/tools/marvin/marvin/marvinInit.py @@ -188,7 +188,8 @@ class MarvinInit: mgt_details = self.__parsedConfig.mgtSvr[0] dbsvr_details = self.__parsedConfig.dbSvr self.__testClient = CSTestClient( - mgt_details, dbsvr_details, + mgt_details, + dbsvr_details, logger=self.__tcRunLogger, test_data_filepath=self.__testDataFilePath, zone=self.__zoneForTests, http://git-wip-us.apache.org/repos/asf/cloudstack/blob/24bf1c56/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/24bf1c56/tools/marvin/marvin/marvinPlugin.py ---------------------------------------------------------------------- diff --git a/tools/marvin/marvin/marvinPlugin.py b/tools/marvin/marvin/marvinPlugin.py index 71f81ad..52a2cde 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))