[BGP] Port tests without FIP

Added NoFipPortTest class to test_port module. They are only executed
when BGP is configured and expose_tenant_networks is enabled. These
tests use a VM without FIP. The tests connect to the fixed IPs from its
tenant networks.

Change-Id: I458ab8f8ebe92a0f53bbd10675ae161450ffc0ff
This commit is contained in:
Eduardo Olivares 2023-04-04 14:41:02 +02:00
parent a3116bf0e1
commit 3d0a48cd8e
9 changed files with 57 additions and 8 deletions

View File

@ -123,6 +123,7 @@ get_router = _router.get_router
get_router_id = _router.get_router_id get_router_id = _router.get_router_id
remove_router_interface = _router.remove_router_interface remove_router_interface = _router.remove_router_interface
wait_for_master_and_backup_agents = _router.wait_for_master_and_backup_agents wait_for_master_and_backup_agents = _router.wait_for_master_and_backup_agents
update_router = _router.update_router
RouterType = _router.RouterType RouterType = _router.RouterType
RouterIdType = _router.RouterIdType RouterIdType = _router.RouterIdType
NoSuchRouter = _router.NoSuchRouter NoSuchRouter = _router.NoSuchRouter

View File

@ -182,6 +182,13 @@ def remove_router_interface(router: RouterIdType,
raise tobiko.ObjectNotFound() from ex raise tobiko.ObjectNotFound() from ex
def update_router(router: RouterIdType, client=None, **params) -> RouterType:
router_id = get_router_id(router)
reply = _client.neutron_client(client).update_router(
router_id, body={'router': params})
return reply['router']
class NoSuchRouter(tobiko.ObjectNotFound): class NoSuchRouter(tobiko.ObjectNotFound):
message = "No such router found for {id!r}" message = "No such router found for {id!r}"

View File

@ -37,6 +37,7 @@ Centos7ServerStackFixture = _centos.Centos7ServerStackFixture
CirrosFlavorStackFixture = _cirros.CirrosFlavorStackFixture CirrosFlavorStackFixture = _cirros.CirrosFlavorStackFixture
CirrosImageFixture = _cirros.CirrosImageFixture CirrosImageFixture = _cirros.CirrosImageFixture
CirrosServerStackFixture = _cirros.CirrosServerStackFixture CirrosServerStackFixture = _cirros.CirrosServerStackFixture
CirrosNoFipServerStackFixture = _cirros.CirrosNoFipServerStackFixture
CirrosServerWithDefaultSecurityGroupStackFixture = ( CirrosServerWithDefaultSecurityGroupStackFixture = (
_cirros.CirrosServerWithDefaultSecurityGroupStackFixture) _cirros.CirrosServerWithDefaultSecurityGroupStackFixture)
CirrosShellConnection = _cirros.CirrosShellConnection CirrosShellConnection = _cirros.CirrosShellConnection

View File

@ -22,6 +22,7 @@ from tobiko import config
from tobiko.openstack import glance from tobiko.openstack import glance
from tobiko.openstack import neutron from tobiko.openstack import neutron
from tobiko.openstack import heat from tobiko.openstack import heat
from tobiko.openstack.stacks import _neutron
from tobiko.openstack.stacks import _nova from tobiko.openstack.stacks import _nova
from tobiko.shell import sh from tobiko.shell import sh
from tobiko.shell import ssh from tobiko.shell import ssh
@ -152,6 +153,11 @@ class ExtraDhcpOptsCirrosServerStackFixture(CirrosServerStackFixture):
use_extra_dhcp_opts = True use_extra_dhcp_opts = True
class CirrosNoFipServerStackFixture(ExtraDhcpOptsCirrosServerStackFixture):
has_floating_ip = False
network_stack = tobiko.required_fixture(_neutron.NetworkNoFipStackFixture)
class MultiIPCirrosServerStackFixture(CirrosServerStackFixture): class MultiIPCirrosServerStackFixture(CirrosServerStackFixture):
template = _hot.heat_template_file('nova/multi_ip_test_stack.yaml') template = _hot.heat_template_file('nova/multi_ip_test_stack.yaml')
expected_creted_status = {heat.CREATE_IN_PROGRESS, heat.CREATE_COMPLETE} expected_creted_status = {heat.CREATE_IN_PROGRESS, heat.CREATE_COMPLETE}

View File

@ -275,6 +275,15 @@ def ensure_router_interface(
add_cleanup=add_cleanup) add_cleanup=add_cleanup)
class RouterNoSnatStackFixture(RouterStackFixture):
"""Extra Router configured with SNAT disabled"""
def setup_fixture(self):
super().setup_fixture()
egi = neutron.get_router(self.router_id)['external_gateway_info']
egi['enable_snat'] = False
neutron.update_router(self.router_id, external_gateway_info=egi)
@neutron.skip_if_missing_networking_extensions('subnet_allocation') @neutron.skip_if_missing_networking_extensions('subnet_allocation')
class SubnetPoolFixture(tobiko.SharedFixture): class SubnetPoolFixture(tobiko.SharedFixture):
"""Neutron Subnet Pool Fixture. """Neutron Subnet Pool Fixture.
@ -567,6 +576,11 @@ class NetworkStackFixture(heat.HeatStackFixture):
predicate=fixture.is_router_distributed) predicate=fixture.is_router_distributed)
class NetworkNoFipStackFixture(NetworkStackFixture):
"""Extra Network Stack where VMs will not have FIPs"""
gateway_stack = tobiko.required_fixture(RouterNoSnatStackFixture)
@neutron.skip_if_missing_networking_extensions('net-mtu-writable') @neutron.skip_if_missing_networking_extensions('net-mtu-writable')
class NetworkWithNetMtuWriteStackFixture(NetworkStackFixture): class NetworkWithNetMtuWriteStackFixture(NetworkStackFixture):

