Skip to content

Commit

Permalink
Bug fixes for some tier 1 tests for CBL-Mariner on QEMU. (#1721)
Browse files Browse the repository at this point in the history
* 1. Add OS type for CBL-Mariner. While CBL-Mariner uses RPM
and so should share the package handling logic, it is not
a derivative of Fedora and has substantial differences.
Hence, the RPM handling logic was split off into a new
base class that both `Fedora` and `CBLMariner` classes
inherit from.

2. Fix a few tests that didn't declare their required
`supported_features`.

3. Restrict tests that rely on VMBus to the `AZURE` platform.
(When the Hyper-V support is added, it can be added as a
platform to these tests as well.)

4. Add support for CBL-Mariner to Docker tool.
  • Loading branch information
cwize1 committed Jan 29, 2022
1 parent c653bda commit 14dfc8a
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 26 deletions.
51 changes: 33 additions & 18 deletions lisa/operating_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -948,37 +948,31 @@ class OpenBSD(BSD):


@dataclass
# yum repolist is of the form `<id> <name>`
# dnf repolist is of the form `<id> <name>`
# Example:
# microsoft-azure-rhel8-eus Microsoft Azure RPMs for RHEL8 Extended Update Support
class FedoraRepositoryInfo(RepositoryInfo):
class RPMRepositoryInfo(RepositoryInfo):
# id for the repository, for example: microsoft-azure-rhel8-eus
id: str


class Fedora(Linux):
# Red Hat Enterprise Linux Server 7.8 (Maipo) => 7.8
_fedora_release_pattern_version = re.compile(r"^.*release\s+([0-9\.]+).*$")

# Linux distros that use RPM.
class RPMDistro(Linux):
# microsoft-azure-rhel8-eus Microsoft Azure RPMs for RHEL8 Extended Update Support
_fedora_repository_info_pattern = re.compile(r"(?P<id>\S+)\s+(?P<name>\S.*\S)\s*")
_rpm_repository_info_pattern = re.compile(r"(?P<id>\S+)\s+(?P<name>\S.*\S)\s*")

# ex: dpdk-20.11-3.el8.x86_64
_fedora_version_splitter_regex = re.compile(
_rpm_version_splitter_regex = re.compile(
r"(?P<package_name>[a-zA-Z0-9\-_]+)-"
r"(?P<major>[0-9]+)\."
r"(?P<minor>[0-9]+)"
r"(?P<patch>\.[0-9]+)?"
r"(?P<build>-[a-zA-Z0-9-_\.]+)?"
)

@classmethod
def name_pattern(cls) -> Pattern[str]:
return re.compile("^Fedora|fedora$")

def get_repositories(self) -> List[RepositoryInfo]:
repo_list_str = self._node.execute(
"yum repolist", sudo=True
f"{self._dnf_tool()} repolist", sudo=True
).stdout.splitlines()

# skip to the first entry in the output
Expand All @@ -990,10 +984,10 @@ def get_repositories(self) -> List[RepositoryInfo]:

repositories: List[RepositoryInfo] = []
for line in repo_list_str:
repo_info = self._fedora_repository_info_pattern.search(line)
repo_info = self._rpm_repository_info_pattern.search(line)
if repo_info:
repositories.append(
FedoraRepositoryInfo(
RPMRepositoryInfo(
name=repo_info.group("name"), id=repo_info.group("id")
)
)
Expand All @@ -1008,7 +1002,7 @@ def _get_package_information(self, package_name: str) -> VersionInfo:
),
)
# rpm package should be of format (package_name)-(version)
matches = self._fedora_version_splitter_regex.search(rpm_info.stdout)
matches = self._rpm_version_splitter_regex.search(rpm_info.stdout)
if not matches:
raise LisaException(
f"Could not parse package version {rpm_info} for {package_name}"
Expand All @@ -1020,7 +1014,7 @@ def _get_package_information(self, package_name: str) -> VersionInfo:
return self._cache_and_return_version_info(package_name, version_info)

def _install_packages(self, packages: List[str], signed: bool = True) -> None:
command = f"dnf install -y {' '.join(packages)}"
command = f"{self._dnf_tool()} install -y {' '.join(packages)}"
if not signed:
command += " --nogpgcheck"

Expand All @@ -1030,7 +1024,7 @@ def _install_packages(self, packages: List[str], signed: bool = True) -> None:
self._log.debug(f"{packages} is/are installed successfully.")

def _package_exists(self, package: str) -> bool:
command = f"dnf list installed {package}"
command = f"{self._dnf_tool()} list installed {package}"
result = self._node.execute(command, sudo=True)
if result.exit_code == 0:
for row in result.stdout.splitlines():
Expand All @@ -1039,6 +1033,18 @@ def _package_exists(self, package: str) -> bool:

return False

def _dnf_tool(self) -> str:
return "dnf"


class Fedora(RPMDistro):
# Red Hat Enterprise Linux Server 7.8 (Maipo) => 7.8
_fedora_release_pattern_version = re.compile(r"^.*release\s+([0-9\.]+).*$")

@classmethod
def name_pattern(cls) -> Pattern[str]:
return re.compile("^Fedora|fedora$")

def install_epel(self) -> None:
# Extra Packages for Enterprise Linux (EPEL) is a special interest group
# (SIG) from the Fedora Project that provides a set of additional packages
Expand Down Expand Up @@ -1218,6 +1224,9 @@ def __verify_package_result(self, result: ExecutableResult, packages: Any) -> No
f"Failed to install {packages}. exit_code: {result.exit_code}"
)

def _dnf_tool(self) -> str:
return "yum"


class CentOs(Redhat):
@classmethod
Expand All @@ -1240,6 +1249,12 @@ def name_pattern(cls) -> Pattern[str]:
return re.compile("^Oracle")


class CBLMariner(RPMDistro):
@classmethod
def name_pattern(cls) -> Pattern[str]:
return re.compile("^Common Base Linux Mariner|mariner$")


@dataclass
# `zypper lr` repolist is of the form
# `<id>|<alias>|<name>|<enabled>|<gpg_check>|<refresh>`
Expand Down
1 change: 1 addition & 0 deletions lisa/sut_orchestrator/qemu/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def _create_node_capabilities(
node_capabilities.disk = schema.DiskOptionSettings()
node_capabilities.network_interface = schema.NetworkInterfaceOptionSettings()
node_capabilities.network_interface.max_nic_count = 1
node_capabilities.network_interface.nic_count = 1
node_capabilities.gpu_count = 0
node_capabilities.features = search_space.SetSpace[schema.FeatureSettings](
is_allow_set=True,
Expand Down
4 changes: 3 additions & 1 deletion lisa/tools/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from lisa.base_tools import Wget
from lisa.executable import Tool
from lisa.operating_system import CentOs, Debian, Redhat
from lisa.operating_system import CBLMariner, CentOs, Debian, Redhat
from lisa.tools.service import Service
from lisa.util import LisaException

Expand Down Expand Up @@ -82,6 +82,8 @@ def _install(self) -> bool:
self.node.os.install_packages(
["docker", "docker-ce", "docker.socket", "docker.service"]
)
elif isinstance(self.node.os, CBLMariner):
self.node.os.install_packages(["moby-engine", "moby-cli"])
else:
raise LisaException(f"{self.node.os.information.vendor} not supported")

Expand Down
11 changes: 7 additions & 4 deletions microsoft/testsuites/core/azure_image_standard.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
Debian,
DebianRepositoryInfo,
Fedora,
FedoraRepositoryInfo,
Oracle,
Posix,
Redhat,
RPMRepositoryInfo,
Suse,
SuseRepositoryInfo,
Ubuntu,
Expand Down Expand Up @@ -350,9 +350,9 @@ def verify_hv_kvp_daemon_installed(self, node: Node) -> None:
)
def verify_repository_installed(self, node: Node) -> None:
assert isinstance(node.os, Posix)
repositories = node.os.get_repositories()

if isinstance(node.os, Debian):
repositories = node.os.get_repositories()
debian_repositories = [
cast(DebianRepositoryInfo, repo) for repo in repositories
]
Expand Down Expand Up @@ -416,6 +416,7 @@ def verify_repository_installed(self, node: Node) -> None:
"be in the `apt-get update` output",
).is_true()
elif isinstance(node.os, Suse):
repositories = node.os.get_repositories()
suse_repositories = [
cast(SuseRepositoryInfo, repo) for repo in repositories
]
Expand Down Expand Up @@ -473,8 +474,9 @@ def verify_repository_installed(self, node: Node) -> None:
"enabled/refreshed",
).is_greater_than(2)
elif isinstance(node.os, Oracle):
repositories = node.os.get_repositories()
oracle_repositories = [
cast(FedoraRepositoryInfo, repo) for repo in repositories
cast(RPMRepositoryInfo, repo) for repo in repositories
]

