Test for activating the same cache path

Signed-off-by: Pawel Skwarlo <pawel.skwarlo@intel.com>
This commit is contained in:
pskwarlo 2022-06-13 14:01:36 +02:00 committed by Pawel Skwarlo
parent 685b68516a
commit 3ff56e77de

View File

@ -0,0 +1,49 @@
#
# Copyright(c) 2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
import pytest
from api.cas import casadm
from api.cas.casadm_parser import get_caches
from core.test_run import TestRun
from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan
from test_utils.size import Size, Unit
from api.cas.cache_config import CacheStatus
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.nand, DiskType.optane]))
@pytest.mark.require_disk("core", DiskTypeLowerThan("cache"))
def test_standby_activate_the_same_cache_path():
"""
title: Activate the same cache path
description: |
Test for loading and activating standby cache from existing metadata.
pass_criteria:
- Successfully prepare a partition and create cache instance partition, then stop it.
- Standby cache loaded on the partition with valid CAS metadata.
- Successfully detach standby cache.
- Activate cache by path.
"""
with TestRun.step("Prepare a partition."):
cache = TestRun.disks["cache"]
cache.create_partitions([Size(200, Unit.MebiByte)])
cache_dev = cache.partitions[0]
with TestRun.step("Start a regular cache instance on the partition and stop it."):
cache = casadm.start_cache(cache_dev, force=True)
cache.stop()
with TestRun.step("Load standby cache on the partition with valid CAS metadata."):
cache = casadm.standby_load(cache_dev)
with TestRun.step("Detach standby cache"):
cache.standby_detach()
with TestRun.step("Activate cache providing path to the partition."):
cache.standby_activate(device=cache_dev)
caches = get_caches()
cache_status = caches[0].get_status()
if cache_status != CacheStatus.running:
TestRun.LOGGER.error("Failed to activate cache with provided path.")