Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion connection/ssh_executor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#
# Copyright(c) 2019-2021 Intel Corporation
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
# Copyright(c) 2026 Unvertical
# SPDX-License-Identifier: BSD-3-Clause
#

Expand Down Expand Up @@ -264,5 +265,5 @@ def resolve_ip_address(self):
pattern, completed_process.stdout + completed_process.stderr, re.MULTILINE
)
return matches[-1].decode("utf-8")
except:
except Exception:
return None
5 changes: 3 additions & 2 deletions connection/utils/output.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
#
# Copyright(c) 2019-2021 Intel Corporation
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
# Copyright(c) 2026 Unvertical
# SPDX-License-Identifier: BSD-3-Clause
#


class Output:
def __init__(self, output_out, output_err, return_code):
self.stdout = output_out.decode('utf-8', errors="ignore").rstrip() if \
type(output_out) == bytes else output_out
isinstance(output_out, bytes) else output_out
self.stderr = output_err.decode('utf-8', errors="ignore").rstrip() if \
type(output_err) == bytes else output_err
isinstance(output_err, bytes) else output_err
self.exit_code = return_code

def __str__(self):
Expand Down
4 changes: 1 addition & 3 deletions log/html_main_log.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#
# Copyright(c) 2019-2021 Intel Corporation
# Copyright(c) 2026 Unvertical
# SPDX-License-Identifier: BSD-3-Clause
#

Expand All @@ -26,9 +27,6 @@ def add_build_info(self, message):
def start_iteration(self, iteration_id):
self.__current_iteration_id = iteration_id

def end_iteration(self):
pass

def end_iteration(self, iteration_result):
root = self.get_root()
iteration_selector_div = root.xpath('/html/body/div/div/div[@id="iteration-selector"]')
Expand Down
3 changes: 2 additions & 1 deletion storage_devices/drbd.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#
# Copyright(c) 2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
# Copyright(c) 2026 Unvertical
# SPDX-License-Identifier: BSD-3-Clause
#

import posixpath
Expand Down
45 changes: 23 additions & 22 deletions storage_devices/lvm.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#
# Copyright(c) 2022 Intel Corporation
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
# Copyright(c) 2026 Unvertical
# SPDX-License-Identifier: BSD-3-Clause
#

