-
Notifications
You must be signed in to change notification settings - Fork 170
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
MANA: add driver survey test #2980
Open
mcgov
wants to merge
2
commits into
main
Choose a base branch
from
mcgov/mana-drjver
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,201 @@ | ||
import re | ||
from typing import Pattern | ||
|
||
from lisa import ( | ||
LisaException, | ||
Node, | ||
SkippedException, | ||
TestCaseMetadata, | ||
TestSuite, | ||
TestSuiteMetadata, | ||
simple_requirement, | ||
) | ||
from lisa.operating_system import Linux, Posix | ||
from lisa.sut_orchestrator import AZURE | ||
from lisa.tools import Dmesg, KernelConfig, Lsmod, Modprobe | ||
|
||
|
||
@TestSuiteMetadata( | ||
area="mana_driver", | ||
category="functional", | ||
description=""" | ||
This test suite checks for the presence of mana and mana_ib drivers | ||
""", | ||
) | ||
class ManaDriverCheck(TestSuite): | ||
MANA_DRIVER_MESSAGE_PATTERN = re.compile(r"\[\s*[0-9.]+\s*\]\s+mana\s+.*") | ||
MANA_IB_DRIVER_MESSAGE_PATTERN = re.compile(r"\[\s*[0-9.]+\s*\]\s+mana_ib\s+.*") | ||
MANA_EN_KCONFIG = "CONFIG_MICROSOFT_MANA" | ||
MANA_IB_KCONFIG = "CONFIG_MANA_INFINIBAND" | ||
|
||
def _check_for_driver( | ||
self, | ||
node: Node, | ||
driver_name: str, | ||
kconfig_variable: str, | ||
dmesg_pattern: Pattern[str], | ||
verify_module_loads: bool = False, | ||
) -> None: | ||
dmesg = node.tools[Dmesg] | ||
lsmod = node.tools[Lsmod] | ||
modprobe = node.tools[Modprobe] | ||
kconfig = node.tools[KernelConfig] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can check config even there is no mana devices There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added a test just kconfig only |
||
|
||
# Check kconfig for mana | ||
mana_is_builtin = kconfig.is_built_in(kconfig_variable) | ||
mana_is_module = kconfig.is_built_as_module(kconfig_variable) | ||
if mana_is_builtin: | ||
node.log.info(f"{driver_name} is reported as builtin in kconfig") | ||
elif mana_is_module: | ||
node.log.info( | ||
f"{driver_name} is reported as a loadable kernel module in kconfig" | ||
) | ||
else: | ||
node.log.info( | ||
( | ||
f"{driver_name} is not in kconfig for this image, " | ||
"checking if driver is present (possible out of tree build)" | ||
) | ||
) | ||
|
||
# check modprobe for loadable module | ||
module_exists = modprobe.module_exists(driver_name) | ||
module_loaded = modprobe.is_module_loaded(driver_name) | ||
|
||
# if it isn't loaded, will not load, and isn't builtin, fail fast. | ||
if not any([module_loaded, module_exists, mana_is_builtin]): | ||
raise LisaException(f"{driver_name} is not present on this system") | ||
|
||
# allow return before loading check to enable kconfig only test | ||
if not verify_module_loads: | ||
return | ||
|
||
# If module is not loaded, but is loadable, attempt to load the module | ||
# This will throw if the module isn't found. | ||
if module_exists and not (mana_is_builtin or module_loaded): | ||
node.log.info(f"Attempting to load {driver_name} driver with modprobe...") | ||
modprobe.load(driver_name) | ||
# verify driver is loaded with lsmod | ||
module_loaded = lsmod.module_exists(driver_name, force_run=True) | ||
if not module_loaded: | ||
raise LisaException( | ||
f"MANA driver {driver_name} was not detected after loading." | ||
) | ||
|
||
# finally, verify that mana driver logs are present after loading. | ||
kernel_driver_output = dmesg.get_output(force_run=True) | ||
matches = dmesg_pattern.search(kernel_driver_output) | ||
if not matches: | ||
raise LisaException( | ||
( | ||
f"{driver_name} driver reported as present but " | ||
f"no {driver_name} logs in driver messages." | ||
) | ||
) | ||
|
||
@TestCaseMetadata( | ||
description=""" | ||
This test case checks for the mana ethernet driver. | ||
""", | ||
priority=3, | ||
requirement=simple_requirement( | ||
supported_platform_type=[AZURE], supported_os=[Posix] | ||
), | ||
) | ||
def verify_mana_en_driver_present(self, node: Node) -> None: | ||
if not node.nics.is_mana_device_present(): | ||
raise SkippedException( | ||
"MANA driver tests should be run in a MANA VM environment" | ||
) | ||
|
||
distro = node.os | ||
if isinstance(distro, Linux): | ||
if distro.get_kernel_information().version < "5.15.0": | ||
raise SkippedException("MANA is not available for kernels < 5.15") | ||
|
||
mana_driver_name = "mana" | ||
self._check_for_driver( | ||
node, | ||
driver_name=mana_driver_name, | ||
kconfig_variable=self.MANA_EN_KCONFIG, | ||
dmesg_pattern=self.MANA_DRIVER_MESSAGE_PATTERN, | ||
verify_module_loads=True, | ||
) | ||
|
||
@TestCaseMetadata( | ||
description=""" | ||
This test case checks for the mana ethernet driver. | ||
""", | ||
priority=3, | ||
requirement=simple_requirement( | ||
supported_platform_type=[AZURE], supported_os=[Posix] | ||
), | ||
) | ||
def verify_mana_ib_driver_present(self, node: Node) -> None: | ||
if not node.nics.is_mana_device_present(): | ||
raise SkippedException( | ||
"MANA driver tests should be run in a MANA VM environment" | ||
) | ||
|
||
distro = node.os | ||
if isinstance(distro, Linux): | ||
if distro.get_kernel_information().version < "5.15.0": | ||
raise SkippedException("MANA is not available for kernels < 5.15") | ||
|
||
mana_driver_name = "mana_ib" | ||
# Check kconfig for mana | ||
self._check_for_driver( | ||
node, | ||
driver_name=mana_driver_name, | ||
kconfig_variable=self.MANA_IB_KCONFIG, | ||
dmesg_pattern=self.MANA_IB_DRIVER_MESSAGE_PATTERN, | ||
verify_module_loads=True, | ||
) | ||
|
||
@TestCaseMetadata( | ||
description=""" | ||
This test case checks kconfig only for the mana ethernet driver. | ||
""", | ||
priority=3, | ||
requirement=simple_requirement( | ||
supported_platform_type=[AZURE], supported_os=[Posix] | ||
), | ||
) | ||
def verify_mana_en_driver_kconfig(self, node: Node) -> None: | ||
distro = node.os | ||
if isinstance(distro, Linux): | ||
if distro.get_kernel_information().version < "5.15.0": | ||
raise SkippedException("MANA is not available for kernels < 5.15") | ||
|
||
mana_driver_name = "mana" | ||
self._check_for_driver( | ||
node, | ||
driver_name=mana_driver_name, | ||
kconfig_variable=self.MANA_EN_KCONFIG, | ||
dmesg_pattern=self.MANA_DRIVER_MESSAGE_PATTERN, | ||
verify_module_loads=False, | ||
) | ||
|
||
@TestCaseMetadata( | ||
description=""" | ||
This test case checks kconfig only for the mana infiniband driver. | ||
""", | ||
priority=3, | ||
requirement=simple_requirement( | ||
supported_platform_type=[AZURE], supported_os=[Posix] | ||
), | ||
) | ||
def verify_mana_ib_driver_kconfig(self, node: Node) -> None: | ||
distro = node.os | ||
if isinstance(distro, Linux): | ||
if distro.get_kernel_information().version < "5.15.0": | ||
raise SkippedException("MANA is not available for kernels < 5.15") | ||
|
||
mana_driver_name = "mana_ib" | ||
self._check_for_driver( | ||
node, | ||
driver_name=mana_driver_name, | ||
kconfig_variable=self.MANA_IB_KCONFIG, | ||
dmesg_pattern=self.MANA_IB_DRIVER_MESSAGE_PATTERN, | ||
verify_module_loads=False, | ||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add the sample messages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see the updated with sample messages