-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Katarzyna Treder <[email protected]>
- Loading branch information
Katarzyna Treder
committed
Nov 13, 2024
1 parent
ef8843b
commit 1a7c13d
Showing
4 changed files
with
163 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# | ||
# Copyright(c) 2024 Huawei Technologies Co., Ltd. | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# | ||
|
||
import os | ||
import random | ||
import pytest | ||
|
||
from api.cas import casadm | ||
from api.cas.init_config import InitConfig | ||
from core.test_run import TestRun | ||
from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan | ||
from test_utils.size import Size, Unit | ||
|
||
|
||
serial_template = "opencas-" | ||
|
||
|
||
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand])) | ||
@pytest.mark.require_disk("core", DiskTypeLowerThan("cache")) | ||
def test_cas_device_serial(): | ||
""" | ||
title: Open CAS device serial creation. | ||
description: Validate if Open CAS generates proper serial for each created CAS device. | ||
pass_criteria: | ||
- Each CAS device has proper serial in following format: | ||
opencas-casX-Y where X is cache ID and Y is core ID | ||
- CAS device serial is not changed after system reboot | ||
""" | ||
caches_count = 4 | ||
cores_count = [random.randint(1, 4) for _ in range(caches_count)] | ||
|
||
with TestRun.step("Prepare devices"): | ||
cache_dev = TestRun.disks["cache"] | ||
core_dev = TestRun.disks["core"] | ||
|
||
cache_dev.create_partitions([Size(1, Unit.GibiByte)] * 4) | ||
core_dev.create_partitions([Size(1, Unit.GibiByte)] * sum(cores_count)) | ||
|
||
with TestRun.step("Start caches and add cores"): | ||
caches = [ | ||
casadm.start_cache(cache_dev.partitions[i], force=True) for i in range(caches_count) | ||
] | ||
cores = [] | ||
core_num = 0 | ||
for cache_num in range(caches_count): | ||
for i in range(cores_count[cache_num]): | ||
cores.append(caches[cache_num].add_core(core_dev.partitions[core_num])) | ||
core_num += 1 | ||
|
||
with TestRun.step("Check if each CAS device has proper serial"): | ||
check_serial(cores) | ||
|
||
with TestRun.step("Create CAS init configuration"): | ||
InitConfig.create_init_config_from_running_configuration() | ||
|
||
with TestRun.step("Reboot platform"): | ||
TestRun.executor.reboot() | ||
|
||
with TestRun.step("Check if CAS devices have proper serial after reboot"): | ||
check_serial(cores) | ||
|
||
|
||
def check_serial(cores): | ||
for core in cores: | ||
serial = core.get_serial() | ||
if serial != serial_template + os.path.basename(core.path): | ||
TestRun.LOGGER.error(f"CAS device {core.path} has wrong serial: '{serial}'") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
test/functional/tests/volumes/test_many_lvms_on_many_cores_by_serial.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# | ||
# Copyright(c) 2024 Huawei Technologies Co., Ltd. | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# | ||
|
||
import datetime | ||
import pytest | ||
|
||
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, validate_configuration | ||
|
||
|
||
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand])) | ||
@pytest.mark.require_disk("core", DiskTypeLowerThan("cache")) | ||
def test_many_lvms_on_many_cores_by_serial(): | ||
""" | ||
title: Test for LVM creation on CAS devices using their serial - many lvms on many cores. | ||
description: | | ||
Validate if LVMs based on CAS devices combined into one volume group are created | ||
successfully using CAS devices serial after system reboot. | ||
pass_criteria: | ||
- CAS devices created successfully | ||
- LVMs created successfully | ||
- FIO with verification ran successfully | ||
- Configuration after reboot match configuration before | ||
""" | ||
with TestRun.step(f"Create CAS device."): | ||
cache_dev = TestRun.disks["cache"] | ||
core_dev = TestRun.disks["core"] | ||
cache_dev.create_partitions([Size(2, Unit.GibiByte)]) | ||
core_dev.create_partitions([Size(2, Unit.GibiByte)] * 4) | ||
|
||
cache = casadm.start_cache(cache_dev.partitions[0], force=True) | ||
cores = [cache.add_core(core_part) for core_part in core_dev.partitions] | ||
|
||
with TestRun.step("Configure LVM to use devices file."): | ||
LvmConfiguration.set_use_devices_file(True) | ||
|
||
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=1, | ||
lv_num=16,) | ||
|
||
lvms = Lvm.create_specific_lvm_configuration(cores, config) | ||
|
||
with TestRun.step("Run FIO with verification on LVM."): | ||
fio_run = (Fio().create_command() | ||
.read_write(ReadWrite.randrw) | ||
.io_engine(IoEngine.sync) | ||
.io_depth(1) | ||
.time_based() | ||
.run_time(datetime.timedelta(seconds=30)) | ||
.do_verify() | ||
.verify(VerifyMethod.md5) | ||
.block_size(Size(1, Unit.Blocks4096))) | ||
for lvm in lvms: | ||
fio_run.add_job().target(lvm).size(lvm.size) | ||
fio_run.run() | ||
|
||
with TestRun.step("Flush buffers"): | ||
for lvm in lvms: | ||
TestRun.executor.run_expect_success(f"hdparm -f {lvm.path}") | ||
|
||
with TestRun.step("Create init config from running configuration"): | ||
config_before_reboot, devices_before = get_test_configuration() | ||
|
||
with TestRun.step("Reboot system."): | ||
TestRun.executor.reboot() | ||
|
||
with TestRun.step("Validate running configuration"): | ||
validate_configuration(config_before_reboot, devices_before) | ||
|
||
with TestRun.step("Run FIO with verification on LVM."): | ||
fio_run.run() | ||
|
||
with TestRun.step("Remove LVMs."): | ||
Lvm.remove_all() |