Skip to content

Commit

Permalink
ch_tests: dynamically determine data disk path
Browse files Browse the repository at this point in the history
The test VM undergoes a reboot during preparation for CH community
tests, causing the device path for the data disk to potentially change.
So, data disk device path is now determined dynamically just before
launching the CH tests, eliminating the need for 'datadisk_name' test
input variable.
  • Loading branch information
pupacha committed Jan 7, 2025
1 parent 21abd2a commit d1661b8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
3 changes: 0 additions & 3 deletions microsoft/testsuites/cloud_hypervisor/ch_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ def _set_ms_clh_param(self, variables: Dict[str, Any]) -> None:
# will not run it with data-disk and it would not add direct=on
# if run_without_cache is not set to YES
use_datadisk = variables.get("use_datadisk", "")
datadisk_name = variables.get("datadisk_name", "")
disable_datadisk_cache = variables.get("disable_datadisk_cache", "")
block_size_kb = variables.get("block_size_kb", "")

Expand All @@ -232,8 +231,6 @@ def _set_ms_clh_param(self, variables: Dict[str, Any]) -> None:
CloudHypervisorTests.block_size_kb = block_size_kb
if use_datadisk:
CloudHypervisorTests.use_datadisk = use_datadisk
if datadisk_name:
CloudHypervisorTests.datadisk_name = datadisk_name
if disable_datadisk_cache:
CloudHypervisorTests.disable_datadisk_cache = disable_datadisk_cache

Expand Down
26 changes: 22 additions & 4 deletions microsoft/testsuites/cloud_hypervisor/ch_tests_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@
Echo,
Git,
Ls,
Lsblk,
Mkdir,
Modprobe,
Whoami,
)
from lisa.util import find_groups_in_lines
from lisa.util import LisaException, find_groups_in_lines


@dataclass
Expand Down Expand Up @@ -62,7 +63,6 @@ class CloudHypervisorTests(Tool):

# Block perf related env var
use_datadisk = ""
datadisk_name = ""
disable_datadisk_cache = ""
block_size_kb = ""

Expand Down Expand Up @@ -164,6 +164,9 @@ def run_metrics_tests(
skip: Optional[List[str]] = None,
subtest_timeout: Optional[int] = None,
) -> None:
if self.use_datadisk:
self._set_data_disk()

if ref:
self.node.tools[Git].checkout(ref, self.repo_root)

Expand Down Expand Up @@ -264,8 +267,6 @@ def _install(self) -> bool:

if self.use_datadisk:
self.env_vars["USE_DATADISK"] = self.use_datadisk
if self.datadisk_name:
self.env_vars["DATADISK_NAME"] = self.datadisk_name
if self.disable_datadisk_cache:
self.env_vars["DISABLE_DATADISK_CACHING"] = self.disable_datadisk_cache
if self.block_size_kb:
Expand Down Expand Up @@ -496,6 +497,23 @@ def _configure_vdpa_devices(self, node: Node) -> None:
node.tools[Chown].change_owner(file=PurePath(device_path), user=user)
node.tools[Chmod].chmod(path=device_path, permission=permission, sudo=True)

def _set_data_disk(self) -> None:
datadisk_name = ""
disks = self.node.tools[Lsblk].get_disks()
# get the first unmounted disk (data disk)
for disk in disks:
if disk.is_mounted:
continue
if disk.name.startswith("sd"):
datadisk_name = disk.device_name
break
# running lsblk once again, just for human readable logs
self.node.execute("lsblk", shell=True)
if not datadisk_name:
raise LisaException("No data disk found")
self._log.debug(f"Using data disk: {datadisk_name}")
self.env_vars["DATADISK_NAME"] = datadisk_name


def extract_jsons(input_string: str) -> List[Any]:
json_results: List[Any] = []
Expand Down

0 comments on commit d1661b8

Please sign in to comment.