Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2889 v2 #34

Merged
merged 38 commits into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
7a9f925
fix: #9 converter breaks with custom port rate
fpfeng Jan 20, 2023
432201d
Merge pull request #11 from xenanetworks/fix-converter-enum
Jan 20, 2023
11aef83
refactor: adjust 2889 folder structure
fpfeng Jan 30, 2023
c832936
Merge pull request #14 from xenanetworks/fch-fix-2889metaxml
Jan 30, 2023
9ed781d
fix: xenanetworks/open-automation-config-converter#17 use enum name
fpfeng Feb 7, 2023
1e65b8e
fix: xenanetworks/open-automation-config-converter#17 use enum name only
fpfeng Feb 14, 2023
1fa73a3
Merge pull request #20 from xenanetworks/fix-use-enum-name
Feb 16, 2023
d00e9f2
Update ts versions to 1.0.1
Feb 16, 2023
15759e4
Merge pull request #21 from xenanetworks/hyu-ts-versions
Feb 16, 2023
4e291ca
feat: create subclass for testing
fpfeng Mar 3, 2023
d8aa6d3
fix: missing check port link before start test
fpfeng Mar 3, 2023
5529582
fix: rate cap unit enum name not match
fpfeng Mar 3, 2023
bc2dd14
fix: init statistics
fpfeng Mar 8, 2023
cc1edcb
fix: wrong ietf default packets
fpfeng Mar 14, 2023
f5f30b5
fix: add reset stats delay
fpfeng Mar 14, 2023
d3bdd0d
fix: not rounding decimal
fpfeng Mar 14, 2023
40b14f1
fix: collect total rx packet from tpld
fpfeng Mar 14, 2023
0b51c8d
fix: add reset delay and max retry check link
fpfeng Mar 14, 2023
e098f59
fix: typo
fpfeng Mar 14, 2023
ab6befc
feat: send out final stats
fpfeng Mar 14, 2023
aae3780
refactor: cleanup code
fpfeng Mar 16, 2023
6dfc743
build: bump version
fpfeng Mar 16, 2023
f1f18e8
refactor: remove debug log
fpfeng Mar 17, 2023
f9003df
fix: error when read empty stats
fpfeng Mar 17, 2023
9310de3
Merge pull request #26 from xenanetworks/2889-bug-fix
Mar 17, 2023
355209d
fix: #27 create port pairs error
fpfeng Mar 20, 2023
8481a98
build: bump version
fpfeng Mar 20, 2023
2f891b6
Merge pull request #28 from xenanetworks/2889-bug-fix
Mar 20, 2023
c5a6f45
fix: #29 set port mdi mode
fpfeng Apr 14, 2023
e72b571
fix: #29 get ipv6 address error
fpfeng Apr 14, 2023
7165bb8
Merge pull request #30 from xenanetworks/fch-2544-fix-error
Apr 18, 2023
6c029ff
Update 2544 version to 1.0.2
Apr 18, 2023
61809d3
Merge pull request #31 from xenanetworks/update_2544_version
Apr 18, 2023
3829146
Add release note generator
Apr 19, 2023
aef246b
feat: tweak for driver v2
fpfeng May 18, 2023
8592fca
fix: update enum value
fpfeng May 18, 2023
2bdd6de
fix: pure hex mac address as driver
fpfeng May 18, 2023
ca5875f
refactor: remove 0x from hex
fpfeng May 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# .github/release.yml

changelog:
exclude:
labels:
- ignore-for-release
categories:
- title: 💥 Breaking Changes
labels:
- breaking-change
- title: 🎉 Exciting New Features
labels:
- feature
- title: 🎨 Improvements
labels:
- improvement
- title: 🐛 Bug Fixes
labels:
- bug
- title: 📝 Documentation
labels:
- documentation
- title: Other Changes
labels:
- "*"
2 changes: 1 addition & 1 deletion plugin2544/meta.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "RFC-2544"
version: "1.0.0"
version: "1.0.2"
core_version: ">=1.0.0"
author:
- "MC"
Expand Down
4 changes: 2 additions & 2 deletions plugin2544/plugin/learning.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def get_bytes_from_macaddress(dmac: "MacAddress") -> Iterator[str]:

def get_link_local_uci_ipv6address(dmac: "MacAddress") -> str:
b = get_bytes_from_macaddress(dmac)
return f"FE80000000000000{int(next(b)) | 2 }{next(b)}{next(b)}FFFE{next(b)}{next(b)}{next(b)}"
return f"FE80000000000000{int(next(b), 16) | 2 }{next(b)}{next(b)}FFFE{next(b)}{next(b)}{next(b)}"[:-1]


