mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
CLOUDSTACK-8018: Improve code quality - test_redundant_router.py
Signed-off-by: SrikanteswaraRao Talluri <talluri@apache.org>
This commit is contained in:
parent
84aaef25d9
commit
100e46bf4e
@ -16,126 +16,34 @@
|
||||
# under the License.
|
||||
|
||||
from nose.plugins.attrib import attr
|
||||
from marvin.lib.base import *
|
||||
from marvin.lib.utils import *
|
||||
from marvin.lib.common import *
|
||||
from marvin.lib.base import (Account,
|
||||
Router,
|
||||
NetworkOffering,
|
||||
Network,
|
||||
VirtualMachine,
|
||||
ServiceOffering,
|
||||
Host)
|
||||
from marvin.lib.utils import cleanup_resources
|
||||
from marvin.lib.common import (get_domain,
|
||||
get_template,
|
||||
get_zone,
|
||||
get_process_status)
|
||||
import time
|
||||
|
||||
# Import Local Modules
|
||||
from marvin.cloudstackTestCase import cloudstackTestCase
|
||||
from marvin.cloudstackAPI import *
|
||||
|
||||
class Services:
|
||||
"""Test Services for customer defects
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.services = {
|
||||
"account": {
|
||||
"email": "test@test.com",
|
||||
"firstname": "Test",
|
||||
"lastname": "User",
|
||||
"username": "test",
|
||||
# Random characters are appended for unique
|
||||
# username
|
||||
"password": "password",
|
||||
},
|
||||
"service_offering": {
|
||||
"name": "Tiny Instance",
|
||||
"displaytext": "Tiny Instance",
|
||||
"cpunumber": 1,
|
||||
"cpuspeed": 100,
|
||||
"memory": 128,
|
||||
},
|
||||
"disk_offering": {
|
||||
"displaytext": "Small",
|
||||
"name": "Small",
|
||||
"disksize": 1
|
||||
},
|
||||
"virtual_machine": {
|
||||
"displayname": "Test VM",
|
||||
"username": "root",
|
||||
"password": "password",
|
||||
"ssh_port": 22,
|
||||
"hypervisor": 'XenServer',
|
||||
"privateport": 22,
|
||||
"publicport": 22,
|
||||
"protocol": 'TCP',
|
||||
},
|
||||
"static_nat": {
|
||||
"startport": 22,
|
||||
"endport": 22,
|
||||
"protocol": "TCP"
|
||||
},
|
||||
"network_offering": {
|
||||
"name": 'Network offering-RVR services',
|
||||
"displaytext": 'Network off-RVR services',
|
||||
"guestiptype": 'Isolated',
|
||||
"supportedservices": 'Vpn,Dhcp,Dns,SourceNat,PortForwarding,Firewall,Lb,UserData,StaticNat',
|
||||
"traffictype": 'GUEST',
|
||||
"availability": 'Optional',
|
||||
"serviceProviderList": {
|
||||
"Vpn": 'VirtualRouter',
|
||||
"Dhcp": 'VirtualRouter',
|
||||
"Dns": 'VirtualRouter',
|
||||
"SourceNat": 'VirtualRouter',
|
||||
"PortForwarding": 'VirtualRouter',
|
||||
"Firewall": 'VirtualRouter',
|
||||
"Lb": 'VirtualRouter',
|
||||
"UserData": 'VirtualRouter',
|
||||
"StaticNat": 'VirtualRouter',
|
||||
},
|
||||
"serviceCapabilityList": {
|
||||
"SourceNat": {
|
||||
"SupportedSourceNatTypes": "peraccount",
|
||||
"RedundantRouter": "true",
|
||||
},
|
||||
"lb": {
|
||||
"SupportedLbIsolation": "dedicated"
|
||||
},
|
||||
},
|
||||
},
|
||||
"network": {
|
||||
"name": "Test Network",
|
||||
"displaytext": "Test Network",
|
||||
},
|
||||
"lbrule": {
|
||||
"name": "SSH",
|
||||
"alg": "roundrobin",
|
||||
# Algorithm used for load balancing
|
||||
"privateport": 22,
|
||||
"publicport": 22,
|
||||
"openfirewall": True,
|
||||
},
|
||||
"natrule": {
|
||||
"privateport": 22,
|
||||
"publicport": 22,
|
||||
"protocol": "TCP"
|
||||
},
|
||||
"natrule_221": {
|
||||
"privateport": 22,
|
||||
"publicport": 221,
|
||||
"protocol": "TCP"
|
||||
},
|
||||
"fw_rule": {
|
||||
"startport": 1,
|
||||
"endport": 6000,
|
||||
"cidr": '55.55.0.0/11',
|
||||
# Any network (For creating FW rule)
|
||||
"protocol": 'TCP',
|
||||
},
|
||||
"ostype": 'CentOS 5.3 (64-bit)',
|
||||
"sleep": 60,
|
||||
}
|
||||
|
||||
|
||||
class TestCreateRvRNetworkOffering(cloudstackTestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.testClient = super(TestCreateRvRNetworkOffering, cls).getClsTestClient()
|
||||
cls.testClient = super(
|
||||
TestCreateRvRNetworkOffering,
|
||||
cls).getClsTestClient()
|
||||
cls.api_client = cls.testClient.getApiClient()
|
||||
|
||||
cls.services = Services().services
|
||||
cls.testdata = cls.testClient.getParsedTestDataConfig()
|
||||
# Get Zone, Domain and templates
|
||||
cls.domain = get_domain(cls.api_client)
|
||||
cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
|
||||
@ -183,7 +91,7 @@ class TestCreateRvRNetworkOffering(cloudstackTestCase):
|
||||
try:
|
||||
network_offering = NetworkOffering.create(
|
||||
self.apiclient,
|
||||
self.services["network_offering"],
|
||||
self.testdata["nw_off_isolated_RVR"],
|
||||
conservemode=True
|
||||
)
|
||||
except Exception as e:
|
||||
@ -228,27 +136,27 @@ class TestCreateRvRNetwork(cloudstackTestCase):
|
||||
cls.testClient = super(TestCreateRvRNetwork, cls).getClsTestClient()
|
||||
cls.api_client = cls.testClient.getApiClient()
|
||||
|
||||
cls.services = Services().services
|
||||
cls.testdata = cls.testClient.getParsedTestDataConfig()
|
||||
# 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.testdata["ostype"]
|
||||
)
|
||||
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
|
||||
cls.services["virtual_machine"]["template"] = cls.template.id
|
||||
cls.testdata["small"]["zoneid"] = cls.zone.id
|
||||
cls.testdata["small"]["template"] = cls.template.id
|
||||
|
||||
cls._cleanup = []
|
||||
cls.service_offering = ServiceOffering.create(
|
||||
cls.api_client,
|
||||
cls.services["service_offering"]
|
||||
cls.testdata["service_offering"]
|
||||
)
|
||||
cls._cleanup.append(cls.service_offering)
|
||||
cls.network_offering = NetworkOffering.create(
|
||||
cls.api_client,
|
||||
cls.services["network_offering"],
|
||||
cls.testdata["nw_off_isolated_RVR"],
|
||||
conservemode=True
|
||||
)
|
||||
cls._cleanup.append(cls.network_offering)
|
||||
@ -272,7 +180,7 @@ class TestCreateRvRNetwork(cloudstackTestCase):
|
||||
self.dbclient = self.testClient.getDbConnection()
|
||||
self.account = Account.create(
|
||||
self.apiclient,
|
||||
self.services["account"],
|
||||
self.testdata["account"],
|
||||
admin=True,
|
||||
domainid=self.domain.id
|
||||
)
|
||||
@ -310,7 +218,7 @@ class TestCreateRvRNetwork(cloudstackTestCase):
|
||||
self.network_offering.id)
|
||||
network = Network.create(
|
||||
self.apiclient,
|
||||
self.services["network"],
|
||||
self.testdata["network"],
|
||||
accountid=self.account.name,
|
||||
domainid=self.account.domainid,
|
||||
networkofferingid=self.network_offering.id,
|
||||
@ -352,9 +260,9 @@ class TestCreateRvRNetwork(cloudstackTestCase):
|
||||
self.debug("Deploying VM in account: %s" % self.account.name)
|
||||
|
||||
# Spawn an instance in that network
|
||||
virtual_machine = VirtualMachine.create(
|
||||
VirtualMachine.create(
|
||||
self.apiclient,
|
||||
self.services["virtual_machine"],
|
||||
self.testdata["small"],
|
||||
accountid=self.account.name,
|
||||
domainid=self.account.domainid,
|
||||
serviceofferingid=self.service_offering.id,
|
||||
@ -363,7 +271,7 @@ class TestCreateRvRNetwork(cloudstackTestCase):
|
||||
self.debug("Deployed VM in network: %s" % network.id)
|
||||
|
||||
# wait for VR to update state
|
||||
time.sleep(self.services["sleep"])
|
||||
time.sleep(self.testdata["sleep"])
|
||||
|
||||
self.debug("Listing routers for network: %s" % network.name)
|
||||
routers = Router.list(
|
||||
@ -426,30 +334,32 @@ class TestCreateRvRNetworkNonDefaultGuestCidr(cloudstackTestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.testClient = super(TestCreateRvRNetworkNonDefaultGuestCidr, cls).getClsTestClient()
|
||||
cls.testClient = super(
|
||||
TestCreateRvRNetworkNonDefaultGuestCidr,
|
||||
cls).getClsTestClient()
|
||||
cls.api_client = cls.testClient.getApiClient()
|
||||
|
||||
cls.services = Services().services
|
||||
cls.testdata = cls.testClient.getParsedTestDataConfig()
|
||||
# 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.testdata["ostype"]
|
||||
)
|
||||
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
|
||||
cls.services["virtual_machine"]["template"] = cls.template.id
|
||||
cls.testdata["small"]["zoneid"] = cls.zone.id
|
||||
cls.testdata["small"]["template"] = cls.template.id
|
||||
|
||||
cls._cleanup = []
|
||||
cls.service_offering = ServiceOffering.create(
|
||||
cls.api_client,
|
||||
cls.services["service_offering"]
|
||||
cls.testdata["service_offering"]
|
||||
)
|
||||
cls._cleanup.append(cls.service_offering)
|
||||
cls.network_offering = NetworkOffering.create(
|
||||
cls.api_client,
|
||||
cls.services["network_offering"],
|
||||
cls.testdata["nw_off_isolated_RVR"],
|
||||
conservemode=True
|
||||
)
|
||||
cls._cleanup.append(cls.network_offering)
|
||||
@ -471,7 +381,7 @@ class TestCreateRvRNetworkNonDefaultGuestCidr(cloudstackTestCase):
|
||||
self.dbclient = self.testClient.getDbConnection()
|
||||
self.account = Account.create(
|
||||
self.apiclient,
|
||||
self.services["account"],
|
||||
self.testdata["account"],
|
||||
admin=True,
|
||||
domainid=self.domain.id
|
||||
)
|
||||
@ -510,7 +420,7 @@ class TestCreateRvRNetworkNonDefaultGuestCidr(cloudstackTestCase):
|
||||
self.network_offering.id)
|
||||
network = Network.create(
|
||||
self.apiclient,
|
||||
self.services["network"],
|
||||
self.testdata["network"],
|
||||
accountid=self.account.name,
|
||||
domainid=self.account.domainid,
|
||||
networkofferingid=self.network_offering.id,
|
||||
@ -564,9 +474,9 @@ class TestCreateRvRNetworkNonDefaultGuestCidr(cloudstackTestCase):
|
||||
self.debug("Deploying VM in account: %s" % self.account.name)
|
||||
|
||||
# Spawn an instance in that network
|
||||
virtual_machine = VirtualMachine.create(
|
||||
VirtualMachine.create(
|
||||
self.apiclient,
|
||||
self.services["virtual_machine"],
|
||||
self.testdata["small"],
|
||||
accountid=self.account.name,
|
||||
domainid=self.account.domainid,
|
||||
serviceofferingid=self.service_offering.id,
|
||||
@ -575,7 +485,7 @@ class TestCreateRvRNetworkNonDefaultGuestCidr(cloudstackTestCase):
|
||||
self.debug("Deployed VM in network: %s" % network.id)
|
||||
|
||||
# wait for VR to update state
|
||||
time.sleep(self.services["sleep"])
|
||||
time.sleep(self.testdata["sleep"])
|
||||
|
||||
self.debug("Listing routers for network: %s" % network.name)
|
||||
routers = Router.list(
|
||||
@ -637,27 +547,27 @@ class TestRVRInternals(cloudstackTestCase):
|
||||
cls.testClient = super(TestRVRInternals, cls).getClsTestClient()
|
||||
cls.api_client = cls.testClient.getApiClient()
|
||||
|
||||
cls.services = Services().services
|
||||
cls.testdata = cls.testClient.getParsedTestDataConfig()
|
||||
# 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.testdata["ostype"]
|
||||
)
|
||||
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
|
||||
cls.services["virtual_machine"]["template"] = cls.template.id
|
||||
cls.testdata["small"]["zoneid"] = cls.zone.id
|
||||
cls.testdata["small"]["template"] = cls.template.id
|
||||
|
||||
cls._cleanup = []
|
||||
cls.service_offering = ServiceOffering.create(
|
||||
cls.api_client,
|
||||
cls.services["service_offering"]
|
||||
cls.testdata["service_offering"]
|
||||
)
|
||||
cls._cleanup.append(cls.service_offering)
|
||||
cls.network_offering = NetworkOffering.create(
|
||||
cls.api_client,
|
||||
cls.services["network_offering"],
|
||||
cls.testdata["nw_off_isolated_RVR"],
|
||||
conservemode=True
|
||||
)
|
||||
cls._cleanup.append(cls.network_offering)
|
||||
@ -680,7 +590,7 @@ class TestRVRInternals(cloudstackTestCase):
|
||||
self.dbclient = self.testClient.getDbConnection()
|
||||
self.account = Account.create(
|
||||
self.apiclient,
|
||||
self.services["account"],
|
||||
self.testdata["account"],
|
||||
admin=True,
|
||||
domainid=self.domain.id
|
||||
)
|
||||
@ -727,7 +637,7 @@ class TestRVRInternals(cloudstackTestCase):
|
||||
self.network_offering.id)
|
||||
network = Network.create(
|
||||
self.apiclient,
|
||||
self.services["network"],
|
||||
self.testdata["network"],
|
||||
accountid=self.account.name,
|
||||
domainid=self.account.domainid,
|
||||
networkofferingid=self.network_offering.id,
|
||||
@ -771,7 +681,7 @@ class TestRVRInternals(cloudstackTestCase):
|
||||
# Spawn an instance in that network
|
||||
virtual_machine = VirtualMachine.create(
|
||||
self.apiclient,
|
||||
self.services["virtual_machine"],
|
||||
self.testdata["small"],
|
||||
accountid=self.account.name,
|
||||
domainid=self.account.domainid,
|
||||
serviceofferingid=self.service_offering.id,
|
||||
@ -780,7 +690,7 @@ class TestRVRInternals(cloudstackTestCase):
|
||||
self.debug("Deployed VM in network: %s" % network.id)
|
||||
|
||||
# wait for VR to update state
|
||||
time.sleep(self.services["sleep"])
|
||||
time.sleep(self.testdata["sleep"])
|
||||
|
||||
self.debug("Listing routers for network: %s" % network.name)
|
||||
routers = Router.list(
|
||||
@ -849,21 +759,15 @@ class TestRVRInternals(cloudstackTestCase):
|
||||
hypervisor=self.hypervisor
|
||||
)
|
||||
else:
|
||||
try:
|
||||
host = {}
|
||||
host.user, host.passwd = get_host_credentials(self.config, master_host.ipaddress)
|
||||
result = get_process_status(
|
||||
master_host.ipaddress,
|
||||
22,
|
||||
host.user,
|
||||
host.passwd,
|
||||
self.testdata['configurableData']['host']["username"],
|
||||
self.testdata['configurableData']['host']["password"],
|
||||
master_router.linklocalip,
|
||||
"ip addr show eth2"
|
||||
)
|
||||
|
||||
except KeyError:
|
||||
self.skipTest("Marvin configuration has no host credentials to check router services")
|
||||
|
||||
res = str(result)
|
||||
|
||||
self.debug("Command 'ip addr show eth2': %s" % result)
|
||||
@ -891,21 +795,15 @@ class TestRVRInternals(cloudstackTestCase):
|
||||
hypervisor=self.hypervisor
|
||||
)
|
||||
else:
|
||||
try:
|
||||
host = {}
|
||||
host.user, host.passwd = get_host_credentials(self.config, backup_host.ipaddress)
|
||||
result = get_process_status(
|
||||
master_host.ipaddress,
|
||||
22,
|
||||
host.user,
|
||||
host.passwd,
|
||||
self.testdata['configurableData']['host']["username"],
|
||||
self.testdata['configurableData']['host']["password"],
|
||||
backup_router.linklocalip,
|
||||
"ip addr show eth2"
|
||||
)
|
||||
|
||||
except KeyError:
|
||||
self.skipTest("Marvin configuration has no host credentials to check router services")
|
||||
|
||||
res = str(result)
|
||||
|
||||
self.debug("Command 'ip addr show eth2': %s" % result)
|
||||
@ -953,27 +851,27 @@ class TestRvRRedundancy(cloudstackTestCase):
|
||||
cls.testClient = super(TestRvRRedundancy, cls).getClsTestClient()
|
||||
cls.api_client = cls.testClient.getApiClient()
|
||||
|
||||
cls.services = Services().services
|
||||
cls.testdata = cls.testClient.getParsedTestDataConfig()
|
||||
# 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.testdata["ostype"]
|
||||
)
|
||||
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
|
||||
cls.services["virtual_machine"]["template"] = cls.template.id
|
||||
cls.testdata["small"]["zoneid"] = cls.zone.id
|
||||
cls.testdata["small"]["template"] = cls.template.id
|
||||
|
||||
cls._cleanup = []
|
||||
cls.service_offering = ServiceOffering.create(
|
||||
cls.api_client,
|
||||
cls.services["service_offering"]
|
||||
cls.testdata["service_offering"]
|
||||
)
|
||||
cls._cleanup.append(cls.service_offering)
|
||||
cls.network_offering = NetworkOffering.create(
|
||||
cls.api_client,
|
||||
cls.services["network_offering"],
|
||||
cls.testdata["nw_off_isolated_RVR"],
|
||||
conservemode=True
|
||||
)
|
||||
cls._cleanup.append(cls.network_offering)
|
||||
@ -996,7 +894,7 @@ class TestRvRRedundancy(cloudstackTestCase):
|
||||
self.cleanup = []
|
||||
self.account = Account.create(
|
||||
self.apiclient,
|
||||
self.services["account"],
|
||||
self.testdata["account"],
|
||||
admin=True,
|
||||
domainid=self.domain.id
|
||||
)
|
||||
@ -1006,7 +904,7 @@ class TestRvRRedundancy(cloudstackTestCase):
|
||||
self.network_offering.id)
|
||||
self.network = Network.create(
|
||||
self.apiclient,
|
||||
self.services["network"],
|
||||
self.testdata["network"],
|
||||
accountid=self.account.name,
|
||||
domainid=self.account.domainid,
|
||||
networkofferingid=self.network_offering.id,
|
||||
@ -1018,7 +916,7 @@ class TestRvRRedundancy(cloudstackTestCase):
|
||||
# Spawn an instance in that network
|
||||
self.virtual_machine = VirtualMachine.create(
|
||||
self.apiclient,
|
||||
self.services["virtual_machine"],
|
||||
self.testdata["small"],
|
||||
accountid=self.account.name,
|
||||
domainid=self.account.domainid,
|
||||
serviceofferingid=self.service_offering.id,
|
||||
@ -1027,7 +925,7 @@ class TestRvRRedundancy(cloudstackTestCase):
|
||||
self.debug("Deployed VM in network: %s" % self.network.id)
|
||||
|
||||
# wait for VR to update state
|
||||
time.sleep(self.services["sleep"])
|
||||
time.sleep(self.testdata["sleep"])
|
||||
return
|
||||
|
||||
def tearDown(self):
|
||||
@ -1095,7 +993,7 @@ class TestRvRRedundancy(cloudstackTestCase):
|
||||
self.fail("Failed to stop master router: %s" % e)
|
||||
|
||||
# wait for VR to update state
|
||||
time.sleep(self.services["sleep"])
|
||||
time.sleep(self.testdata["sleep"])
|
||||
|
||||
self.debug("Listing routers for network: %s" % self.network.name)
|
||||
routers = Router.list(
|
||||
@ -1109,12 +1007,14 @@ class TestRvRRedundancy(cloudstackTestCase):
|
||||
"list router should return Master and backup routers"
|
||||
)
|
||||
self.assertIn(
|
||||
routers[0].redundantstate,
|
||||
['UNKNOWN', 'FAULT'],
|
||||
"Redundant state of the master router should be UNKNOWN/FAULT but is %s" % routers[0].redundantstate
|
||||
)
|
||||
routers[0].redundantstate, [
|
||||
'UNKNOWN', 'FAULT'], "Redundant state of the master router\
|
||||
should be UNKNOWN/FAULT but is %s" %
|
||||
routers[0].redundantstate)
|
||||
|
||||
self.debug("Checking state of the backup router in %s" % self.network.name)
|
||||
self.debug(
|
||||
"Checking state of the backup router in %s" %
|
||||
self.network.name)
|
||||
routers = Router.list(
|
||||
self.apiclient,
|
||||
id=backup_router.id,
|
||||
@ -1128,8 +1028,8 @@ class TestRvRRedundancy(cloudstackTestCase):
|
||||
self.assertEqual(
|
||||
routers[0].redundantstate,
|
||||
'MASTER',
|
||||
"Redundant state of the router should be MASTER but is %s" % routers[0].redundantstate
|
||||
)
|
||||
"Redundant state of the router should be MASTER but is %s" %
|
||||
routers[0].redundantstate)
|
||||
|
||||
self.debug("Starting the old MASTER router")
|
||||
try:
|
||||
@ -1139,9 +1039,11 @@ class TestRvRRedundancy(cloudstackTestCase):
|
||||
self.fail("Failed to start master router: %s" % e)
|
||||
|
||||
# wait for VR to update state
|
||||
time.sleep(self.services["sleep"])
|
||||
time.sleep(self.testdata["sleep"])
|
||||
|
||||
self.debug("Checking state of the master router in %s" % self.network.name)
|
||||
self.debug(
|
||||
"Checking state of the master router in %s" %
|
||||
self.network.name)
|
||||
routers = Router.list(
|
||||
self.apiclient,
|
||||
id=master_router.id,
|
||||
@ -1155,8 +1057,8 @@ class TestRvRRedundancy(cloudstackTestCase):
|
||||
self.assertEqual(
|
||||
routers[0].redundantstate,
|
||||
'BACKUP',
|
||||
"Redundant state of the router should be BACKUP but is %s" % routers[0].redundantstate
|
||||
)
|
||||
"Redundant state of the router should be BACKUP but is %s" %
|
||||
routers[0].redundantstate)
|
||||
self.assertEqual(
|
||||
master_router.publicip,
|
||||
routers[0].publicip,
|
||||
@ -1221,9 +1123,11 @@ class TestRvRRedundancy(cloudstackTestCase):
|
||||
self.fail("Failed to stop backup router: %s" % e)
|
||||
|
||||
# wait for VR update state
|
||||
time.sleep(self.services["sleep"])
|
||||
time.sleep(self.testdata["sleep"])
|
||||
|
||||
self.debug("Checking state of the backup router in %s" % self.network.name)
|
||||
self.debug(
|
||||
"Checking state of the backup router in %s" %
|
||||
self.network.name)
|
||||
routers = Router.list(
|
||||
self.apiclient,
|
||||
id=backup_router.id,
|
||||
@ -1235,12 +1139,14 @@ class TestRvRRedundancy(cloudstackTestCase):
|
||||
"list router should return Master and backup routers"
|
||||
)
|
||||
self.assertIn(
|
||||
routers[0].redundantstate,
|
||||
['UNKNOWN', 'FAULT'],
|
||||
"Redundant state of the backup router should be UNKNOWN/FAULT but is %s" % routers[0].redundantstate
|
||||
)
|
||||
routers[0].redundantstate, [
|
||||
'UNKNOWN', 'FAULT'], "Redundant state of the backup router\
|
||||
should be UNKNOWN/FAULT but is %s" %
|
||||
routers[0].redundantstate)
|
||||
|
||||
self.debug("Checking state of the master router in %s" % self.network.name)
|
||||
self.debug(
|
||||
"Checking state of the master router in %s" %
|
||||
self.network.name)
|
||||
routers = Router.list(
|
||||
self.apiclient,
|
||||
id=master_router.id,
|
||||
@ -1254,8 +1160,8 @@ class TestRvRRedundancy(cloudstackTestCase):
|
||||
self.assertEqual(
|
||||
routers[0].redundantstate,
|
||||
'MASTER',
|
||||
"Redundant state of the router should be MASTER but is %s" % routers[0].redundantstate
|
||||
)
|
||||
"Redundant state of the router should be MASTER but is %s" %
|
||||
routers[0].redundantstate)
|
||||
|
||||
self.debug("Starting the old BACKUP router")
|
||||
try:
|
||||
@ -1265,9 +1171,11 @@ class TestRvRRedundancy(cloudstackTestCase):
|
||||
self.fail("Failed to stop master router: %s" % e)
|
||||
|
||||
# wait for VR to start and update state
|
||||
time.sleep(self.services["sleep"])
|
||||
time.sleep(self.testdata["sleep"])
|
||||
|
||||
self.debug("Checking state of the backup router in %s" % self.network.name)
|
||||
self.debug(
|
||||
"Checking state of the backup router in %s" %
|
||||
self.network.name)
|
||||
routers = Router.list(
|
||||
self.apiclient,
|
||||
id=backup_router.id,
|
||||
@ -1281,8 +1189,8 @@ class TestRvRRedundancy(cloudstackTestCase):
|
||||
self.assertEqual(
|
||||
routers[0].redundantstate,
|
||||
'BACKUP',
|
||||
"Redundant state of the router should be BACKUP but is %s" % routers[0].redundantstate
|
||||
)
|
||||
"Redundant state of the router should be BACKUP but is %s" %
|
||||
routers[0].redundantstate)
|
||||
self.assertEqual(
|
||||
backup_router.publicip,
|
||||
routers[0].publicip,
|
||||
@ -1341,9 +1249,11 @@ class TestRvRRedundancy(cloudstackTestCase):
|
||||
self.fail("Failed to reboot MASTER router: %s" % e)
|
||||
|
||||
# wait for VR to update state
|
||||
time.sleep(self.services["sleep"])
|
||||
time.sleep(self.testdata["sleep"])
|
||||
|
||||
self.debug("Checking state of the master router in %s" % self.network.name)
|
||||
self.debug(
|
||||
"Checking state of the master router in %s" %
|
||||
self.network.name)
|
||||
routers = Router.list(
|
||||
self.apiclient,
|
||||
id=master_router.id,
|
||||
@ -1357,10 +1267,12 @@ class TestRvRRedundancy(cloudstackTestCase):
|
||||
self.assertEqual(
|
||||
routers[0].redundantstate,
|
||||
'BACKUP',
|
||||
"Redundant state of the router should be BACKUP but is %s" % routers[0].redundantstate
|
||||
)
|
||||
"Redundant state of the router should be BACKUP but is %s" %
|
||||
routers[0].redundantstate)
|
||||
|
||||
self.debug("Checking state of the backup router in %s" % self.network.name)
|
||||
self.debug(
|
||||
"Checking state of the backup router in %s" %
|
||||
self.network.name)
|
||||
routers = Router.list(
|
||||
self.apiclient,
|
||||
id=backup_router.id,
|
||||
@ -1374,8 +1286,8 @@ class TestRvRRedundancy(cloudstackTestCase):
|
||||
self.assertEqual(
|
||||
routers[0].redundantstate,
|
||||
'MASTER',
|
||||
"Redundant state of the router should be MASTER but is %s" % routers[0].redundantstate
|
||||
)
|
||||
"Redundant state of the router should be MASTER but is %s" %
|
||||
routers[0].redundantstate)
|
||||
self.assertEqual(
|
||||
master_router.publicip,
|
||||
routers[0].publicip,
|
||||
@ -1434,9 +1346,11 @@ class TestRvRRedundancy(cloudstackTestCase):
|
||||
self.fail("Failed to reboot BACKUP router: %s" % e)
|
||||
|
||||
# wait for VR to update state
|
||||
time.sleep(self.services["sleep"])
|
||||
time.sleep(self.testdata["sleep"])
|
||||
|
||||
self.debug("Checking state of the backup router in %s" % self.network.name)
|
||||
self.debug(
|
||||
"Checking state of the backup router in %s" %
|
||||
self.network.name)
|
||||
routers = Router.list(
|
||||
self.apiclient,
|
||||
id=backup_router.id,
|
||||
@ -1450,10 +1364,12 @@ class TestRvRRedundancy(cloudstackTestCase):
|
||||
self.assertEqual(
|
||||
routers[0].redundantstate,
|
||||
'BACKUP',
|
||||
"Redundant state of the router should be BACKUP but is %s" % routers[0].redundantstate
|
||||
)
|
||||
"Redundant state of the router should be BACKUP but is %s" %
|
||||
routers[0].redundantstate)
|
||||
|
||||
self.debug("Checking state of the master router in %s" % self.network.name)
|
||||
self.debug(
|
||||
"Checking state of the master router in %s" %
|
||||
self.network.name)
|
||||
routers = Router.list(
|
||||
self.apiclient,
|
||||
id=master_router.id,
|
||||
@ -1467,8 +1383,8 @@ class TestRvRRedundancy(cloudstackTestCase):
|
||||
self.assertEqual(
|
||||
routers[0].redundantstate,
|
||||
'MASTER',
|
||||
"Redundant state of the router should be MASTER but is %s" % routers[0].redundantstate
|
||||
)
|
||||
"Redundant state of the router should be MASTER but is %s" %
|
||||
routers[0].redundantstate)
|
||||
self.assertEqual(
|
||||
master_router.publicip,
|
||||
routers[0].publicip,
|
||||
@ -1514,10 +1430,8 @@ class TestRvRRedundancy(cloudstackTestCase):
|
||||
)
|
||||
|
||||
if routers[0].redundantstate == 'MASTER':
|
||||
master_router = routers[0]
|
||||
backup_router = routers[1]
|
||||
else:
|
||||
master_router = routers[1]
|
||||
backup_router = routers[0]
|
||||
|
||||
self.debug("Stopping the backup router")
|
||||
@ -1527,9 +1441,11 @@ class TestRvRRedundancy(cloudstackTestCase):
|
||||
self.fail("Failed to stop BACKUP router: %s" % e)
|
||||
|
||||
# wait for VR to update state
|
||||
time.sleep(self.services["sleep"])
|
||||
time.sleep(self.testdata["sleep"])
|
||||
|
||||
self.debug("Checking state of the backup router in %s" % self.network.name)
|
||||
self.debug(
|
||||
"Checking state of the backup router in %s" %
|
||||
self.network.name)
|
||||
routers = Router.list(
|
||||
self.apiclient,
|
||||
id=backup_router.id,
|
||||
@ -1543,13 +1459,14 @@ class TestRvRRedundancy(cloudstackTestCase):
|
||||
self.assertIn(
|
||||
routers[0].redundantstate,
|
||||
'UNKNOWN',
|
||||
"Redundant state of the backup router should be UNKNOWN but is %s" % routers[0].redundantstate
|
||||
)
|
||||
"Redundant state of the backup router\
|
||||
should be UNKNOWN but is %s" %
|
||||
routers[0].redundantstate)
|
||||
|
||||
# Spawn an instance in that network
|
||||
vm_2 = VirtualMachine.create(
|
||||
self.apiclient,
|
||||
self.services["virtual_machine"],
|
||||
self.testdata["small"],
|
||||
accountid=self.account.name,
|
||||
domainid=self.account.domainid,
|
||||
serviceofferingid=self.service_offering.id,
|
||||
@ -1575,9 +1492,11 @@ class TestRvRRedundancy(cloudstackTestCase):
|
||||
)
|
||||
|
||||
# wait for VR to update state
|
||||
time.sleep(self.services["sleep"])
|
||||
time.sleep(self.testdata["sleep"])
|
||||
|
||||
self.debug("Checking state of the backup router in %s" % self.network.name)
|
||||
self.debug(
|
||||
"Checking state of the backup router in %s" %
|
||||
self.network.name)
|
||||
routers = Router.list(
|
||||
self.apiclient,
|
||||
id=backup_router.id,
|
||||
@ -1591,6 +1510,6 @@ class TestRvRRedundancy(cloudstackTestCase):
|
||||
self.assertEqual(
|
||||
routers[0].redundantstate,
|
||||
'BACKUP',
|
||||
"Redundant state of the router should be BACKUP but is %s" % routers[0].redundantstate
|
||||
)
|
||||
"Redundant state of the router should be BACKUP but is %s" %
|
||||
routers[0].redundantstate)
|
||||
return
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user