зеркало из https://github.com/microsoft/lisa.git
feat: Implement mshv_install test to verify Linux Dom0 boot against fresh Hyper-V bins (#3262)
* Introduce mshv_install testsuite comment out kdstub fix typo fix import fix import disable serial console update node paths to use Path class +self Add logic to copy files into privileged dirs convert to str debug logging return code * address comments Use Cp tool add sha256sum for verification before and after fix exe import Cp test sleep * readd kdstub, remove test instrumentation bump timeout to 120s use mshv_binpath to locate bins, copy kdstub to appropriate path in efi part clean up names log binpath for testing * drop test_data dir, parse and validate mshv_binpath instead lint flake8 lint 2 lint 3 lint 4 * Run automatic linter * collect dmesg for diagnosing mshv driver failure * Update imports * flake * fix up tools invocations to remove repeated code
This commit is contained in:
Родитель
ccfbf88143
Коммит
5db69ffb96
|
@ -2,8 +2,11 @@
|
|||
# Licensed under the MIT license.
|
||||
|
||||
import secrets
|
||||
from pathlib import Path
|
||||
|
||||
from lisa import Node
|
||||
from lisa.executable import Tool
|
||||
from lisa.tools import Dmesg
|
||||
from lisa.util.process import Process
|
||||
|
||||
|
||||
|
@ -45,3 +48,9 @@ class CloudHypervisor(Tool):
|
|||
shell=True,
|
||||
sudo=sudo,
|
||||
)
|
||||
|
||||
def save_dmesg_logs(self, node: Node, log_path: Path) -> None:
|
||||
dmesg_str = node.tools[Dmesg].get_output()
|
||||
dmesg_path = log_path / "dmesg"
|
||||
with open(str(dmesg_path), "w", encoding="utf-8") as f:
|
||||
f.write(dmesg_str)
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
# Copyright (c) Microsoft Corporation.
|
||||
# Licensed under the MIT license.
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict
|
||||
|
||||
from lisa import Logger, Node, TestCaseMetadata, TestSuite, TestSuiteMetadata
|
||||
from lisa.tools import Cp, Ls, Reboot
|
||||
from lisa.util import SkippedException
|
||||
from microsoft.testsuites.mshv.cloud_hypervisor_tool import CloudHypervisor
|
||||
|
||||
|
||||
@TestSuiteMetadata(
|
||||
area="mshv",
|
||||
category="functional",
|
||||
description="""
|
||||
This test suite is to test VM working well after updating Microsoft Hyper-V on VM
|
||||
and rebooting.
|
||||
""",
|
||||
)
|
||||
class MshvHostInstallSuite(TestSuite):
|
||||
CONFIG_BINPATH = "mshv_binpath"
|
||||
|
||||
_test_path_init_hvix = Path("/home/cloud") / "hvix64.exe"
|
||||
|
||||
_init_path_init_kdstub = Path("/home/cloud") / "kdstub.dll"
|
||||
|
||||
_init_path_init_lxhvloader = Path("/home/cloud") / "lxhvloader.dll"
|
||||
|
||||
_test_path_dst_hvix = Path("/boot/efi/Windows/System32") / "hvix64.exe"
|
||||
|
||||
_test_path_dst_kdstub = Path("/boot/efi/Windows/System32") / "kdstub.dll"
|
||||
|
||||
_test_path_dst_lxhvloader = Path("/boot/efi") / "lxhvloader.dll"
|
||||
|
||||
@TestCaseMetadata(
|
||||
description="""
|
||||
This test case will
|
||||
1. Update to new MSHV components over old ones in a
|
||||
pre-configured MSHV image
|
||||
2. Reboot VM, check that mshv comes up
|
||||
|
||||
The test expects the directory containing MSHV binaries to be passed in
|
||||
the mshv_binpath variable.
|
||||
"""
|
||||
)
|
||||
def verify_mshv_install_succeeds(
|
||||
self,
|
||||
log: Logger,
|
||||
node: Node,
|
||||
variables: Dict[str, Any],
|
||||
log_path: Path,
|
||||
) -> None:
|
||||
binpath = variables.get(self.CONFIG_BINPATH, "")
|
||||
if not binpath:
|
||||
raise SkippedException(
|
||||
"Requires a path to MSHV binaries to be passed via mshv_binpath"
|
||||
)
|
||||
|
||||
test_hvix_file_path = Path(binpath) / "hvix64.exe"
|
||||
test_kdstub_file_path = Path(binpath) / "kdstub.dll"
|
||||
test_lxhvloader_file_path = Path(binpath) / "lxhvloader.dll"
|
||||
|
||||
log.info(f"binpath: {binpath}")
|
||||
|
||||
# Copy Hvix64.exe, kdstub.dll, lxhvloader.dll into test machine
|
||||
copy_tool = node.tools[Cp]
|
||||
node.shell.copy(test_hvix_file_path, self._test_path_init_hvix)
|
||||
copy_tool.copy(self._test_path_init_hvix, self._test_path_dst_hvix, sudo=True)
|
||||
|
||||
node.shell.copy(test_kdstub_file_path, self._init_path_init_kdstub)
|
||||
copy_tool.copy(
|
||||
self._init_path_init_kdstub, self._test_path_dst_kdstub, sudo=True
|
||||
)
|
||||
|
||||
node.shell.copy(test_lxhvloader_file_path, self._init_path_init_lxhvloader)
|
||||
copy_tool.copy(
|
||||
self._init_path_init_lxhvloader, self._test_path_dst_lxhvloader, sudo=True
|
||||
)
|
||||
|
||||
node.tools[Reboot].reboot_and_check_panic(log_path)
|
||||
node.tools[CloudHypervisor].save_dmesg_logs(node, log_path)
|
||||
|
||||
# 2. check that mshv comes up
|
||||
mshv = node.tools[Ls].path_exists("/dev/mshv", sudo=True)
|
||||
assert (
|
||||
mshv
|
||||
), "/dev/mshv not detected upon reboot. Check dmesg for mshv driver errors."
|
|
@ -9,7 +9,7 @@ from assertpy import assert_that
|
|||
from lisa import Logger, Node, TestCaseMetadata, TestSuite, TestSuiteMetadata
|
||||
from lisa.messages import TestStatus, send_sub_test_result_message
|
||||
from lisa.testsuite import TestResult
|
||||
from lisa.tools import Cp, Dmesg, Free, Ls, Lscpu, QemuImg, Rm, Ssh, Usermod, Wget
|
||||
from lisa.tools import Cp, Free, Ls, Lscpu, QemuImg, Rm, Ssh, Usermod, Wget
|
||||
from lisa.util import SkippedException
|
||||
from microsoft.testsuites.mshv.cloud_hypervisor_tool import CloudHypervisor
|
||||
|
||||
|
@ -120,7 +120,7 @@ class MshvHostStressTestSuite(TestSuite):
|
|||
test_status=TestStatus.FAILED,
|
||||
test_message=repr(e),
|
||||
)
|
||||
self._save_dmesg_logs(node, log_path)
|
||||
node.tools[CloudHypervisor].save_dmesg_logs(node, log_path)
|
||||
assert_that(failures).is_equal_to(0)
|
||||
return
|
||||
|
||||
|
@ -221,9 +221,3 @@ class MshvHostStressTestSuite(TestSuite):
|
|||
return PurePath("/mnt")
|
||||
else:
|
||||
return node.working_path
|
||||
|
||||
def _save_dmesg_logs(self, node: Node, log_path: Path) -> None:
|
||||
dmesg_str = node.tools[Dmesg].get_output()
|
||||
dmesg_path = log_path / "dmesg"
|
||||
with open(str(dmesg_path), "w", encoding="utf-8") as f:
|
||||
f.write(dmesg_str)
|
||||
|
|
Загрузка…
Ссылка в новой задаче