Skip to content

Commit

Permalink
Merge branch 'main' into functional_refactor_storm_control
Browse files Browse the repository at this point in the history
  • Loading branch information
stavrukPLV authored May 5, 2023
2 parents 0c019db + 2d8049e commit bd96b82
Show file tree
Hide file tree
Showing 39 changed files with 2,985 additions and 304 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
'suite_functional_port_isolation': 'Functional Port Isolation tests',
'suite_functional_igmp': 'IGMP snooping functional tests',
'suite_functional_storm_control': 'Functional Storm Control tests',
'suite_functional_policer': 'Policer functional tests',
}

PYTEST_SUITE_GROUPS = {
Expand Down Expand Up @@ -123,5 +124,6 @@
'suite_functional_port_isolation',
'suite_functional_igmp',
'suite_functional_storm_control',
'suite_functional_policer',
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
pytestmark = [
pytest.mark.suite_functional_bridging,
pytest.mark.asyncio,
pytest.mark.usefixtures('cleanup_bridges', 'cleanup_tgen')
pytest.mark.usefixtures('cleanup_bridges', 'cleanup_tgen', 'cleanup_mtu')
]


Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import pytest
import asyncio

from dent_os_testbed.utils.test_utils.tb_utils import get_port_stats
from dent_os_testbed.lib.bridge.bridge_link import BridgeLink
from dent_os_testbed.lib.bridge.bridge_fdb import BridgeFdb
from dent_os_testbed.lib.ethtool.ethtool import Ethtool
from dent_os_testbed.lib.ip.ip_link import IpLink

from dent_os_testbed.utils.test_utils.tgen_utils import (
Expand All @@ -25,17 +25,6 @@
]


async def get_port_stats(device_host_name, ports):
stats = {}
for port in ports:
out = await Ethtool.show(input_data=[{device_host_name: [
{'devname': port, 'options': '-S'}
]}], parse_output=True)
assert out[0][device_host_name]['rc'] == 0
stats[port] = out[0][device_host_name]['parsed_output']
return stats


async def test_bridging_packets_oversize(testbed):
"""
Test Name: test_bridging_packets_oversize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,13 @@ async def remove_default_gateway(testbed):


@pytest_asyncio.fixture()
async def change_port_mtu(testbed):
async def cleanup_mtu(testbed):
tgen_dev, dent_devices = await tgen_utils_get_dent_devices_with_tgen(testbed, [], 4)
if not tgen_dev or not dent_devices:
print('The testbed does not have enough dent with tgen connections')
return
dent = dent_devices[0].host_name
ports = tgen_dev.links_dict[dent][1]
mtu = 1000

# Get current mtu to restore it later
out = await IpLink.show(input_data=[{dent: [
Expand All @@ -111,12 +110,6 @@ async def change_port_mtu(testbed):

def_mtu_map = [link for link in out[0][dent]['parsed_output'] if link['ifname'] in ports]

# Configure new mtu
out = await IpLink.set(input_data=[{dent: [
{'device': port, 'mtu': mtu} for port in ports
]}])
assert out[0][dent]['rc'] == 0, 'Failed to set port mtu'

yield # Run the test

# Restore old mtu
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async def get_port_stats(dent, ports):
return stats


@pytest.mark.usefixtures('change_port_mtu')
@pytest.mark.usefixtures('cleanup_mtu')
async def test_ipv4_oversized_mtu(testbed):
"""
Test Name: test_ipv4_oversized_mtu
Expand All @@ -57,6 +57,8 @@ async def test_ipv4_oversized_mtu(testbed):
ports = tgen_dev.links_dict[dent][1]
traffic_duration = 10
delayed_stats_update_time = 10
mtu = 1000

address_map = (
# swp port, tg port, swp ip, tg ip, plen
(ports[0], tg_ports[0], '1.1.1.1', '1.1.1.2', 24),
Expand Down Expand Up @@ -101,7 +103,11 @@ async def test_ipv4_oversized_mtu(testbed):

await tgen_utils_setup_streams(tgen_dev, None, streams)

# 4. Port mtu should be configured in the change_port_mtu fixture
# 4. Configure interfaces MTU to 1000
out = await IpLink.set(input_data=[{dent: [
{'device': port, 'mtu': mtu} for port in ports
]}])
assert out[0][dent]['rc'] == 0, 'Failed to set port mtu'

# 5. Generate traffic with packet size 1200
old_stats = await get_port_stats(dent, (port for port, *_ in address_map))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@ async def verify_dut_routes(dent, expected_routes):

for expected_route in expected_routes:
for route in routes:
for key in expected_route: # find matching route
if key == 'flags':
continue
if expected_route[key] != route[key]:
break
else: # route found
assert all(flag in route['flags'] for flag in expected_route['flags']), \
f'Route {route} should have {expected_route["flags"]} flags'
break
if not all(expected_route[key] == route.get(key)
for key in expected_route
if key not in ['flags', 'should_exist']):
# if some keys do not match go to the next route
continue
# route found
assert expected_route['should_exist'], f'Route {route} found, but not expected'
assert all(flag in route['flags'] for flag in expected_route['flags']), \
f'Route {route} should have {expected_route["flags"]} flags'
break
else: # route not found
raise LookupError(f'Route {expected_route} expected, but not found')
if expected_route['should_exist']:
raise LookupError(f'Route {expected_route} expected, but not found')


async def verify_dut_neighbors(dent, expected_neis):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ async def test_ipv6_basic_config(testbed):

expected_routes = [{'dev': info.swp,
'dst': info.swp_ip[:-1] + f'/{info.plen}',
'should_exist': True,
'flags': ['rt_trap']}
for info in address_map]
await verify_dut_routes(dent, expected_routes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ async def test_ipv6_on_bridge(testbed):
# connected routes added and offloaded
expected_routes = [{'dev': info.swp,
'dst': info.swp_ip[:-1] + f'/{info.plen}',
'should_exist': True,
'flags': ['rt_trap']}
for info in address_map]
await verify_dut_routes(dent, expected_routes)
Expand Down Expand Up @@ -334,6 +335,7 @@ async def test_ipv6_move_host_on_bridge(testbed):
# 2. Verify IP configuration: no errors on IP address adding, connected routes added and offloaded
expected_routes = [{'dev': info.swp,
'dst': info.swp_ip[:-1] + f'/{info.plen}',
'should_exist': True,
'flags': ['rt_trap']}
for info in address_map]
await verify_dut_routes(dent, expected_routes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,12 @@ async def test_ipv64_nh_reconfig(testbed):

expected_routes = [{'dev': info.swp,
'dst': info.swp_ip[:-1] + ('0/' if version == IPV4 else '/') + str(info.plen),
'should_exist': True,
'flags': ['rt_trap']}
for info in address_map[version]]
expected_routes += [{'dev': nh_route[version].swp,
'dst': f'{nh_route[version].dst}/{nh_route[version].plen}',
'should_exist': True,
'flags': ['offload', 'rt_offload']}]
await verify_dut_routes(dent, expected_routes)

Expand Down Expand Up @@ -377,10 +379,12 @@ async def test_ipv64_nh_routes(testbed):
# Verify connected routes added and offloaded
expected_routes = [{'dev': info.swp,
'dst': info.swp_ip[:-1] + ('/' if ':' in info.swp_ip else '0/') + str(info.plen),
'should_exist': True,
'flags': ['rt_trap']}
for info in address_map]
expected_routes += [{'dev': route.swp,
'dst': f'{route.dst}/{route.plen}',
'should_exist': True,
'flags': ['offload', 'rt_offload']}
for route in nh_route]
await verify_dut_routes(dent, expected_routes)
Loading

0 comments on commit bd96b82

Please sign in to comment.