Skip to content

Commit

Permalink
Fix tests after LVM API refactor
Browse files Browse the repository at this point in the history
Signed-off-by: Katarzyna Treder <[email protected]>
  • Loading branch information
Katarzyna Treder committed Nov 13, 2024
1 parent 37d91fd commit 7ebf948
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 76 deletions.
12 changes: 6 additions & 6 deletions test/functional/tests/io_class/test_io_class_lvm_on_cas.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#
# Copyright(c) 2022 Intel Corporation
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
# SPDX-License-Identifier: BSD-3-Clause
#

Expand All @@ -16,6 +17,7 @@
from test_tools.fio.fio import Fio
from test_tools.fio.fio_param import ReadWrite, IoEngine
from test_utils.size import Size, Unit
from tests.volumes.common import lvm_filters

mount_point = "/mnt/"
io_target = "/mnt/test"
Expand Down Expand Up @@ -43,16 +45,14 @@ def test_io_class_lvm_on_cas():
cache = casadm.start_cache(cache_dev.partitions[0], CacheMode.WB, force=True)
core = cache.add_core(core_dev.partitions[0])

with TestRun.step("Create LVM on CAS device."):
lvm_filters = ["a/.*/", "r|/dev/sd*|", "r|/dev/hd*|", "r|/dev/xvd*|", "r/disk/", "r/block/",
"r|/dev/nvme*|"]
with TestRun.step("Add CAS device type to the LVM config file."):
LvmConfiguration.add_block_device_to_lvm_config("cas")

with TestRun.step("Create LVM on CAS device."):
config = LvmConfiguration(lvm_filters,
pv_num=1,
vg_num=1,
lv_num=1,
cache_num=1,
cas_dev_num=1)
lv_num=1,)

lvms = Lvm.create_specific_lvm_configuration(core, config)
lvm = lvms[0]
Expand Down
16 changes: 16 additions & 0 deletions test/functional/tests/volumes/common.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
#
# Copyright(c) 2022 Intel Corporation
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
# SPDX-License-Identifier: BSD-3-Clause
#

from api.cas.init_config import InitConfig, opencas_conf_path
from test_tools import fs_utils
from core.test_run import TestRun
from test_utils.os_utils import get_block_device_names_list
from test_utils.size import Size, Unit

test_file_size = Size(500, Unit.KiloByte)
lvm_filters = [
"a/.*/", "r|/dev/sd*|", "r|/dev/hd*|", "r|/dev/xvd*|", "r/disk/", "r/block/",
"r|/dev/nvme*|", "r|/dev/vd*|"
]


def create_files_with_md5sums(destination_path, files_count):
Expand Down Expand Up @@ -40,3 +48,11 @@ def compare_md5sums(md5_sums_source, files_to_check_path, copy_to_tmp=False):
TestRun.fail(f"Source and target files {file_to_check_path} checksums are different.")

TestRun.LOGGER.info(f"Successful verification, md5sums match.")


def get_test_configuration():
InitConfig.create_init_config_from_running_configuration()
config_output = TestRun.executor.run(f"cat {opencas_conf_path}")
devices = get_block_device_names_list(exclude_list=[7]) # 7 stands for loop device

return config_output.stdout, devices
29 changes: 8 additions & 21 deletions test/functional/tests/volumes/test_many_cores_on_many_lvms.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
#
# Copyright(c) 2022 Intel Corporation
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
# SPDX-License-Identifier: BSD-3-Clause
#

import datetime
import pytest

from api.cas.init_config import InitConfig, opencas_conf_path
from storage_devices.lvm import Lvm, LvmConfiguration
from api.cas import casadm
from core.test_run import TestRun
from storage_devices.disk import DiskType, DiskTypeSet
from test_tools.fio.fio import Fio
from test_tools.fio.fio_param import ReadWrite, IoEngine, VerifyMethod
from test_utils.size import Size, Unit
from tests.volumes.common import get_test_configuration


@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand]))
Expand All @@ -36,15 +38,17 @@ def test_many_cores_on_many_lvms():
cache_dev = cache_device.partitions[0]
core_dev = core_device.partitions[0]

with TestRun.step("Configure LVM to use device filters."):
LvmConfiguration.set_use_devices_file(False)

with TestRun.step("Create LVMs."):
config = LvmConfiguration(lvm_filters=[],
pv_num=1,
vg_num=1,
lv_num=16,
cache_num=1,
cas_dev_num=16)
)

lvms = Lvm.create_specific_lvm_configuration([core_dev], config, lvm_as_core=True)
lvms = Lvm.create_specific_lvm_configuration([core_dev], config)

with TestRun.step(f"Create CAS device."):
cache = casadm.start_cache(cache_dev, force=True)
Expand Down Expand Up @@ -102,20 +106,3 @@ def test_many_cores_on_many_lvms():

with TestRun.step("Remove LVMs."):
Lvm.remove_all()


def get_block_devices_list():
cmd = f"lsblk -l | awk '{{print $1}}' | grep -v loop"
devices = TestRun.executor.run_expect_success(cmd).stdout
devices_list = devices.splitlines()
devices_list.sort()

