Adding Netscaler test cases and fixing bugs in HA test suite.

This commit is contained in:
Chirag Jog 2012-06-13 20:34:14 +05:30
parent 93530c60be
commit 17978438ee
7 changed files with 2998 additions and 1130 deletions

View File

@ -21,7 +21,7 @@ from marvin.cloudstackAPI import *
from integration.lib.utils import *
from integration.lib.base import *
from integration.lib.common import *
from marvin.remoteSSHClient import remoteSSHClient
from marvin import remoteSSHClient
import datetime
@ -80,7 +80,7 @@ class Services:
"templates": {
"displaytext": "Public Template",
"name": "Public template",
"ostypeid": '946b031b-0e10-4f4a-a3fc-d212ae2ea07f',
"ostypeid": '1d4a6dce-8db1-4c08-8752-e88b360d8287',
"url": "http://download.cloud.com/releases/2.0.0/UbuntuServer-10-04-64bit.vhd.bz2",
"hypervisor": 'XenServer',
"format" : 'VHD',
@ -89,7 +89,7 @@ class Services:
"isextractable": True,
"templatefilter": 'self',
},
"ostypeid": '946b031b-0e10-4f4a-a3fc-d212ae2ea07f',
"ostypeid": '1d4a6dce-8db1-4c08-8752-e88b360d8287',
# Cent OS 5.3 (64 bit)
"sleep": 60,
"timeout": 100,
@ -198,7 +198,7 @@ class TestHighAvailability(cloudstackTestCase):
True,
"List hosts should return valid host response"
)
self.assertEqual(
self.assertGreaterEqual(
len(hosts),
2,
"There must be two hosts present in a cluster"
@ -277,15 +277,6 @@ class TestHighAvailability(cloudstackTestCase):
self.debug("Creating LB rule on IP with NAT: %s" %
public_ip.ipaddress.ipaddress)
# Open up firewall port for SSH
fw_rule = FireWallRule.create(
self.apiclient,
ipaddressid=public_ip.ipaddress.id,
protocol=self.services["natrule"]["protocol"],
cidrlist=['0.0.0.0/0'],
startport=self.services["natrule"]["publicport"],
endport=self.services["natrule"]["publicport"]
)
# Create Load Balancer rule on IP already having NAT rule
lb_rule = LoadBalancerRule.create(
self.apiclient,
@ -600,7 +591,7 @@ class TestHighAvailability(cloudstackTestCase):
True,
"List hosts should return valid host response"
)
self.assertEqual(
self.assertGreaterEqual(
len(hosts),
2,
"There must be two hosts present in a cluster"
@ -676,16 +667,6 @@ class TestHighAvailability(cloudstackTestCase):
ipaddressid=public_ip.ipaddress.id
)
# Open up firewall port for SSH
fw_rule = FireWallRule.create(
self.apiclient,
ipaddressid=public_ip.ipaddress.id,
protocol=self.services["natrule"]["protocol"],
cidrlist=['0.0.0.0/0'],
startport=self.services["natrule"]["publicport"],
endport=self.services["natrule"]["publicport"]
)
self.debug("Creating LB rule on IP with NAT: %s" %
public_ip.ipaddress.ipaddress)

View File

@ -63,12 +63,23 @@ class Services:
"password": 'nsroot',
"networkdevicetype": 'NetscalerVPXLoadBalancer',
"publicinterface": '1/1',
"privateinterface": '0/1',
"privateinterface": '1/1',
"numretries": 2,
"lbdevicededicated": False,
"lbdevicecapacity": 50,
"port": 22,
},
"netscaler_dedicated": {
"ipaddress": '192.168.100.213',
"username": 'nsroot',
"password": 'nsroot',
"networkdevicetype": 'NetscalerVPXLoadBalancer',
"publicinterface": '1/1',
"privateinterface": '1/1',
"numretries": 2,
"lbdevicededicated": True,
"port": 22,
},
"network_offering_dedicated": {
"name": 'Netscaler',
"displaytext": 'Netscaler',
@ -262,6 +273,7 @@ class TestAddNetScaler(cloudstackTestCase):
return
class TestInvalidParametersNetscaler(cloudstackTestCase):
@classmethod
@ -502,7 +514,7 @@ class TestInvalidParametersNetscaler(cloudstackTestCase):
)
return
@unittest.skip("Issue- Unable to validate user credentials while creating nw offering")
class TestNetScalerDedicated(cloudstackTestCase):
@classmethod
@ -528,10 +540,9 @@ class TestNetScalerDedicated(cloudstackTestCase):
if isinstance(physical_networks, list):
physical_network = physical_networks[0]
cls.services["netscaler"]["lbdevicededicated"] = True
cls.netscaler = NetScaler.add(
cls.api_client,
cls.services["netscaler"],
cls.services["netscaler_dedicated"],
physicalnetworkid=physical_network.id
)
@ -702,8 +713,8 @@ class TestNetScalerDedicated(cloudstackTestCase):
# Creating network using the network offering created
self.debug("Trying to create network with network offering: %s" %
self.network_offering.id)
with self.assertRaises(Exception):
Network.create(
Network.create(
self.apiclient,
self.services["network"],
accountid=self.account_2.account.name,
@ -711,9 +722,21 @@ class TestNetScalerDedicated(cloudstackTestCase):
networkofferingid=self.network_offering.id,
zoneid=self.zone.id
)
self.debug("Deploying an instance in account: %s" % self.account_2.account.name)
with self.assertRaises(Exception):
VirtualMachine.create(
self.apiclient,
self.services["virtual_machine"],
accountid=self.account_2.account.name,
domainid=self.account_2.account.domainid,
serviceofferingid=self.service_offering.id,
networkids=[str(self.network.id)]
)
self.debug("Deply instacne in dedicated Network offering mode failed")
return
class TestNetScalerShared(cloudstackTestCase):
@classmethod
@ -827,12 +850,12 @@ class TestNetScalerShared(cloudstackTestCase):
raise Exception("Warning: Exception during cleanup : %s" % e)
return
def test_netscaler_dedicated_mode(self):
"""Test netscaler device in dedicated mode
def test_netscaler_shared_mode(self):
"""Test netscaler device in shared mode
"""
# Validate the following
# 1. Add Netscaler device in dedicated mode.
# 1. Add Netscaler device in shared mode.
# 2. Netscaler should be configured successfully.It should be able to
# service only 1 account.
@ -955,6 +978,7 @@ class TestNetScalerShared(cloudstackTestCase):
return
class TestNetScalerCustomCapacity(cloudstackTestCase):
@classmethod
@ -1074,14 +1098,14 @@ class TestNetScalerCustomCapacity(cloudstackTestCase):
raise Exception("Warning: Exception during cleanup : %s" % e)
return
def test_netscaler_dedicated_mode(self):
"""Test netscaler device in dedicated mode
def test_netscaler_custom_capacity(self):
"""Test netscaler device with custom capacity
"""
# Validate the following
# 1. Add Netscaler device in dedicated mode.
# 1. Add Netscaler device in shared mode with capacity 3
# 2. Netscaler should be configured successfully.It should be able to
# service only 1 account.
# service only 3 accounts.
ns_list = NetScaler.list(
self.apiclient,
@ -1226,6 +1250,7 @@ class TestNetScalerCustomCapacity(cloudstackTestCase):
return
class TestNetScalerNoCapacity(cloudstackTestCase):
@classmethod
@ -1250,7 +1275,7 @@ class TestNetScalerNoCapacity(cloudstackTestCase):
)
if isinstance(physical_networks, list):
physical_network = physical_networks[0]
cls.services["netscaler"]["lbdevicecapacity"] = 2
cls.netscaler = NetScaler.add(
cls.api_client,
cls.services["netscaler"],
@ -1345,14 +1370,15 @@ class TestNetScalerNoCapacity(cloudstackTestCase):
raise Exception("Warning: Exception during cleanup : %s" % e)
return
def test_netscaler_dedicated_mode(self):
"""Test netscaler device in dedicated mode
def test_netscaler_no_capacity(self):
"""Test netscaler device with no capacity remaining
"""
# Validate the following
# 1. Add Netscaler device in dedicated mode.
# 1. Add Netscaler device in shared mode with capacity 2
# 2. Netscaler should be configured successfully.It should be able to
# service only 1 account.
# service only 2 accounts.
# 3. Deploy instance for account 3 should fail
ns_list = NetScaler.list(
self.apiclient,
@ -1497,6 +1523,7 @@ class TestNetScalerNoCapacity(cloudstackTestCase):
return
class TestGuestNetworkWithNetScaler(cloudstackTestCase):
@classmethod
@ -2049,6 +2076,7 @@ class TestGuestNetworkWithNetScaler(cloudstackTestCase):
return
class TestGuestNetworkShutDown(cloudstackTestCase):
@classmethod
@ -2209,7 +2237,7 @@ class TestGuestNetworkShutDown(cloudstackTestCase):
name='network.gc.wait'
)
# Sleep to ensure that all resources are deleted
time.sleep((int(interval[0].value) + int(wait[0].value))*2)
time.sleep((int(interval[0].value) + int(wait[0].value)) * 2)
self.debug("SSH into netscaler: %s" %
self.services["netscaler"]["ipaddress"])
@ -2459,6 +2487,7 @@ class TestGuestNetworkShutDown(cloudstackTestCase):
return
class TestServiceProvider(cloudstackTestCase):
@classmethod
@ -2750,8 +2779,15 @@ class TestServiceProvider(cloudstackTestCase):
id=self.netscaler_provider.id,
state='Disabled'
)
self.debug("Deploying VM in the network: %s" % self.network.id)
with self.assertRaises(Exception):
self.debug("Deploying VM in the network: %s" % self.network.id)
LoadBalancerRule.create(
self.apiclient,
self.services["lbrule"],
ipaddressid=public_ip.ipaddress.id,
accountid=self.account.account.name,
networkid=self.network.id
)
VirtualMachine.create(
self.apiclient,
self.services["virtual_machine"],
@ -2763,6 +2799,7 @@ class TestServiceProvider(cloudstackTestCase):
return
class TestDeleteNetscaler(cloudstackTestCase):
@classmethod

View File

@ -1571,7 +1571,6 @@ class TestMultipleLbRules(cloudstackTestCase):
return
class TestMultipleLbRulesSameIp(cloudstackTestCase):
@classmethod

File diff suppressed because it is too large Load Diff

View File

@ -58,7 +58,7 @@ class Services:
"protocol": 'TCP',
},
"netscaler": {
"ipaddress": '10.147.40.100',
"ipaddress": '192.168.100.213',
"username": 'nsroot',
"password": 'nsroot',
"networkdevicetype": 'NetscalerVPXLoadBalancer',
@ -100,7 +100,7 @@ class Services:
"publicport": 22,
"openfirewall": False,
},
"ostypeid": '2b58909b-7d9e-45d9-80d8-e58d0bbcbf07',
"ostypeid": '946b031b-0e10-4f4a-a3fc-d212ae2ea07f',
# Cent OS 5.3 (64 bit)
"sleep": 60,
"timeout": 10,

File diff suppressed because it is too large Load Diff

View File

@ -171,7 +171,8 @@ class VirtualMachine:
@classmethod
def create(cls, apiclient, services, templateid=None, accountid=None,
domainid=None, networkids=None, serviceofferingid=None,
securitygroupids=None, projectid=None, mode='basic'):
securitygroupids=None, projectid=None, startvm=None,
diskofferingid=None, mode='basic'):
"""Create the instance"""
cmd = deployVirtualMachine.deployVirtualMachineCmd()
@ -204,7 +205,9 @@ class VirtualMachine:
elif "template" in services:
cmd.templateid = services["template"]
if "diskoffering" in services:
if diskofferingid:
cmd.diskofferingid = diskofferingid
elif "diskoffering" in services:
cmd.diskofferingid = services["diskoffering"]
if securitygroupids:
@ -216,8 +219,16 @@ class VirtualMachine:
if projectid:
cmd.projectid = projectid
if startvm is not None:
cmd.startvm = startvm
virtual_machine = apiclient.deployVirtualMachine(cmd)
if startvm == False:
virtual_machine.ssh_ip = virtual_machine.nic[0].ipaddress
virtual_machine.public_ip = virtual_machine.nic[0].ipaddress
return VirtualMachine(virtual_machine.__dict__, services)
# VM should be in Running state after deploy
timeout = 10
while True:
@ -328,6 +339,26 @@ class VirtualMachine:
cmd.id = volume.id
return apiclient.detachVolume(cmd)
def attach_iso(self, apiclient, iso):
"""Attach ISO to instance"""
cmd = attachIso.attachIsoCmd()
cmd.id = iso.id
cmd.virtualmachineid = self.id
return apiclient.attachIso(cmd)
def detach_iso(self, apiclient):
"""Detach ISO to instance"""
cmd = detachIso.detachIsoCmd()
cmd.id = self.id
return apiclient.detachIso(cmd)
def change_service_offering(self, apiclient, serviceOfferingId):
"""Change service offering of the instance"""
cmd = changeServiceForVirtualMachine.changeServiceForVirtualMachineCmd()
cmd.id = self.id
cmd.serviceofferingid = serviceOfferingId
return apiclient.changeServiceForVirtualMachine(cmd)
@classmethod
def list(cls, apiclient, **kwargs):
"""List all VMs matching criteria"""
@ -343,10 +374,8 @@ class VirtualMachine:
cmd.id = self.id
try:
response = apiclient.resetPasswordForVirtualMachine(cmd)
print response
except Exception as e:
raise Exception("Reset Password failed! - %s" % e)
print type(response)
if isinstance(response, list):
return response[0].password
@ -685,7 +714,6 @@ class Iso:
response = iso_response[0]
# Again initialize timeout to avoid listISO failure
timeout = 5
print response.status
# Check whether download is in progress(for Ex:10% Downloaded)
# or ISO is 'Successfully Installed'
if response.status == 'Successfully Installed':
@ -1006,10 +1034,10 @@ class NetworkOffering:
'provider': provider
})
if "servicecapabilitylist" in services:
cmd.servicecapabilitylist = []
cmd.serviceCapabilityList = []
for service, capability in services["servicecapabilitylist"].items():
for ctype, value in capability.items():
cmd.servicecapabilitylist.append({
cmd.serviceCapabilityList.append({
'service': service,
'capabilitytype': ctype,
'capabilityvalue': value
@ -1018,6 +1046,7 @@ class NetworkOffering:
cmd.specifyVlan = services["specifyVlan"]
if "specifyIpRanges" in services:
cmd.specifyIpRanges = services["specifyIpRanges"]
cmd.availability = 'Optional'
[setattr(cmd, k, v) for k, v in kwargs.items()]
@ -1172,19 +1201,19 @@ class LoadBalancerRule:
for name, value in param.items():
cmd.param.append({'name': name, 'value': value})
return apiclient.createLBStickinessPolicy(cmd)
def deleteSticky(self, apiclient, id):
"""Deletes stickyness policy"""
cmd = deleteLBStickinessPolicy.deleteLBStickinessPolicyCmd()
cmd.id = id
return apiclient.deleteLBStickinessPolicy(cmd)
@classmethod
def listStickyPolicies(cls, apiclient, lbruleid, **kwargs):
"""Lists stickiness policies for load balancing rule"""
cmd= listLBStickinessPolicies.listLBStickinessPoliciesCmd()
cmd = listLBStickinessPolicies.listLBStickinessPoliciesCmd()
cmd.lbruleid = lbruleid
[setattr(cmd, k, v) for k, v in kwargs.items()]
return apiclient.listLBStickinessPolicies(cmd)
@ -1443,7 +1472,7 @@ class Network:
cmd = restartNetwork.restartNetworkCmd()
cmd.id = self.id
if cleanup:
cmd.cleanup = cleanup
cmd.cleanup = cleanup
return(apiclient.restartNetwork(cmd))
@classmethod
@ -2090,3 +2119,55 @@ class NetworkServiceProvider:
cmd = listNetworkServiceProviders.listNetworkServiceProvidersCmd()
[setattr(cmd, k, v) for k, v in kwargs.items()]
return(apiclient.listNetworkServiceProviders(cmd))
class Router:
"""Manage router life cycle"""
def __init__(self, items):
self.__dict__.update(items)
@classmethod
def start(cls, apiclient, id):
"""Starts the router"""
cmd = startRouter.startRouterCmd()
cmd.id = id
return apiclient.startRouter(cmd)
@classmethod
def stop(cls, apiclient, id, forced=None):
"""Stops the router"""
cmd = stopRouter.stopRouterCmd()
cmd.id = id
if forced:
cmd.forced = forced
return apiclient.stopRouter(cmd)
@classmethod
def reboot(cls, apiclient, id):
"""Reboots the router"""
cmd = rebootRouter.rebootRouterCmd()
cmd.id = id
return apiclient.rebootRouter(cmd)
@classmethod
def destroy(cls, apiclient, id):
"""Destroy the router"""
cmd = destroyRouter.destroyRouterCmd()
cmd.id = id
return apiclient.destroyRouter(cmd)
@classmethod
def change_service_offering(cls, apiclient, id, serviceofferingid):
"""Change service offering of the router"""
cmd = changeServiceForRouter.changeServiceForRouterCmd()
cmd.id = id
cmd.serviceofferingid = serviceofferingid
return apiclient.changeServiceForRouter(cmd)
@classmethod
def list(cls, apiclient, **kwargs):
"""List routers"""
cmd = listRouters.listRoutersCmd()
[setattr(cmd, k, v) for k, v in kwargs.items()]
return(apiclient.listRouters(cmd))