View File

@ -38,19 +38,18 @@ def test_server_creation(stack=TestServerCreationStack):
number_of_servers=0).first number_of_servers=0).first
class NetworkNoFipStackFixture(_neutron.NetworkStackFixture): class TestNetworkNoFipStackFixture(_neutron.NetworkNoFipStackFixture):
"""Neutron network where VMs will be created with no FIP""" """Neutron network where VMs will be created with no FIP"""
def setup_fixture(self): def setup_fixture(self):
super().setup_fixture() super().setup_fixture()
# this stack will be deleted at the end of the test # this stack will be deleted at the end of the test
tobiko.add_cleanup(NetworkNoFipStackFixture.cleanup_fixture, self) tobiko.add_cleanup(TestNetworkNoFipStackFixture.cleanup_fixture, self)
class TestServerNoFipCreationStack(_cirros.CirrosServerStackFixture): class TestServerNoFipCreationStack(_cirros.CirrosNoFipServerStackFixture):
"""Nova instance without FIP intended to be used for testing server """Nova instance without FIP intended to be used for testing server
creation""" creation"""
has_floating_ip = False network_stack = tobiko.required_fixture(TestNetworkNoFipStackFixture)
network_stack = tobiko.required_fixture(NetworkNoFipStackFixture)
def test_server_creation_no_fip(): def test_server_creation_no_fip():

View File

@ -302,9 +302,9 @@ class OpenStackTopology(tobiko.SharedFixture):
neutron.METADATA_AGENT: 'devstack@q-meta', neutron.METADATA_AGENT: 'devstack@q-meta',
neutron.OVN_METADATA_AGENT: 'devstack@q-ovn-metadata-agent', neutron.OVN_METADATA_AGENT: 'devstack@q-ovn-metadata-agent',
neutron.NEUTRON_OVN_METADATA_AGENT: 'devstack@q-ovn-metadata-agent', neutron.NEUTRON_OVN_METADATA_AGENT: 'devstack@q-ovn-metadata-agent',
neutron.OVN_CONTROLLER: 'ovn-controller' neutron.OVN_CONTROLLER: 'ovn-controller',
# TODO(eolivare): ovn_bgp_agent on devstack? neutron.OVN_BGP_AGENT: 'ovn-bgp-agent',
# TODO(eolivare): frr on devstack? neutron.FRR: 'frr'
} }
agent_to_container_name_mappings: typing.Dict[str, str] = {} agent_to_container_name_mappings: typing.Dict[str, str] = {}

View File

@ -31,6 +31,7 @@ from tobiko.shell import sh
from tobiko.openstack import neutron from tobiko.openstack import neutron
from tobiko.openstack import stacks from tobiko.openstack import stacks
from tobiko.openstack import topology from tobiko.openstack import topology
from tobiko.tripleo import overcloud
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
@ -159,6 +160,24 @@ class ExtraDhcpOptsPortTest(PortTest):
re.MULTILINE)) re.MULTILINE))
@overcloud.skip_unless_ovn_bgp_agent
class NoFipPortTest(ExtraDhcpOptsPortTest):
stack = tobiko.required_fixture(stacks.CirrosNoFipServerStackFixture)
def setUp(self):
super().setUp()
try:
node = topology.find_openstack_node(group='networker')
except topology.NoSuchOpenStackTopologyNodeGroup:
node = topology.find_openstack_node(group='controller')
expose_tenant_networks = topology.get_config_setting(
'bgp-agent.conf', node.ssh_client, 'expose_tenant_networks')
if expose_tenant_networks is None or (
expose_tenant_networks.lower() != 'true'):
tobiko.skip_test('BGP expose_tenant_networks is disabled')
@neutron.skip_unless_is_ovn() @neutron.skip_unless_is_ovn()
class ExtraDhcpOptsPortLoggingTest(testtools.TestCase): class ExtraDhcpOptsPortLoggingTest(testtools.TestCase):

View File

@ -342,6 +342,8 @@ skip_unless_ovn_using_ha = tobiko.skip_unless(
'OVN does not use HA DB model', is_ovn_using_ha) 'OVN does not use HA DB model', is_ovn_using_ha)
# TODO(eolivare): make this method work with devstack
@_undercloud.skip_if_missing_undercloud
def is_ovn_bgp_agent_running(): def is_ovn_bgp_agent_running():
return (len(tripleo.get_overcloud_nodes_running_service( return (len(tripleo.get_overcloud_nodes_running_service(
topology.get_agent_service_name(neutron.OVN_BGP_AGENT))) > 0) topology.get_agent_service_name(neutron.OVN_BGP_AGENT))) > 0)