Fix imports
Signed-off-by: Katarzyna Treder <katarzyna.treder@h-partners.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#
|
||||
# Copyright(c) 2019-2022 Intel Corporation
|
||||
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
|
@@ -1,9 +1,9 @@
|
||||
#
|
||||
# Copyright(c) 2019-2022 Intel Corporation
|
||||
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
|
||||
import pytest
|
||||
|
||||
from api.cas import casadm, ioclass_config
|
||||
@@ -12,7 +12,7 @@ from api.cas.casadm_params import OutputFormat
|
||||
from api.cas.ioclass_config import IoClass
|
||||
from core.test_run import TestRun
|
||||
from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan
|
||||
from test_tools import fs_tools
|
||||
from test_tools.fs_tools import read_file, remove
|
||||
from type_def.size import Size, Unit
|
||||
|
||||
ioclass_config_path = "/tmp/opencas_ioclass.conf"
|
||||
@@ -61,7 +61,7 @@ def test_io_class_export_configuration():
|
||||
f"{casadm.list_io_classes_cmd(str(cache.cache_id), OutputFormat.csv.name)}"
|
||||
f" > {saved_config_path}"
|
||||
)
|
||||
csv = fs_utils.read_file(saved_config_path)
|
||||
csv = read_file(saved_config_path)
|
||||
if not IoClass.compare_ioclass_lists(IoClass.csv_to_list(csv), random_list):
|
||||
TestRun.LOGGER.error(
|
||||
"Exported configuration does not match expected\n"
|
||||
@@ -98,7 +98,7 @@ def test_io_class_export_configuration():
|
||||
)
|
||||
|
||||
with TestRun.LOGGER.step(f"Test cleanup"):
|
||||
fs_utils.remove(saved_config_path)
|
||||
remove(saved_config_path)
|
||||
|
||||
|
||||
def prepare(cache_mode: CacheMode = None):
|
||||
|
@@ -1,5 +1,6 @@
|
||||
#
|
||||
# Copyright(c) 2019-2022 Intel Corporation
|
||||
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
|
@@ -1,21 +1,20 @@
|
||||
#
|
||||
# Copyright(c) 2019-2022 Intel Corporation
|
||||
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
import random
|
||||
import time
|
||||
from datetime import datetime
|
||||
|
||||
import pytest
|
||||
|
||||
import test_tools.fs_tools
|
||||
from datetime import datetime
|
||||
|
||||
from api.cas import ioclass_config, casadm
|
||||
from core.test_run import TestRun
|
||||
from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan
|
||||
from test_tools import fs_tools
|
||||
from test_tools.dd import Dd
|
||||
from test_tools.fs_tools import Filesystem
|
||||
from test_tools.fs_tools import Filesystem, create_directory, remove
|
||||
from test_utils.filesystem.directory import Directory
|
||||
from test_utils.filesystem.file import File
|
||||
from test_tools.os_tools import drop_caches, DropCachesMode, sync
|
||||
@@ -47,19 +46,19 @@ def test_ioclass_directory_depth(filesystem):
|
||||
with TestRun.step(
|
||||
f"Prepare {filesystem.name} filesystem and mount {core.path} " f"at {mountpoint}."
|
||||
):
|
||||
test_tools.fs_utils.create_filesystem(filesystem)
|
||||
core.create_filesystem(filesystem)
|
||||
core.mount(mountpoint)
|
||||
sync()
|
||||
|
||||
with TestRun.step(f"Create the base directory: {base_dir_path}."):
|
||||
fs_utils.create_directory(base_dir_path)
|
||||
create_directory(base_dir_path)
|
||||
|
||||
with TestRun.step(f"Create a nested directory."):
|
||||
nested_dir_path = base_dir_path
|
||||
random_depth = random.randint(40, 80)
|
||||
for i in range(random_depth):
|
||||
nested_dir_path += f"/dir_{i}"
|
||||
fs_utils.create_directory(path=nested_dir_path, parents=True)
|
||||
create_directory(path=nested_dir_path, parents=True)
|
||||
|
||||
# Test classification in nested dir by reading a previously unclassified file
|
||||
with TestRun.step("Create the first file in the nested directory."):
|
||||
@@ -177,9 +176,9 @@ def test_ioclass_directory_file_operations(filesystem):
|
||||
casadm.load_io_classes(cache_id=cache.cache_id, file=ioclass_config_path)
|
||||
|
||||
with TestRun.step(
|
||||
f"Prepare {filesystem.name} filesystem " f"and mounting {core.path} at {mountpoint}."
|
||||
f"Prepare {filesystem.name} filesystem and mounting {core.path} at {mountpoint}."
|
||||
):
|
||||
test_tools.fs_utils.create_filesystem(fs_type=filesystem)
|
||||
core.create_filesystem(fs_type=filesystem)
|
||||
core.mount(mount_point=mountpoint)
|
||||
sync()
|
||||
|
||||
@@ -347,7 +346,7 @@ def test_ioclass_directory_dir_operations(filesystem):
|
||||
with TestRun.step(
|
||||
f"Prepare {filesystem.name} filesystem " f"and mount {core.path} at {mountpoint}."
|
||||
):
|
||||
test_tools.fs_utils.create_filesystem(fs_type=filesystem)
|
||||
core.create_filesystem(fs_type=filesystem)
|
||||
core.mount(mount_point=mountpoint)
|
||||
sync()
|
||||
|
||||
@@ -399,7 +398,7 @@ def test_ioclass_directory_dir_operations(filesystem):
|
||||
)
|
||||
|
||||
with TestRun.step(f"Remove {classified_dir_path_2}."):
|
||||
fs_utils.remove(path=classified_dir_path_2, force=True, recursive=True)
|
||||
remove(path=classified_dir_path_2, force=True, recursive=True)
|
||||
sync()
|
||||
drop_caches(DropCachesMode.ALL)
|
||||
|
||||
|
@@ -1,11 +1,13 @@
|
||||
#
|
||||
# Copyright(c) 2022 Intel Corporation
|
||||
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
from collections import namedtuple
|
||||
import pytest
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
from api.cas.ioclass_config import default_config_file_path
|
||||
from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan
|
||||
from core.test_run import TestRun
|
||||
|
@@ -1,17 +1,16 @@
|
||||
#
|
||||
# Copyright(c) 2020-2022 Intel Corporation
|
||||
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
import pytest
|
||||
|
||||
from collections import namedtuple
|
||||
from math import isclose
|
||||
|
||||
import pytest
|
||||
|
||||
import test_tools.fs_tools
|
||||
from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan
|
||||
from test_tools import fs_tools
|
||||
from test_tools.fs_tools import Filesystem
|
||||
from test_tools.fs_tools import Filesystem, create_directory
|
||||
from .io_class_common import *
|
||||
|
||||
|
||||
@@ -38,7 +37,7 @@ def test_io_class_eviction_priority():
|
||||
|
||||
with TestRun.step(f"Preparing filesystem and mounting {core.path} at {mountpoint}"):
|
||||
filesystem = Filesystem.xfs
|
||||
test_tools.fs_utils.create_filesystem(filesystem)
|
||||
core.create_filesystem(filesystem)
|
||||
core.mount(mountpoint)
|
||||
sync()
|
||||
|
||||
@@ -51,7 +50,7 @@ def test_io_class_eviction_priority():
|
||||
IoclassConfig(4, 1, 1.00, f"{mountpoint}/D"),
|
||||
]
|
||||
for io_class in io_classes:
|
||||
fs_utils.create_directory(io_class.dir_path, parents=True)
|
||||
create_directory(io_class.dir_path, parents=True)
|
||||
|
||||
with TestRun.step("Adding io classes for all dirs"):
|
||||
for io_class in io_classes:
|
||||
|
@@ -1,13 +1,12 @@
|
||||
#
|
||||
# Copyright(c) 2019-2022 Intel Corporation
|
||||
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
import random
|
||||
|
||||
import pytest
|
||||
|
||||
import test_tools.fs_tools
|
||||
from api.cas import ioclass_config, casadm
|
||||
from core.test_run import TestRun
|
||||
from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan
|
||||
@@ -57,7 +56,7 @@ def test_ioclass_file_extension():
|
||||
casadm.load_io_classes(cache_id=cache.cache_id, file=ioclass_config_path)
|
||||
|
||||
with TestRun.step(f"Prepare filesystem and mount {core.path} at {mountpoint}."):
|
||||
test_tools.fs_utils.create_filesystem(Filesystem.ext3)
|
||||
core.create_filesystem(Filesystem.ext3)
|
||||
core.mount(mountpoint)
|
||||
|
||||
with TestRun.step("Flush cache."):
|
||||
@@ -124,7 +123,7 @@ def test_ioclass_file_name_prefix():
|
||||
with TestRun.step(f"Prepare filesystem and mount {core.path} at {mountpoint}"):
|
||||
previous_occupancy = cache.get_occupancy()
|
||||
|
||||
test_tools.fs_utils.create_filesystem(Filesystem.ext3)
|
||||
core.create_filesystem(Filesystem.ext3)
|
||||
core.mount(mountpoint)
|
||||
|
||||
current_occupancy = cache.get_occupancy()
|
||||
@@ -210,7 +209,7 @@ def test_ioclass_file_extension_preexisting_filesystem():
|
||||
|
||||
with TestRun.step(f"Prepare files on raw block device."):
|
||||
casadm.remove_core(cache.cache_id, core_id=core.core_id)
|
||||
test_tools.fs_utils.create_filesystem(Filesystem.ext3)
|
||||
core.core_device.create_filesystem(Filesystem.ext3)
|
||||
core.core_device.mount(mountpoint)
|
||||
|
||||
for ext in extensions:
|
||||
@@ -292,7 +291,7 @@ def test_ioclass_file_offset():
|
||||
casadm.load_io_classes(cache_id=cache.cache_id, file=ioclass_config_path)
|
||||
|
||||
with TestRun.step(f"Prepare filesystem and mount {core.path} at {mountpoint}."):
|
||||
test_tools.fs_utils.create_filesystem(Filesystem.ext3)
|
||||
core.create_filesystem(Filesystem.ext3)
|
||||
core.mount(mountpoint)
|
||||
|
||||
with TestRun.step("Flush cache."):
|
||||
@@ -384,7 +383,7 @@ def test_ioclass_file_size(filesystem):
|
||||
with TestRun.step(
|
||||
f"Prepare {filesystem.name} filesystem and mount {core.path} " f"at {mountpoint}."
|
||||
):
|
||||
test_tools.fs_utils.create_filesystem(filesystem)
|
||||
core.create_filesystem(filesystem)
|
||||
core.mount(mountpoint)
|
||||
sync()
|
||||
|
||||
|
@@ -6,15 +6,13 @@
|
||||
|
||||
import pytest
|
||||
|
||||
import test_tools.fs_tools
|
||||
from api.cas import casadm, ioclass_config
|
||||
from api.cas.cache_config import CacheMode
|
||||
from api.cas.ioclass_config import IoClass
|
||||
from core.test_run import TestRun
|
||||
from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan
|
||||
from storage_devices.lvm import Lvm, LvmConfiguration
|
||||
from test_tools import fs_tools
|
||||
from test_tools.fs_tools import Filesystem
|
||||
from test_tools.fs_tools import Filesystem, read_file, remove
|
||||
from test_tools.fio.fio import Fio
|
||||
from test_tools.fio.fio_param import ReadWrite, IoEngine
|
||||
from type_def.size import Size, Unit
|
||||
@@ -59,11 +57,11 @@ def test_io_class_lvm_on_cas():
|
||||
lvm = lvms[0]
|
||||
|
||||
with TestRun.step("Create filesystem for LVM and mount it."):
|
||||
test_tools.fs_utils.create_filesystem(Filesystem.ext4)
|
||||
lvm.create_filesystem(Filesystem.ext4)
|
||||
lvm.mount(mount_point)
|
||||
|
||||
with TestRun.step("Prepare and load IO class config."):
|
||||
io_classes = IoClass.csv_to_list(fs_utils.read_file("/etc/opencas/ioclass-config.csv"))
|
||||
io_classes = IoClass.csv_to_list(read_file("/etc/opencas/ioclass-config.csv"))
|
||||
# remove two firs elements/lines: unclassified and metadata
|
||||
io_classes.pop(1)
|
||||
io_classes.pop(0)
|
||||
@@ -124,7 +122,7 @@ def test_io_class_lvm_on_cas():
|
||||
else:
|
||||
file_size = Size(1100, Unit.MebiByte)
|
||||
|
||||
fs_utils.remove(io_target)
|
||||
remove(io_target)
|
||||
|
||||
with TestRun.step("Remove LVMs."):
|
||||
TestRun.executor.run(f"umount {mount_point}")
|
||||
|
@@ -4,19 +4,17 @@
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
import pytest
|
||||
|
||||
from collections import namedtuple
|
||||
from math import isclose
|
||||
|
||||
import pytest
|
||||
|
||||
import test_tools.fs_tools
|
||||
from api.cas import ioclass_config, casadm
|
||||
from api.cas.cache_config import CacheMode, CacheLineSize
|
||||
from api.cas.ioclass_config import IoClass, default_config_file_path
|
||||
from core.test_run import TestRun
|
||||
from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan
|
||||
from test_tools import fs_tools
|
||||
from test_tools.fs_tools import Filesystem
|
||||
from test_tools.fs_tools import Filesystem, create_directory
|
||||
from test_tools.os_tools import sync
|
||||
from test_tools.udev import Udev
|
||||
from type_def.size import Unit, Size
|
||||
@@ -57,7 +55,7 @@ def test_io_class_occupancy_directory_write(io_size_multiplication, cache_mode):
|
||||
|
||||
with TestRun.step(f"Prepare filesystem and mount {core.path} at {mountpoint}"):
|
||||
filesystem = Filesystem.xfs
|
||||
test_tools.fs_utils.create_filesystem(filesystem)
|
||||
core.create_filesystem(filesystem)
|
||||
core.mount(mountpoint)
|
||||
sync()
|
||||
|
||||
@@ -70,7 +68,7 @@ def test_io_class_occupancy_directory_write(io_size_multiplication, cache_mode):
|
||||
]
|
||||
|
||||
for io_class in io_classes:
|
||||
fs_utils.create_directory(io_class.dir_path, parents=True)
|
||||
create_directory(io_class.dir_path, parents=True)
|
||||
|
||||
with TestRun.step("Remove old ioclass config"):
|
||||
ioclass_config.remove_ioclass_config()
|
||||
@@ -187,7 +185,7 @@ def test_io_class_occupancy_directory_read(io_size_multiplication):
|
||||
|
||||
with TestRun.step(f"Prepare filesystem and mount {core.path} at {mountpoint}"):
|
||||
filesystem = Filesystem.xfs
|
||||
test_tools.fs_utils.create_filesystem(filesystem)
|
||||
core.create_filesystem(filesystem)
|
||||
core.mount(mountpoint)
|
||||
sync()
|
||||
|
||||
@@ -200,7 +198,7 @@ def test_io_class_occupancy_directory_read(io_size_multiplication):
|
||||
]
|
||||
|
||||
for io_class in io_classes:
|
||||
fs_utils.create_directory(io_class.dir_path, parents=True)
|
||||
create_directory(io_class.dir_path, parents=True)
|
||||
|
||||
with TestRun.step(
|
||||
f"In each directory create file with size of {io_size_multiplication} "
|
||||
@@ -317,7 +315,7 @@ def test_ioclass_occupancy_sum_cache():
|
||||
|
||||
with TestRun.step(f"Prepare filesystem and mount {core.path} at {mountpoint}"):
|
||||
filesystem = Filesystem.xfs
|
||||
test_tools.fs_utils.create_filesystem(filesystem)
|
||||
core.create_filesystem(filesystem)
|
||||
core.mount(mountpoint)
|
||||
sync()
|
||||
|
||||
@@ -331,7 +329,7 @@ def test_ioclass_occupancy_sum_cache():
|
||||
]
|
||||
|
||||
for io_class in io_classes:
|
||||
fs_utils.create_directory(io_class.dir_path, parents=True)
|
||||
create_directory(io_class.dir_path, parents=True)
|
||||
|
||||
with TestRun.step("Remove old ioclass config"):
|
||||
ioclass_config.remove_ioclass_config()
|
||||
|
@@ -1,21 +1,20 @@
|
||||
#
|
||||
# Copyright(c) 2020-2022 Intel Corporation
|
||||
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
import pytest
|
||||
|
||||
from collections import namedtuple
|
||||
from math import isclose
|
||||
|
||||
import pytest
|
||||
|
||||
import test_tools.fs_tools
|
||||
from api.cas import ioclass_config, casadm
|
||||
from api.cas.cache_config import CacheMode, CacheLineSize
|
||||
from api.cas.ioclass_config import IoClass, default_config_file_path
|
||||
from storage_devices.device import Device
|
||||
from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan
|
||||
from test_tools import fs_tools
|
||||
from test_tools.fs_tools import Filesystem
|
||||
from test_tools.fs_tools import Filesystem, create_directory
|
||||
from test_tools.os_tools import sync
|
||||
from test_tools.udev import Udev
|
||||
from tests.io_class.io_class_common import (
|
||||
@@ -54,7 +53,7 @@ def test_ioclass_occupancy_load():
|
||||
|
||||
with TestRun.step(f"Prepare filesystem and mount {core.path} at {mountpoint}"):
|
||||
filesystem = Filesystem.xfs
|
||||
test_tools.fs_utils.create_filesystem(filesystem)
|
||||
core.create_filesystem(filesystem)
|
||||
core.mount(mountpoint)
|
||||
sync()
|
||||
|
||||
@@ -67,7 +66,7 @@ def test_ioclass_occupancy_load():
|
||||
]
|
||||
|
||||
for io_class in io_classes:
|
||||
fs_utils.create_directory(io_class.dir_path, parents=True)
|
||||
create_directory(io_class.dir_path, parents=True)
|
||||
|
||||
with TestRun.step("Remove old ioclass config"):
|
||||
ioclass_config.remove_ioclass_config()
|
||||
|
@@ -1,21 +1,20 @@
|
||||
#
|
||||
# Copyright(c) 2020-2022 Intel Corporation
|
||||
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
import pytest
|
||||
|
||||
from collections import namedtuple
|
||||
from math import isclose
|
||||
|
||||
import pytest
|
||||
|
||||
import test_tools.fs_tools
|
||||
from api.cas import ioclass_config, casadm
|
||||
from api.cas.cache_config import CacheMode, CacheLineSize
|
||||
from api.cas.ioclass_config import IoClass, default_config_file_path
|
||||
from core.test_run_utils import TestRun
|
||||
from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan
|
||||
from test_tools import fs_tools
|
||||
from test_tools.fs_tools import Filesystem
|
||||
from test_tools.fs_tools import Filesystem, create_directory, move
|
||||
from test_tools.os_tools import sync
|
||||
from test_tools.udev import Udev
|
||||
from type_def.size import Unit
|
||||
@@ -56,7 +55,7 @@ def test_ioclass_repart(io_class_size_multiplication):
|
||||
|
||||
with TestRun.step(f"Prepare filesystem and mount {core.path} at {mountpoint}"):
|
||||
filesystem = Filesystem.xfs
|
||||
test_tools.fs_utils.create_filesystem(filesystem)
|
||||
core.create_filesystem(filesystem)
|
||||
core.mount(mountpoint)
|
||||
sync()
|
||||
|
||||
@@ -69,7 +68,7 @@ def test_ioclass_repart(io_class_size_multiplication):
|
||||
]
|
||||
|
||||
for io_class in io_classes:
|
||||
fs_utils.create_directory(io_class.dir_path, parents=True)
|
||||
create_directory(io_class.dir_path, parents=True)
|
||||
|
||||
with TestRun.step("Remove old io class config"):
|
||||
ioclass_config.remove_ioclass_config()
|
||||
@@ -125,7 +124,7 @@ def test_ioclass_repart(io_class_size_multiplication):
|
||||
|
||||
with TestRun.step("Force repart - move files to created directories and read theirs contents"):
|
||||
for i, io_class in enumerate(io_classes):
|
||||
fs_utils.move(source=f"{mountpoint}/{i}", destination=io_class.dir_path)
|
||||
move(source=f"{mountpoint}/{i}", destination=io_class.dir_path)
|
||||
run_io_dir_read(f"{io_class.dir_path}/{i}")
|
||||
|
||||
with TestRun.step("Check if each ioclass reached it's occupancy limit"):
|
||||
|
@@ -1,19 +1,19 @@
|
||||
#
|
||||
# Copyright(c) 2020-2022 Intel Corporation
|
||||
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
import pytest
|
||||
|
||||
from recordclass import recordclass
|
||||
|
||||
import test_tools.fs_tools
|
||||
from api.cas import ioclass_config, casadm
|
||||
from api.cas.cache_config import CacheMode, CacheLineSize
|
||||
from api.cas.ioclass_config import IoClass, default_config_file_path
|
||||
from core.test_run import TestRun
|
||||
from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan
|
||||
from test_tools import fs_tools
|
||||
from test_tools.fs_tools import Filesystem
|
||||
from test_tools.fs_tools import Filesystem, create_directory
|
||||
from test_tools.os_tools import sync
|
||||
from test_tools.udev import Udev
|
||||
from type_def.size import Unit
|
||||
@@ -48,7 +48,7 @@ def test_ioclass_resize(cache_line_size, new_occupancy):
|
||||
|
||||
with TestRun.step(f"Prepare filesystem and mount {core.path} at {mountpoint}"):
|
||||
filesystem = Filesystem.xfs
|
||||
test_tools.fs_utils.create_filesystem(filesystem)
|
||||
core.create_filesystem(filesystem)
|
||||
core.mount(mountpoint)
|
||||
sync()
|
||||
|
||||
@@ -56,7 +56,7 @@ def test_ioclass_resize(cache_line_size, new_occupancy):
|
||||
IoclassConfig = recordclass("IoclassConfig", "id eviction_prio max_occupancy dir_path")
|
||||
io_class = IoclassConfig(2, 3, 0.10, f"{mountpoint}/A")
|
||||
|
||||
fs_utils.create_directory(io_class.dir_path, parents=True)
|
||||
create_directory(io_class.dir_path, parents=True)
|
||||
|
||||
with TestRun.step("Remove old ioclass config"):
|
||||
ioclass_config.remove_ioclass_config()
|
||||
|
@@ -1,17 +1,17 @@
|
||||
#
|
||||
# Copyright(c) 2022 Intel Corporation
|
||||
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
import pytest
|
||||
|
||||
from collections import namedtuple
|
||||
from math import isclose
|
||||
|
||||
import test_tools.fs_tools
|
||||
from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan
|
||||
from api.cas.ioclass_config import IoClass, default_config_file_path
|
||||
from test_tools import fs_tools
|
||||
from test_tools.fs_tools import Filesystem
|
||||
from test_tools.fs_tools import Filesystem, create_directory
|
||||
from core.test_run import TestRun
|
||||
from type_def.size import Size, Unit
|
||||
from .io_class_common import (
|
||||
@@ -44,7 +44,7 @@ def test_io_class_pinning_eviction():
|
||||
cache_line_count = cache.get_statistics().config_stats.cache_size
|
||||
|
||||
with TestRun.step("Mount filesystem"):
|
||||
test_tools.fs_utils.create_filesystem(Filesystem.xfs)
|
||||
core.create_filesystem(Filesystem.xfs)
|
||||
core.mount(mountpoint)
|
||||
|
||||
with TestRun.step("Prepare test dirs"):
|
||||
@@ -58,7 +58,7 @@ def test_io_class_pinning_eviction():
|
||||
]
|
||||
|
||||
for io_class in io_classes:
|
||||
fs_utils.create_directory(io_class.dir_path, parents=True)
|
||||
create_directory(io_class.dir_path, parents=True)
|
||||
|
||||
with TestRun.step("Remove old config"):
|
||||
ioclass_config.remove_ioclass_config()
|
||||
@@ -141,7 +141,7 @@ def test_pinned_ioclasses_eviction():
|
||||
cache_line_count = cache.get_statistics().config_stats.cache_size
|
||||
|
||||
with TestRun.step("Mount filesystem"):
|
||||
test_tools.fs_utils.create_filesystem(Filesystem.xfs)
|
||||
core.create_filesystem(Filesystem.xfs)
|
||||
core.mount(mountpoint)
|
||||
|
||||
with TestRun.step("Prepare test dirs"):
|
||||
@@ -152,7 +152,7 @@ def test_pinned_ioclasses_eviction():
|
||||
]
|
||||
|
||||
for io_class in io_classes:
|
||||
fs_utils.create_directory(io_class.dir_path, parents=True)
|
||||
create_directory(io_class.dir_path, parents=True)
|
||||
|
||||
with TestRun.step("Remove old config"):
|
||||
ioclass_config.remove_ioclass_config()
|
||||
|
@@ -1,5 +1,6 @@
|
||||
#
|
||||
# Copyright(c) 2022 Intel Corporation
|
||||
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
|
@@ -1,5 +1,6 @@
|
||||
#
|
||||
# Copyright(c) 2022 Intel Corporation
|
||||
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
@@ -9,8 +10,8 @@ from api.cas import ioclass_config, cli_messages
|
||||
from api.cas.ioclass_config import IoClass
|
||||
from core.test_run import TestRun
|
||||
from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan
|
||||
from test_tools import fs_tools
|
||||
from connection.utils.output import CmdException
|
||||
from test_tools.fs_tools import read_file, write_file
|
||||
from type_def.size import Unit, Size
|
||||
from tests.io_class.io_class_common import prepare, ioclass_config_path
|
||||
|
||||
@@ -86,7 +87,7 @@ def test_io_class_prevent_wrong_configuration():
|
||||
f"{IoClass.default_header()}\n{loaded_io_classes_str}"
|
||||
)
|
||||
|
||||
config_io_classes = IoClass.csv_to_list(fs_utils.read_file(ioclass_config_path))
|
||||
config_io_classes = IoClass.csv_to_list(read_file(ioclass_config_path))
|
||||
if not IoClass.compare_ioclass_lists(config_io_classes, loaded_io_classes):
|
||||
TestRun.fail("Default IO class configuration not loaded correctly.")
|
||||
|
||||
@@ -98,7 +99,7 @@ def test_io_class_prevent_wrong_configuration():
|
||||
f"Preparing headerless configuration file with following content:\n"
|
||||
f"{headerless_configuration}"
|
||||
)
|
||||
fs_utils.write_file(ioclass_config_path, headerless_configuration)
|
||||
write_file(ioclass_config_path, headerless_configuration)
|
||||
try_load_malformed_config(
|
||||
cache,
|
||||
config_io_classes,
|
||||
@@ -114,7 +115,7 @@ def test_io_class_prevent_wrong_configuration():
|
||||
TestRun.LOGGER.info(
|
||||
f"Testing following header with default IO class:\n" f"{config_content}"
|
||||
)
|
||||
fs_utils.write_file(ioclass_config_path, config_content)
|
||||
write_file(ioclass_config_path, config_content)
|
||||
try_load_malformed_config(cache, config_io_classes, expected_err_msg=err_message)
|
||||
|
||||
with TestRun.step(
|
||||
@@ -123,7 +124,7 @@ def test_io_class_prevent_wrong_configuration():
|
||||
):
|
||||
config_content = f"{IoClass.default_header()}\n{double_io_class_configuration}"
|
||||
TestRun.LOGGER.info(f"Testing following configuration file:\n{config_content}")
|
||||
fs_utils.write_file(ioclass_config_path, config_content)
|
||||
write_file(ioclass_config_path, config_content)
|
||||
try_load_malformed_config(
|
||||
cache,
|
||||
config_io_classes,
|
||||
@@ -139,7 +140,7 @@ def test_io_class_prevent_wrong_configuration():
|
||||
TestRun.LOGGER.info(
|
||||
f"Testing following header with default IO class:\n{config_content}"
|
||||
)
|
||||
fs_utils.write_file(ioclass_config_path, config_content)
|
||||
write_file(ioclass_config_path, config_content)
|
||||
try_load_malformed_config(cache, config_io_classes, expected_err_msg=err_message)
|
||||
|
||||
|
||||
|
@@ -1,10 +1,10 @@
|
||||
#
|
||||
# Copyright(c) 2019-2022 Intel Corporation
|
||||
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
import time
|
||||
|
||||
import pytest
|
||||
|
||||
from api.cas import ioclass_config, casadm
|
||||
|
@@ -4,17 +4,15 @@
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
import pytest
|
||||
|
||||
import test_tools.fs_tools
|
||||
from collections import namedtuple
|
||||
|
||||
from api.cas import ioclass_config, casadm
|
||||
from core.test_run import TestRun
|
||||
from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan
|
||||
from test_tools import fs_tools
|
||||
from test_tools.dd import Dd
|
||||
from test_tools.fs_tools import Filesystem
|
||||
from test_tools.fs_tools import Filesystem, create_directory
|
||||
from test_tools.os_tools import drop_caches, DropCachesMode, sync
|
||||
from test_tools.udev import Udev
|
||||
from type_def.size import Unit, Size
|
||||
@@ -43,7 +41,7 @@ def test_ioclass_usage_sum():
|
||||
|
||||
with TestRun.step(f"Prepare filesystem and mount {core.path} at {mountpoint}"):
|
||||
filesystem = Filesystem.xfs
|
||||
test_tools.fs_utils.create_filesystem(filesystem)
|
||||
core.create_filesystem(filesystem)
|
||||
core.mount(mountpoint)
|
||||
sync()
|
||||
|
||||
@@ -57,7 +55,7 @@ def test_ioclass_usage_sum():
|
||||
]
|
||||
|
||||
for io_class in io_classes:
|
||||
fs_utils.create_directory(io_class.dir_path, parents=True)
|
||||
create_directory(io_class.dir_path, parents=True)
|
||||
|
||||
with TestRun.step("Add io classes for all dirs"):
|
||||
ioclass_config.remove_ioclass_config()
|
||||
|
@@ -1,27 +1,27 @@
|
||||
#
|
||||
# Copyright(c) 2022 Intel Corporation
|
||||
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
import os
|
||||
import pytest
|
||||
|
||||
from datetime import timedelta
|
||||
|
||||
import test_tools.fs_tools
|
||||
import test_tools.runlevel
|
||||
from api.cas import ioclass_config, casadm_parser
|
||||
from api.cas.cache_config import CacheMode
|
||||
from api.cas.casadm_params import StatsFilter
|
||||
from api.cas.casadm_parser import get_caches, get_cores
|
||||
from api.cas.init_config import InitConfig
|
||||
from api.cas.ioclass_config import IoClass
|
||||
from api.cas.ioclass_config import IoClass, remove_ioclass_config, create_ioclass_config, \
|
||||
add_ioclass
|
||||
from core.test_run_utils import TestRun
|
||||
from storage_devices.disk import DiskTypeSet, DiskType, DiskTypeLowerThan
|
||||
from test_tools import fs_tools
|
||||
from test_tools.fs_tools import Filesystem
|
||||
from test_tools.fs_tools import Filesystem, copy, read_file
|
||||
from test_tools.fio.fio import Fio
|
||||
from test_tools.fio.fio_param import IoEngine, ReadWrite
|
||||
from test_tools.os_tools import sync, drop_caches
|
||||
from test_tools.runlevel import Runlevel
|
||||
from test_tools.runlevel import Runlevel, change_runlevel
|
||||
from type_def.size import Size, Unit
|
||||
from tests.io_class.io_class_common import (
|
||||
prepare,
|
||||
@@ -52,7 +52,7 @@ def test_io_class_service_load(runlevel):
|
||||
run_io_dir_read(core.path)
|
||||
|
||||
with TestRun.step("Create ext4 filesystem on CAS device and mount it."):
|
||||
test_tools.fs_utils.create_filesystem(Filesystem.ext4)
|
||||
core.create_filesystem(Filesystem.ext4)
|
||||
core.mount(mountpoint)
|
||||
|
||||
with TestRun.step(
|
||||
@@ -79,18 +79,18 @@ def test_io_class_service_load(runlevel):
|
||||
sync()
|
||||
|
||||
with TestRun.step(f"Reboot system to runlevel {runlevel}."):
|
||||
test_tools.runlevel.change_runlevel(runlevel)
|
||||
change_runlevel(runlevel)
|
||||
TestRun.executor.reboot()
|
||||
|
||||
with TestRun.step(
|
||||
"Check if CAS device loads properly - "
|
||||
"IO class configuration and statistics shall not change"
|
||||
):
|
||||
caches = casadm_parser.get_caches()
|
||||
caches = get_caches()
|
||||
if len(caches) != 1:
|
||||
TestRun.fail("Cache did not start at boot time.")
|
||||
cache = caches[0]
|
||||
cores = casadm_parser.get_cores(cache.cache_id)
|
||||
cores = get_cores(cache.cache_id)
|
||||
if len(cores) != 1:
|
||||
TestRun.fail(f"Actual number of cores: {len(cores)}\nExpected number of cores: 1")
|
||||
core = cores[0]
|
||||
@@ -160,17 +160,17 @@ def run_io():
|
||||
|
||||
|
||||
def prepare_and_load_io_class_config(cache, metadata_not_cached=False):
|
||||
ioclass_config.remove_ioclass_config()
|
||||
remove_ioclass_config()
|
||||
|
||||
if metadata_not_cached:
|
||||
ioclass_config.create_ioclass_config(
|
||||
create_ioclass_config(
|
||||
add_default_rule=True, ioclass_config_path=ioclass_config_path
|
||||
)
|
||||
ioclass_config.add_ioclass(1, "metadata&done", 1, "0.00", ioclass_config_path)
|
||||
add_ioclass(1, "metadata&done", 1, "0.00", ioclass_config_path)
|
||||
else:
|
||||
fs_utils.copy(template_config_path, ioclass_config_path)
|
||||
copy(template_config_path, ioclass_config_path)
|
||||
|
||||
config_io_classes = IoClass.csv_to_list(fs_utils.read_file(ioclass_config_path))
|
||||
config_io_classes = IoClass.csv_to_list(read_file(ioclass_config_path))
|
||||
cache.load_io_class(ioclass_config_path)
|
||||
output_io_classes = cache.list_io_classes()
|
||||
if not IoClass.compare_ioclass_lists(config_io_classes, output_io_classes):
|
||||
|
@@ -13,8 +13,7 @@ from api.cas.cache_config import CacheMode, CleaningPolicy, SeqCutOffPolicy
|
||||
from api.cas.ioclass_config import IoClass
|
||||
from core.test_run_utils import TestRun
|
||||
from storage_devices.disk import DiskTypeSet, DiskType, DiskTypeLowerThan
|
||||
from test_tools import fs_tools
|
||||
from test_tools.fs_tools import Filesystem
|
||||
from test_tools.fs_tools import Filesystem, remove, read_file
|
||||
from test_tools.fio.fio import Fio
|
||||
from test_tools.fio.fio_param import IoEngine, ReadWrite
|
||||
from test_tools.os_tools import sync, drop_caches
|
||||
@@ -83,7 +82,7 @@ def test_io_class_stats_file_size_core_fs(cache_mode: CacheMode, filesystem: Fil
|
||||
issued_reqs_no = \
|
||||
result[0].write_requests_number() + result[0].read_requests_number()
|
||||
check_statistics(cache, core, io_classes, io_class, issued_reqs_no)
|
||||
fs_utils.remove(f"{core.mount_point}/*", force=True, recursive=True)
|
||||
remove(f"{core.mount_point}/*", force=True, recursive=True)
|
||||
|
||||
size_min = size + Size(512, Unit.Byte)
|
||||
|
||||
@@ -140,7 +139,7 @@ def test_io_class_stats_file_size_core_direct(cache_mode: CacheMode):
|
||||
issued_reqs_no = \
|
||||
result[0].write_requests_number() + result[0].read_requests_number()
|
||||
check_statistics(cache, core, io_classes, io_class_direct, issued_reqs_no)
|
||||
fs_utils.remove(f"{core.path}/*", force=True, recursive=True)
|
||||
remove(f"{core.path}/*", force=True, recursive=True)
|
||||
|
||||
size_min = size + Size(512, Unit.Byte)
|
||||
|
||||
@@ -191,7 +190,7 @@ def check_statistics(cache, core, io_classes, tested_io_class, issued_reqs_no):
|
||||
|
||||
|
||||
def prepare_io_classes(cache):
|
||||
template_io_classes = IoClass.csv_to_list(fs_utils.read_file(template_config_path))
|
||||
template_io_classes = IoClass.csv_to_list(read_file(template_config_path))
|
||||
test_io_classes = []
|
||||
|
||||
for io_class in template_io_classes:
|
||||
|
@@ -1,5 +1,6 @@
|
||||
#
|
||||
# Copyright(c) 2019-2022 Intel Corporation
|
||||
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
|
@@ -1,22 +1,22 @@
|
||||
#
|
||||
# Copyright(c) 2019-2022 Intel Corporation
|
||||
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
import random
|
||||
import time
|
||||
from itertools import permutations
|
||||
|
||||
import pytest
|
||||
|
||||
import test_tools.fs_tools
|
||||
from itertools import permutations
|
||||
|
||||
from api.cas import ioclass_config, casadm
|
||||
from api.cas.ioclass_config import IoClass
|
||||
from core.test_run import TestRun
|
||||
from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan
|
||||
from test_tools import fs_tools
|
||||
from test_tools.dd import Dd
|
||||
from test_tools.fs_tools import Filesystem
|
||||
from test_tools.fs_tools import Filesystem, create_directory, remove, \
|
||||
replace_first_pattern_occurrence
|
||||
from test_tools.fio.fio import Fio
|
||||
from test_tools.fio.fio_param import ReadWrite, IoEngine
|
||||
from test_utils.filesystem.file import File
|
||||
@@ -233,7 +233,7 @@ def test_ioclass_direct(filesystem):
|
||||
f"Preparing {filesystem.name} filesystem and mounting {core.path} at"
|
||||
f" {mountpoint}"
|
||||
)
|
||||
test_tools.fs_utils.create_filesystem(filesystem)
|
||||
core.create_filesystem(filesystem)
|
||||
core.mount(mountpoint)
|
||||
sync()
|
||||
else:
|
||||
@@ -329,7 +329,7 @@ def test_ioclass_metadata(filesystem):
|
||||
with TestRun.step(
|
||||
f"Prepare {filesystem.name} filesystem and mount {core.path} " f"at {mountpoint}."
|
||||
):
|
||||
test_tools.fs_utils.create_filesystem(filesystem)
|
||||
core.create_filesystem(filesystem)
|
||||
core.mount(mountpoint)
|
||||
sync()
|
||||
|
||||
@@ -373,7 +373,7 @@ def test_ioclass_metadata(filesystem):
|
||||
|
||||
with TestRun.step(f"Create directory {test_dir_path}."):
|
||||
requests_to_metadata_before = requests_to_metadata_after
|
||||
fs_utils.create_directory(path=test_dir_path)
|
||||
create_directory(path=test_dir_path)
|
||||
|
||||
TestRun.LOGGER.info(f"Moving test files into {test_dir_path}")
|
||||
for file in files:
|
||||
@@ -388,7 +388,7 @@ def test_ioclass_metadata(filesystem):
|
||||
TestRun.fail("No requests to metadata while moving files!")
|
||||
|
||||
with TestRun.step(f"Remove {test_dir_path}."):
|
||||
fs_utils.remove(path=test_dir_path, force=True, recursive=True)
|
||||
remove(path=test_dir_path, force=True, recursive=True)
|
||||
|
||||
with TestRun.step("Check requests to metadata."):
|
||||
requests_to_metadata_after = cache.get_io_class_statistics(
|
||||
@@ -475,9 +475,9 @@ def test_ioclass_id_as_condition():
|
||||
with TestRun.step(
|
||||
f"Prepare {filesystem.name} filesystem " f"and mount {core.path} at {mountpoint}."
|
||||
):
|
||||
test_tools.fs_utils.create_filesystem(filesystem)
|
||||
core.create_filesystem(filesystem)
|
||||
core.mount(mountpoint)
|
||||
fs_utils.create_directory(base_dir_path)
|
||||
create_directory(base_dir_path)
|
||||
sync()
|
||||
# CAS needs some time to resolve directory to inode
|
||||
time.sleep(ioclass_config.MAX_CLASSIFICATION_DELAY.seconds)
|
||||
@@ -616,10 +616,10 @@ def test_ioclass_conditions_or():
|
||||
with TestRun.step(
|
||||
f"Prepare {filesystem.name} filesystem " f"and mount {core.path} at {mountpoint}."
|
||||
):
|
||||
test_tools.fs_utils.create_filesystem(filesystem)
|
||||
core.create_filesystem(filesystem)
|
||||
core.mount(mountpoint)
|
||||
for i in range(1, 6):
|
||||
fs_utils.create_directory(f"{mountpoint}/dir{i}")
|
||||
create_directory(f"{mountpoint}/dir{i}")
|
||||
sync()
|
||||
|
||||
with TestRun.step("Perform IO fulfilling each condition and check if occupancy raises."):
|
||||
@@ -683,7 +683,7 @@ def test_ioclass_conditions_and():
|
||||
TestRun.LOGGER.info(
|
||||
f"Preparing {filesystem.name} filesystem " f"and mounting {core.path} at {mountpoint}"
|
||||
)
|
||||
test_tools.fs_utils.create_filesystem(filesystem)
|
||||
core.create_filesystem(filesystem)
|
||||
core.mount(mountpoint)
|
||||
sync()
|
||||
|
||||
@@ -744,9 +744,9 @@ def test_ioclass_effective_ioclass():
|
||||
with TestRun.LOGGER.step(
|
||||
f"Preparing {filesystem.name} filesystem " f"and mounting {core.path} at {mountpoint}"
|
||||
):
|
||||
test_tools.fs_utils.create_filesystem(filesystem)
|
||||
core.create_filesystem(filesystem)
|
||||
core.mount(mountpoint)
|
||||
fs_utils.create_directory(test_dir)
|
||||
create_directory(test_dir)
|
||||
sync()
|
||||
|
||||
for i, permutation in TestRun.iteration(enumerate(permutations(range(1, 5)), start=1)):
|
||||
@@ -832,7 +832,7 @@ def add_done_to_second_non_exclusive_condition(rules, permutation, cache):
|
||||
if non_exclusive_conditions == 2:
|
||||
break
|
||||
second_class_id += 1
|
||||
fs_utils.replace_first_pattern_occurrence(ioclass_config_path, rules[idx], f"{rules[idx]}&done")
|
||||
replace_first_pattern_occurrence(ioclass_config_path, rules[idx], f"{rules[idx]}&done")
|
||||
sync()
|
||||
casadm.load_io_classes(cache_id=cache.cache_id, file=ioclass_config_path)
|
||||
return second_class_id
|
||||
|
Reference in New Issue
Block a user