All testcase automation for feaure
- lb vip route advertisement Change-Id: I4ba7359df64edd89892f945bc90e52f78076f27e
This commit is contained in:
parent
af2a19cf93
commit
36965d655a
@ -383,11 +383,11 @@ class ApplianceManager(manager.NetworkScenarioTest):
|
||||
sec_client=None,
|
||||
**kwargs):
|
||||
rule = self._create_security_group_rule(
|
||||
tenant_id=tenant_id,
|
||||
sec_group_rules_client=sec_rule_client,
|
||||
security_groups_client=sec_client,
|
||||
secgroup=sg,
|
||||
**kwargs)
|
||||
tenant_id=tenant_id,
|
||||
sec_group_rules_client=sec_rule_client,
|
||||
security_groups_client=sec_client,
|
||||
secgroup=sg,
|
||||
**kwargs)
|
||||
return rule
|
||||
|
||||
def _get_server_portid_and_ip4(self, server, ip_addr=None):
|
||||
@ -617,3 +617,22 @@ class ApplianceManager(manager.NetworkScenarioTest):
|
||||
user_id = self.security_groups_client.user_id
|
||||
tenant_id = self.security_groups_client.tenant_id
|
||||
return user_id, tenant_id
|
||||
|
||||
def _create_subnet_pool(self, client, name, default_quota=None,
|
||||
shared='false'):
|
||||
# create subnet pool
|
||||
prefix = CONF.network.default_network
|
||||
subnetpool_client = client.subnetpools_client
|
||||
if default_quota is None:
|
||||
body = subnetpool_client.create_subnetpool(name=name,
|
||||
prefixes=prefix,
|
||||
shared=shared)
|
||||
else:
|
||||
body = subnetpool_client.create_subnetpool(
|
||||
name=name, prefixes=prefix, shared=shared,
|
||||
default_quota=default_quota)
|
||||
subnetpool_id = body["subnetpool"]["id"]
|
||||
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
|
||||
subnetpool_client.delete_subnetpool,
|
||||
subnetpool_id)
|
||||
return body
|
||||
|
@ -15,7 +15,8 @@ import time
|
||||
|
||||
from oslo_log import log as logging
|
||||
from tempest import config
|
||||
|
||||
from tempest.lib.common.utils import data_utils
|
||||
from tempest.lib.common.utils import test_utils
|
||||
from tempest.lib import decorators
|
||||
|
||||
from vmware_nsx_tempest_plugin.common import constants
|
||||
@ -62,6 +63,24 @@ class TestLBVipRoute(feature_manager.FeatureManager):
|
||||
"""
|
||||
super(TestLBVipRoute, cls).skip_checks()
|
||||
|
||||
def _create_network_topo(self, subnetpool_id, prefixlen=26):
|
||||
net_client = self.cmgr_adm.networks_client
|
||||
body = {'name': 'provider-network'}
|
||||
network = net_client.create_network(**body)
|
||||
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
|
||||
net_client.delete_network,
|
||||
network['network']['id'])
|
||||
body = {"network_id": network['network']['id'],
|
||||
"ip_version": 4, "subnetpool_id": subnetpool_id,
|
||||
"prefixlen": 28}
|
||||
subnet_client = self.cmgr_adm.subnets_client
|
||||
subnet = subnet_client.create_subnet(**body)
|
||||
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
|
||||
subnet_client.delete_subnet,
|
||||
subnet['subnet']['id'])
|
||||
network_topo = dict(network=network, subnet=subnet)
|
||||
return network_topo
|
||||
|
||||
@decorators.idempotent_id('2317349c-02dd-0016-c228-98844caa46c3')
|
||||
def test_lb_vip_route_with_tenant_net(self):
|
||||
"""
|
||||
@ -241,3 +260,126 @@ class TestLBVipRoute(feature_manager.FeatureManager):
|
||||
0]['advertiseRouteType'] == 'T1_LB_VIP':
|
||||
route_present = True
|
||||
self.assertEqual(False, route_present, 'Lb vip route is present')
|
||||
|
||||
@decorators.idempotent_id('2317349c-02cc-1127-d339-09955dbb47d4')
|
||||
def test_lb_vip_route_with_overlapping_subnet_tenant_network(self):
|
||||
"""
|
||||
Check lb vip vip route should be present with external net
|
||||
"""
|
||||
subnetpool_name = data_utils.rand_name('subnetpools')
|
||||
body = self._create_subnet_pool(self.cmgr_adm, subnetpool_name)
|
||||
subnetpool_id = body["subnetpool"]["id"]
|
||||
network_topo = self._create_network_topo(subnetpool_id, prefixlen=28)
|
||||
subnet_client = self.cmgr_adm.subnets_client
|
||||
body = {"network_id": network_topo['network']['network']['id'],
|
||||
"ip_version": 4, "subnetpool_id": subnetpool_id,
|
||||
"prefixlen": 28, "enable_dhcp": 'false'}
|
||||
subnet = subnet_client.create_subnet(**body)
|
||||
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
|
||||
subnet_client.delete_subnet,
|
||||
subnet['subnet']['id'])
|
||||
kwargs = {"enable_snat": True}
|
||||
router_state_1 = self.create_topology_router(set_gateway=True,
|
||||
routers_client=self.
|
||||
cmgr_adm.routers_client,
|
||||
**kwargs)
|
||||
subnet_lbaas = network_topo['subnet']['subnet']
|
||||
self.cmgr_adm.routers_client.add_router_interface(
|
||||
router_state_1['id'], subnet_id=subnet_lbaas["id"])
|
||||
self.addCleanup(
|
||||
test_utils.call_and_ignore_notfound_exc,
|
||||
self.cmgr_adm.routers_client.remove_router_interface,
|
||||
router_state_1['id'],
|
||||
subnet_id=subnet_lbaas["id"])
|
||||
loadbalancer = self.load_balancers_admin_client.\
|
||||
create_load_balancer(name='test-lb',
|
||||
vip_subnet_id=subnet_lbaas['id']
|
||||
)['loadbalancer']
|
||||
self.load_balancers_admin_client.\
|
||||
wait_for_load_balancer_status(loadbalancer['id'])
|
||||
listener = self.listeners_admin_client.create_listener(
|
||||
loadbalancer_id=loadbalancer['id'], protocol='HTTP',
|
||||
protocol_port='80', name='test_listener')['listener']
|
||||
self.load_balancers_admin_client.\
|
||||
wait_for_load_balancer_status(loadbalancer['id'])
|
||||
pool = self.pools_admin_client.create_pool(
|
||||
listener_id=listener['id'],
|
||||
lb_algorithm='ROUND_ROBIN', protocol='HTTP')['pool']
|
||||
self.load_balancers_admin_client.\
|
||||
wait_for_load_balancer_status(loadbalancer['id'])
|
||||
self.health_monitors_admin_client.create_health_monitor(
|
||||
pool_id=pool['id'], type='PING',
|
||||
delay='5', max_retries='3',
|
||||
timeout='5')
|
||||
self.load_balancers_admin_client.\
|
||||
wait_for_load_balancer_status(loadbalancer['id'])
|
||||
self.members_admin_client.create_member(
|
||||
pool['id'], subnet_id=subnet_lbaas['id'],
|
||||
address="127.0.0.1",
|
||||
protocol_port=80)['member']
|
||||
self.load_balancers_admin_client.\
|
||||
wait_for_load_balancer_status(loadbalancer['id'])
|
||||
time.sleep(30)
|
||||
nsx_router_nat_rules = self.nsx.get_logical_router_nat_rule_ips(
|
||||
router_state_1['name'], router_state_1['id'])
|
||||
route_present = False
|
||||
lb_resource = {}
|
||||
lb_resource['vip_ip'] = loadbalancer['vip_address']
|
||||
lb_resource['lb_id'] = loadbalancer['id']
|
||||
for advertised_net in nsx_router_nat_rules['advertisedNetworks']:
|
||||
if len(advertised_net['networks']) > 0:
|
||||
if lb_resource['vip_ip'] in advertised_net[
|
||||
'networks'][0]['network'] and\
|
||||
advertised_net['networks'][
|
||||
0]['advertiseRouteType'] == 'T1_LB_VIP' and\
|
||||
advertised_net['networks'][0]['advertiseAllow']:
|
||||
route_present = True
|
||||
self.assertEqual(False, route_present, 'Lb vip route is advertised')
|
||||
vip_fip = self.create_floatingip(
|
||||
loadbalancer,
|
||||
client=self.cmgr_adm.floating_ips_client,
|
||||
port_id=loadbalancer['vip_port_id'])
|
||||
self.vip_ip_address = vip_fip['floating_ip_address']
|
||||
time.sleep(30)
|
||||
nsx_router_nat_rules = self.nsx.get_logical_router_nat_rule_ips(
|
||||
router_state_1['name'], router_state_1['id'])
|
||||
route_present = False
|
||||
for advertised_net in nsx_router_nat_rules['advertisedNetworks']:
|
||||
if len(advertised_net['networks']) > 0:
|
||||
if self.vip_ip_address in advertised_net[
|
||||
'networks'][0]['network'] and\
|
||||
advertised_net['networks'][
|
||||
0]['advertiseRouteType'] == 'T1_LB_VIP' and\
|
||||
advertised_net['networks'][0]['advertiseAllow']:
|
||||
route_present = True
|
||||
self.assertEqual(True, route_present, 'Lb vip route is not advertised')
|
||||
kwargs = dict(port_id=None)
|
||||
self.cmgr_adm.floating_ips_client.\
|
||||
update_floatingip(vip_fip['id'],
|
||||
**kwargs)['floatingip']
|
||||
time.sleep(30)
|
||||
nsx_router_nat_rules = self.nsx.get_logical_router_nat_rule_ips(
|
||||
router_state_1['name'], router_state_1['id'])
|
||||
route_present = False
|
||||
for advertised_net in nsx_router_nat_rules['advertisedNetworks']:
|
||||
if len(advertised_net['networks']) > 0:
|
||||
if lb_resource['vip_ip'] in advertised_net[
|
||||
'networks'][0]['network'] and\
|
||||
advertised_net['networks'][
|
||||
0]['advertiseRouteType'] == 'T1_LB_VIP' and\
|
||||
advertised_net['networks'][0]['advertiseAllow']:
|
||||
route_present = True
|
||||
self.assertEqual(False, route_present, 'Lb vip route is advertised')
|
||||
self.delete_loadbalancer_resources(lb_resource['lb_id'], admin=True)
|
||||
time.sleep(30)
|
||||
nsx_router_nat_rules = self.nsx.get_logical_router_nat_rule_ips(
|
||||
router_state_1['name'], router_state_1['id'])
|
||||
route_present = False
|
||||
for advertised_net in nsx_router_nat_rules['advertisedNetworks']:
|
||||
if len(advertised_net['networks']) > 0:
|
||||
if lb_resource['vip_ip'] in advertised_net[
|
||||
'networks'][0]['network'] and\
|
||||
advertised_net['networks'][
|
||||
0]['advertiseRouteType'] == 'T1_LB_VIP':
|
||||
route_present = True
|
||||
self.assertEqual(False, route_present, 'Lb vip route is present')
|
||||
|
Loading…
Reference in New Issue
Block a user