commit
15c05a64c3
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright(c) 2019-2021 Intel Corporation
|
# Copyright(c) 2019-2022 Intel Corporation
|
||||||
# SPDX-License-Identifier: BSD-3-Clause
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
#
|
#
|
||||||
|
|
||||||
@ -25,6 +25,10 @@ class InitConfig:
|
|||||||
def add_core(self, cache_id, core_id, core_device: Device, extra_flags=""):
|
def add_core(self, cache_id, core_id, core_device: Device, extra_flags=""):
|
||||||
self.core_config_lines.append(CoreConfigLine(cache_id, core_id, core_device, extra_flags))
|
self.core_config_lines.append(CoreConfigLine(cache_id, core_id, core_device, extra_flags))
|
||||||
|
|
||||||
|
def remove_config_file(self):
|
||||||
|
fs_utils.remove(opencas_conf_path, force=False)
|
||||||
|
|
||||||
|
|
||||||
def save_config_file(self):
|
def save_config_file(self):
|
||||||
config_lines = []
|
config_lines = []
|
||||||
InitConfig.create_default_init_config()
|
InitConfig.create_default_init_config()
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from api.cas import casadm, casctl, casadm_parser
|
from api.cas import casadm, casctl, casadm_parser
|
||||||
from api.cas.casadm_parser import get_caches, get_cores
|
from api.cas.casadm_parser import get_caches, get_cores, get_cas_devices_dict
|
||||||
from api.cas.cache_config import CacheMode
|
from api.cas.cache_config import CacheMode
|
||||||
from api.cas.init_config import InitConfig
|
from api.cas.init_config import InitConfig
|
||||||
from core.test_run import TestRun
|
from core.test_run import TestRun
|
||||||
@ -16,6 +16,7 @@ from test_tools.disk_utils import Filesystem
|
|||||||
from test_utils import fstab
|
from test_utils import fstab
|
||||||
from test_tools.dd import Dd
|
from test_tools.dd import Dd
|
||||||
from test_utils.size import Unit, Size
|
from test_utils.size import Unit, Size
|
||||||
|
from test_utils.os_utils import sync, Udev
|
||||||
|
|
||||||
|
|
||||||
mountpoint = "/mnt"
|
mountpoint = "/mnt"
|
||||||
@ -151,7 +152,9 @@ def test_cas_init_with_changed_mode(cache_mode_pair):
|
|||||||
validate_cache(cache_mode_pair[1])
|
validate_cache(cache_mode_pair[1])
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip(reason="not implemented")
|
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand]))
|
||||||
|
@pytest.mark.require_disk("core", DiskTypeSet([DiskType.hdd]))
|
||||||
|
@pytest.mark.require_plugin("power_control")
|
||||||
def test_cas_startup_lazy():
|
def test_cas_startup_lazy():
|
||||||
"""
|
"""
|
||||||
title: Test successful boot with CAS configuration including lazy_startup
|
title: Test successful boot with CAS configuration including lazy_startup
|
||||||
@ -160,21 +163,97 @@ def test_cas_startup_lazy():
|
|||||||
pass_criteria:
|
pass_criteria:
|
||||||
- DUT boots sucesfully
|
- DUT boots sucesfully
|
||||||
- caches are configured as expected
|
- caches are configured as expected
|
||||||
steps:
|
|
||||||
- Prepare one drive for caches and one for cores
|
|
||||||
- Create 2 cache partitions and 4 core partitons
|
|
||||||
- Create opencas.conf config for 2 caches each with 2 core partition as cores
|
|
||||||
- Mark first cache as lazy_startup=True
|
|
||||||
- Mark first core of second cache as lazy_startup=True
|
|
||||||
- Run casctl init
|
|
||||||
- Run casctl stop
|
|
||||||
- Remove first cache partition
|
|
||||||
- Remove first core of second cache partition
|
|
||||||
- Reboot DUT
|
|
||||||
- Verify DUT booted successfully
|
|
||||||
- Verify CAS configured properly
|
|
||||||
"""
|
"""
|
||||||
pass
|
with TestRun.step("Prepare partitions"):
|
||||||
|
cache_disk = TestRun.disks["cache"]
|
||||||
|
core_disk = TestRun.disks["core"]
|
||||||
|
cache_disk.create_partitions([Size(200, Unit.MebiByte)] * 2)
|
||||||
|
core_disk.create_partitions([Size(200, Unit.MebiByte)] * 4)
|
||||||
|
|
||||||
|
with TestRun.step(f"Add a cache configuration with cache device with `lazy_startup` flag"):
|
||||||
|
init_conf = InitConfig()
|
||||||
|
init_conf.add_cache(1, cache_disk.partitions[0], extra_flags="lazy_startup=True")
|
||||||
|
init_conf.add_core(1, 1, core_disk.partitions[0])
|
||||||
|
init_conf.add_core(1, 2, core_disk.partitions[1])
|
||||||
|
|
||||||
|
expected_core_pool_paths = set(c.path for c in core_disk.partitions[:2])
|
||||||
|
|
||||||
|
with TestRun.step(f"Add a cache configuration with core device with `lazy_startup` flag"):
|
||||||
|
init_conf.add_cache(2, cache_disk.partitions[1])
|
||||||
|
init_conf.add_core(2, 1, core_disk.partitions[2])
|
||||||
|
init_conf.add_core(2, 2, core_disk.partitions[3], extra_flags="lazy_startup=True")
|
||||||
|
init_conf.save_config_file()
|
||||||
|
sync()
|
||||||
|
|
||||||
|
expected_caches_paths = set([cache_disk.partitions[1].path])
|
||||||
|
expected_cores_paths = set(c.path for c in core_disk.partitions[2:])
|
||||||
|
active_core_path = core_disk.partitions[2].path
|
||||||
|
inactive_core_path = core_disk.partitions[3].path
|
||||||
|
|
||||||
|
with TestRun.step(f"Start and stop all the configurations using the casctl utility"):
|
||||||
|
output = casctl.init(True)
|
||||||
|
if output.exit_code != 0:
|
||||||
|
TestRun.fail(f"Failed to initialize caches from config file. Error: {output.stdout}")
|
||||||
|
casadm.stop_all_caches()
|
||||||
|
|
||||||
|
with TestRun.step(
|
||||||
|
"Disable udev to allow manipulating partitions without CAS being automatically loaded"
|
||||||
|
):
|
||||||
|
Udev.disable()
|
||||||
|
|
||||||
|
with TestRun.step(f"Remove one cache patition and one core partition"):
|
||||||
|
cache_disk.remove_partition(cache_disk.partitions[0])
|
||||||
|
core_disk.remove_partition(core_disk.partitions[3])
|
||||||
|
|
||||||
|
with TestRun.step("Reboot DUT"):
|
||||||
|
power_control = TestRun.plugin_manager.get_plugin("power_control")
|
||||||
|
power_control.power_cycle()
|
||||||
|
|
||||||
|
with TestRun.step("Verify if all the devices are initialized properly"):
|
||||||
|
core_pool_list = get_cas_devices_dict()["core_pool"]
|
||||||
|
caches_list = get_cas_devices_dict()["caches"].values()
|
||||||
|
cores_list = get_cas_devices_dict()["cores"].values()
|
||||||
|
|
||||||
|
core_pool_paths = {c["device"] for c in core_pool_list}
|
||||||
|
if core_pool_paths != expected_core_pool_paths:
|
||||||
|
TestRun.error(
|
||||||
|
f"Expected the following devices in core pool "
|
||||||
|
f"{expected_core_pool_paths}. Got {core_pool_paths}"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
TestRun.LOGGER.info("Core pool is ok")
|
||||||
|
|
||||||
|
caches_paths = {c["device"] for c in caches_list}
|
||||||
|
if caches_paths != expected_caches_paths:
|
||||||
|
TestRun.error(
|
||||||
|
f"Expected the following devices as caches "
|
||||||
|
f"{expected_caches_paths}. Got {caches_paths}"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
TestRun.LOGGER.info("Caches are ok")
|
||||||
|
|
||||||
|
cores_paths = {c["device"] for c in cores_list}
|
||||||
|
if cores_paths != expected_cores_paths:
|
||||||
|
TestRun.error(
|
||||||
|
f"Expected the following devices as cores "
|
||||||
|
f"{expected_caches_paths}. Got {cores_paths}"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
TestRun.LOGGER.info("Core devices are ok")
|
||||||
|
|
||||||
|
cores_paths = {c["device"] for c in cores_list}
|
||||||
|
cores_states = {c["device"]: c["status"] for c in cores_list}
|
||||||
|
if cores_states[active_core_path] != "Active":
|
||||||
|
TestRun.LOGGER.error(
|
||||||
|
f"Core {active_core_path} should be Active "
|
||||||
|
f"but is {cores_states[active_core_path]} instead!"
|
||||||
|
)
|
||||||
|
|
||||||
|
if cores_states[inactive_core_path] != "Inactive":
|
||||||
|
TestRun.LOGGER.error(
|
||||||
|
f"Core {inactive_core_path} should be Inactive "
|
||||||
|
f"but is {cores_states[inactive_core_path]} instead!"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip(reason="not implemented")
|
@pytest.mark.skip(reason="not implemented")
|
||||||
@ -221,7 +300,9 @@ def test_cas_startup_negative_missing_cache():
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip(reason="not implemented")
|
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand]))
|
||||||
|
@pytest.mark.require_disk("core", DiskTypeSet([DiskType.hdd]))
|
||||||
|
@pytest.mark.require_plugin("power_control")
|
||||||
def test_failover_config_startup():
|
def test_failover_config_startup():
|
||||||
"""
|
"""
|
||||||
title: Test successful boot with failover-specific configuration options
|
title: Test successful boot with failover-specific configuration options
|
||||||
@ -231,16 +312,96 @@ def test_failover_config_startup():
|
|||||||
pass_criteria:
|
pass_criteria:
|
||||||
- DUT boots sucesfully
|
- DUT boots sucesfully
|
||||||
- caches are configured as expected
|
- caches are configured as expected
|
||||||
steps:
|
|
||||||
- Prepare two drives for cache and one for core
|
|
||||||
- Create opencas.conf config for two caches: one target_failover_state=active with core
|
|
||||||
and one target_failover_state=standby
|
|
||||||
- Initialize configuration
|
|
||||||
- Reboot DUT
|
|
||||||
- Wait for successful boot
|
|
||||||
- Verify caches state
|
|
||||||
"""
|
"""
|
||||||
pass
|
with TestRun.step("Prepare partitions"):
|
||||||
|
cache_disk = TestRun.disks["cache"]
|
||||||
|
core_disk = TestRun.disks["core"]
|
||||||
|
cache_disk.create_partitions([Size(200, Unit.MebiByte)] * 2)
|
||||||
|
core_disk.create_partitions([Size(200, Unit.MebiByte)])
|
||||||
|
|
||||||
|
with TestRun.step(
|
||||||
|
f"Add a cache configuration with cache device with "
|
||||||
|
"`target_failover_state=active` flag and a core"
|
||||||
|
):
|
||||||
|
init_conf = InitConfig()
|
||||||
|
init_conf.add_cache(
|
||||||
|
1, cache_disk.partitions[0], extra_flags="target_failover_state=active"
|
||||||
|
)
|
||||||
|
init_conf.add_core(1, 1, core_disk.partitions[0])
|
||||||
|
active_cache_path = cache_disk.partitions[0].path
|
||||||
|
active_core_path = core_disk.partitions[0].path
|
||||||
|
|
||||||
|
with TestRun.step(
|
||||||
|
f"Add a cache configuration with cache device with "
|
||||||
|
"`target_failover_state=failover` flag"
|
||||||
|
):
|
||||||
|
init_conf.add_cache(
|
||||||
|
2,
|
||||||
|
cache_disk.partitions[1],
|
||||||
|
extra_flags="target_failover_state=standby,cache_line_size=4",
|
||||||
|
)
|
||||||
|
standby_cache_path = cache_disk.partitions[1].path
|
||||||
|
init_conf.save_config_file()
|
||||||
|
sync()
|
||||||
|
|
||||||
|
with TestRun.step(f"Start and stop all the configurations using the casctl utility"):
|
||||||
|
output = casctl.init(True)
|
||||||
|
if output.exit_code != 0:
|
||||||
|
TestRun.fail(f"Failed to initialize caches from config file. Error: {output.stdout}")
|
||||||
|
casadm.stop_all_caches()
|
||||||
|
|
||||||
|
with TestRun.step("Reboot DUT"):
|
||||||
|
power_control = TestRun.plugin_manager.get_plugin("power_control")
|
||||||
|
power_control.power_cycle()
|
||||||
|
|
||||||
|
with TestRun.step("Verify if all the devices are initialized properly"):
|
||||||
|
core_pool_list = get_cas_devices_dict()["core_pool"]
|
||||||
|
caches_list = get_cas_devices_dict()["caches"].values()
|
||||||
|
cores_list = get_cas_devices_dict()["cores"].values()
|
||||||
|
|
||||||
|
if len(core_pool_list) != 0:
|
||||||
|
TestRun.error(f"No cores expected in core pool. Got {core_pool_list}")
|
||||||
|
else:
|
||||||
|
TestRun.LOGGER.info("Core pool is ok")
|
||||||
|
|
||||||
|
expected_caches_paths = set([active_cache_path, standby_cache_path])
|
||||||
|
caches_paths = {c["device"] for c in caches_list}
|
||||||
|
if caches_paths != expected_caches_paths:
|
||||||
|
TestRun.error(
|
||||||
|
f"Expected the following devices as caches "
|
||||||
|
f"{expected_caches_paths}. Got {caches_paths}"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
TestRun.LOGGER.info("Caches are ok")
|
||||||
|
|
||||||
|
expected_core_paths = set([active_core_path])
|
||||||
|
cores_paths = {c["device"] for c in cores_list}
|
||||||
|
if cores_paths != expected_core_paths:
|
||||||
|
TestRun.error(
|
||||||
|
f"Expected the following devices as cores "
|
||||||
|
f"{expected_core_paths}. Got {cores_paths}"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
TestRun.LOGGER.info("Core devices are ok")
|
||||||
|
|
||||||
|
cores_states = {c["device"]: c["status"] for c in cores_list}
|
||||||
|
if cores_states[active_core_path] != "Active":
|
||||||
|
TestRun.LOGGER.error(
|
||||||
|
f"Core {active_core_path} should be Active "
|
||||||
|
f"but is {cores_states[active_core_path]} instead!"
|
||||||
|
)
|
||||||
|
|
||||||
|
caches_states = {c["device"]: c["status"] for c in caches_list}
|
||||||
|
if caches_states[active_cache_path] != "Running":
|
||||||
|
TestRun.LOGGER.error(
|
||||||
|
f"Cache {active_cache_path} should be Running "
|
||||||
|
f"but is {caches_states[active_cache_path]} instead!"
|
||||||
|
)
|
||||||
|
if caches_states[standby_cache_path] != "Standby":
|
||||||
|
TestRun.LOGGER.error(
|
||||||
|
f"Cache {standby_cache_path} should be Standby "
|
||||||
|
f"but is {caches_states[standby_cache_path]} instead!"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip(reason="not implemented")
|
@pytest.mark.skip(reason="not implemented")
|
||||||
|
Loading…
Reference in New Issue
Block a user