return devices_list


def get_test_configuration():
InitConfig.create_init_config_from_running_configuration()
config_output = TestRun.executor.run(f"cat {opencas_conf_path}")
devices = get_block_devices_list()

return config_output.stdout, devices
34 changes: 10 additions & 24 deletions test/functional/tests/volumes/test_many_lvms_on_many_cores.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
#
# Copyright(c) 2022 Intel Corporation
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
# SPDX-License-Identifier: BSD-3-Clause
#

import datetime
import pytest

from api.cas.init_config import InitConfig, opencas_conf_path
from storage_devices.lvm import Lvm, LvmConfiguration

from api.cas import casadm
from core.test_run import TestRun
from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan
from test_tools.fio.fio import Fio
from test_tools.fio.fio_param import ReadWrite, IoEngine, VerifyMethod
from test_utils.size import Size, Unit
from tests.volumes.common import get_test_configuration, lvm_filters


@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand]))
Expand Down Expand Up @@ -48,16 +49,18 @@ def test_many_lvms_on_many_cores():
for core_dev in core_partitions:
cores.append(cache.add_core(core_dev))

with TestRun.step("Create LVMs on CAS device."):
lvm_filters = ["a/.*/", "r|/dev/sd*|", "r|/dev/hd*|", "r|/dev/xvd*|", "r/disk/", "r/block/",
"r|/dev/nvme*|"]
with TestRun.step("Configure LVM to use device filters."):
LvmConfiguration.set_use_devices_file(False)

with TestRun.step("Add CAS device type to the LVM config file."):
LvmConfiguration.add_block_device_to_lvm_config("cas")

with TestRun.step("Create LVMs on CAS device."):
config = LvmConfiguration(lvm_filters,
pv_num=4,
vg_num=4,
lv_num=4,
cache_num=1,
cas_dev_num=len(cores))
)

lvms = Lvm.create_specific_lvm_configuration(cores, config)

Expand Down Expand Up @@ -108,20 +111,3 @@ def test_many_lvms_on_many_cores():
with TestRun.step("Remove LVMs and clean up config changes."):
Lvm.remove_all()
LvmConfiguration.remove_filters_from_config()


def get_block_devices_list():
cmd = f"lsblk -l | awk '{{print $1}}' | grep -v loop"
devices = TestRun.executor.run_expect_success(cmd).stdout
devices_list = devices.splitlines()
devices_list.sort()

return devices_list


def get_test_configuration():
InitConfig.create_init_config_from_running_configuration()
config_output = TestRun.executor.run(f"cat {opencas_conf_path}")
devices = get_block_devices_list()

return config_output.stdout, devices
35 changes: 10 additions & 25 deletions test/functional/tests/volumes/test_many_lvms_on_single_core.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
#
# Copyright(c) 2022 Intel Corporation
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
# SPDX-License-Identifier: BSD-3-Clause
#

import datetime
import pytest

from api.cas.init_config import InitConfig, opencas_conf_path
from storage_devices.lvm import Lvm, LvmConfiguration

from api.cas import casadm
from core.test_run import TestRun
from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan
from test_tools.fio.fio import Fio
from test_tools.fio.fio_param import ReadWrite, IoEngine, VerifyMethod
from test_utils.size import Size, Unit
from tests.volumes.common import get_test_configuration, lvm_filters


@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand]))
Expand All @@ -38,16 +39,17 @@ def test_many_lvms_on_single_core():
cache = casadm.start_cache(cache_dev.partitions[0], force=True)
core = cache.add_core(core_dev.partitions[0])

with TestRun.step("Create LVMs on CAS device."):
lvm_filters = ["a/.*/", "r|/dev/sd*|", "r|/dev/hd*|", "r|/dev/xvd*|", "r/disk/", "r/block/",
"r|/dev/nvme*|"]
with TestRun.step("Configure LVM to use device filters."):
LvmConfiguration.set_use_devices_file(False)

with TestRun.step("Add CAS device type to the LVM config file."):
LvmConfiguration.add_block_device_to_lvm_config("cas")

with TestRun.step("Create LVMs on CAS device."):
config = LvmConfiguration(lvm_filters,
pv_num=1,
vg_num=1,
lv_num=16,
cache_num=1,
cas_dev_num=1)
lv_num=2,)

lvms = Lvm.create_specific_lvm_configuration(core, config)

Expand Down Expand Up @@ -97,20 +99,3 @@ def test_many_lvms_on_single_core():

with TestRun.step("Remove LVMs."):
Lvm.remove_all()


def get_block_devices_list():
cmd = f"lsblk -l | awk '{{print $1}}' | grep -v loop"
devices = TestRun.executor.run_expect_success(cmd).stdout
devices_list = devices.splitlines()
devices_list.sort()

return devices_list


def get_test_configuration():
InitConfig.create_init_config_from_running_configuration()
config_output = TestRun.executor.run(f"cat {opencas_conf_path}")
devices = get_block_devices_list()

return config_output.stdout, devices

0 comments on commit 7ebf948

Please sign in to comment.