unskipping skipped tests

and indentation fixes

Signed-off-by: Prasanna Santhanam <tsp@apache.org>
This commit is contained in:
Prasanna Santhanam 2013-05-27 10:10:01 +05:30
parent 61e150fd58
commit 16e9eaca80
2 changed files with 337 additions and 342 deletions

View File

@ -18,15 +18,12 @@
""" P1 tests for dedicated Host high availability
"""
#Import Local Modules
import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin.integration.lib.utils import *
from marvin.integration.lib.base import *
from marvin.integration.lib.common import *
from marvin import remoteSSHClient
import datetime
class Services:
@ -34,90 +31,90 @@ class Services:
def __init__(self):
self.services = {
"account": {
"email": "test@test.com",
"firstname": "HA",
"lastname": "HA",
"username": "HA",
# Random characters are appended for unique
# username
"password": "password",
},
"service_offering_with_ha": {
"name": "Tiny Instance With HA Enabled",
"displaytext": "Tiny Instance",
"cpunumber": 1,
"cpuspeed": 100, # in MHz
"memory": 128, # In MBs
},
"service_offering_without_ha": {
"name": "Tiny Instance Without HA",
"displaytext": "Tiny Instance",
"cpunumber": 1,
"cpuspeed": 100, # in MHz
"memory": 128, # In MBs
},
"virtual_machine": {
"displayname": "VM",
"username": "root",
"password": "password",
"ssh_port": 22,
"hypervisor": 'XenServer',
# Hypervisor type should be same as
# hypervisor type of cluster
"privateport": 22,
"publicport": 22,
"protocol": 'TCP',
},
"ostype": 'CentOS 5.3 (64-bit)',
"timeout": 100,
}
"account": {
"email": "test@test.com",
"firstname": "HA",
"lastname": "HA",
"username": "HA",
# Random characters are appended for unique
# username
"password": "password",
},
"service_offering_with_ha": {
"name": "Tiny Instance With HA Enabled",
"displaytext": "Tiny Instance",
"cpunumber": 1,
"cpuspeed": 100, # in MHz
"memory": 128, # In MBs
},
"service_offering_without_ha": {
"name": "Tiny Instance Without HA",
"displaytext": "Tiny Instance",
"cpunumber": 1,
"cpuspeed": 100, # in MHz
"memory": 128, # In MBs
},
"virtual_machine": {
"displayname": "VM",
"username": "root",
"password": "password",
"ssh_port": 22,
"hypervisor": 'XenServer',
# Hypervisor type should be same as
# hypervisor type of cluster
"privateport": 22,
"publicport": 22,
"protocol": 'TCP',
},
"ostype": 'CentOS 5.3 (64-bit)',
"timeout": 100,
}
class TestHostHighAvailability(cloudstackTestCase):
""" Dedicated host HA test cases """
@classmethod
def setUpClass(cls):
cls.api_client = super(
TestHostHighAvailability,
cls
).getClsTestClient().getApiClient()
TestHostHighAvailability,
cls
).getClsTestClient().getApiClient()
cls.services = Services().services
# Get Zone, Domain and templates
cls.domain = get_domain(
cls.api_client,
cls.services
)
cls.api_client,
cls.services
)
cls.zone = get_zone(
cls.api_client,
cls.services
)
cls.api_client,
cls.services
)
cls.template = get_template(
cls.api_client,
cls.zone.id,
cls.services["ostype"]
)
cls.api_client,
cls.zone.id,
cls.services["ostype"]
)
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
cls.services["virtual_machine"]["template"] = cls.template.id
cls.service_offering_with_ha = ServiceOffering.create(
cls.api_client,
cls.services["service_offering_with_ha"],
offerha=True
)
cls.api_client,
cls.services["service_offering_with_ha"],
offerha=True
)
cls.service_offering_without_ha = ServiceOffering.create(
cls.api_client,
cls.services["service_offering_without_ha"],
offerha=False
)
cls.api_client,
cls.services["service_offering_without_ha"],
offerha=False
)
cls._cleanup = [
cls.service_offering_with_ha,
cls.service_offering_without_ha,
]
cls.service_offering_with_ha,
cls.service_offering_without_ha,
]
return
@classmethod
@ -133,11 +130,11 @@ class TestHostHighAvailability(cloudstackTestCase):
self.apiclient = self.testClient.getApiClient()
self.dbclient = self.testClient.getDbConnection()
self.account = Account.create(
self.apiclient,
self.services["account"],
admin=True,
domainid=self.domain.id
)
self.apiclient,
self.services["account"],
admin=True,
domainid=self.domain.id
)
self.cleanup = [self.account]
return
@ -150,8 +147,8 @@ class TestHostHighAvailability(cloudstackTestCase):
raise Exception("Warning: Exception during cleanup : %s" % e)
return
@attr(configuration = "ha.tag")
@attr(tags = ["advanced", "advancedns", "sg", "basic", "eip", "simulator"])
@attr(configuration="ha.tag")
@attr(tags=["advanced", "advancedns", "sg", "basic", "eip", "simulator"])
def test_01_vm_deployment_with_compute_offering_with_ha_enabled(self):
""" Test VM deployments (Create HA enabled Compute Service Offering and VM) """
@ -166,57 +163,57 @@ class TestHostHighAvailability(cloudstackTestCase):
#list and validate above created service offering with Ha enabled
list_service_response = list_service_offering(
self.apiclient,
id=self.service_offering_with_ha.id
)
self.apiclient,
id=self.service_offering_with_ha.id
)
self.assertEqual(
isinstance(list_service_response, list),
True,
"listServiceOfferings returned invalid object in response."
)
)
self.assertNotEqual(
len(list_service_response),
0,
"listServiceOfferings returned empty list."
)
)
self.assertEqual(
list_service_response[0].offerha,
True,
"The service offering is not HA enabled"
)
)
#create virtual machine with the service offering with Ha enabled
virtual_machine = VirtualMachine.create(
self.apiclient,
self.services["virtual_machine"],
accountid=self.account.name,
domainid=self.account.domainid,
serviceofferingid=self.service_offering_with_ha.id
)
self.apiclient,
self.services["virtual_machine"],
accountid=self.account.name,
domainid=self.account.domainid,
serviceofferingid=self.service_offering_with_ha.id
)
vms = VirtualMachine.list(
self.apiclient,
id=virtual_machine.id,
listall=True
)
self.apiclient,
id=virtual_machine.id,
listall=True
)
self.assertEqual(
isinstance(vms, list),
True,
"listVirtualMachines returned invalid object in response."
)
)
self.assertNotEqual(
len(vms),
0,
"listVirtualMachines returned empty list."
)
)
self.debug("Deployed VM on host: %s" % vms[0].hostid)
self.assertEqual(
vms[0].haenable,
True,
"VM not created with HA enable tag"
)
)
@attr(configuration = "ha.tag")
@attr(tags = ["advanced", "advancedns", "sg", "basic", "eip", "simulator", "multihost"])
@attr(configuration="ha.tag")
@attr(tags=["advanced", "advancedns", "sg", "basic", "eip", "simulator", "multihost"])
def test_02_no_vm_creation_on_host_with_haenabled(self):
""" Verify you can not create new VMs on hosts with an ha.tag """
@ -232,30 +229,30 @@ class TestHostHighAvailability(cloudstackTestCase):
#create and verify virtual machine with HA enabled service offering
virtual_machine_with_ha = VirtualMachine.create(
self.apiclient,
self.services["virtual_machine"],
accountid=self.account.name,
domainid=self.account.domainid,
serviceofferingid=self.service_offering_with_ha.id
)
self.apiclient,
self.services["virtual_machine"],
accountid=self.account.name,
domainid=self.account.domainid,
serviceofferingid=self.service_offering_with_ha.id
)
vms = VirtualMachine.list(
self.apiclient,
id=virtual_machine_with_ha.id,
listall=True
)
self.apiclient,
id=virtual_machine_with_ha.id,
listall=True
)
self.assertEqual(
isinstance(vms, list),
True,
"listVirtualMachines returned invalid object in response."
)
)
self.assertNotEqual(
len(vms),
0,
"listVirtualMachines returned empty list."
)
)
vm = vms[0]
@ -263,53 +260,53 @@ class TestHostHighAvailability(cloudstackTestCase):
#validate the virtual machine created is host Ha enabled
list_hosts_response = list_hosts(
self.apiclient,
id=vm.hostid
)
self.apiclient,
id=vm.hostid
)
self.assertEqual(
isinstance(list_hosts_response, list),
True,
"listHosts returned invalid object in response."
)
)
self.assertNotEqual(
len(list_hosts_response),
0,
"listHosts retuned empty list in response."
)
)
self.assertEqual(
list_hosts_response[0].hahost,
False,
"VM created on HA enabled host."
)
)
#create and verify virtual machine with Ha disabled service offering
virtual_machine_without_ha = VirtualMachine.create(
self.apiclient,
self.services["virtual_machine"],
accountid=self.account.name,
domainid=self.account.domainid,
serviceofferingid=self.service_offering_without_ha.id
)
self.apiclient,
self.services["virtual_machine"],
accountid=self.account.name,
domainid=self.account.domainid,
serviceofferingid=self.service_offering_without_ha.id
)
vms = VirtualMachine.list(
self.apiclient,
id=virtual_machine_without_ha.id,
listall=True
)
self.apiclient,
id=virtual_machine_without_ha.id,
listall=True
)
self.assertEqual(
isinstance(vms, list),
True,
"listVirtualMachines returned invalid object in response."
)
)
self.assertNotEqual(
len(vms),
0,
"listVirtualMachines returned empty list."
)
)
vm = vms[0]
@ -317,20 +314,20 @@ class TestHostHighAvailability(cloudstackTestCase):
#verify that the virtual machine created on the host is Ha disabled
list_hosts_response = list_hosts(
self.apiclient,
id=vm.hostid
)
self.apiclient,
id=vm.hostid
)
self.assertEqual(
isinstance(list_hosts_response, list),
True,
"listHosts returned invalid object in response."
)
)
self.assertNotEqual(
len(list_hosts_response),
0,
"listHosts returned empty list."
)
)
host = list_hosts_response[0]
@ -338,10 +335,10 @@ class TestHostHighAvailability(cloudstackTestCase):
host.hahost,
False,
"VM migrated to HA enabled host."
)
)
@attr(configuration = "ha.tag")
@attr(tags = ["advanced", "advancedns", "sg", "basic", "eip", "simulator", "multihost"])
@attr(configuration="ha.tag")
@attr(tags=["advanced", "advancedns", "sg", "basic", "eip", "simulator", "multihost"])
def test_03_cant_migrate_vm_to_host_with_ha_positive(self):
""" Verify you can not migrate VMs to hosts with an ha.tag (positive) """
@ -355,30 +352,30 @@ class TestHostHighAvailability(cloudstackTestCase):
#create and verify the virtual machine with HA enabled service offering
virtual_machine_with_ha = VirtualMachine.create(
self.apiclient,
self.services["virtual_machine"],
accountid=self.account.name,
domainid=self.account.domainid,
serviceofferingid=self.service_offering_with_ha.id
)
self.apiclient,
self.services["virtual_machine"],
accountid=self.account.name,
domainid=self.account.domainid,
serviceofferingid=self.service_offering_with_ha.id
)
vms = VirtualMachine.list(
self.apiclient,
id=virtual_machine_with_ha.id,
listall=True,
)
self.apiclient,
id=virtual_machine_with_ha.id,
listall=True,
)
self.assertEqual(
isinstance(vms, list),
True,
"List VMs should return valid response for deployed VM"
)
)
self.assertNotEqual(
len(vms),
0,
"List VMs should return valid response for deployed VM"
)
)
vm = vms[0]
@ -386,19 +383,19 @@ class TestHostHighAvailability(cloudstackTestCase):
#Find out a Suitable host for VM migration
list_hosts_response = list_hosts(
self.apiclient,
)
self.apiclient,
)
self.assertEqual(
isinstance(list_hosts_response, list),
True,
"The listHosts API returned the invalid list"
)
)
self.assertNotEqual(
len(list_hosts_response),
0,
"The listHosts returned nothing."
)
)
suitableHost = None
for host in list_hosts_response:
if host.suitableformigration == True and host.hostid != vm.hostid:
@ -417,20 +414,20 @@ class TestHostHighAvailability(cloudstackTestCase):
#Verify that the VM migrated to a targeted Suitable host
list_vm_response = list_virtual_machines(
self.apiclient,
id=vm.id
)
self.apiclient,
id=vm.id
)
self.assertEqual(
isinstance(list_vm_response, list),
True,
"The listVirtualMachines returned the invalid list."
)
)
self.assertNotEqual(
list_vm_response,
None,
"The listVirtualMachines API returned nothing."
)
)
vm_response = list_vm_response[0]
@ -438,16 +435,16 @@ class TestHostHighAvailability(cloudstackTestCase):
vm_response.id,
vm.id,
"The virtual machine id and the the virtual machine from listVirtualMachines is not matching."
)
)
self.assertEqual(
vm_response.hostid,
suitableHost.id,
"The VM is not migrated to targeted suitable host."
)
)
@attr(configuration = "ha.tag")
@attr(tags = ["advanced", "advancedns", "sg", "basic", "eip", "simulator", "multihost"])
@attr(configuration="ha.tag")
@attr(tags=["advanced", "advancedns", "sg", "basic", "eip", "simulator", "multihost"])
def test_04_cant_migrate_vm_to_host_with_ha_negative(self):
""" Verify you can not migrate VMs to hosts with an ha.tag (negative) """
@ -461,30 +458,30 @@ class TestHostHighAvailability(cloudstackTestCase):
#create and verify virtual machine with HA enabled service offering
virtual_machine_with_ha = VirtualMachine.create(
self.apiclient,
self.services["virtual_machine"],
accountid=self.account.name,
domainid=self.account.domainid,
serviceofferingid=self.service_offering_with_ha.id
)
self.apiclient,
self.services["virtual_machine"],
accountid=self.account.name,
domainid=self.account.domainid,
serviceofferingid=self.service_offering_with_ha.id
)
vms = VirtualMachine.list(
self.apiclient,
id=virtual_machine_with_ha.id,
listall=True
)
self.apiclient,
id=virtual_machine_with_ha.id,
listall=True
)
self.assertEqual(
isinstance(vms, list),
True,
"The listVirtualMachines returned invalid object in response."
)
)
self.assertNotEqual(
len(vms),
0,
"The listVirtualMachines returned empty response."
)
)
vm = vms[0]
@ -492,25 +489,25 @@ class TestHostHighAvailability(cloudstackTestCase):
#Find out Non-Suitable host for VM migration
list_hosts_response = list_hosts(
self.apiclient,
)
self.apiclient,
)
self.assertEqual(
isinstance(list_hosts_response, list),
True,
"listHosts returned invalid object in response."
)
)
self.assertNotEqual(
len(list_hosts_response),
0,
"listHosts returned empty response."
)
)
notSuitableHost = None
notSuitableHost = None
for host in list_hosts_response:
if not host.suitableformigration and host.hostid != vm.hostid:
notSuitableHost = host
break
break
self.assertTrue(notSuitableHost is not None, "notsuitablehost should not be None")
@ -524,36 +521,36 @@ class TestHostHighAvailability(cloudstackTestCase):
#Verify that the virtual machine got migrated to targeted Non-Suitable host
list_vm_response = list_virtual_machines(
self.apiclient,
id=vm.id
)
self.apiclient,
id=vm.id
)
self.assertEqual(
isinstance(list_vm_response, list),
True,
"listVirtualMachine returned invalid object in response."
)
)
self.assertNotEqual(
len(list_vm_response),
0,
"listVirtualMachines returned empty response."
)
)
self.assertEqual(
list_vm_response[0].id,
vm.id,
"Virtual machine id with the virtual machine from listVirtualMachine is not matching."
)
)
self.assertEqual(
list_vm_response[0].hostid,
notSuitableHost.id,
"The detination host id of migrated VM is not matching."
)
)
@attr(configuration = "ha.tag")
@attr(speed = "slow")
@attr(tags = ["advanced", "advancedns", "sg", "basic", "eip", "simulator", "multihost"])
@attr(configuration="ha.tag")
@attr(speed="slow")
@attr(tags=["advanced", "advancedns", "sg", "basic", "eip", "simulator", "multihost"])
def test_05_no_vm_with_ha_gets_migrated_to_ha_host_in_live_migration(self):
""" Verify that none of the VMs with HA enabled migrate to an ha tagged host during live migration """
@ -570,55 +567,55 @@ class TestHostHighAvailability(cloudstackTestCase):
# create and verify virtual machine with HA disabled service offering
virtual_machine_with_ha = VirtualMachine.create(
self.apiclient,
self.services["virtual_machine"],
accountid=self.account.name,
domainid=self.account.domainid,
serviceofferingid=self.service_offering_with_ha.id
)
self.apiclient,
self.services["virtual_machine"],
accountid=self.account.name,
domainid=self.account.domainid,
serviceofferingid=self.service_offering_with_ha.id
)
vms = VirtualMachine.list(
self.apiclient,
id=virtual_machine_with_ha.id,
listall=True
)
self.apiclient,
id=virtual_machine_with_ha.id,
listall=True
)
self.assertEqual(
isinstance(vms, list),
True,
"List VMs should return valid response for deployed VM"
)
)
self.assertNotEqual(
len(vms),
0,
"List VMs should return valid response for deployed VM"
)
)
vm_with_ha_enabled = vms[0]
#Verify the virtual machine got created on non HA host
list_hosts_response = list_hosts(
self.apiclient,
id=vm_with_ha_enabled.hostid
)
self.apiclient,
id=vm_with_ha_enabled.hostid
)
self.assertEqual(
isinstance(list_hosts_response, list),
True,
"Check list response returns a valid list"
)
)
self.assertNotEqual(
len(list_hosts_response),
0,
"Check Host is available"
)
)
self.assertEqual(
list_hosts_response[0].hahost,
False,
"The virtual machine is not ha enabled so check if VM is created on host which is also not ha enabled"
)
)
#put the Host in maintainance mode
self.debug("Enabling maintenance mode for host %s" % vm_with_ha_enabled.hostid)
@ -634,58 +631,58 @@ class TestHostHighAvailability(cloudstackTestCase):
self.apiclient,
virtualmachineid=vm_with_ha_enabled.id,
interval=timeout
)
)
vms = VirtualMachine.list(
self.apiclient,
id=vm_with_ha_enabled.id,
listall=True,
)
self.apiclient,
id=vm_with_ha_enabled.id,
listall=True,
)
self.assertEqual(
isinstance(vms, list),
True,
"List VMs should return valid response for deployed VM"
)
)
self.assertNotEqual(
len(vms),
0,
"List VMs should return valid response for deployed VM"
)
)
vm_with_ha_enabled1 = vms[0]
list_hosts_response = list_hosts(
self.apiclient,
id=vm_with_ha_enabled1.hostid
)
self.apiclient,
id=vm_with_ha_enabled1.hostid
)
self.assertEqual(
isinstance(list_hosts_response, list),
True,
"Check list response returns a valid list"
)
)
self.assertNotEqual(
len(list_hosts_response),
0,
"Check Host is available"
)
)
self.assertEqual(
list_hosts_response[0].hahost,
False,
"The virtual machine is not ha enabled so check if VM is created on host which is also not ha enabled"
)
)
self.debug("Disabling the maintenance mode for host %s" % vm_with_ha_enabled.hostid)
cmd = cancelHostMaintenance.cancelHostMaintenanceCmd()
cmd.id = vm_with_ha_enabled.hostid
self.apiclient.cancelHostMaintenance(cmd)
@attr(configuration = "ha.tag")
@attr(speed = "slow")
@attr(tags = ["advanced", "advancedns", "sg", "basic", "eip", "simulator", "multihost"])
@attr(configuration="ha.tag")
@attr(speed="slow")
@attr(tags=["advanced", "advancedns", "sg", "basic", "eip", "simulator", "multihost"])
def test_06_no_vm_without_ha_gets_migrated_to_ha_host_in_live_migration(self):
""" Verify that none of the VMs without HA enabled migrate to an ha tagged host during live migration """
@ -702,55 +699,55 @@ class TestHostHighAvailability(cloudstackTestCase):
# create and verify virtual machine with HA disabled service offering
virtual_machine_without_ha = VirtualMachine.create(
self.apiclient,
self.services["virtual_machine"],
accountid=self.account.name,
domainid=self.account.domainid,
serviceofferingid=self.service_offering_without_ha.id
)
self.apiclient,
self.services["virtual_machine"],
accountid=self.account.name,
domainid=self.account.domainid,
serviceofferingid=self.service_offering_without_ha.id
)
vms = VirtualMachine.list(
self.apiclient,
id=virtual_machine_without_ha.id,
listall=True
)
self.apiclient,
id=virtual_machine_without_ha.id,
listall=True
)
self.assertEqual(
isinstance(vms, list),
True,
"List VMs should return valid response for deployed VM"
)
)
self.assertNotEqual(
len(vms),
0,
"List VMs should return valid response for deployed VM"
)
)
vm_with_ha_disabled = vms[0]
#Verify the virtual machine got created on non HA host
list_hosts_response = list_hosts(
self.apiclient,
id=vm_with_ha_disabled.hostid
)
self.apiclient,
id=vm_with_ha_disabled.hostid
)
self.assertEqual(
isinstance(list_hosts_response, list),
True,
"Check list response returns a valid list"
)
)
self.assertNotEqual(
len(list_hosts_response),
0,
"Check Host is available"
)
)
self.assertEqual(
list_hosts_response[0].hahost,
False,
"The virtual machine is not ha enabled so check if VM is created on host which is also not ha enabled"
)
)
#put the Host in maintainance mode
self.debug("Enabling maintenance mode for host %s" % vm_with_ha_disabled.hostid)
@ -766,47 +763,47 @@ class TestHostHighAvailability(cloudstackTestCase):
self.apiclient,
virtualmachineid=vm_with_ha_disabled.id,
interval=timeout
)
)
vms = VirtualMachine.list(
self.apiclient,
id=vm_with_ha_disabled.id,
listall=True
)
self.apiclient,
id=vm_with_ha_disabled.id,
listall=True
)
self.assertEqual(
isinstance(vms, list),
True,
"List VMs should return valid response for deployed VM"
)
)
self.assertNotEqual(
len(vms),
0,
"List VMs should return valid response for deployed VM"
)
)
list_hosts_response = list_hosts(
self.apiclient,
id=vms[0].hostid
)
self.apiclient,
id=vms[0].hostid
)
self.assertEqual(
isinstance(list_hosts_response, list),
True,
"Check list response returns a valid list"
)
)
self.assertNotEqual(
len(list_hosts_response),
0,
"Check Host is available"
)
)
self.assertEqual(
list_hosts_response[0].hahost,
False,
"The virtual machine is not ha enabled so check if VM is created on host which is also not ha enabled"
)
)
self.debug("Disabling the maintenance mode for host %s" % vm_with_ha_disabled.hostid)
cmd = cancelHostMaintenance.cancelHostMaintenanceCmd()

View File

@ -186,7 +186,6 @@ class Services:
}
@unittest.skip("No suitable setup available for testing")
class TestVMLifeCycleHostmaintenance(cloudstackTestCase):
@classmethod
@ -562,7 +561,6 @@ class TestVMLifeCycleHostmaintenance(cloudstackTestCase):
return
@unittest.skip("No suitable setup available for testing")
class TestVPCNetworkRules(cloudstackTestCase):
@classmethod