mirror of https://github.com/apache/cloudstack.git
Added few exception changes,test suite name generation for information collected post run, fixed pep8 issues
Signed-off-by: santhoshe <santhosh.edukulla@gmail.com> Conflicts: tools/marvin/marvin/marvinInit.py
This commit is contained in:
parent
c42e9036f7
commit
24bf1c56df
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
'''
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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)):
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Reference in New Issue