mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-9187 - Adds test to cover multiple nics and nic removal
This commit is contained in:
parent
749ac2e224
commit
b1e4210682
|
|
@ -135,7 +135,7 @@ class Services:
|
|||
"vpc": {
|
||||
"name": "TestVPC",
|
||||
"displaytext": "TestVPC",
|
||||
"cidr": '10.0.0.1/24'
|
||||
"cidr": '10.0.0.0/16'
|
||||
},
|
||||
"network": {
|
||||
"name": "Test Network",
|
||||
|
|
@ -346,11 +346,11 @@ class TestVPCRedundancy(cloudstackTestCase):
|
|||
"Marvin configuration has no host credentials to\
|
||||
check router services")
|
||||
|
||||
if result.count(vals[0]) == 1:
|
||||
cnts[vals.index(vals[0])] += 1
|
||||
if result.count(status_to_check) == 1:
|
||||
cnts[vals.index(status_to_check)] += 1
|
||||
|
||||
if cnts[vals.index(status_to_check)] != expected_count:
|
||||
self.fail("Expected '%s' routers at state '%s', but found '%s'!" % (expected_count, status_to_check, cnts[vals.index('status_to_check')]))
|
||||
self.fail("Expected '%s' routers at state '%s', but found '%s'!" % (expected_count, status_to_check, cnts[vals.index(status_to_check)]))
|
||||
|
||||
def stop_router(self, router):
|
||||
self.logger.debug('Stopping router %s' % router.id)
|
||||
|
|
@ -398,7 +398,7 @@ class TestVPCRedundancy(cloudstackTestCase):
|
|||
cmd.id = router.id
|
||||
self.apiclient.startRouter(cmd)
|
||||
|
||||
def create_network(self, net_offerring, gateway='10.1.1.1', vpc=None, nr_vms=2):
|
||||
def create_network(self, net_offerring, gateway='10.1.1.1', vpc=None, nr_vms=2, mark_net_cleanup=True):
|
||||
if not nr_vms or nr_vms <= 0:
|
||||
self.fail("At least 1 VM has to be created. You informed nr_vms < 1")
|
||||
try:
|
||||
|
|
@ -430,17 +430,18 @@ class TestVPCRedundancy(cloudstackTestCase):
|
|||
except Exception, e:
|
||||
self.fail('Unable to create a Network with offering=%s because of %s ' % (net_offerring, e))
|
||||
o = networkO(obj_network)
|
||||
|
||||
for i in range(0, nr_vms):
|
||||
vm1 = self.deployvm_in_network(obj_network)
|
||||
o.add_vm(vm1)
|
||||
|
||||
self.cleanup.insert(2, obj_network)
|
||||
self.cleanup.insert(3, nw_off)
|
||||
self.cleanup.insert(0, nw_off)
|
||||
if mark_net_cleanup:
|
||||
self.cleanup.insert(0, obj_network)
|
||||
|
||||
for i in range(0, nr_vms):
|
||||
vm1 = self.deployvm_in_network(obj_network, mark_vm_cleanup=mark_net_cleanup)
|
||||
o.add_vm(vm1)
|
||||
|
||||
return o
|
||||
|
||||
def deployvm_in_network(self, network, host_id=None):
|
||||
def deployvm_in_network(self, network, host_id=None, mark_vm_cleanup=True):
|
||||
try:
|
||||
self.logger.debug('Creating VM in network=%s' % network.name)
|
||||
vm = VirtualMachine.create(
|
||||
|
|
@ -454,7 +455,8 @@ class TestVPCRedundancy(cloudstackTestCase):
|
|||
)
|
||||
|
||||
self.logger.debug('Created VM=%s in network=%s' % (vm.id, network.name))
|
||||
self.cleanup.insert(0, vm)
|
||||
if mark_vm_cleanup:
|
||||
self.cleanup.insert(0, vm)
|
||||
return vm
|
||||
except:
|
||||
self.fail('Unable to create VM in a Network=%s' % network.name)
|
||||
|
|
@ -521,7 +523,8 @@ class TestVPCRedundancy(cloudstackTestCase):
|
|||
self.fail("Failed to SSH into VM - %s" % (public_ip.ipaddress.ipaddress))
|
||||
|
||||
@attr(tags=["advanced", "intervlan"], required_hardware="true")
|
||||
def test_01_create_redundant_VPC_2tiers_4VMs_4IPs_4PF_ACL(self):
|
||||
def test_04_create_redundant_VPC_2tiers_4VMs_4IPs_4PF_ACL(self):
|
||||
self.skipTest("Skipping for now...")
|
||||
""" Create a redundant VPC with two networks with two VMs in each network """
|
||||
self.logger.debug("Starting test_01_create_redundant_VPC_2tiers_4VMs_4IPs_4PF_ACL")
|
||||
self.query_routers()
|
||||
|
|
@ -546,7 +549,8 @@ class TestVPCRedundancy(cloudstackTestCase):
|
|||
self.do_vpc_test(False)
|
||||
|
||||
@attr(tags=["advanced", "intervlan"], required_hardware="true")
|
||||
def test_02_redundant_VPC_default_routes(self):
|
||||
def test_05_redundant_VPC_default_routes(self):
|
||||
self.skipTest("Skipping for now...")
|
||||
""" Create a redundant VPC with two networks with two VMs in each network and check default routes"""
|
||||
self.logger.debug("Starting test_02_redundant_VPC_default_routes")
|
||||
self.query_routers()
|
||||
|
|
@ -558,6 +562,7 @@ class TestVPCRedundancy(cloudstackTestCase):
|
|||
|
||||
@attr(tags=["advanced", "intervlan"], required_hardware="true")
|
||||
def test_03_create_redundant_VPC_1tier_2VMs_2IPs_2PF_ACL_reboot_routers(self):
|
||||
self.skipTest("Skipping for now...")
|
||||
""" Create a redundant VPC with two networks with two VMs in each network """
|
||||
self.logger.debug("Starting test_01_create_redundant_VPC_2tiers_4VMs_4IPs_4PF_ACL")
|
||||
self.query_routers()
|
||||
|
|
@ -575,7 +580,7 @@ class TestVPCRedundancy(cloudstackTestCase):
|
|||
self.do_vpc_test(False)
|
||||
|
||||
@attr(tags=["advanced", "intervlan"], required_hardware="true")
|
||||
def test_04_rvpc_network_garbage_collector_nics(self):
|
||||
def test_01_rvpc_network_garbage_collector_nics(self):
|
||||
""" Create a redundant VPC with 1 Tier, 1 VM, 1 ACL, 1 PF and test Network GC Nics"""
|
||||
self.logger.debug("Starting test_04_rvpc_network_garbage_collector_nics")
|
||||
self.query_routers()
|
||||
|
|
@ -585,21 +590,66 @@ class TestVPCRedundancy(cloudstackTestCase):
|
|||
self.do_vpc_test(False)
|
||||
|
||||
self.stop_vm()
|
||||
|
||||
gc_wait = Configurations.list(self.apiclient, name="network.gc.wait")
|
||||
gc_interval = Configurations.list(self.apiclient, name="network.gc.interval")
|
||||
|
||||
self.logger.debug("network.gc.wait is ==> %s" % gc_wait)
|
||||
self.logger.debug("network.gc.interval is ==> %s" % gc_wait)
|
||||
|
||||
total_sleep = 90
|
||||
if gc_wait and gc_interval:
|
||||
total_sleep = int(gc_wait[0].value) + int(gc_interval[0].value)
|
||||
else:
|
||||
self.logger.debug("Could not retrieve the keys 'network.gc.interval' and 'network.gc.wait'. Sleeping for 2 minutes.")
|
||||
|
||||
time.sleep(total_sleep)
|
||||
|
||||
self.check_routers_state(status_to_check="BACKUP", expected_count=2)
|
||||
self.start_vm()
|
||||
self.check_routers_state(status_to_check="MASTER")
|
||||
self.do_vpc_test(False)
|
||||
|
||||
@attr(tags=["advanced", "intervlan"], required_hardware="true")
|
||||
def test_02_rvpc_multi_tiers(self):
|
||||
""" Create a redundant VPC with 1 Tier, 1 VM, 1 ACL, 1 PF and test Network GC Nics"""
|
||||
self.logger.debug("Starting test_04_rvpc_network_garbage_collector_nics")
|
||||
self.query_routers()
|
||||
|
||||
network = self.create_network(self.services["network_offering"], "10.1.1.1", nr_vms=1, mark_net_cleanup=False)
|
||||
self.networks.append(network)
|
||||
self.networks.append(self.create_network(self.services["network_offering_no_lb"], "10.1.2.1", nr_vms=1))
|
||||
self.networks.append(self.create_network(self.services["network_offering_no_lb"], "10.1.3.1", nr_vms=1))
|
||||
|
||||
self.check_routers_state()
|
||||
self.add_nat_rules()
|
||||
self.do_vpc_test(False)
|
||||
|
||||
self.destroy_vm(network)
|
||||
network.get_net().delete(self.apiclient)
|
||||
self.networks.remove(network)
|
||||
|
||||
self.check_routers_state(status_to_check="MASTER")
|
||||
self.do_vpc_test(False)
|
||||
|
||||
def destroy_vm(self, network):
|
||||
vms_to_delete = []
|
||||
for vm in network.get_vms():
|
||||
vm.get_vm().delete(self.apiclient, expunge=True)
|
||||
vms_to_delete.append(vm)
|
||||
|
||||
all_vms = network.get_vms()
|
||||
[all_vms.remove(vm) for vm in vms_to_delete]
|
||||
|
||||
def stop_vm(self):
|
||||
for o in self.networks:
|
||||
for vm in o.get_vms():
|
||||
vm.stop(self.apiclient)
|
||||
vm.get_vm().stop(self.apiclient)
|
||||
|
||||
def start_vm(self):
|
||||
for o in self.networks:
|
||||
for vm in o.get_vms():
|
||||
vm.start(self.apiclient)
|
||||
vm.get_vm().start(self.apiclient)
|
||||
|
||||
def delete_nat_rules(self):
|
||||
for o in self.networks:
|
||||
|
|
|
|||
Loading…
Reference in New Issue