Skip to content

Commit

Permalink
fix lsvmbus failure in ready environment
Browse files Browse the repository at this point in the history
create a virtual tool VmGeneration in Azure. The lsvmbus depends on it.
These tools are shared between Azure and Hyper-V, will be moved to some
shared folder, when Hyper-V implements.
  • Loading branch information
Chi Song authored and squirrelsc committed May 4, 2021
1 parent d9440e3 commit abdcfe4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
7 changes: 2 additions & 5 deletions lisa/sut_orchestrator/azure/platform_.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
from lisa.node import Node, RemoteNode
from lisa.platform_ import Platform
from lisa.secret import PATTERN_GUID, PATTERN_HEADTAIL, add_secret
from lisa.sut_orchestrator.azure.tools import Waagent
from lisa.sut_orchestrator.azure.tools import VmGeneration, Waagent
from lisa.tools import Dmesg, Modinfo
from lisa.util import (
LisaException,
Expand Down Expand Up @@ -536,10 +536,7 @@ def _get_node_information(self, node: Node) -> Dict[str, str]:
information["lis_version"] = modinfo.get_version("hv_vmbus")

node.log.debug("detecting vm generation...")
information[KEY_VM_GENERATION] = "1"
cmd_result = node.execute(cmd="ls -lt /sys/firmware/efi", no_error_log=True)
if cmd_result.exit_code == 0:
information[KEY_VM_GENERATION] = "2"
information[KEY_VM_GENERATION] = node.tools[VmGeneration].get_generation()
node.log.debug(f"vm generation: {information[KEY_VM_GENERATION]}")

return information
Expand Down
21 changes: 21 additions & 0 deletions lisa/sut_orchestrator/azure/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,24 @@ def get_version(self) -> str:
result = self.run("-version")
found_version = find_patterns_in_lines(result.stdout, [self.__version_pattern])
return found_version[0][0] if found_version[0] else ""


class VmGeneration(Tool):
"""
This is a virtual tool to detect VM generation of Hyper-V technology.
"""

@property
def command(self) -> str:
return "ls -lt /sys/firmware/efi"

def _check_exists(self) -> bool:
return True

def get_generation(self) -> str:
cmd_result = self.run()
if cmd_result.exit_code == 0:
generation = "2"
else:
generation = "1"
return generation
5 changes: 2 additions & 3 deletions testsuites/basic/lsvmbus.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from lisa import Environment, Node, TestCaseMetadata, TestSuite, TestSuiteMetadata
from lisa.operating_system import Windows
from lisa.sut_orchestrator.azure.tools import VmGeneration
from lisa.testsuite import simple_requirement
from lisa.tools import Lscpu, Lsvmbus

Expand Down Expand Up @@ -56,10 +57,8 @@ class LsVmBus(TestSuite):
requirement=simple_requirement(unsupported_os=[Windows]),
)
def lsvmbus_channel_counting(self, environment: Environment, node: Node) -> None:
# get vm generation info
environment_information = environment.get_information()
# get expected vm bus names
vmbus_class = VmbusNames(environment_information["vm_generation"] == "1")
vmbus_class = VmbusNames("1" == node.tools[VmGeneration].get_generation())

lsvmbus_tool = node.tools[Lsvmbus]
vmbus_list = lsvmbus_tool.get_vmbuses()
Expand Down

0 comments on commit abdcfe4

Please sign in to comment.