CLOUDSTACK-7911: Adding test cases for usage test path

Signed-off-by: SrikanteswaraRao Talluri <talluri@apache.org>
This commit is contained in:
Ashutosh K 2015-01-30 07:56:08 -08:00 committed by SrikanteswaraRao Talluri
parent a68de9acb6
commit ada8cdce70
5 changed files with 3382 additions and 11 deletions

File diff suppressed because it is too large Load Diff

View File

@ -828,6 +828,11 @@ test_data = {
"mode": "HTTP_DOWNLOAD", "mode": "HTTP_DOWNLOAD",
"templatefilter": "self" "templatefilter": "self"
}, },
"volume_from_snapshot": {
"diskname": 'Volume from snapshot',
"size": "1",
"zoneid": ""
},
"templatefilter": 'self', "templatefilter": 'self',
"templates": { "templates": {
"displaytext": 'Template', "displaytext": 'Template',
@ -1512,7 +1517,8 @@ test_data = {
"ldapPassword": "" "ldapPassword": ""
}, },
"systemVmDelay": 120, "systemVmDelay": 120,
"vmware_cluster" : { "setUsageConfigurationThroughTestCase": True
"vmware_cluster" : {
"hypervisor": 'VMware', "hypervisor": 'VMware',
"clustertype": 'ExternalManaged', "clustertype": 'ExternalManaged',
"username": '', "username": '',

View File

@ -35,7 +35,7 @@ class DbConnection(object):
self.passwd = passwd self.passwd = passwd
self.database = db self.database = db
def execute(self, sql=None, params=None): def execute(self, sql=None, params=None, db=None):
if sql is None: if sql is None:
return None return None
@ -45,7 +45,7 @@ class DbConnection(object):
port=int(self.port), port=int(self.port),
user=str(self.user), user=str(self.user),
password=str(self.passwd), password=str(self.passwd),
db=str(self.database))) as conn: db=str(self.database) if not db else db)) as conn:
conn.autocommit = True conn.autocommit = True
with contextlib.closing(conn.cursor(buffered=True)) as cursor: with contextlib.closing(conn.cursor(buffered=True)) as cursor:
cursor.execute(sql, params) cursor.execute(sql, params)

View File

@ -795,7 +795,7 @@ class Volume:
domainid=None, diskofferingid=None, projectid=None): domainid=None, diskofferingid=None, projectid=None):
"""Create Volume""" """Create Volume"""
cmd = createVolume.createVolumeCmd() cmd = createVolume.createVolumeCmd()
cmd.name = services["diskname"] cmd.name = "-".join([services["diskname"], random_gen()])
if diskofferingid: if diskofferingid:
cmd.diskofferingid = diskofferingid cmd.diskofferingid = diskofferingid
@ -1284,12 +1284,12 @@ class Iso:
@classmethod @classmethod
def create(cls, apiclient, services, account=None, domainid=None, def create(cls, apiclient, services, account=None, domainid=None,
projectid=None): projectid=None, zoneid=None):
"""Create an ISO""" """Create an ISO"""
# Create ISO from URL # Create ISO from URL
cmd = registerIso.registerIsoCmd() cmd = registerIso.registerIsoCmd()
cmd.displaytext = services["displaytext"] cmd.displaytext = services["displaytext"]
cmd.name = services["name"] cmd.name = "-".join([services["name"], random_gen()])
if "ostypeid" in services: if "ostypeid" in services:
cmd.ostypeid = services["ostypeid"] cmd.ostypeid = services["ostypeid"]
elif "ostype" in services: elif "ostype" in services:
@ -1308,7 +1308,11 @@ class Iso:
"Unable to find Ostype is required for creating ISO") "Unable to find Ostype is required for creating ISO")
cmd.url = services["url"] cmd.url = services["url"]
cmd.zoneid = services["zoneid"]
if zoneid:
cmd.zoneid = zoneid
else:
cmd.zoneid = services["zoneid"]
if "isextractable" in services: if "isextractable" in services:
cmd.isextractable = services["isextractable"] cmd.isextractable = services["isextractable"]
@ -1625,7 +1629,7 @@ class EgressFireWallRule:
@classmethod @classmethod
def create(cls, apiclient, networkid, protocol, cidrlist=None, def create(cls, apiclient, networkid, protocol, cidrlist=None,
startport=None, endport=None): startport=None, endport=None, type=None, code=None):
"""Create Egress Firewall Rule""" """Create Egress Firewall Rule"""
cmd = createEgressFirewallRule.createEgressFirewallRuleCmd() cmd = createEgressFirewallRule.createEgressFirewallRuleCmd()
cmd.networkid = networkid cmd.networkid = networkid
@ -1636,6 +1640,10 @@ class EgressFireWallRule:
cmd.startport = startport cmd.startport = startport
if endport: if endport:
cmd.endport = endport cmd.endport = endport
if type:
cmd.type = type
if code:
cmd.code = code
return EgressFireWallRule( return EgressFireWallRule(
apiclient.createEgressFirewallRule(cmd).__dict__) apiclient.createEgressFirewallRule(cmd).__dict__)
@ -4712,4 +4720,34 @@ class SimulatorMock:
except Exception as e: except Exception as e:
raise e raise e
class Usage:
"""Manage Usage Generation"""
def __init__(self, items):
self.__dict__.update(items)
@classmethod
def listRecords(cls, apiclient, **kwargs):
"""Lists domains"""
cmd = listUsageRecords.listUsageRecordsCmd()
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
return(apiclient.listUsageRecords(cmd))
@classmethod
def listTypes(cls, apiclient, **kwargs):
"""Lists domains"""
cmd = listUsageTypes.listUsageTypesCmd()
[setattr(cmd, k, v) for k, v in kwargs.items()]
if 'account' in kwargs.keys() and 'domainid' in kwargs.keys():
cmd.listall = True
return(apiclient.listUsageTypes(cmd))
@classmethod
def generateRecords(cls, apiclient, **kwargs):
"""Lists domains"""
cmd = generateUsageRecords.generateUsageRecordsCmd()
[setattr(cmd, k, v) for k, v in kwargs.items()]
return(apiclient.generateUsageRecords(cmd))

View File

@ -501,8 +501,8 @@ def verifyRouterState(apiclient, routerid, allowedstates):
listvalidationresult = validateList(routers) listvalidationresult = validateList(routers)
if listvalidationresult[0] == FAIL: if listvalidationresult[0] == FAIL:
return [FAIL, listvalidationresult[2]] return [FAIL, listvalidationresult[2]]
if routers[0].redundantstate not in allowedstates: if routers[0].state.lower() not in allowedstates:
return [FAIL, "Redundant state of the router should be in %s but is %s" % return [FAIL, "state of the router should be in %s but is %s" %
(allowedstates, routers[0].redundantstate)] (allowedstates, routers[0].state)]
return [PASS, None] return [PASS, None]