Allow MTU tests to arrange proper MTU value

MTU tests will adjust external network MTU and 'shared' parameter
accoring to tests needs and restore at the end.
However the tests are blocked on devstack due to [1] and can be
executed for now only on a podified environment.

[1] https://bugs.launchpad.net/neutron/+bug/2060828

Change-Id: I088e6c7bb1e7c6ddfc2f98032758d9a10dcfcb7a
This commit is contained in:
Roman Safronov 2024-06-04 22:50:24 +03:00
parent eacd16a847
commit 1bb1e4c108
2 changed files with 101 additions and 98 deletions

View File

@ -31,7 +31,7 @@ WB_CONF = config.CONF.whitebox_neutron_plugin_options
LOG = log.getLogger(__name__)
class GatewayMtuTest(base.TrafficFlowTest):
class GatewayMtuTest(base.TrafficFlowTest, base.BaseTempestTestCaseOvn):
credentials = ['primary', 'admin']
@classmethod
@ -137,14 +137,27 @@ class GatewayMtuTest(base.TrafficFlowTest):
def setup(self):
self._validate_environment_config()
self.network = self.create_network()
subnet = self.create_subnet(self.network)
self.router = self.create_router_by_client()
self.create_router_interface(self.router['id'], subnet['id'])
self.external_network = self.client.show_network(
CONF.network.public_network_id)['network']
if not self.external_network['shared']:
self.addCleanup(self.os_admin.network_client.update_network,
self.external_network['id'], shared=False)
self.os_admin.network_client.update_network(
self.external_network['id'], shared=True)
self.external_mtu = self.external_network['mtu']
self.internal_mtu = self.network['mtu']
if int(self.external_mtu) >= int(self.internal_mtu):
self.original_mtu = self.external_mtu
new_mtu = self.internal_mtu - 30
self.addCleanup(self._restore_external_network_mtu)
self.external_mtu = self.os_admin.network_client.update_network(
CONF.network.public_network_id, mtu=new_mtu)['network']['mtu']
self._validate_ovn_db_mtu_settings()
ext_vm = self._create_server(
network=self.external_network,
create_floating_ip=False)
@ -163,14 +176,10 @@ class GatewayMtuTest(base.TrafficFlowTest):
self.test_server_client = ssh.Client(
test_server_ip, self.username,
pkey=self.keypair['private_key'], proxy_client=server_ssh_client)
self.validate_current_mtus()
def validate_current_mtus(self):
self.internal_mtu = self.network['mtu']
self.external_mtu = self.external_network['mtu']
if int(self.external_mtu) > int(self.internal_mtu):
raise self.skipException(
'Internal network MTU is smaller than external.')
def _restore_external_network_mtu(self):
self.os_admin.network_client.update_network(
CONF.network.public_network_id, mtu=self.original_mtu)
def validate_next_hop_mtu(self, starting_payload_size):
next_hop_mtu = self._verify_capture_for_icmp_unreacheable(
@ -202,6 +211,83 @@ class GatewayMtuTest(base.TrafficFlowTest):
self.validate_next_hop_mtu(
starting_payload_size=maximal_payload_for_internal_net)
def _validate_ovn_db_mtu_settings(self):
router_port = self.os_admin.network_client.list_ports(
device_id=self.router['id'],
device_owner=lib_constants.DEVICE_OWNER_ROUTER_GW)['ports'][0]
ovn_gateway_mtu = self.get_router_port_gateway_mtu(router_port['id'])
self.assertEqual(
self.external_mtu, ovn_gateway_mtu,
"MTU is not set properly in OVN DB")
class GatewayMtuTestUdp(GatewayMtuTest):
credentials = ['primary', 'admin']
@decorators.idempotent_id('7f7470ff-31b4-4ad8-bfa7-82dcca174744')
def test_south_to_north_pmtud_udp_basic(self):
"""Verify that south->north path MTU discovery is working for UDP
Setup:
Environment with public network MTU smaller than tenant networks.
Scenario:
1. Create router connected to pre-existed external network.
It is expected that the external network MTU is lower than
internal network MTU (will be created in the next step)
2. Create internal network, connect it to the router and spawn
2 instances, one will be used as a proxy in order to be able
to access the test server even during no-FIP scenario.
3. Launch traffic capture on the test server and send a UDP
packet matching the internal network MTU to the host
connected to the external network (local address from
external network is used).
4. Validate that the router returned ICMP 'fragmentation
needed' message and send a new UDP packet matching MTU
in this message.
5. Validate that the smaller file was delivered to the external
address and the router did not send any ICMP message.
6. Add a FIP to the test server and repeat steps 3-5.
"""
self.check_pmtud_basic()
@decorators.idempotent_id('cab28be4-7d11-485b-b99e-ea511fe2a675')
def test_south_to_north_pmtud_udp_change_mtu(self):
"""Verify that south->north path MTU discovery is working for UDP
Setup:
Environment with public network MTU smaller than tenant networks.
Scenario:
1. Create router connected to pre-existed external network.
It is expected that the external network MTU is lower than
internal network MTU (will be created in the next step)
2. Create internal network, connect it to the router and spawn
2 instances, one will be used as a proxy in order to be able
to access the test server even during no-FIP scenario.
3. Verify that OVN DB MTU entries are configured correctly.
4. Change MTU of the external network and verify that OVN DB
MTU settings upated accordingly.
5. Verify that south->north path MTU discovery is working for UDP
using new the MTU (see details in test_south_to_north_pmtud_udp
description, steps 3-6)
6. After the test the original MTU of the external network is
restored.
"""
self.setup()
new_mtu = int(self.external_mtu) - 20
self.external_mtu = self.os_admin.network_client.update_network(
CONF.network.public_network_id, mtu=new_mtu)['network']['mtu']
self._validate_ovn_db_mtu_settings()
minimal_payload_causing_fragmentation = (
self.external_mtu - constants.ETHERNET_HEADER_LENGTH + 1)
self.validate_next_hop_mtu(
starting_payload_size=minimal_payload_causing_fragmentation)
self.create_floatingip(port=self.test_server['port'])
self.validate_next_hop_mtu(
starting_payload_size=minimal_payload_causing_fragmentation)
class GatewayMtuTestIcmp(GatewayMtuTest):
@ -276,87 +362,3 @@ class GatewayMtuTestIcmp(GatewayMtuTest):
@decorators.idempotent_id('10d73cf0-7506-4899-864c-cebe43099be3')
def test_northbound_pmtud_icmp(self):
self.check_pmtud_basic()
class GatewayMtuTestOvn(GatewayMtuTest, base.BaseTempestTestCaseOvn):
credentials = ['primary', 'admin']
def _validate_ovn_db_mtu_settings(self):
router_port = self.os_admin.network_client.list_ports(
device_id=self.router['id'],
device_owner=lib_constants.DEVICE_OWNER_ROUTER_GW)['ports'][0]
ovn_gateway_mtu = self.get_router_port_gateway_mtu(router_port['id'])
self.assertEqual(
self.external_mtu, ovn_gateway_mtu,
"MTU is not set properly in OVN DB")
def _restore_external_network_mtu(self):
self.os_admin.network_client.update_network(
CONF.network.public_network_id, mtu=self.original_mtu)
@decorators.idempotent_id('7f7470ff-31b4-4ad8-bfa7-82dcca174744')
def test_south_to_north_pmtud_udp_basic(self):
"""Verify that south->north path MTU discovery is working for UDP
Setup:
Environment with public network MTU smaller than tenant networks.
Scenario:
1. Create router connected to pre-existed external network.
It is expected that the external network MTU is lower than
internal network MTU (will be created in the next step)
2. Create internal network, connect it to the router and spawn
2 instances, one will be used as a proxy in order to be able
to access the test server even during no-FIP scenario.
3. Launch traffic capture on the test server and send a UDP
packet matching the internal network MTU to the host
connected to the external network (local address from
external network is used).
4. Validate that the router returned ICMP 'fragmentation
needed' message and send a new UDP packet matching MTU
in this message.
5. Validate that the smaller file was delivered to the external
address and the router did not send any ICMP message.
6. Add a FIP to the test server and repeat steps 3-5.
"""
self.check_pmtud_basic()
@decorators.idempotent_id('cab28be4-7d11-485b-b99e-ea511fe2a675')
def test_south_to_north_pmtud_udp_change_mtu(self):
"""Verify that south->north path MTU discovery is working for UDP
Setup:
Environment with public network MTU smaller than tenant networks.
Scenario:
1. Create router connected to pre-existed external network.
It is expected that the external network MTU is lower than
internal network MTU (will be created in the next step)
2. Create internal network, connect it to the router and spawn
2 instances, one will be used as a proxy in order to be able
to access the test server even during no-FIP scenario.
3. Verify that OVN DB MTU entries are configured correctly.
4. Change MTU of the external network and verify that OVN DB
MTU settings upated accordingly.
5. Verify that south->north path MTU discovery is working for UDP
using new the MTU (see details in test_south_to_north_pmtud_udp
description, steps 3-6)
6. After the test the original MTU of the external network is
restored.
"""
self.setup()
self._validate_ovn_db_mtu_settings()
self.original_mtu = self.external_network['mtu']
self.addCleanup(self._restore_external_network_mtu)
new_mtu = int(self.external_mtu) - 30
self.external_network = self.os_admin.network_client.update_network(
CONF.network.public_network_id, mtu=new_mtu)['network']
self.validate_current_mtus()
self._validate_ovn_db_mtu_settings()
minimal_payload_causing_fragmentation = (
self.external_mtu - constants.ETHERNET_HEADER_LENGTH + 1)
self.validate_next_hop_mtu(
starting_payload_size=minimal_payload_causing_fragmentation)
self.create_floatingip(port=self.test_server['port'])
self.validate_next_hop_mtu(
starting_payload_size=minimal_payload_causing_fragmentation)

View File

@ -26,6 +26,7 @@
(^whitebox_neutron_tempest_plugin.tests.scenario.test_router_flavors)|\
(^whitebox_neutron_tempest_plugin.tests.scenario.test_security_group_logging)|\
(^whitebox_neutron_tempest_plugin.tests.scenario.test_l3ha_ovn)|\
(^whitebox_neutron_tempest_plugin.tests.scenario.test_mtu)|\
(test_multicast.*restart)|\
(test_multicast.*ext*)|\
(^whitebox_neutron_tempest_plugin.*test_qos_user_policies)|\
@ -33,8 +34,7 @@
(^whitebox_neutron_tempest_plugin.*many_vms)|\
(^whitebox_neutron_tempest_plugin.*test_previously_used_ip)|\
(^whitebox_neutron_tempest_plugin.tests.scenario.test_ovn_dbs.OvnDbsMonitoringTest.*)|\
(^whitebox_neutron_tempest_plugin.*ovn_controller_restart)|\
(test_south_to_north_pmtud_udp_change_mtu)"
(^whitebox_neutron_tempest_plugin.*ovn_controller_restart)"
devstack_localrc:
USE_PYTHON3: true
NETWORK_API_EXTENSIONS: "{{ (network_api_extensions_common + network_api_extensions_tempest) | join(',') }}"
@ -432,6 +432,8 @@
service_providers:
service_provider: "L3_ROUTER_NAT:user-defined:neutron.services.ovn_l3.service_providers.user_defined.UserDefined"
tempest_concurrency: 1
# (rsafrono) whitebox_neutron_tempest_plugin.tests.scenario.test_mtu are not enabled on devstack
# due to https://bugs.launchpad.net/neutron/+bug/2060828
tempest_test_regex: "\
(^whitebox_neutron_tempest_plugin.tests.scenario.test_metadata_rate_limiting)|\
(^whitebox_neutron_tempest_plugin.tests.scenario.test_router_flavors)|\
@ -444,8 +446,7 @@
(^whitebox_neutron_tempest_plugin.*many_vms)|\
(^whitebox_neutron_tempest_plugin.*test_previously_used_ip)|\
(^whitebox_neutron_tempest_plugin.tests.scenario.test_ovn_dbs.OvnDbsMonitoringTest.*)|\
(^whitebox_neutron_tempest_plugin.*ovn_controller_restart)|\
(test_south_to_north_pmtud_udp_change_mtu)"
(^whitebox_neutron_tempest_plugin.*ovn_controller_restart)"
tempest_exclude_regex: ""
- job: