99 lines
3.5 KiB
Python
99 lines
3.5 KiB
Python
import pytest
|
|
|
|
|
|
def test_import_subpackages() -> None:
|
|
import fiwicontrol
|
|
import fiwicontrol.commands
|
|
import fiwicontrol.concentrator
|
|
import fiwicontrol.fabric
|
|
import fiwicontrol.flows
|
|
import fiwicontrol.fronthaul
|
|
import fiwicontrol.lab
|
|
import fiwicontrol.power
|
|
import fiwicontrol.radio
|
|
import fiwicontrol.spc
|
|
import fiwicontrol.telemetry
|
|
from fiwicontrol.concentrator import ConcentratorPlatform
|
|
from fiwicontrol.fabric import Fabric, FabricDefinition, FabricExitCode, FDIR_LOG_PREFIX
|
|
from fiwicontrol.fronthaul import FrontHaul
|
|
from fiwicontrol.radio import RadioHead
|
|
from fiwicontrol.telemetry import (
|
|
CablePortStats,
|
|
FrontHaulTelemetry,
|
|
FronthaulBoardInfo,
|
|
PcieSlotTelemetry,
|
|
SfpModuleInventory,
|
|
SfpModuleTelemetry,
|
|
SystemPowerRails,
|
|
)
|
|
|
|
assert fiwicontrol.__version__
|
|
assert "iperf" in (fiwicontrol.flows.__doc__ or "").lower()
|
|
assert "Shewhart" in (fiwicontrol.spc.__doc__ or "")
|
|
tel = FrontHaulTelemetry(
|
|
monitor_source="Adnacom Monitor v1.0.0",
|
|
board=FronthaulBoardInfo(
|
|
device_bdf="0000:01:00.0",
|
|
board_name="H3",
|
|
mode="Host",
|
|
hw_rev="1.0.1",
|
|
fw_rev="1.2.0",
|
|
board_serial="4C-0A-3D-62-13-13",
|
|
pcie_switch="PEX8718",
|
|
),
|
|
pcie_slot=PcieSlotTelemetry(port=0, capability="Gen3 x4", link_state="Gen3 x4"),
|
|
cable_ports=(
|
|
CablePortStats(port=1, capability="Gen2 x1", training_ms=17.0, remote_up_ms=3.0, recovery=3),
|
|
),
|
|
sfp_inventory=(
|
|
SfpModuleInventory(
|
|
port=1,
|
|
present=True,
|
|
power_supply_v=3.33,
|
|
state="On",
|
|
vendor="6COM",
|
|
part_number="6C-SFP+-LR, Rev.B",
|
|
serial_number="6C82510221225",
|
|
technology="1310 nm VCSEL",
|
|
),
|
|
),
|
|
sfp_telemetry=(SfpModuleTelemetry(port=1, temp_c=33.3, vcc_v=3.31, rx_power_uw=501.0, rx_power_dbm=-3.0, tx_bias_ma=28.9),),
|
|
system_power=SystemPowerRails(tpex_c=37.0, topu_c=31.0, slot_3v3_v=3.33, rail_3v3_v=3.33),
|
|
)
|
|
fh = FrontHaul(
|
|
medium="pcie",
|
|
vendor_id=0x1234,
|
|
device_id=0x5678,
|
|
link_states=("L0",),
|
|
telemetry=tel,
|
|
)
|
|
h = RadioHead(
|
|
radio_id="rrh-01",
|
|
patch_panel_port=17,
|
|
ssid="lab-bss",
|
|
bssid="02:00:00:00:01:00",
|
|
fronthaul=fh,
|
|
)
|
|
assert h.radio_id == "rrh-01"
|
|
assert h.patch_panel_port == 17
|
|
assert h.fronthaul is not None and h.fronthaul.medium == "pcie"
|
|
assert h.fronthaul.telemetry is not None
|
|
assert h.fronthaul.telemetry.monitor_source == "Adnacom Monitor v1.0.0"
|
|
assert h.fronthaul.telemetry.board is not None and h.fronthaul.telemetry.board.pcie_switch == "PEX8718"
|
|
assert h.associated_clients == []
|
|
|
|
fab = Fabric(fabric_id="test-fabric", rrhs=(h,))
|
|
assert fab.fabric_id == "test-fabric" and len(fab.rrhs) == 1 and fab.rrhs[0].radio_id == "rrh-01"
|
|
assert FabricDefinition.JSON_SCHEMA_VERSION == 1
|
|
assert FabricExitCode.SUCCESS == 0
|
|
assert "[FiWi" in FDIR_LOG_PREFIX
|
|
assert FabricDefinition.__name__ == "FabricDefinition"
|
|
assert ConcentratorPlatform(label="pkg").snapshot().logical_processors >= 1
|
|
|
|
|
|
def test_fabric_rejects_empty_rrhs() -> None:
|
|
from fiwicontrol.fabric import Fabric
|
|
|
|
with pytest.raises(ValueError, match="rrhs must be non-empty"):
|
|
Fabric(fabric_id="empty", rrhs=())
|