def get_address_list(
Expand Down Expand Up @@ -125,7 +125,7 @@ async def get_address_learning_packet(
packet = NDPPacket(
smac=smac,
source_ip=IPv6Address(source_ip),
destination_ip=IPv6Address(destination_ip),
destination_ip=IPv6Address(int(destination_ip, 16)),
dmac=dmac,
).make_ndp_packet()
packet_list.append(packet)
Expand Down
5 changes: 3 additions & 2 deletions plugin2544/plugin/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from .stream_struct import StreamStruct
from ..utils import exceptions, constants as const
from ..utils.field import MacAddress, NonNegativeDecimal

if TYPE_CHECKING:
from xoa_core.core.test_suites.datasets import PortIdentity
from xoa_driver import ports as xoa_ports, testers as xoa_testers
Expand Down Expand Up @@ -108,7 +107,9 @@ async def set_broadr_reach_mode(self, broadr_reach_mode: const.BRRModeStr) -> No
await self.port_ins.brr_mode.set(broadr_reach_mode.to_xmp())

async def set_mdi_mdix_mode(self, mdi_mdix_mode: const.MdiMdixMode) -> None:
if self.port_ins.info.capabilities.can_mdi_mdix == enums.YesNo.NO:
is_port_can_mdi_mdix = self.port_ins.info.capabilities.can_mdi_mdix == enums.YesNo.YES
is_port_can_set_speed = self.port_ins.info.port_possible_speed_modes
if not is_port_can_mdi_mdix or (is_port_can_mdi_mdix and not is_port_can_set_speed):
self._xoa_out.send_warning(
exceptions.MdiMdixModeNotSupport(self._port_identity.name)
)
Expand Down
85 changes: 85 additions & 0 deletions plugin2889/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import hashlib
import traceback
from pathlib import Path
from typing import TYPE_CHECKING
from xoa_core.types import PluginAbstract

if TYPE_CHECKING:
from plugin2889.dataset import TestSuiteConfiguration2889

from plugin2889.plugin.dataset import TestSuiteDataSharing
from plugin2889.const import TestType
from plugin2889.util.logger import logger
from plugin2889.plugin.test_abstract import PluginParameter
from plugin2889.plugin.test_rate import RateTest
from plugin2889.plugin.test_congestion_control import CongestionControlTest
from plugin2889.plugin.test_forward_pressure import ForwardPressureTest
from plugin2889.plugin.test_max_forwarding_rate import MaxForwardingRateTest
from plugin2889.plugin.test_address_caching_capacity import AddressCachingCapacityTest
from plugin2889.plugin.test_address_learning_rate import AddressLearningRateTest
from plugin2889.plugin.test_errored_frames_filtering import ErroredFramesFilteringTest
from plugin2889.plugin.test_broadcast_forwarding import BroadcastForwardingTest


TEST_TYPE_CLASS = {
TestType.RATE_TEST: RateTest,
TestType.CONGESTION_CONTROL: CongestionControlTest,
TestType.FORWARD_PRESSURE: ForwardPressureTest,
TestType.MAX_FORWARDING_RATE: MaxForwardingRateTest,
TestType.ADDRESS_CACHING_CAPACITY: AddressCachingCapacityTest,
TestType.ADDRESS_LEARNING_RATE: AddressLearningRateTest,
TestType.ERRORED_FRAMES_FILTERING: ErroredFramesFilteringTest,
TestType.BROADCAST_FORWARDING: BroadcastForwardingTest,
}

TEST_ERROR_PATH = Path().resolve() / 'test_error'


class TestSuite2889(PluginAbstract["TestSuiteConfiguration2889"]):
def prepare(self) -> None:
pass

async def __do_test(self) -> None:
plugin_params = PluginParameter(
testers=self.testers,
port_identities=self.port_identities,
xoa_out=self.xoa_out,
full_test_config=self.cfg,
data_sharing=TestSuiteDataSharing(),
state_conditions=self.state_conditions,
)
for test_suit_config in self.cfg.enabled_test_suit_config_list:
test_suit_class = TEST_TYPE_CLASS[test_suit_config.test_type]
logger.debug(f"init {test_suit_class}")
await test_suit_class(plugin_params, test_suit_config).start()

async def __post_test(self) -> None:
logger.info("test finish")

async def start(self) -> None:
await self.__do_test()
await self.__post_test()






class TestSuite2889Testing(TestSuite2889):
def get_error_id(self, tb_exc: str) -> str:
return hashlib.md5(tb_exc.encode('utf-8')).hexdigest()

async def start(self) -> None:
TEST_ERROR_PATH.mkdir(exist_ok=True)
try:
await super().start()
except Exception:
tb_exc = traceback.format_exc()
error_id = self.get_error_id(tb_exc)
current_error_path = TEST_ERROR_PATH / error_id
current_error_path.mkdir(exist_ok=True)
with open(current_error_path / 'traceback.txt', 'w') as error_log:
traceback.print_exc(file=error_log)
self.xoa_out.send_statistics({
'error_id': error_id
})
57 changes: 44 additions & 13 deletions plugin2889/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@
DELAY_LEARNING_MAC = 1
DELAY_LEARNING_ADDRESS = 1
DELAY_CREATE_PORT_PAIR = 3
DELAY_WAIT_RESET_PORT = 5
DELAY_WAIT_RESET_STATS = 2
INTERVAL_CHECK_SHOULD_STOP_TRAFFIC = 0.01
INTERVAL_CHECK_PORT_SYNC = 1
INTERVAL_CHECK_PORT_RESERVE = 0.5
INTERVAL_CLEAR_STATISTICS = 0.01
INTERVAL_INJECT_FCS_ERROR = 0.2

CHECK_SYNC_MAX_RETRY = 30

# https://en.wikipedia.org/wiki/Ethernet_frame
# 20 = Preamble + Start frame delimiter + Interpacket gap
Expand All @@ -27,14 +30,42 @@
DECIMAL_100 = Decimal(100)
WAIT_SYNC_STATE_TIMEOUT = 30
INVALID_PORT_ROLE = 'invalid port role'
DEFAULT_MIXED_PACKET_SIZE = (
56,
60,
64,
70,
78,
92,
256,
496,
512,
570,
576,
594,
1438,
1518,
9216,
16360,
)
DEFAULT_IETF_PACKET_SIZE = (
64,
128,
256,
512,
1024,
1280,
1518,
)
MIXED_DEFAULT_WEIGHTS = (0, 0, 0, 0, 57, 3, 5, 1, 2, 5, 1, 4, 4, 18, 0, 0)


class Enum(CaseSensitiveEnum):
@classmethod
def _missing_(cls, value):
if isinstance(value, str):
for member in cls:
if member.value == value.lower():
if member.name == value:
return member


Expand Down Expand Up @@ -156,8 +187,8 @@ def is_destination(self) -> bool:


class PortRateCapProfile(Enum):
PHYSICAL = "physical_port_rate"
CUSTOM = "custom_rate_cap"
PHYSICAL_PORT_RATE = "physical_port_rate"
CUSTOM = "custom"

@property
def is_custom(self) -> bool:
Expand Down Expand Up @@ -189,9 +220,9 @@ class StreamRateType(Enum):


class PortRateCapUnitInt(Enum):
GBPS = 1e9
MBPS = 1e6
KBPS = 1e3
FIELD_1E9_BPS = 1e9
FIELD_1E6_BPS = 1e6
FIELD_1E3_BPS = 1e3
BPS = 1


Expand Down Expand Up @@ -280,7 +311,7 @@ def is_pair_topology(self) -> bool:
return self == type(self).PAIRS


class LatencyModeStr(Enum):
class LatencyMode(Enum):
FIRST2LAST = "first_to_last"
LAST2LAST = "last_to_last"
FIRST2FIRST = "first_to_first"
Expand Down Expand Up @@ -310,17 +341,17 @@ def is_config_scope(self) -> bool:


class FECModeStr(Enum):
ON = "on"
OFF = "off"
FC_FEC = "fc_fec"
ON = "ON"
OFF = "OFF"
FC_FEC = "FIRECODE"

def to_xmp(self) -> "enums.FECMode":
return enums.FECMode[self.name]


class PacketSizeType(Enum):
IETF_DEFAULT = "ietf_default"
CUSTOM = "custom_sizes"
CUSTOM_SIZES = "custom_sizes"
RANGE = "specified"
INCREMENTING = "incrementing"
BUTTERFLY = "butterfly"
Expand All @@ -329,15 +360,15 @@ class PacketSizeType(Enum):

@property
def is_custom(self) -> bool:
return self == type(self).CUSTOM
return self == type(self).CUSTOM_SIZES

@property
def is_mix(self) -> bool:
return self == type(self).MIX

@property
def is_fix(self) -> bool:
return self in [type(self).IETF_DEFAULT, type(self).CUSTOM, type(self).RANGE]
return self in [type(self).IETF_DEFAULT, type(self).CUSTOM_SIZES, type(self).RANGE]

def to_xmp(self):
if self.is_fix:
Expand Down
Loading