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

reload nics when pci device name changed #2869

Merged
merged 1 commit into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 7 additions & 1 deletion lisa/nic.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from assertpy import assert_that
from retry import retry

from lisa.tools import Cat, Ip, KernelConfig, Lspci, Modprobe, Tee
from lisa.tools import Cat, Ip, KernelConfig, Ls, Lspci, Modprobe, Tee
from lisa.util import InitializableMixin, LisaException, constants, find_groups_in_lines

if TYPE_CHECKING:
Expand Down Expand Up @@ -488,11 +488,17 @@ def module_exists(self, module_name: str) -> bool:
return modprobe.module_exists(module_name)

def get_packets(self, nic_name: str, name: str = "tx_packets") -> int:
if not self.packet_path_exist(nic_name, name):
self.reload()
cat = self._node.tools[Cat]
return int(
cat.read(f"/sys/class/net/{nic_name}/statistics/{name}", force_run=True)
)

def packet_path_exist(self, nic_name: str, name: str = "tx_packets") -> bool:
ls = self._node.tools[Ls]
return ls.path_exists(f"/sys/class/net/{nic_name}/statistics/{name}", sudo=True)


class NicsBSD(Nics):
# hn0
Expand Down
5 changes: 3 additions & 2 deletions microsoft/testsuites/network/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def initialize_nic_info(
f"there is no sriov nic attached to VM {node.name}"
).is_greater_than(0)
nics_info = node.nics
nics_info.initialize()
nics_info.reload()
found_ip = False
for interface_info in interfaces_info_list:
# for some old distro, need run dhclient to get ip address for extra nics
Expand Down Expand Up @@ -70,7 +70,8 @@ def sriov_basic_test(environment: Environment) -> None:
devices_slots = lspci.get_device_names_by_type(
constants.DEVICE_TYPE_SRIOV, force_run=True
)

if len(devices_slots) != len(set(node.nics.get_device_slots())):
node.nics.reload()
assert_that(devices_slots).described_as(
"count of sriov devices listed from lspci is not expected,"
" please check the driver works properly"
Expand Down
Loading