Skip to content

Commit

Permalink
Merge pull request #34 from xenanetworks/2889-v2
Browse files Browse the repository at this point in the history
2889 v2
  • Loading branch information
Leonard Yu authored May 31, 2023
2 parents 704212a + ca5875f commit 3cc9f0b
Show file tree
Hide file tree
Showing 30 changed files with 980 additions and 251 deletions.
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:
- "*"
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

0 comments on commit 3cc9f0b

Please sign in to comment.