Skip to content

Commit

Permalink
Merge branch 'main' into l1_tests_reboot_device
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriilisovskyi committed Jun 19, 2023
2 parents 5b01ffb + 898d3c7 commit 2f19191
Show file tree
Hide file tree
Showing 66 changed files with 2,189 additions and 821 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@
'suite_functional_storm_control': 'Functional Storm Control tests',
'suite_functional_policer': 'Policer functional tests',
'suite_functional_devlink': 'Devlink functional tests',
'suite_functional_hard_drop_counters': 'Hard Drop counters functional tests',
'suite_functional_table_size': 'Table size functional tests',
}

PYTEST_SUITE_GROUPS = {
Expand Down Expand Up @@ -127,5 +129,7 @@
'suite_functional_storm_control',
'suite_functional_policer',
'suite_functional_devlink',
'suite_functional_hard_drop_counters',
'suite_functional_table_size',
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
from functools import reduce
import pytest_asyncio
import asyncio

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 (
tgen_utils_get_dent_devices_with_tgen,
)


adv_modes = {
'10baseT/Half': 0x001,
'10baseT/Full': 0x002,
'100baseT/Half': 0x004,
'100baseT/Full': 0x008,
'1000baseT/Full': 0x020,
'10000baseT/Full': 0x1000,
}


@pytest_asyncio.fixture()
async def restore_port_speed(testbed):
tgen_dev, dent_devices = await tgen_utils_get_dent_devices_with_tgen(testbed, [], 2)
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]

out = await IpLink.show(input_data=[{dent: [{'cmd_options': '-j'}]}], parse_output=True)
assert out[0][dent]['rc'] == 0, 'Failed to get port state'

if not all(link['operstate'] == 'UP'
for link in out[0][dent]['parsed_output']
if link['ifname'] in ports):
# not all ports are up
# port hast to be UP to see current advertisement modes and/or speed
out = await IpLink.set(input_data=[{dent: [
{'device': port, 'operstate': 'up'}
for port in ports
]}])
assert out[0][dent]['rc'] == 0, 'Failed to set operstate up'

await asyncio.sleep(10)

ethtool = await asyncio.gather(*[
Ethtool.show(input_data=[{dent: [{'devname': port}]}], parse_output=True)
for port in ports
])
assert all(out[0][dent]['rc'] == 0 for out in ethtool), 'Failed to get ports\' speed'

yield # Run the test

cmd = []
for out, port in zip(ethtool, ports):
mode = out[0][dent]['parsed_output']
if 'Unknown!' in mode['speed']:
continue
if mode['auto-negotiation'] == 'on':
adv = reduce(lambda x, y: x | y,
[adv_modes[m]
for m in mode['advertised_link_modes'].split(' ')
if m in adv_modes])
cmd.append({
'devname': port,
'autoneg': mode['auto-negotiation'],
'advertise': f'{adv:X}',
})
else: # not autoneg
cmd.append({
'devname': port,
'autoneg': 'off',
'speed': int(mode['speed'][:-4]),
'duplex': mode['duplex'].lower(),
})

if cmd:
await Ethtool.set(input_data=[{dent: cmd}])
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

pytestmark = [pytest.mark.suite_functional_l1,
pytest.mark.asyncio,
pytest.mark.usefixtures('cleanup_bridges', 'cleanup_tgen')]
pytest.mark.usefixtures('cleanup_bridges', 'cleanup_tgen', 'restore_port_speed')]


@pytest.mark.parametrize('speed , duplex',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

pytestmark = [pytest.mark.suite_functional_l1,
pytest.mark.asyncio,
pytest.mark.usefixtures('cleanup_bridges', 'cleanup_tgen')]
pytest.mark.usefixtures('cleanup_bridges', 'cleanup_tgen', 'restore_port_speed')]


@pytest.mark.parametrize('speed , duplex',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

pytestmark = [pytest.mark.suite_functional_l1,
pytest.mark.asyncio,
pytest.mark.usefixtures('cleanup_bridges', 'cleanup_tgen')]
pytest.mark.usefixtures('cleanup_bridges', 'cleanup_tgen', 'restore_port_speed')]


