Skip to content

Commit

Permalink
add disk_controller_type as case requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
LiliDeng committed Dec 9, 2023
1 parent e6e1e79 commit 7eef34e
Showing 1 changed file with 44 additions and 26 deletions.
70 changes: 44 additions & 26 deletions microsoft/testsuites/core/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,14 @@
)
from lisa.node import Node
from lisa.operating_system import BSD, Windows
from lisa.schema import DiskType
from lisa.schema import DiskControllerType, DiskType
from lisa.sut_orchestrator import AZURE
from lisa.sut_orchestrator.azure.features import AzureDiskOptionSettings
from lisa.sut_orchestrator.azure.tools import Waagent
from lisa.tools import Blkid, Cat, Dmesg, Echo, Lsblk, Mount, NFSClient, Swap, Sysctl
from lisa.tools.blkid import PartitionInfo
from lisa.tools.journalctl import Journalctl
from lisa.util import (
BadEnvironmentStateException,
LisaException,
SkippedException,
get_matched_str,
)
from lisa.util import BadEnvironmentStateException, LisaException, get_matched_str
from lisa.util.perf_timer import create_timer


Expand Down Expand Up @@ -234,7 +229,7 @@ def verify_resource_disk_io(self, node: RemoteNode) -> None:

@TestCaseMetadata(
description="""
This test verifies the disk controller type of the VM.
This test verifies scsi disk controller type of the VM.
Steps:
1. Get the disk type of the boot partition.
Expand All @@ -243,28 +238,28 @@ def verify_resource_disk_io(self, node: RemoteNode) -> None:
priority=1,
requirement=simple_requirement(
supported_platform_type=[AZURE],
disk=AzureDiskOptionSettings(disk_controller_type=DiskControllerType.SCSI),
),
)
def verify_disk_controller_type(self, node: RemoteNode) -> None:
node_disk = node.features[Disk]

# Get VM's 'disk controller type' with azure api
vm_disk_controller_type = node_disk.get_hardware_disk_controller_type()
def verify_scsi_disk_controller_type(self, node: RemoteNode) -> None:
self._verify_disk_controller_type(node, DiskControllerType.SCSI)

# Get 'disk controller type' from within VM.
os_disk_controller_type = node_disk.get_os_disk_controller_type()

# With certain SKUs & gen1 images 'disk_controller_type' will be 'None'
if not vm_disk_controller_type:
raise SkippedException(
"The VM size doesn't have disk controller type information."
"Few VM Sizes and gen1 images doesn't support 'disk_controller_type'"
)
@TestCaseMetadata(
description="""
This test verifies nvme disk controller type of the VM.
assert_that(
os_disk_controller_type,
"The disk controller types of hardware and OS should be the same.",
).is_equal_to(vm_disk_controller_type)
Steps:
1. Get the disk type of the boot partition.
2. Compare it with hardware disk controller type of the VM.
""",
priority=1,
requirement=simple_requirement(
supported_platform_type=[AZURE],
disk=AzureDiskOptionSettings(disk_controller_type=DiskControllerType.NVME),
),
)
def verify_nvme_disk_controller_type(self, node: RemoteNode) -> None:
self._verify_disk_controller_type(node, DiskControllerType.NVME)

@TestCaseMetadata(
description="""
Expand Down Expand Up @@ -625,3 +620,26 @@ def _check_root_partition_in_log(
):
return False
return True

def _verify_disk_controller_type(
self, node: RemoteNode, disk_controller_type: DiskControllerType
) -> None:
node_disk = node.features[Disk]

# Get VM's 'disk controller type' with azure api
vm_disk_controller_type = node_disk.get_hardware_disk_controller_type()

# Get 'disk controller type' from within VM.
os_disk_controller_type = node_disk.get_os_disk_controller_type()

assert_that(
os_disk_controller_type,
"The disk controller types of hardware and OS should be the same.",
).is_equal_to(disk_controller_type.value)

# With certain SKUs & gen1 images 'disk_controller_type' will be 'None'
if vm_disk_controller_type:
assert_that(
os_disk_controller_type,
"The disk controller types of hardware and OS should be the same.",
).is_equal_to(vm_disk_controller_type)

0 comments on commit 7eef34e

Please sign in to comment.