# verify that `base` repository is present
Expand All @@ -485,8 +487,9 @@ def verify_repository_installed(self, node: Node) -> None:
is_latest_repository_present, "Latest repository should be present"
).is_true()
elif isinstance(node.os, Fedora):
repositories = node.os.get_repositories()
fedora_repositories = [
cast(FedoraRepositoryInfo, repo) for repo in repositories
cast(RPMRepositoryInfo, repo) for repo in repositories
]

# verify that `base` repository is present
Expand Down
12 changes: 11 additions & 1 deletion microsoft/testsuites/core/lsvmbus.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

from assertpy import assert_that

from lisa import Node, TestCaseMetadata, TestSuite, TestSuiteMetadata
from lisa import (
Node,
TestCaseMetadata,
TestSuite,
TestSuiteMetadata,
simple_requirement,
)
from lisa.sut_orchestrator import AZURE
from lisa.sut_orchestrator.azure.tools import VmGeneration
from lisa.tools import Lscpu, Lsvmbus

Expand Down Expand Up @@ -63,6 +70,9 @@ class LsVmBus(TestSuite):
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/scsi/storvsc_drv.c#n952 # noqa: E501
""",
priority=1,
requirement=simple_requirement(
supported_platform_type=[AZURE],
),
)
def lsvmbus_count_devices_channels(self, node: Node) -> None:
# 1. Check expected vmbus device names presented in the lsvmbus output.
Expand Down
13 changes: 11 additions & 2 deletions microsoft/testsuites/core/vm_hot_resize.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@

from assertpy import assert_that

from lisa import Node, TestCaseMetadata, TestSuite, TestSuiteMetadata
from lisa.features.resize import Resize
from lisa import (
Node,
TestCaseMetadata,
TestSuite,
TestSuiteMetadata,
simple_requirement,
)
from lisa.features import Resize
from lisa.schema import NodeSpace
from lisa.tools import Lscpu

Expand All @@ -27,6 +33,9 @@ class VmHotResize(TestSuite):
2. Check the node's core count and memory size against their expected values
""",
priority=1,
requirement=simple_requirement(
supported_features=[Resize],
),
)
def verify_vm_hot_resize(self, node: Node) -> None:
resize = node.features[Resize]
Expand Down
1 change: 1 addition & 0 deletions microsoft/testsuites/docker/dockersuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ def _run_and_verify_results(

docker_run_output = node.execute(
f"cat {docker_run_output_file}",
sudo=True,
expected_exit_code=0,
expected_exit_code_failure_message="Docker run output file not found",
cwd=node.working_path,
Expand Down

0 comments on commit 14dfc8a

Please sign in to comment.