mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-8340: Adding test case for stop/start operation for VPC router
Signed-off-by: SrikanteswaraRao Talluri <talluri@apache.org> This closes #122
This commit is contained in:
parent
6a881b9337
commit
c09427401a
@ -40,13 +40,17 @@ from marvin.lib.common import (get_zone,
|
||||
get_template,
|
||||
wait_for_cleanup,
|
||||
add_netscaler,
|
||||
list_networks)
|
||||
# For more info on ddt refer to http://ddt.readthedocs.org/en/latest/api.html#module-ddt
|
||||
list_networks,
|
||||
verifyRouterState)
|
||||
# For more info on ddt refer to
|
||||
# http://ddt.readthedocs.org/en/latest/api.html#module-ddt
|
||||
from ddt import ddt, data
|
||||
import time
|
||||
from marvin.codes import PASS
|
||||
|
||||
|
||||
class Services:
|
||||
|
||||
"""Test VPC network services
|
||||
"""
|
||||
|
||||
@ -91,7 +95,8 @@ class Services:
|
||||
"SourceNat": {"SupportedSourceNatTypes": "peraccount"},
|
||||
},
|
||||
},
|
||||
# Offering that uses Netscaler as provider for LB inside VPC, dedicated = false
|
||||
# Offering that uses Netscaler as provider for LB inside VPC,
|
||||
# dedicated = false
|
||||
"network_off_netscaler": {
|
||||
"name": 'Network offering-netscaler',
|
||||
"displaytext": 'Network offering-netscaler',
|
||||
@ -234,6 +239,7 @@ class Services:
|
||||
"timeout": 10,
|
||||
}
|
||||
|
||||
|
||||
@ddt
|
||||
class TestVPCNetwork(cloudstackTestCase):
|
||||
|
||||
@ -245,7 +251,8 @@ class TestVPCNetwork(cloudstackTestCase):
|
||||
cls.services = Services().services
|
||||
|
||||
# Added an attribute to track if Netscaler addition was successful.
|
||||
# Value is checked in tests and if not configured, Netscaler tests will be skipped
|
||||
# Value is checked in tests and if not configured, Netscaler tests will
|
||||
# be skipped
|
||||
cls.ns_configured = False
|
||||
# Get Zone, Domain and templates
|
||||
cls.domain = get_domain(cls.api_client)
|
||||
@ -265,9 +272,13 @@ class TestVPCNetwork(cloudstackTestCase):
|
||||
)
|
||||
cls._cleanup.append(cls.service_offering)
|
||||
# Configure Netscaler device
|
||||
# If configuration succeeds, set ns_configured to True so that Netscaler tests are executed
|
||||
# If configuration succeeds, set ns_configured to True so that
|
||||
# Netscaler tests are executed
|
||||
try:
|
||||
cls.netscaler = add_netscaler(cls.api_client, cls.zone.id, cls.services["netscaler"])
|
||||
cls.netscaler = add_netscaler(
|
||||
cls.api_client,
|
||||
cls.zone.id,
|
||||
cls.services["netscaler"])
|
||||
cls._cleanup.append(cls.netscaler)
|
||||
cls.debug("Netscaler configured")
|
||||
cls.ns_configured = True
|
||||
@ -302,7 +313,6 @@ class TestVPCNetwork(cloudstackTestCase):
|
||||
cleanup_resources(self.apiclient, self.cleanup)
|
||||
except Exception as e:
|
||||
self.debug("Warning: Exception during cleanup : %s" % e)
|
||||
#raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||
return
|
||||
|
||||
def validate_vpc_offering(self, vpc_offering):
|
||||
@ -367,12 +377,13 @@ class TestVPCNetwork(cloudstackTestCase):
|
||||
# all of supported Services(Vpn,dhcpdns,UserData, SourceNat,Static
|
||||
# NAT,LB and PF,LB,NetworkAcl ) provided by VPCVR and conserve
|
||||
# mode is ON
|
||||
# 3. Create a network tier using the network offering created in step2 as
|
||||
# part of this VPC.
|
||||
# 3. Create a network tier using the network offering created in
|
||||
# step 2 as part of this VPC.
|
||||
# 4. Validate Network is created
|
||||
# 5. Repeat test for offering which has Netscaler as external LB provider
|
||||
# 5. Repeat test for offering which has Netscaler as external LB
|
||||
# provider
|
||||
|
||||
if (value == "network_offering_vpcns" and self.ns_configured == False):
|
||||
if (value == "network_offering_vpcns" and not self.ns_configured):
|
||||
self.skipTest('Netscaler not configured: skipping test')
|
||||
|
||||
if (value == "network_offering"):
|
||||
@ -465,13 +476,14 @@ class TestVPCNetwork(cloudstackTestCase):
|
||||
# and conserve mode is ON
|
||||
# 3. Create a network using the network offering created in step2 as
|
||||
# part of this VPC.
|
||||
# 4. Network creation should fail since SourceNat offered by VR instead of VPCVR
|
||||
# 5. Repeat test for offering which has Netscaler as external LB provider
|
||||
# 4. Network creation should fail since SourceNat offered by VR
|
||||
# instead of VPCVR
|
||||
# 5. Repeat test for offering which has Netscaler as external LB
|
||||
# provider
|
||||
|
||||
if (value == "network_offering_vpcns" and self.ns_configured == False):
|
||||
if (value == "network_offering_vpcns" and not self.ns_configured):
|
||||
self.skipTest('Netscaler not configured: skipping test')
|
||||
|
||||
|
||||
if (value == "network_offering"):
|
||||
vpc_off_list = VpcOffering.list(
|
||||
self.apiclient,
|
||||
@ -541,11 +553,11 @@ class TestVPCNetwork(cloudstackTestCase):
|
||||
# 4. Create another network using the network offering created in
|
||||
# step3 as part of this VPC
|
||||
# 5. Create Network should fail
|
||||
# 6. Repeat test for offering which has Netscaler as external LB provider
|
||||
if (value == "network_offering_vpcns" and self.ns_configured == False):
|
||||
# 6. Repeat test for offering which has Netscaler as external LB
|
||||
# provider
|
||||
if (value == "network_offering_vpcns" and not self.ns_configured):
|
||||
self.skipTest('Netscaler not configured: skipping test')
|
||||
|
||||
|
||||
if (value == "network_offering"):
|
||||
vpc_off_list = VpcOffering.list(
|
||||
self.apiclient,
|
||||
@ -633,7 +645,8 @@ class TestVPCNetwork(cloudstackTestCase):
|
||||
vpcid=vpc.id
|
||||
)
|
||||
self.debug(
|
||||
"Network creation failed as network with LB service already exists")
|
||||
"Network creation failed as network with LB service\
|
||||
already exists")
|
||||
return
|
||||
|
||||
@attr(tags=["intervlan"])
|
||||
@ -783,7 +796,8 @@ class TestVPCNetwork(cloudstackTestCase):
|
||||
# 5. Create network fails since VPC offering doesn't support LB
|
||||
|
||||
self.debug("Creating a VPC offering without LB service")
|
||||
self.services["vpc_offering"]["supportedservices"] = 'Dhcp,Dns,SourceNat,PortForwarding,Vpn,UserData,StaticNat'
|
||||
self.services["vpc_offering"][
|
||||
"supportedservices"] = 'Dhcp,Dns,SourceNat,PortForwarding,Vpn,UserData,StaticNat'
|
||||
|
||||
vpc_off = VpcOffering.create(
|
||||
self.apiclient,
|
||||
@ -852,7 +866,8 @@ class TestVPCNetwork(cloudstackTestCase):
|
||||
# part of this VPC
|
||||
|
||||
self.debug("Creating a VPC offering without LB service")
|
||||
self.services["vpc_offering"]["supportedservices"] = 'Dhcp,Dns,SourceNat,PortForwarding,UserData,StaticNat'
|
||||
self.services["vpc_offering"][
|
||||
"supportedservices"] = 'Dhcp,Dns,SourceNat,PortForwarding,UserData,StaticNat'
|
||||
|
||||
vpc_off = VpcOffering.create(
|
||||
self.apiclient,
|
||||
@ -879,7 +894,8 @@ class TestVPCNetwork(cloudstackTestCase):
|
||||
self.validate_vpc_network(vpc)
|
||||
|
||||
self.debug("Creating network offering without SourceNAT service")
|
||||
self.services["network_offering"]["supportedservices"] = 'Dhcp,Dns,PortForwarding,Lb,UserData,StaticNat,NetworkACL'
|
||||
self.services["network_offering"][
|
||||
"supportedservices"] = 'Dhcp,Dns,PortForwarding,Lb,UserData,StaticNat,NetworkACL'
|
||||
self.services["network_offering"]["serviceProviderList"] = {
|
||||
"Dhcp": 'VpcVirtualRouter',
|
||||
"Dns": 'VpcVirtualRouter',
|
||||
@ -910,11 +926,13 @@ class TestVPCNetwork(cloudstackTestCase):
|
||||
# 1. Create VPC Offering using Default Offering
|
||||
# 2. Create a VPC using the above VPC offering
|
||||
# 3. Create a network offering with guest type=shared
|
||||
# 4. Create a network using the network offering created in step3 as part of this VPC
|
||||
# 4. Create a network using the network offering created
|
||||
# in step3 as part of this VPC
|
||||
# 5. Create network fails since it using shared offering
|
||||
# 6. Repeat test for offering which has Netscaler as external LB provider
|
||||
# 6. Repeat test for offering which has Netscaler as external LB
|
||||
# provider
|
||||
|
||||
if (value == "network_offering_vpcns" and self.ns_configured == False):
|
||||
if (value == "network_offering_vpcns" and not self.ns_configured):
|
||||
self.skipTest('Netscaler not configured: skipping test')
|
||||
|
||||
if (value == "network_off_shared"):
|
||||
@ -982,8 +1000,10 @@ class TestVPCNetwork(cloudstackTestCase):
|
||||
# 1. Create a network offering with guest type=Isolated that has all
|
||||
# supported Services(Vpn,dhcpdns,UserData, SourceNat,Static NAT,LB
|
||||
# and PF,LB,NetworkAcl ) provided by VPCVR and conserve mode is ON
|
||||
# 2. Create offering fails since Conserve mode ON isn't allowed within VPC
|
||||
# 3. Repeat test for offering which has Netscaler as external LB provider
|
||||
# 2. Create offering fails since Conserve mode ON isn't allowed within
|
||||
# VPC
|
||||
# 3. Repeat test for offering which has Netscaler as external LB
|
||||
# provider
|
||||
|
||||
self.debug("Creating network offering with conserve mode = ON")
|
||||
|
||||
@ -997,6 +1017,7 @@ class TestVPCNetwork(cloudstackTestCase):
|
||||
"Network creation failed as VPC support nw with conserve mode OFF")
|
||||
return
|
||||
|
||||
|
||||
@ddt
|
||||
class TestVPCNetworkRanges(cloudstackTestCase):
|
||||
|
||||
@ -1008,7 +1029,8 @@ class TestVPCNetworkRanges(cloudstackTestCase):
|
||||
cls.services = Services().services
|
||||
|
||||
# Added an attribute to track if Netscaler addition was successful.
|
||||
# Value is checked in tests and if not configured, Netscaler tests will be skipped
|
||||
# Value is checked in tests and if not configured, Netscaler tests will
|
||||
# be skipped
|
||||
cls.ns_configured = False
|
||||
# Get Zone, Domain and templates
|
||||
cls.domain = get_domain(cls.api_client)
|
||||
@ -1028,9 +1050,13 @@ class TestVPCNetworkRanges(cloudstackTestCase):
|
||||
)
|
||||
cls._cleanup.append(cls.service_offering)
|
||||
# Configure Netscaler device
|
||||
# If configuration succeeds, set ns_configured to True so that Netscaler tests are executed
|
||||
# If configuration succeeds, set ns_configured to True so that
|
||||
# Netscaler tests are executed
|
||||
try:
|
||||
cls.netscaler = add_netscaler(cls.api_client, cls.zone.id, cls.services["netscaler"])
|
||||
cls.netscaler = add_netscaler(
|
||||
cls.api_client,
|
||||
cls.zone.id,
|
||||
cls.services["netscaler"])
|
||||
cls._cleanup.append(cls.netscaler)
|
||||
cls.ns_configured = True
|
||||
except Exception as e:
|
||||
@ -1125,9 +1151,10 @@ class TestVPCNetworkRanges(cloudstackTestCase):
|
||||
# 1. Create a VPC with cidr - 10.1.1.1/16
|
||||
# 2. Add network1 with cidr - 10.2.1.1/24 to this VPC
|
||||
# 3. Network creation should fail.
|
||||
# 4. Repeat test for offering which has Netscaler as external LB provider
|
||||
# 4. Repeat test for offering which has Netscaler as external LB
|
||||
# provider
|
||||
|
||||
if (value == "network_offering_vpcns" and self.ns_configured == False):
|
||||
if (value == "network_offering_vpcns" and not self.ns_configured):
|
||||
self.skipTest('Netscaler not configured: skipping test')
|
||||
|
||||
if (value == "network_offering"):
|
||||
@ -1193,7 +1220,8 @@ class TestVPCNetworkRanges(cloudstackTestCase):
|
||||
# 1. Create a VPC with cidr - 10.1.1.1/16
|
||||
# 2. Add network1 with cidr - 10.2.1.1/24 to this VPC
|
||||
# 3. Network creation should fail.
|
||||
# 4. Repeat test for offering which has Netscaler as external LB provider
|
||||
# 4. Repeat test for offering which has Netscaler as external LB
|
||||
# provider
|
||||
|
||||
self.debug("Creating a VPC offering")
|
||||
vpc_off = VpcOffering.create(
|
||||
@ -1257,9 +1285,10 @@ class TestVPCNetworkRanges(cloudstackTestCase):
|
||||
# 1. Create a VPC with cidr - 10.1.1.1/16
|
||||
# 2. Add network1 with cidr - 10.1.1.1/8 to this VPC
|
||||
# 3. Network creation should fail.
|
||||
# 4. Repeat test for offering which has Netscaler as external LB provider
|
||||
# 4. Repeat test for offering which has Netscaler as external LB
|
||||
# provider
|
||||
|
||||
if (value == "network_offering_vpcns" and self.ns_configured == False):
|
||||
if (value == "network_offering_vpcns" and not self.ns_configured):
|
||||
self.skipTest('Netscaler not configured: skipping test')
|
||||
|
||||
if (value == "network_offering"):
|
||||
@ -1332,10 +1361,11 @@ class TestVPCNetworkRanges(cloudstackTestCase):
|
||||
# 3. Add network2 with cidr - 10.1.1.1/24 to this VPC
|
||||
# 4. Add network3 with cidr - 10.1.1.1/26 to this VPC
|
||||
# 5. Network creation in step 3 & 4 should fail.
|
||||
# 6. Repeat test for offering which has Netscaler as external LB provider
|
||||
# 6. Repeat test for offering which has Netscaler as external LB
|
||||
# provider
|
||||
|
||||
self.services = Services().services
|
||||
if (value == "network_offering_vpcns" and self.ns_configured == False):
|
||||
if (value == "network_offering_vpcns" and not self.ns_configured):
|
||||
self.skipTest('Netscaler not configured: skipping test')
|
||||
|
||||
if (value == "network_offering"):
|
||||
@ -1429,7 +1459,7 @@ class TestVPCNetworkRanges(cloudstackTestCase):
|
||||
gateway='10.1.1.1',
|
||||
vpcid=vpc.id
|
||||
)
|
||||
self.debug("Network creation as network range 10.1.1.1/24 is same" + \
|
||||
self.debug("Network creation as network range 10.1.1.1/24 is same" +
|
||||
"as that of existing network")
|
||||
|
||||
self.debug("Creating network having overlapping network ranges")
|
||||
@ -1462,9 +1492,10 @@ class TestVPCNetworkRanges(cloudstackTestCase):
|
||||
# 2. Add network1 with cidr - 10.1.1.1/24 to this VPC
|
||||
# 3. Create another account
|
||||
# 4. Create network using this account - Network creation should fail
|
||||
# 5. Repeat test for offering which has Netscaler as external LB provider
|
||||
# 5. Repeat test for offering which has Netscaler as external LB
|
||||
# provider
|
||||
|
||||
if (value == "network_offering_vpcns" and self.ns_configured == False):
|
||||
if (value == "network_offering_vpcns" and not self.ns_configured):
|
||||
self.skipTest('Netscaler not configured: skipping test')
|
||||
|
||||
if (value == "network_offering"):
|
||||
@ -1536,6 +1567,7 @@ class TestVPCNetworkRanges(cloudstackTestCase):
|
||||
"Network creation failed as VPC belongs to different account")
|
||||
return
|
||||
|
||||
|
||||
class TestVPCNetworkUpgrade(cloudstackTestCase):
|
||||
|
||||
@classmethod
|
||||
@ -1645,7 +1677,8 @@ class TestVPCNetworkUpgrade(cloudstackTestCase):
|
||||
|
||||
@attr(tags=["advanced", "intervlan"], required_hardware="true")
|
||||
def test_01_network_services_upgrade(self):
|
||||
""" Test update Network that is part of a VPC to a network offering that has more services
|
||||
""" Test update Network that is part of a VPC to a network
|
||||
offering that has more services
|
||||
"""
|
||||
|
||||
# Validate the following
|
||||
@ -1691,7 +1724,8 @@ class TestVPCNetworkUpgrade(cloudstackTestCase):
|
||||
nw_off.update(self.apiclient, state='Enabled')
|
||||
self.cleanup.append(nw_off)
|
||||
|
||||
self.services["network_offering"]["supportedservices"] = 'Vpn,Dhcp,Dns,SourceNat,UserData,Lb,StaticNat,NetworkACL'
|
||||
self.services["network_offering"][
|
||||
"supportedservices"] = 'Vpn,Dhcp,Dns,SourceNat,UserData,Lb,StaticNat,NetworkACL'
|
||||
self.services["network_offering"]["serviceProviderList"] = {
|
||||
"Vpn": 'VpcVirtualRouter',
|
||||
"Dhcp": 'VpcVirtualRouter',
|
||||
@ -1931,18 +1965,26 @@ class TestVPCNetworkUpgrade(cloudstackTestCase):
|
||||
except Exception as e:
|
||||
self.fail("Failed to stop VMs, %s" % e)
|
||||
|
||||
# When all Vms ain network are stopped, network state changes from Implemented --> Shutdown --> Allocated
|
||||
# We can't update the network when it is in Shutodown state, hence we should wait for the state to change to
|
||||
# Allocated and then update the network
|
||||
# When all Vms ain network are stopped, network state changes
|
||||
# from Implemented --> Shutdown --> Allocated
|
||||
# We can't update the network when it is in Shutodown state, hence
|
||||
# we should wait for the state to change to allocated and
|
||||
# then update the network
|
||||
retriesCount = 20
|
||||
while True:
|
||||
networks = list_networks(self.apiclient, id=network_1.id)
|
||||
self.assertEqual(validateList(networks)[0], PASS, "networks list validation failed, list id %s" % networks)
|
||||
self.assertEqual(
|
||||
validateList(networks)[0],
|
||||
PASS,
|
||||
"networks list validation failed, list id %s" %
|
||||
networks)
|
||||
self.debug("network state is %s" % networks[0].state)
|
||||
if networks[0].state == "Allocated":
|
||||
break
|
||||
if retriesCount == 0:
|
||||
self.fail("Network state should change to Allocated, it is %s" % networks[0].state)
|
||||
self.fail(
|
||||
"Network state should change to Allocated, it is %s" %
|
||||
networks[0].state)
|
||||
retriesCount -= 1
|
||||
time.sleep(60)
|
||||
|
||||
@ -2005,7 +2047,8 @@ class TestVPCNetworkUpgrade(cloudstackTestCase):
|
||||
|
||||
@attr(tags=["advanced", "intervlan"], required_hardware="true")
|
||||
def test_02_network_vpcvr2vr_upgrade(self):
|
||||
""" Test update Network that is NOT part of a VPC to a nw offering that has services that are provided by VPCVR and vice versa
|
||||
""" Test update Network that is NOT part of a VPC to a nw offering
|
||||
that has services that are provided by VPCVR and vice versa
|
||||
"""
|
||||
|
||||
# Validate the following
|
||||
@ -2050,7 +2093,8 @@ class TestVPCNetworkUpgrade(cloudstackTestCase):
|
||||
nw_off.update(self.apiclient, state='Enabled')
|
||||
self.cleanup.append(nw_off)
|
||||
|
||||
self.services["network_offering"]["supportedservices"] = 'Vpn,Dhcp,Dns,SourceNat,PortForwarding,UserData,Lb,StaticNat'
|
||||
self.services["network_offering"][
|
||||
"supportedservices"] = 'Vpn,Dhcp,Dns,SourceNat,PortForwarding,UserData,Lb,StaticNat'
|
||||
self.services["network_offering"]["serviceProviderList"] = {
|
||||
"Vpn": 'VirtualRouter',
|
||||
"Dhcp": 'VirtualRouter',
|
||||
@ -2113,6 +2157,7 @@ class TestVPCNetworkUpgrade(cloudstackTestCase):
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
class TestVPCNetworkGc(cloudstackTestCase):
|
||||
|
||||
@classmethod
|
||||
@ -2356,14 +2401,20 @@ class TestVPCNetworkGc(cloudstackTestCase):
|
||||
wait_for_cleanup(self.apiclient,
|
||||
["network.gc.interval", "network.gc.wait"])
|
||||
|
||||
lbrules = LoadBalancerRule.list(self.apiclient, networkid=self.network_1.id)
|
||||
lbrules = LoadBalancerRule.list(
|
||||
self.apiclient,
|
||||
networkid=self.network_1.id)
|
||||
self.debug("List of LB Rules %s" % lbrules)
|
||||
self.assertEqual(lbrules, None, "LBrules were not cleared after network GC thread is run")
|
||||
self.assertEqual(
|
||||
lbrules,
|
||||
None,
|
||||
"LBrules were not cleared after network GC thread is run")
|
||||
return
|
||||
|
||||
@attr(tags=["advanced", "intervlan"], required_hardware="true")
|
||||
def test_02_start_vm_network_gc(self):
|
||||
""" Test network rules after starting a VpcVr that was shutdown after network.gc
|
||||
""" Test network rules after starting a VpcVr that
|
||||
was shutdown after network.gc
|
||||
"""
|
||||
|
||||
# Validate the following
|
||||
@ -2533,3 +2584,167 @@ class TestVPCNetworkGc(cloudstackTestCase):
|
||||
"Ping to outside world from VM should be successful"
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
class TestRouterOperations(cloudstackTestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.testClient = super(TestRouterOperations, cls).getClsTestClient()
|
||||
cls.api_client = cls.testClient.getApiClient()
|
||||
|
||||
cls.services = Services().services
|
||||
|
||||
# Get Zone, Domain and templates
|
||||
cls.domain = get_domain(cls.api_client)
|
||||
cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
|
||||
cls.template = get_template(
|
||||
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._cleanup = []
|
||||
|
||||
cls.service_offering = ServiceOffering.create(
|
||||
cls.api_client,
|
||||
cls.services["service_offering"]
|
||||
)
|
||||
cls.vpc_off = VpcOffering.create(
|
||||
cls.api_client,
|
||||
cls.services["vpc_offering"]
|
||||
)
|
||||
cls.vpc_off.update(cls.api_client, state='Enabled')
|
||||
|
||||
cls.account = Account.create(
|
||||
cls.api_client,
|
||||
cls.services["account"],
|
||||
admin=True,
|
||||
domainid=cls.domain.id
|
||||
)
|
||||
cls._cleanup.append(cls.account)
|
||||
|
||||
cls.services["vpc"]["cidr"] = '10.1.1.1/16'
|
||||
cls.vpc = VPC.create(
|
||||
cls.api_client,
|
||||
cls.services["vpc"],
|
||||
vpcofferingid=cls.vpc_off.id,
|
||||
zoneid=cls.zone.id,
|
||||
account=cls.account.name,
|
||||
domainid=cls.account.domainid
|
||||
)
|
||||
|
||||
cls.nw_off = NetworkOffering.create(
|
||||
cls.api_client,
|
||||
cls.services["network_offering"],
|
||||
conservemode=False
|
||||
)
|
||||
# Enable Network offering
|
||||
cls.nw_off.update(cls.api_client, state='Enabled')
|
||||
cls._cleanup.append(cls.nw_off)
|
||||
cls._cleanup.append(cls.vpc_off)
|
||||
|
||||
cls.network_1 = Network.create(
|
||||
cls.api_client,
|
||||
cls.services["network"],
|
||||
accountid=cls.account.name,
|
||||
domainid=cls.account.domainid,
|
||||
networkofferingid=cls.nw_off.id,
|
||||
zoneid=cls.zone.id,
|
||||
gateway='10.1.1.1',
|
||||
vpcid=cls.vpc.id
|
||||
)
|
||||
# Spawn an instance in that network
|
||||
cls.vm_1 = VirtualMachine.create(
|
||||
cls.api_client,
|
||||
cls.services["virtual_machine"],
|
||||
accountid=cls.account.name,
|
||||
domainid=cls.account.domainid,
|
||||
serviceofferingid=cls.service_offering.id,
|
||||
networkids=[str(cls.network_1.id)]
|
||||
)
|
||||
return
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
try:
|
||||
# Cleanup resources used
|
||||
cleanup_resources(cls.api_client, cls._cleanup)
|
||||
except Exception as e:
|
||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||
return
|
||||
|
||||
def setUp(self):
|
||||
self.apiclient = self.testClient.getApiClient()
|
||||
self.dbclient = self.testClient.getDbConnection()
|
||||
return
|
||||
|
||||
def tearDown(self):
|
||||
return
|
||||
|
||||
@attr(tags=["advanced", "intervlan"], required_hardware="true")
|
||||
def test_stop_start_vpc_router(self):
|
||||
""" Test stop and start VPC router
|
||||
|
||||
# 1. List the router in VPC network
|
||||
# 2. Stop the router and verify that router is in stopped state
|
||||
# 3. Start the router and verify that router is in running state
|
||||
"""
|
||||
|
||||
# Validate the following
|
||||
# 1. Stop vm3 and vm4
|
||||
# 2. Wait for network GC. Restart VPC VR
|
||||
# 3. All the network rules created shall continue to work.
|
||||
|
||||
self.debug("Finding the VPC virtual router for account: %s" %
|
||||
self.account.name)
|
||||
routers = Router.list(
|
||||
self.apiclient,
|
||||
account=self.account.name,
|
||||
domainid=self.account.domainid,
|
||||
listall=True
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(routers, list),
|
||||
True,
|
||||
"List routers shall return a valid list"
|
||||
)
|
||||
vpcvr = routers[0]
|
||||
self.debug("restarting the VPC virtual router")
|
||||
|
||||
try:
|
||||
Router.stop(
|
||||
self.apiclient,
|
||||
id=vpcvr.id
|
||||
)
|
||||
except Exception as e:
|
||||
self.fail("Failed to stop the virtual router: %s, %s" %
|
||||
(vpcvr.id, e))
|
||||
|
||||
response = verifyRouterState(self.apiclient, vpcvr.id, "stopped")
|
||||
exceptionOccured = response[0]
|
||||
isRouterInDesiredState = response[1]
|
||||
exceptionMessage = response[2]
|
||||
|
||||
if (exceptionOccured or (not isRouterInDesiredState)):
|
||||
self.fail(exceptionMessage)
|
||||
|
||||
self.debug("Starting the router with ID: %s" % vpcvr.id)
|
||||
try:
|
||||
Router.start(
|
||||
self.apiclient,
|
||||
id=vpcvr.id
|
||||
)
|
||||
except Exception as e:
|
||||
self.fail("Failed to start the virtual router: %s, %s" %
|
||||
(vpcvr.id, e))
|
||||
|
||||
response = verifyRouterState(self.apiclient, vpcvr.id, "running")
|
||||
exceptionOccured = response[0]
|
||||
isRouterInDesiredState = response[1]
|
||||
exceptionMessage = response[2]
|
||||
|
||||
if (exceptionOccured or (not isRouterInDesiredState)):
|
||||
self.fail(exceptionMessage)
|
||||
return
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user