Skip to content

Commit b87eb65

Browse files
committed
Dpdk: annotation fixes for mypy
1 parent f798f14 commit b87eb65

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

microsoft/testsuites/dpdk/dpdkutil.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,8 @@ def verify_dpdk_build(
518518
except (NotEnoughMemoryException, UnsupportedOperationException) as err:
519519
raise SkippedException(err)
520520
testpmd = test_kit.testpmd
521-
521+
if result is not None:
522+
annotate_dpdk_test_result(test_kit, test_result=result, log=log)
522523
# grab a nic and run testpmd
523524
test_nic = node.nics.get_secondary_nic()
524525

@@ -534,8 +535,7 @@ def verify_dpdk_build(
534535
assert_that(tx_pps).described_as(
535536
f"TX-PPS ({tx_pps}) should have been greater than 2^20 (~1m) PPS."
536537
).is_greater_than(2**20)
537-
if result is not None:
538-
annotate_dpdk_test_result(test_kit, test_result=result, log=log)
538+
539539
return test_kit
540540

541541

@@ -1126,7 +1126,7 @@ class NicType(Enum):
11261126

11271127

11281128
# Short name for nic types
1129-
NIC_SHORT_NAMES = {
1129+
NIC_SHORT_NAMES: Dict[NicType, str] = {
11301130
NicType.CX3: "cx3",
11311131
NicType.CX4: "cx4",
11321132
NicType.CX5: "cx5",
@@ -1139,22 +1139,21 @@ def get_node_nic_short_name(node: Node) -> str:
11391139
devices = node.tools[Lspci].get_devices_by_type(DEVICE_TYPE_SRIOV)
11401140
if node.nics.is_mana_device_present():
11411141
return NIC_SHORT_NAMES[NicType.MANA]
1142-
short_names = map(lambda x: x.value, [NicType.CX3, NicType.CX4, NicType.CX5])
1143-
for nic_name in short_names:
1144-
if any([str(nic_name) in x.device_info for x in devices]):
1142+
mlx_nics = [NicType.CX3, NicType.CX4, NicType.CX5]
1143+
for nic_name in mlx_nics:
1144+
if any([nic_name.value in x.device_info for x in devices]):
11451145
return NIC_SHORT_NAMES[nic_name]
11461146
# We assert much earlier to enforce that SRIOV is enabled,
11471147
# so we should never hit this unless someone is testing a new platform.
11481148
# Instead of asserting, just log that the short name was not found.
1149-
known_nic_types = ",".join(short_names)
1149+
known_nic_types = ",".join([x.value for x in mlx_nics])
11501150
found_nic_types = ",".join(map(str, [x.device_id for x in devices]))
1151-
node.log.debug(
1151+
# assert, this will be caught in annotate_dpdk_test_result
1152+
# and logged, rather than failing the test.
1153+
raise AssertionError(
11521154
"Unknown NIC hardware was detected during DPDK test case. "
11531155
f"Expected one of: {known_nic_types}. Found {found_nic_types}. "
11541156
)
1155-
# this is just a function for annotating a result, so don't assert
1156-
# if there's
1157-
return found_nic_types
11581157

11591158

11601159
# Add dpdk/rdma/nic info to dpdk test result
@@ -1170,19 +1169,19 @@ def annotate_dpdk_test_result(
11701169
test_result.information["dpdk_version"] = str(dpdk_version)
11711170
log.debug(f"Found dpdk version: {dpdk_version}")
11721171
except AssertionError as err:
1173-
test_kit.node.log.debug(f"Could not fetch DPDK version info: {str(err)}")
1172+
log.debug(f"Could not fetch DPDK version info: {str(err)}")
11741173
try:
11751174
rdma_version = test_kit.rdma_core.get_installed_version()
11761175
test_result.information["rdma_version"] = str(rdma_version)
11771176
log.debug(f"Found rdma version: {rdma_version}")
11781177
except AssertionError as err:
1179-
test_kit.node.log.debug(f"Could not fetch RDMA version info: {str(err)}")
1178+
log.debug(f"Could not fetch RDMA version info: {str(err)}")
11801179
try:
11811180
nic_hw = get_node_nic_short_name(test_kit.node)
11821181
test_result.information["nic_hw"] = nic_hw
11831182
log.debug(f"Found nic version: {nic_hw}")
11841183
except AssertionError as err:
1185-
test_kit.node.log.debug(f"Could not fetch NIC short name: {str(err)}")
1184+
log.debug(f"Could not fetch NIC short name: {str(err)}")
11861185

11871186

11881187
def skip_32bit_test_on_unsupported_distros(os: OperatingSystem) -> None:

0 commit comments

Comments
 (0)