From 65e8f2dc537427f28d43d90f3fb175a24c34ae02 Mon Sep 17 00:00:00 2001 From: Santhosh Edukulla Date: Wed, 2 Apr 2014 20:34:09 +0530 Subject: [PATCH] Fixed issues related to CLOUDSTACK-5674 Fixed issues mentioned for CLOUDSTACK-5674. More changes in the bug Signed-off-by: Santhosh Edukulla Signed-off-by: SrikanteswaraRao Talluri --- test/integration/smoke/test_nic.py | 5 +- test/integration/smoke/test_ssvm.py | 2 - tools/marvin/marvin/cloudstackConnection.py | 18 +++---- tools/marvin/marvin/cloudstackTestClient.py | 8 +-- tools/marvin/marvin/config/test_data.py | 23 +++++++- tools/marvin/marvin/marvinLog.py | 5 +- tools/marvin/marvin/marvinPlugin.py | 18 +++++-- tools/marvin/setup.py | 58 +++++++++++---------- 8 files changed, 82 insertions(+), 55 deletions(-) diff --git a/test/integration/smoke/test_nic.py b/test/integration/smoke/test_nic.py index afff95da5a9..de027ee14ee 100644 --- a/test/integration/smoke/test_nic.py +++ b/test/integration/smoke/test_nic.py @@ -65,10 +65,7 @@ class TestNic(cloudstackTestCase): zone.id, self.services["ostype"] ) - if self.template == FAILED: - self.fail("get_template() failed to return template with description %s" % self.services["ostype"]) - - # Set Zones and disk offerings + # Set Zones and disk offerings self.services["small"]["zoneid"] = zone.id self.services["small"]["template"] = template.id diff --git a/test/integration/smoke/test_ssvm.py b/test/integration/smoke/test_ssvm.py index b03f8cca4b2..63cdbff5e1d 100644 --- a/test/integration/smoke/test_ssvm.py +++ b/test/integration/smoke/test_ssvm.py @@ -34,8 +34,6 @@ _multiprocess_shared_ = True class TestSSVMs(cloudstackTestCase): def setUp(self): - - self.testClient = super(TestSSVMs, cls).getClsTestClient() self.apiclient = self.testClient.getApiClient() self.hypervisor = self.testClient.getHypervisorInfo() self.cleanup = [] diff --git a/tools/marvin/marvin/cloudstackConnection.py b/tools/marvin/marvin/cloudstackConnection.py index c4a4b0d88e8..e3c559054c1 100644 --- a/tools/marvin/marvin/cloudstackConnection.py +++ b/tools/marvin/marvin/cloudstackConnection.py @@ -21,9 +21,9 @@ import base64 import hmac import hashlib import time -from .cloudstackAPI import * -from . import jsonHelper -from .codes import ( +from cloudstackAPI import * +import jsonHelper +from marvin.codes import ( FAILED, INVALID_RESPONSE, INVALID_INPUT, @@ -110,8 +110,8 @@ class CSConnection(object): break time.sleep(5) timeout -= 5 - self.logger.debug("JobId:%s is Still Processing, " - "Will TimeOut in:%s" % (str(jobid), + self.logger.debug("=== JobId:%s is Still Processing, " + "Will TimeOut in:%s ====" % (str(jobid), str(timeout))) end_time = time.time() tot_time = int(start_time - end_time) @@ -122,9 +122,9 @@ class CSConnection(object): str(time.ctime(end_time)), str(tot_time))) return async_response except Exception as e: - self.__lastError = GetDetailExceptionInfo(e) - self.logger.exception("__poll: Exception Occurred :%s" % - self.__lastError) + self.__lastError = e + self.logger.exception("==== __poll: Exception Occurred :%s ====" % + str(self.__lastError)) return FAILED def getLastError(self): @@ -353,7 +353,7 @@ class CSConnection(object): payload=payload, method=method) if cmd_response == FAILED: - return FAILED + raise self.__lastError ''' 4. Check if the Command Response received above is valid or Not. diff --git a/tools/marvin/marvin/cloudstackTestClient.py b/tools/marvin/marvin/cloudstackTestClient.py index b3a06220d66..25dfcc7ec52 100644 --- a/tools/marvin/marvin/cloudstackTestClient.py +++ b/tools/marvin/marvin/cloudstackTestClient.py @@ -141,16 +141,14 @@ class CSTestClient(object): list_user = listUsers.listUsersCmd() list_user.account = "admin" list_user_res = self.__apiClient.listUsers(list_user) - if list_user_res == FAILED or list_user_res is None or\ + if list_user_res is None or\ (validateList(list_user_res)[0] != PASS): self.__logger.error("__createApiClient: API " "Client Creation Failed") return FAILED - user_id = list_user_res[0].id api_key = list_user_res[0].apikey security_key = list_user_res[0].secretkey - if api_key is None: ret = self.__getKeys(user_id) if ret != FAILED: @@ -162,6 +160,10 @@ class CSTestClient(object): "Creation Failed while " "Registering User") return FAILED + else: + self.__mgmtDetails.port = 8080 + self.__mgmtDetails.apiKey = api_key + self.__mgmtDetails.securityKey = security_key ''' Now Create the Connection objects and Api Client using new details diff --git a/tools/marvin/marvin/config/test_data.py b/tools/marvin/marvin/config/test_data.py index 3c1d4aff6da..55e90d4e9e4 100644 --- a/tools/marvin/marvin/config/test_data.py +++ b/tools/marvin/marvin/config/test_data.py @@ -295,7 +295,6 @@ test_data = { "Lb": {"lbSchemes": "internal", "SupportedLbIsolation": "dedicated"} } }, - "natrule": { "privateport": 22, "publicport": 2222, @@ -350,6 +349,12 @@ test_data = { }, "templatefilter": 'self', + "templates": { + "displaytext": 'Template', + "name": 'Template', + "ostype": "CentOS 5.3 (64-bit)", + "templatefilter": 'self', + }, "security_group" : { "name": "custom_Sec_Grp" }, "ingress_rule": { "protocol": "TCP", @@ -414,5 +419,19 @@ test_data = { "displaytext": "vpc-tier2", "gateway" : "10.2.1.1", "netmask" : "255.255.255.192" - } + }, + "server": { + "displayname": "TestVM", + "username": "root", + "password": "password", + "ssh_port": 22, + "hypervisor": 'XenServer', + "privateport": 22, + "publicport": 22, + "protocol": 'TCP' + }, + "privateport": 22, + "publicport": 22, + "protocol": 'TCP', + "forvirtualnetwork": "true" } diff --git a/tools/marvin/marvin/marvinLog.py b/tools/marvin/marvin/marvinLog.py index 075f33a5f2b..9b4dd19ce86 100644 --- a/tools/marvin/marvin/marvinLog.py +++ b/tools/marvin/marvin/marvinLog.py @@ -25,6 +25,7 @@ from marvin.codes import (SUCCESS, FAILED ) from marvin.cloudstackException import GetDetailExceptionInfo +from marvin.lib.utils import random_gen class MarvinLog: @@ -140,9 +141,9 @@ class MarvinLog: temp_ts = time.strftime("%b_%d_%Y_%H_%M_%S", time.localtime()) if test_module_name is None: - temp_path = temp_ts + temp_path = temp_ts + "_" + random_gen() else: - temp_path = str(test_module_name) + "__" + str(temp_ts) + temp_path = str(test_module_name) + "__" + str(temp_ts) + "_" + random_gen() temp_dir = "MarvinLogs" if ((log_cfg is not None) and diff --git a/tools/marvin/marvin/marvinPlugin.py b/tools/marvin/marvin/marvinPlugin.py index 4fee27aedcb..1425006b357 100644 --- a/tools/marvin/marvin/marvinPlugin.py +++ b/tools/marvin/marvin/marvinPlugin.py @@ -26,6 +26,7 @@ from nose.plugins.base import Plugin from marvin.codes import (SUCCESS, FAILED, EXCEPTION) +from marvin.lib.utils import random_gen from marvin.cloudstackException import GetDetailExceptionInfo @@ -230,7 +231,8 @@ class MarvinPlugin(Plugin): self.__testRunner = nose.core.\ TextTestRunner(stream=self.__resultStream, descriptions=True, - verbosity=2) + verbosity=2, + config=self.conf) return SUCCESS return FAILED except Exception as e: @@ -272,7 +274,13 @@ class MarvinPlugin(Plugin): test.AcctType) def finalize(self, result): - src = self.__logFolderPath.strip("//") - dst = os.path.split(src)[0] + "/" + self.__testModName - os.system("mv " + src + " " + dst) - print "===Final Results: %s===" % str(dst) + try: + src = self.__logFolderPath + log_cfg = self.__parsedConfig.logger + tmp = log_cfg.__dict__.get('LogFolderPath') + "/MarvinLogs" + dst = tmp + "/" + self.__testName + "_" + random_gen() + cmd = "mv " + src + " " + dst + os.system(cmd) + print "===Final Results: %s===" % str(dst) + except Exception, e: + print "=== Exception occurred under finalize :%s"%str(GetDetailExceptionInfo(e)) diff --git a/tools/marvin/setup.py b/tools/marvin/setup.py index 12164269f81..91606423c76 100644 --- a/tools/marvin/setup.py +++ b/tools/marvin/setup.py @@ -6,9 +6,9 @@ # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -30,33 +30,35 @@ except ImportError: VERSION = '0.1.0' import os + + def read(fname): return open(os.path.join(os.path.dirname(__file__), fname)).read().strip() setup(name="Marvin", - version=VERSION, - description="Marvin - Python client for Apache CloudStack", - author="Edison Su", - author_email="Edison.Su@citrix.com", - maintainer="Prasanna Santhanam", - maintainer_email="tsp@apache.org", - long_description="Marvin is the Apache CloudStack python client written around the unittest framework", - platforms=("Any",), - url="https://builds.apache.org/job/cloudstack-marvin/", - packages=["marvin", "marvin.cloudstackAPI", - "marvin.lib", "marvin.config","marvin.sandbox", - "marvin.sandbox.advanced", "marvin.sandbox.advancedsg", "marvin.sandbox.basic"], - license="LICENSE.txt", - install_requires=[ - "mysql-connector-python", - "requests", - "paramiko", - "nose", - "ddt >= 0.4.0" - ], - py_modules=['marvin.marvinPlugin'], - zip_safe=False, - entry_points={ - 'nose.plugins': ['marvinPlugin = marvin.marvinPlugin:MarvinPlugin'] - }, -) + version=VERSION, + description="Marvin - Python client for Apache CloudStack", + author="Edison Su", + author_email="Edison.Su@citrix.com", + maintainer="Prasanna Santhanam", + maintainer_email="tsp@apache.org", + long_description="Marvin is the Apache CloudStack python client written around the unittest framework", + platforms=("Any",), + url="https://builds.apache.org/job/cloudstack-marvin/", + packages=["marvin", "marvin.cloudstackAPI", + "marvin.lib", "marvin.config", "marvin.sandbox", + "marvin.sandbox.advanced", "marvin.sandbox.advancedsg", "marvin.sandbox.basic"], + license="LICENSE.txt", + install_requires=[ + "mysql-connector-python", + "requests", + "paramiko", + "nose", + "ddt >= 0.4.0" + ], + py_modules=['marvin.marvinPlugin'], + zip_safe=False, + entry_points={ + 'nose.plugins': ['marvinPlugin = marvin.marvinPlugin:MarvinPlugin'] + }, + )