@pytest.mark.parametrize('l1_settings', ['autodetect', 'autoneg'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

pytestmark = [pytest.mark.suite_functional_l1,
pytest.mark.asyncio,
pytest.mark.usefixtures('cleanup_bridges', 'cleanup_tgen')]
pytest.mark.usefixtures('cleanup_bridges', 'cleanup_tgen', 'restore_port_speed')]


@pytest.mark.parametrize('speed , duplex',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

pytestmark = [pytest.mark.suite_functional_l1,
pytest.mark.asyncio,
pytest.mark.usefixtures('cleanup_bridges', 'cleanup_tgen')]
pytest.mark.usefixtures('cleanup_bridges', 'cleanup_tgen', 'restore_port_speed')]


async def test_l1_mixed_speed(testbed):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ async def test_l1_port_state_status(testbed):
await port_state(testbed, 1)


@pytest.mark.skip(reason='https://github.com/dentproject/dentOS/issues/152')
async def test_l1_link_up_state_software_power_cycle(testbed):
"""
Test Name: test_l1_link_up_state_software_power_cycle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ async def test_acl_all_selectors(testbed, action, use_tagged_traffic, qdisc_type
await tgen_utils_stop_traffic(tgen_dev)

# 10. Verify "pass" and "trap" traffic was forwarded, "drop" was dropped
await asyncio.sleep(5)
ixia_stats = await tgen_utils_get_traffic_stats(tgen_dev, 'Flow Statistics')

for row in ixia_stats.Rows:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,8 @@ async def test_bridging_admin_state_down_up(testbed):
await tgen_utils_stop_traffic(tgen_dev)

# check the traffic stats
stats = await tgen_utils_get_traffic_stats(tgen_dev, 'Traffic Item Statistics')
stats = await tgen_utils_get_traffic_stats(tgen_dev, 'Flow Statistics')
for row in stats.Rows:
assert float(row['Tx Frames']) > 0.000, f'Failed>Ixia should transmit traffic: {row["Tx Frames"]}'
assert tgen_utils_get_loss(row) == 100.000, \
f"Verify that traffic from {row['Tx Port']} to {row['Rx Port']} not forwarded.\n{out}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ async def test_bridging_ageing_refresh(testbed):
await tgen_utils_stop_traffic(tgen_dev)

# check the traffic stats
stats = await tgen_utils_get_traffic_stats(tgen_dev, 'Traffic Item Statistics')
stats = await tgen_utils_get_traffic_stats(tgen_dev, 'Flow Statistics')
for row in stats.Rows:
assert tgen_utils_get_loss(row) == 0.000, \
f"Verify that traffic from {row['Tx Port']} to {row['Rx Port']} forwarded.\n{out}"
Expand All @@ -130,7 +130,7 @@ async def test_bridging_ageing_refresh(testbed):
await tgen_utils_start_traffic(tgen_dev)

# check the traffic stats
stats = await tgen_utils_get_traffic_stats(tgen_dev, 'Traffic Item Statistics')
stats = await tgen_utils_get_traffic_stats(tgen_dev, 'Flow Statistics')
for row in stats.Rows:
assert tgen_utils_get_loss(row) == 0.000, \
f"Verify that traffic from {row['Tx Port']} to {row['Rx Port']} forwarded.\n{out}"
Expand All @@ -151,7 +151,7 @@ async def test_bridging_ageing_refresh(testbed):
await asyncio.sleep(2*ageing_time)

# check the traffic stats
stats = await tgen_utils_get_traffic_stats(tgen_dev, 'Traffic Item Statistics')
stats = await tgen_utils_get_traffic_stats(tgen_dev, 'Flow Statistics')
for row in stats.Rows:
assert tgen_utils_get_loss(row) == 0.000, \
f"Verify that traffic from {row['Tx Port']} to {row['Rx Port']} forwarded.\n{out}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ async def test_bridging_bum_traffic_bridge_with_rif(testbed):
list_streams = get_streams(srcMac, self_mac, prefix, dev_groups, tg_ports)
await tgen_utils_setup_streams(tgen_dev, config_file_name=None, streams=list_streams)

tcpdump = asyncio.create_task(tb_device_tcpdump(dent_dev, 'swp1', '-n', count_only=False, timeout=5, dump=True))
tcpdump = asyncio.create_task(tb_device_tcpdump(dent_dev, ports[0], '-n', count_only=False, timeout=15, dump=True))

await tgen_utils_start_traffic(tgen_dev)
await asyncio.sleep(traffic_duration)
Expand Down Expand Up @@ -140,9 +140,7 @@ async def test_bridging_bum_traffic_bridge_with_rif(testbed):
assert tgen_utils_get_loss(row) == expected_loss[row['Traffic Item']], \
'Verify that traffic from swp1 to swp2 forwarded/not forwarded in accordance.'

await tcpdump
print(f'TCPDUMP: packets={tcpdump.result()}')
data = tcpdump.result()
data = await tcpdump

count_of_packets = re.findall(r'(\d+) packets (captured|received|dropped)', data)
for count, type in count_of_packets:
Expand Down Expand Up @@ -222,7 +220,7 @@ async def test_bridging_bum_traffic_bridge_without_rif(testbed):
list_streams = get_streams(srcMac, self_mac, prefix, dev_groups, tg_ports)
await tgen_utils_setup_streams(tgen_dev, config_file_name=None, streams=list_streams)

tcpdump = asyncio.create_task(tb_device_tcpdump(dent_dev, 'swp1', '-n', count_only=False, timeout=5, dump=True))
tcpdump = asyncio.create_task(tb_device_tcpdump(dent_dev, ports[0], '-n', count_only=False, timeout=15, dump=True))

await tgen_utils_start_traffic(tgen_dev)
await asyncio.sleep(traffic_duration)
Expand Down Expand Up @@ -258,9 +256,7 @@ async def test_bridging_bum_traffic_bridge_without_rif(testbed):
assert tgen_utils_get_loss(row) == expected_loss[row['Traffic Item']], \
'Verify that traffic from swp1 to swp2 forwarded/not forwarded in accordance.'

await tcpdump
print(f'TCPDUMP: packets={tcpdump.result()}')
data = tcpdump.result()
data = await tcpdump

count_of_packets = re.findall(r'(\d+) packets (captured|received|dropped)', data)
for count, type in count_of_packets:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,21 +90,19 @@ async def test_bridging_bum_traffic_port_with_rif(testbed):
list_streams = get_streams(srcMac, self_mac, prefix, dev_groups, tg_ports)
await tgen_utils_setup_streams(tgen_dev, config_file_name=None, streams=list_streams)

tcpdump = asyncio.create_task(tb_device_tcpdump(dent_dev, 'swp1', '-n', count_only=False, timeout=5, dump=True))
tcpdump = asyncio.create_task(tb_device_tcpdump(dent_dev, ports[0], '-n', count_only=False, timeout=15, dump=True))

await tgen_utils_start_traffic(tgen_dev)
await asyncio.sleep(traffic_duration)
await tgen_utils_stop_traffic(tgen_dev)

# check the traffic stats
stats = await tgen_utils_get_traffic_stats(tgen_dev, 'Traffic Item Statistics')
stats = await tgen_utils_get_traffic_stats(tgen_dev, 'Flow Statistics')
for row in stats.Rows:
assert tgen_utils_get_loss(row) == 100.000, \
f"Verify that traffic from {row['Tx Port']} to {row['Rx Port']} not forwarded.\n{out}"

await tcpdump
print(f'TCPDUMP: packets={tcpdump.result()}')
data = tcpdump.result()
data = await tcpdump

count_of_packets = re.findall(r'(\d+) packets (captured|received|dropped)', data)
for count, type in count_of_packets:
Expand Down Expand Up @@ -170,21 +168,19 @@ async def test_bridging_bum_traffic_port_without_rif(testbed):
list_streams = get_streams(srcMac, self_mac, prefix, dev_groups, tg_ports)
await tgen_utils_setup_streams(tgen_dev, config_file_name=None, streams=list_streams)

tcpdump = asyncio.create_task(tb_device_tcpdump(dent_dev, 'swp1', '-n', count_only=False, timeout=5, dump=True))
tcpdump = asyncio.create_task(tb_device_tcpdump(dent_dev, ports[0], '-n', count_only=False, timeout=15, dump=True))

await tgen_utils_start_traffic(tgen_dev)
await asyncio.sleep(traffic_duration)
await tgen_utils_stop_traffic(tgen_dev)

# check the traffic stats
stats = await tgen_utils_get_traffic_stats(tgen_dev, 'Traffic Item Statistics')
stats = await tgen_utils_get_traffic_stats(tgen_dev, 'Flow Statistics')
for row in stats.Rows:
assert tgen_utils_get_loss(row) == 100.000, \
f"Verify that traffic from {row['Tx Port']} to {row['Rx Port']} not forwarded.\n{out}"

await tcpdump
print(f'TCPDUMP: packets={tcpdump.result()}')
data = tcpdump.result()
data = await tcpdump

count_of_packets = re.findall(r'(\d+) packets (captured|received|dropped)', data)
for count, type in count_of_packets:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ async def test_bridging_backward_forwarding(testbed):
await tgen_utils_stop_traffic(tgen_dev)

# check the traffic stats
stats = await tgen_utils_get_traffic_stats(tgen_dev, 'Traffic Item Statistics')
stats = await tgen_utils_get_traffic_stats(tgen_dev, 'Flow Statistics')
for row in stats.Rows:
assert tgen_utils_get_loss(row) == 100.000, \
f"Verify that traffic from {row['Tx Port']} to {row['Rx Port']} not forwarded.\n{out}"
Expand Down Expand Up @@ -316,7 +316,7 @@ async def test_bridging_forward_block_different_packets(testbed):
await tgen_utils_stop_traffic(tgen_dev)

# check the traffic stats
stats = await tgen_utils_get_traffic_stats(tgen_dev, 'Traffic Item Statistics')
stats = await tgen_utils_get_traffic_stats(tgen_dev, 'Flow Statistics')
for row in stats.Rows:
assert tgen_utils_get_loss(row) == 0.000, \
f"Verify that traffic from {row['Tx Port']} to {row['Rx Port']} forwarded.\n{out}"
Expand Down Expand Up @@ -403,7 +403,7 @@ async def test_bridging_fdb_flush_on_down(testbed):
await tgen_utils_stop_traffic(tgen_dev)

# check the traffic stats
stats = await tgen_utils_get_traffic_stats(tgen_dev, 'Traffic Item Statistics')
stats = await tgen_utils_get_traffic_stats(tgen_dev, 'Flow Statistics')
for row in stats.Rows:
assert tgen_utils_get_loss(row) == 0.000, \
f"Verify that traffic from {row['Tx Port']} to {row['Rx Port']} forwarded.\n{out}"
Expand Down Expand Up @@ -576,6 +576,7 @@ async def test_bridging_unregistered_traffic(testbed):
traffic_duration = 10
mac_count = 1500
pps_value = 1000
wait = 6

out = await IpLink.add(
input_data=[{device_host_name: [
Expand Down Expand Up @@ -652,9 +653,10 @@ async def test_bridging_unregistered_traffic(testbed):
await tgen_utils_start_traffic(tgen_dev)
await asyncio.sleep(traffic_duration)
await tgen_utils_stop_traffic(tgen_dev)
await asyncio.sleep(wait)

# check the traffic stats
stats = await tgen_utils_get_traffic_stats(tgen_dev, 'Traffic Item Statistics')
stats = await tgen_utils_get_traffic_stats(tgen_dev, 'Flow Statistics')
for row in stats.Rows:
assert tgen_utils_get_loss(row) == 0.000, \
f"Verify that traffic from {row['Tx Port']} to {row['Rx Port']} forwarded.\n{out}"
Expand All @@ -668,9 +670,10 @@ async def test_bridging_unregistered_traffic(testbed):
await tgen_utils_start_traffic(tgen_dev)
await asyncio.sleep(traffic_duration)
await tgen_utils_stop_traffic(tgen_dev)
await asyncio.sleep(wait)

# check the traffic stats
stats = await tgen_utils_get_traffic_stats(tgen_dev, 'Traffic Item Statistics')
stats = await tgen_utils_get_traffic_stats(tgen_dev, 'Flow Statistics')
for row in stats.Rows:
assert tgen_utils_get_loss(row) == 100.000, \
f"Verify that traffic from {row['Tx Port']} to {row['Rx Port']} not forwarded.\n{out}"
Expand All @@ -684,9 +687,10 @@ async def test_bridging_unregistered_traffic(testbed):
await tgen_utils_start_traffic(tgen_dev)
await asyncio.sleep(traffic_duration)
await tgen_utils_stop_traffic(tgen_dev)
await asyncio.sleep(wait)

# check the traffic stats
stats = await tgen_utils_get_traffic_stats(tgen_dev, 'Traffic Item Statistics')
stats = await tgen_utils_get_traffic_stats(tgen_dev, 'Flow Statistics')
for row in stats.Rows:
assert tgen_utils_get_loss(row) == 0.000, \
f"Verify that traffic from {row['Tx Port']} to {row['Rx Port']} forwarded.\n{out}"
Expand Down Expand Up @@ -772,7 +776,7 @@ async def test_bridging_wrong_fcs(testbed):
await tgen_utils_stop_traffic(tgen_dev)

# check the traffic stats
stats = await tgen_utils_get_traffic_stats(tgen_dev, 'Traffic Item Statistics')
stats = await tgen_utils_get_traffic_stats(tgen_dev, 'Flow Statistics')
for row in stats.Rows:
assert float(row['Tx Frames']) > 0.000, f'Failed>Ixia should transmit traffic: {row["Tx Frames"]}'
assert tgen_utils_get_loss(row) == 100.000, \
Expand Down
Loading

0 comments on commit 2f19191

Please sign in to comment.