[fix issue] add is_test_target flag for node

This commit is contained in:
Lili Deng 2023-01-11 20:37:33 +08:00 коммит произвёл LiliDeng
Родитель e291bd47ee
Коммит 6b79bf6f10
3 изменённых файлов: 41 добавлений и 21 удалений

Просмотреть файл

@ -41,6 +41,7 @@ class Node(subclasses.BaseClassWithRunbookMixin, ContextMixin, InitializableMixi
runbook: schema.Node,
index: int,
logger_name: str,
is_test_target: bool = True,
base_part_path: Optional[Path] = None,
parent_logger: Optional[Logger] = None,
) -> None:
@ -48,6 +49,7 @@ class Node(subclasses.BaseClassWithRunbookMixin, ContextMixin, InitializableMixi
self.is_default = runbook.is_default
self.capability = runbook.capability
self.name = runbook.name
self.is_test_target = is_test_target
self.index = index
self._shell: Optional[Shell] = None
@ -162,6 +164,7 @@ class Node(subclasses.BaseClassWithRunbookMixin, ContextMixin, InitializableMixi
index: int,
runbook: schema.Node,
logger_name: str = "node",
is_test_target: bool = True,
base_part_path: Optional[Path] = None,
parent_logger: Optional[Logger] = None,
) -> Node:
@ -172,12 +175,14 @@ class Node(subclasses.BaseClassWithRunbookMixin, ContextMixin, InitializableMixi
index=index,
runbook=runbook,
logger_name=logger_name,
is_test_target=is_test_target,
base_part_path=base_part_path,
parent_logger=parent_logger,
)
node.log.debug(
f"created, type: '{node.__class__.__name__}', default: {runbook.is_default}"
f", is_test_target: {is_test_target}"
)
return node
@ -555,12 +560,14 @@ class LocalNode(Node):
index: int,
logger_name: str,
base_part_path: Optional[Path],
is_test_target: bool = True,
parent_logger: Optional[Logger] = None,
) -> None:
super().__init__(
index=index,
runbook=runbook,
logger_name=logger_name,
is_test_target=is_test_target,
base_part_path=base_part_path,
parent_logger=parent_logger,
)
@ -668,6 +675,7 @@ def local_node_connect(
index=index,
runbook=node_runbook,
logger_name=name,
is_test_target=False,
base_part_path=base_part_path,
parent_logger=parent_logger,
)
@ -695,7 +703,11 @@ def quick_connect(
setup node information and initialize connection.
"""
node = Node.create(
index, runbook, logger_name=logger_name, parent_logger=parent_logger
index,
runbook,
is_test_target=False,
logger_name=logger_name,
parent_logger=parent_logger,
)
if isinstance(node, RemoteNode):
node.set_connection_info_by_runbook()

Просмотреть файл

@ -381,28 +381,32 @@ class Posix(OperatingSystem, BaseClassMixin):
self._node.execute("modinfo hv_netvsc").save_stdout_to_file(
saved_path / "modinfo-hv_netvsc.txt"
)
from lisa.tools import Chmod, Find
find_tool = self._node.tools[Find]
file_list = find_tool.find_files(
self._node.get_pure_path("/var/log/azure/"),
file_type="f",
sudo=True,
ignore_not_exist=True,
)
if len(file_list) > 0:
self._node.tools[Chmod].update_folder("/var/log/azure/", "a+rwX", sudo=True)
file_list.append("/etc/os-release")
file_list.append("/var/log/waagent.log")
for file in file_list:
try:
file_name = file.split("/")[-1]
self._node.shell.copy_back(
self._node.get_pure_path(file),
saved_path / f"{file_name}.txt",
if self._node.is_test_target:
from lisa.tools import Chmod, Find
find_tool = self._node.tools[Find]
file_list = find_tool.find_files(
self._node.get_pure_path("/var/log/azure/"),
file_type="f",
sudo=True,
ignore_not_exist=True,
)
if len(file_list) > 0:
self._node.tools[Chmod].update_folder(
"/var/log/azure/", "a+rwX", sudo=True
)
except FileNotFoundError:
self._log.debug(f"File {file} doesn't exist.")
file_list.append("/etc/os-release")
file_list.append("/var/log/waagent.log")
for file in file_list:
try:
file_name = file.split("/")[-1]
self._node.shell.copy_back(
self._node.get_pure_path(file),
saved_path / f"{file_name}.txt",
)
except FileNotFoundError:
self._log.debug(f"File {file} doesn't exist.")
def get_package_information(
self, package_name: str, use_cached: bool = True

Просмотреть файл

@ -40,6 +40,7 @@ class CustomLocalNode(node.LocalNode):
index: int,
runbook: CustomLocalNodeSchema,
logger_name: str,
is_test_target: bool = True,
base_part_path: Optional[Path] = None,
parent_logger: Optional[Logger] = None,
) -> None:
@ -47,6 +48,7 @@ class CustomLocalNode(node.LocalNode):
index=index,
runbook=runbook,
logger_name=logger_name,
is_test_target=is_test_target,
base_part_path=base_part_path,
parent_logger=parent_logger,
)
@ -84,6 +86,7 @@ class CustomRemoteNode(node.RemoteNode):
index: int,
runbook: CustomRemoteNodeSchema,
logger_name: str,
is_test_target: bool = True,
base_part_path: Optional[Path] = None,
parent_logger: Optional[Logger] = None,
) -> None:
@ -91,6 +94,7 @@ class CustomRemoteNode(node.RemoteNode):
index=index,
runbook=runbook,
logger_name=logger_name,
is_test_target=is_test_target,
base_part_path=base_part_path,
parent_logger=parent_logger,
)