CLOUDSTACK:4537 - Fixed shared network and vpc test cases

Signed-off-by: venkataswamybabu budumuru <venkataswamybabu.budumuru@citrix.com>
This commit is contained in:
Gaurav Aradhye 2013-09-20 02:41:37 -04:00 committed by venkataswamybabu budumuru
parent fbf057a323
commit 98daad9300

View File

@ -189,7 +189,6 @@ class Services:
"mode": 'advanced' "mode": 'advanced'
} }
class TestVMLifeCycleVPC(cloudstackTestCase): class TestVMLifeCycleVPC(cloudstackTestCase):
@classmethod @classmethod
@ -927,13 +926,6 @@ class TestVMLifeCycleSharedNwVPC(cloudstackTestCase):
domainid=cls.domain.id domainid=cls.domain.id
) )
cls.vpc_off = VpcOffering.create(
cls.api_client,
cls.services["vpc_offering"]
)
cls.vpc_off.update(cls.api_client, state='Enabled')
cls.services["vpc"]["cidr"] = '10.1.1.1/16' cls.services["vpc"]["cidr"] = '10.1.1.1/16'
cls.vpc = VPC.create( cls.vpc = VPC.create(
cls.api_client, cls.api_client,
@ -984,6 +976,10 @@ class TestVMLifeCycleSharedNwVPC(cloudstackTestCase):
cls.services["network"]["physicalnetworkid"] = physical_network.id cls.services["network"]["physicalnetworkid"] = physical_network.id
cls.services["network"]["vlan"] = shared_vlan cls.services["network"]["vlan"] = shared_vlan
# Start Ip and End Ip should be specified for shared network
cls.services["network"]["startip"] = '10.1.2.20'
cls.services["network"]["endip"] = '10.1.2.30'
# Creating network using the network offering created # Creating network using the network offering created
cls.network_2 = Network.create( cls.network_2 = Network.create(
cls.api_client, cls.api_client,
@ -994,7 +990,7 @@ class TestVMLifeCycleSharedNwVPC(cloudstackTestCase):
zoneid=cls.zone.id, zoneid=cls.zone.id,
gateway='10.1.2.1', gateway='10.1.2.1',
) )
# Spawn an instance in that network
cls.vm_1 = VirtualMachine.create( cls.vm_1 = VirtualMachine.create(
cls.api_client, cls.api_client,
cls.services["virtual_machine"], cls.services["virtual_machine"],
@ -1004,7 +1000,7 @@ class TestVMLifeCycleSharedNwVPC(cloudstackTestCase):
networkids=[str(cls.network_1.id), networkids=[str(cls.network_1.id),
str(cls.network_2.id)] str(cls.network_2.id)]
) )
# Spawn an instance in that network
cls.vm_2 = VirtualMachine.create( cls.vm_2 = VirtualMachine.create(
cls.api_client, cls.api_client,
cls.services["virtual_machine"], cls.services["virtual_machine"],
@ -1014,6 +1010,8 @@ class TestVMLifeCycleSharedNwVPC(cloudstackTestCase):
networkids=[str(cls.network_1.id), networkids=[str(cls.network_1.id),
str(cls.network_2.id)] str(cls.network_2.id)]
) )
cls.vm_3 = VirtualMachine.create( cls.vm_3 = VirtualMachine.create(
cls.api_client, cls.api_client,
cls.services["virtual_machine"], cls.services["virtual_machine"],
@ -1023,6 +1021,7 @@ class TestVMLifeCycleSharedNwVPC(cloudstackTestCase):
networkids=[str(cls.network_1.id), networkids=[str(cls.network_1.id),
str(cls.network_2.id)] str(cls.network_2.id)]
) )
cls.public_ip_1 = PublicIPAddress.create( cls.public_ip_1 = PublicIPAddress.create(
cls.api_client, cls.api_client,
accountid=cls.account.name, accountid=cls.account.name,
@ -1040,7 +1039,10 @@ class TestVMLifeCycleSharedNwVPC(cloudstackTestCase):
vpcid=cls.vpc.id, vpcid=cls.vpc.id,
domainid=cls.account.domainid domainid=cls.account.domainid
) )
cls.lb_rule.assign(cls.api_client, [cls.vm_1, cls.vm_2, cls.vm_3])
# Only the vms in the same network can be added to load balancing rule
# hence we can't add vm_2 with vm_1
cls.lb_rule.assign(cls.api_client, [cls.vm_1])
cls.public_ip_2 = PublicIPAddress.create( cls.public_ip_2 = PublicIPAddress.create(
cls.api_client, cls.api_client,
@ -1084,16 +1086,20 @@ class TestVMLifeCycleSharedNwVPC(cloudstackTestCase):
) )
cls._cleanup = [ cls._cleanup = [
cls.account, cls.account,
cls.service_offering, cls.network_2,
cls.nw_off, cls.nw_off,
cls.shared_nw_off, cls.shared_nw_off,
cls.vpc_off cls.vpc_off,
cls.service_offering,
] ]
return return
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
try: try:
cls.vpc_off.update(cls.api_client, state='Disabled')
cls.shared_nw_off.update(cls.api_client, state='Disabled')
cls.nw_off.update(cls.api_client, state='Disabled')
cleanup_resources(cls.api_client, cls._cleanup) cleanup_resources(cls.api_client, cls._cleanup)
except Exception as e: except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e) raise Exception("Warning: Exception during cleanup : %s" % e)
@ -1381,6 +1387,9 @@ class TestVMLifeCycleSharedNwVPC(cloudstackTestCase):
except Exception as e: except Exception as e:
self.fail("Failed to destroy the virtual instances, %s" % e) self.fail("Failed to destroy the virtual instances, %s" % e)
#Wait for expunge interval to cleanup VM
wait_for_cleanup(self.apiclient, ["expunge.delay", "expunge.interval"])
self.debug("Check if the instance is in stopped state?") self.debug("Check if the instance is in stopped state?")
vms = VirtualMachine.list( vms = VirtualMachine.list(
self.apiclient, self.apiclient,
@ -1388,15 +1397,9 @@ class TestVMLifeCycleSharedNwVPC(cloudstackTestCase):
listall=True listall=True
) )
self.assertEqual( self.assertEqual(
isinstance(vms, list), vms,
True, None,
"List virtual machines should return a valid list" "List virtual machines should not return anything"
)
vm = vms[0]
self.assertEqual(
vm.state,
"Expunging",
"Virtual machine should be in expunging state"
) )
self.debug("Validating if network rules are coonfigured properly?") self.debug("Validating if network rules are coonfigured properly?")
@ -1652,7 +1655,7 @@ class TestVMLifeCycleSharedNwVPC(cloudstackTestCase):
["expunge.interval", "expunge.delay"] ["expunge.interval", "expunge.delay"]
) )
# Check if the network rules still exists after Vm expunged # Check if the network rules still exists after Vm expunged
self.debug("Checking if NAT rules existed ") self.debug("Checking if NAT rules existed ")
with self.assertRaises(Exception): with self.assertRaises(Exception):
nat_rules = NATRule.list( nat_rules = NATRule.list(
@ -1668,7 +1671,6 @@ class TestVMLifeCycleSharedNwVPC(cloudstackTestCase):
) )
return return
class TestVMLifeCycleBothIsolated(cloudstackTestCase): class TestVMLifeCycleBothIsolated(cloudstackTestCase):
@classmethod @classmethod
@ -2004,7 +2006,6 @@ class TestVMLifeCycleBothIsolated(cloudstackTestCase):
) )
return return
class TestVMLifeCycleStoppedVPCVR(cloudstackTestCase): class TestVMLifeCycleStoppedVPCVR(cloudstackTestCase):
@classmethod @classmethod
@ -2690,7 +2691,7 @@ class TestVMLifeCycleStoppedVPCVR(cloudstackTestCase):
["expunge.interval", "expunge.delay"] ["expunge.interval", "expunge.delay"]
) )
# Check if the network rules still exists after Vm expunged # Check if the network rules still exists after Vm expunged
self.debug("Checking if NAT rules existed ") self.debug("Checking if NAT rules existed ")
with self.assertRaises(Exception): with self.assertRaises(Exception):
nat_rules = NATRule.list( nat_rules = NATRule.list(