Expand Down Expand Up @@ -57,15 +58,15 @@ def __add_block_dev_to_lvm_config(
TestRun.LOGGER.info(f"Device type '{block_device_type}' already present in config")
return

TestRun.LOGGER.info(f"Add block device type to existing list")
TestRun.LOGGER.info("Add block device type to existing list")
new_type_prefix = f"types = [\"{block_device_type}\", {number_of_partitions}, "

config_update_cmd = f"sed -i 's/{types_prototype_regex}/\t{new_type_prefix}/g'" \
f" {lvm_config_path}"
else:
TestRun.LOGGER.info(f"Create new types variable")
TestRun.LOGGER.info("Create new types variable")
new_types = f"types = [\"{block_device_type}\", {number_of_partitions}]"
characteristic_line = f"# Configuration option devices\\/sysfs_scan."
characteristic_line = "# Configuration option devices\\/sysfs_scan."
config_update_cmd = f"sed -i /'{characteristic_line}'/i\\ '{tab}{new_types}' " \
f"{lvm_config_path}"

Expand All @@ -79,7 +80,7 @@ def __add_filter_to_lvm_config(
filter: str
):
if filter is None:
TestRun.LOGGER.error(f"Lvm filter for lvm config not provided.")
TestRun.LOGGER.error("Lvm filter for lvm config not provided.")

filters_definition = cls.read_filter_definition_from_lvm_config()

Expand All @@ -91,13 +92,13 @@ def __add_filter_to_lvm_config(
new_filter_formatted = filter.replace("/", "\\/")
new_filter_prefix = f"filter = [ \"{new_filter_formatted}\", "

TestRun.LOGGER.info(f"Adding filter to existing list")
TestRun.LOGGER.info("Adding filter to existing list")
config_update_cmd = f"sed -i 's/{filter_prototype_regex}/\t{new_filter_prefix}/g'" \
f" {lvm_config_path}"
else:
TestRun.LOGGER.info(f"Create new filter variable")
TestRun.LOGGER.info("Create new filter variable")
new_filter = f"filter = [\"{filter}\"]"
characteristic_line = f"# Configuration option devices\\/global_filter."
characteristic_line = "# Configuration option devices\\/global_filter."
config_update_cmd = f"sed -i /'{characteristic_line}'/i\\ '{tab}{new_filter}' " \
f"{lvm_config_path}"

Expand All @@ -122,7 +123,7 @@ def add_block_device_to_lvm_config(
device_type: str
):
if device_type is None:
TestRun.LOGGER.error(f"No device provided.")
TestRun.LOGGER.error("No device provided.")

cls.__add_block_dev_to_lvm_config(device_type)

Expand All @@ -132,7 +133,7 @@ def add_filters_to_lvm_config(
filters: []
):
if filters is None:
raise ValueError(f"Lvm filters for lvm config not provided.")
raise ValueError("Lvm filters for lvm config not provided.")

for f in filters:
cls.__add_filter_to_lvm_config(f)
Expand All @@ -143,15 +144,15 @@ def configure_filters(
lvm_filters: [],
):
if lvm_filters:
TestRun.LOGGER.info(f"Preparing configuration for LVMs - filters.")
TestRun.LOGGER.info("Preparing configuration for LVMs - filters.")
LvmConfiguration.add_filters_to_lvm_config(lvm_filters)

os_disk_filters = [
f"a|/dev/{disk}|" for disk in get_system_disks()
] if Lvm.get_os_vg() else None

if os_disk_filters:
TestRun.LOGGER.info(f"Add OS disks to LVM filters.")
TestRun.LOGGER.info("Add OS disks to LVM filters.")
LvmConfiguration.add_filters_to_lvm_config(os_disk_filters)

@staticmethod
Expand Down Expand Up @@ -192,7 +193,7 @@ def __get_vg_name(cls, prefix: str = "vg"):

@staticmethod
def get_all_volume_groups():
output_lines = TestRun.executor.run(f"pvscan").stdout.splitlines()
output_lines = TestRun.executor.run("pvscan").stdout.splitlines()

volume_groups = {}
for line in output_lines:
Expand Down Expand Up @@ -236,7 +237,7 @@ def is_vg_already_present(cls, dev_number: int, device_paths: str = None):
for vg in volume_groups:
for pv in volume_groups[vg]:
if pv in device_paths:
TestRun.LOGGER.warning(f"Some devices are used in other LVM volume group")
TestRun.LOGGER.warning("Some devices are used in other LVM volume group")
return False

@classmethod
Expand Down Expand Up @@ -325,7 +326,7 @@ def configure_global_filter(
pv_devs = [pv_devs]

if global_filter_def:
TestRun.LOGGER.info(f"Configure 'global filter' variable")
TestRun.LOGGER.info("Configure 'global filter' variable")
links = []
for pv_dev in pv_devs:
link = pv_dev.get_device_link("/dev/disk/by-id")
Expand All @@ -350,17 +351,17 @@ def configure_global_filter(
global_filter += ", "
global_filter = global_filter[:-2]

TestRun.LOGGER.info(f"Create new 'global filter' variable")
TestRun.LOGGER.info("Create new 'global filter' variable")

new_global = f"global_filter = [{global_filter}]"
characteristic_line = f"# Configuration option devices\\/types."
characteristic_line = "# Configuration option devices\\/types."
config_update_cmd = f"sed -i /'{characteristic_line}'/i\\ " \
f"'{tab}{new_global}' {lvm_config_path}"

TestRun.LOGGER.info(f"Adding global filter '{global_filter}' to {lvm_config_path}")
TestRun.executor.run(config_update_cmd)

TestRun.LOGGER.info(f"Remove 'filter' in order to 'global_filter' to be used")
TestRun.LOGGER.info("Remove 'filter' in order to 'global_filter' to be used")
if LvmConfiguration.read_filter_definition_from_lvm_config():
LvmConfiguration.remove_filters_from_config()

Expand Down Expand Up @@ -410,7 +411,7 @@ def create(
elif isinstance(volume_size_or_percent, int):
size_cmd = f"--extents {volume_size_or_percent}%VG"
else:
raise ValueError(f"Incorrect type of the first argument (volume_size_or_percent).")
raise ValueError("Incorrect type of the first argument (volume_size_or_percent).")

if not name:
name = cls.__get_unique_lv_name()
Expand Down Expand Up @@ -450,7 +451,7 @@ def discover_logical_volumes(cls):
)
)
else:
TestRun.LOGGER.info(f"No LVMs present in the system.")
TestRun.LOGGER.info("No LVMs present in the system.")

return volumes

Expand Down Expand Up @@ -503,19 +504,19 @@ def remove_all(cls):
TestRun.executor.run(f"vgchange -an {vg_name}")
VolumeGroup.remove(vg_name)

cmd = f"pvdisplay | grep 'PV Name' | awk '{{print $3}}'"
cmd = "pvdisplay | grep 'PV Name' | awk '{{print $3}}'"
os_disks = get_system_disks()
# invert grep to make sure os_disks won`t be wiped during lvms cleanup
cmd += "".join([f" | grep -v {os_disk}" for os_disk in os_disks])
pv_names = TestRun.executor.run(cmd).stdout.splitlines()
for pv_name in pv_names:
cls.remove_pv(pv_name)

TestRun.LOGGER.info(f"Successfully removed all LVMs.")
TestRun.LOGGER.info("Successfully removed all LVMs.")

@staticmethod
def make_sure_lv_is_active(lv_path: str):
cmd = f"lvscan"
cmd = "lvscan"
output_lines = TestRun.executor.run_expect_success(cmd).stdout.splitlines()

for line in output_lines:
Expand Down
3 changes: 2 additions & 1 deletion storage_devices/nullblk.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
# Copyright(c) 2026 Unvertical
# SPDX-License-Identifier: BSD-3-Clause
#

Expand Down Expand Up @@ -44,7 +45,7 @@ def list(cls):

@staticmethod
def _list_devices():
ls_output = ls(f"/dev/nullb*")
ls_output = ls("/dev/nullb*")
if "No such file or directory" in ls_output:
return []
return parse_ls_output(ls_output)
5 changes: 3 additions & 2 deletions test_tools/drbdadm.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#
# Copyright(c) 2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
# Copyright(c) 2026 Unvertical
# SPDX-License-Identifier: BSD-3-Clause
#

from core.test_run import TestRun
Expand All @@ -22,7 +23,7 @@ def up(resource_name: str):
# disable resource
@staticmethod
def down_all():
cmd = f"drbdadm down all"
cmd = "drbdadm down all"
return TestRun.executor.run_expect_success(cmd)

@staticmethod
Expand Down
3 changes: 2 additions & 1 deletion test_tools/git.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#
# Copyright(c) 2019-2022 Intel Corporation
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
# Copyright(c) 2026 Unvertical
# SPDX-License-Identifier: BSD-3-Clause
#

Expand Down Expand Up @@ -118,4 +119,4 @@ def checkout_version(version):
f"cd {TestRun.usr.working_dir} && "
f"git submodule update --force")
if output.exit_code != 0:
raise CmdException(f"Failed to update submodules", output)
raise CmdException("Failed to update submodules", output)
9 changes: 5 additions & 4 deletions test_tools/linux_packaging.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#
# Copyright(c) 2022 Intel Corporation
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
# Copyright(c) 2026 Unvertical
# SPDX-License-Identifier: BSD-3-Clause
#

Expand All @@ -27,7 +28,7 @@ def check_if_installed(self):
return output.exit_code == 0

def install(self):
TestRun.LOGGER.info(f"Installing RPM packages")
TestRun.LOGGER.info("Installing RPM packages")

if not self.packages:
raise ValueError("No packages given.")
Expand All @@ -43,7 +44,7 @@ def install(self):
raise CmdException("Installation failed or errors found during the process.", output)

def uninstall(self):
TestRun.LOGGER.info(f"Uninstalling RPM packages")
TestRun.LOGGER.info("Uninstalling RPM packages")

if not self.check_if_installed():
raise FileNotFoundError("Could not uninstall - packages not installed yet.")
Expand Down Expand Up @@ -82,7 +83,7 @@ def check_if_installed(self):
return output.exit_code == 0

def install(self):
TestRun.LOGGER.info(f"Installing DEB packages")
TestRun.LOGGER.info("Installing DEB packages")

if not self.packages:
raise ValueError("No packages given.")
Expand All @@ -98,7 +99,7 @@ def install(self):
raise CmdException("Installation failed or errors found during the process.", output)

def uninstall(self):
TestRun.LOGGER.info(f"Uninstalling DEB packages")
TestRun.LOGGER.info("Uninstalling DEB packages")

if not self.check_if_installed():
raise FileNotFoundError("Could not uninstall - packages not installed yet.")
Expand Down
7 changes: 4 additions & 3 deletions test_tools/mdadm.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#
# Copyright(c) 2020-2021 Intel Corporation
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
# Copyright(c) 2026 Unvertical
# SPDX-License-Identifier: BSD-3-Clause
#

Expand All @@ -14,7 +15,7 @@
class Mdadm:
@staticmethod
def assemble(device_paths: str = None):
cmd = f"mdadm --assemble " + (device_paths if device_paths else "--scan")
cmd = "mdadm --assemble " + (device_paths if device_paths else "--scan")
return TestRun.executor.run(cmd)

@staticmethod
Expand Down Expand Up @@ -71,7 +72,7 @@ def detail_result(cls, raid_device_paths: str):

@staticmethod
def examine(brief: bool = True, device_paths: str = None):
cmd = f"mdadm --examine "
cmd = "mdadm --examine "
if brief:
cmd += "--brief "
cmd += (device_paths if device_paths else "--scan")
Expand Down Expand Up @@ -109,7 +110,7 @@ def examine_result(cls, device_paths: str = None):

@staticmethod
def stop(device_paths: str = None):
cmd = f"mdadm --stop " + (device_paths if device_paths else "--scan")
cmd = "mdadm --stop " + (device_paths if device_paths else "--scan")
return TestRun.executor.run_expect_success(cmd)

@staticmethod
Expand Down
Loading