Add fault injection tests (same ID, remove IO)

Signed-off-by: Rafal Stefanowski <rafal.stefanowski@intel.com>
This commit is contained in:
Rafal Stefanowski 2019-11-28 18:33:30 +01:00
parent 18c77daec9
commit f68d34b3ad
2 changed files with 195 additions and 0 deletions

View File

@ -0,0 +1,89 @@
#
# Copyright(c) 2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
import time
import pytest
from api.cas import cli, casadm
from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan
from core.test_run import TestRun
from test_utils.size import Size, Unit
@pytest.mark.require_disk("cache_1", DiskTypeSet([DiskType.optane, DiskType.nand]))
@pytest.mark.require_disk("cache_2", DiskTypeSet([DiskType.optane, DiskType.nand]))
def test_another_cache_with_same_id():
"""
title: Test for creating another cache device with the same ID.
description: |
Checking if adding another cache device and setting
the same cache ID as the previous one fails.
pass_criteria:
- No additional cache device added.
"""
with TestRun.step("Start cache with ID = 1"):
cache_dev_1 = TestRun.disks["cache_1"]
cache_dev_1.create_partitions([Size(2, Unit.GibiByte)])
TestRun.executor.run_expect_success(
cli.start_cmd(
cache_dev_1.partitions[0].system_path, cache_id="1", force=True
)
)
with TestRun.step("Try to start another cache with the same ID = 1"):
cache_dev_2 = TestRun.disks["cache_2"]
cache_dev_2.create_partitions([Size(2, Unit.GibiByte)])
TestRun.executor.run_expect_fail(
cli.start_cmd(
cache_dev_2.partitions[0].system_path, cache_id="1", force=True
)
)
with TestRun.step("Stop all caches"):
casadm.stop_all_caches()
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand]))
@pytest.mark.require_disk("core_1", DiskTypeLowerThan("cache"))
@pytest.mark.require_disk("core_2", DiskTypeLowerThan("cache"))
def test_another_core_with_same_id():
"""
title: Test for creating another core device with the same ID.
description: |
Checking if adding another core device and setting
the same core ID as the previous one fails.
pass_criteria:
- No additional core device added.
"""
with TestRun.step("Start cache device"):
cache_dev = TestRun.disks["cache"]
cache_dev.create_partitions([Size(2, Unit.GibiByte)])
cache = casadm.start_cache(cache_dev.partitions[0], force=True)
with TestRun.step("Add core with ID = 1"):
core_dev_1 = TestRun.disks["core_1"]
core_dev_1.create_partitions([Size(1, Unit.GibiByte)])
TestRun.executor.run_expect_success(
cli.add_core_cmd(
cache_id=f"{cache.cache_id}",
core_dev=f"{core_dev_1.partitions[0].system_path}",
core_id="1",
)
)
with TestRun.step("Try to add another core with the same ID = 1"):
core_dev_2 = TestRun.disks["core_2"]
core_dev_2.create_partitions([Size(1, Unit.GibiByte)])
TestRun.executor.run_expect_fail(
cli.add_core_cmd(
cache_id=f"{cache.cache_id}",
core_dev=f"{core_dev_2.partitions[0].system_path}",
core_id="1",
)
)
with TestRun.step("Stop all caches"):
casadm.stop_all_caches()

View File

@ -0,0 +1,106 @@
#
# Copyright(c) 2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
import time
import pytest
from datetime import timedelta
from api.cas import cli, casadm
from test_tools.fio.fio import Fio
from test_tools.fio.fio_param import ReadWrite, IoEngine
from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan
from core.test_run import TestRun
from test_utils.size import Size, Unit
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand]))
@pytest.mark.require_disk("core", DiskTypeLowerThan("cache"))
def test_remove_core_during_io():
"""
title: Test for removing core device during IO.
description: |
Creating CAS device, running fio on it and checking
if core can be removed during IO operations.
pass_criteria:
- Core device is not removed.
"""
with TestRun.step("Start cache and add core"):
cache, core = prepare()
with TestRun.step("Running 'fio'"):
fio = (
Fio()
.create_command()
.io_engine(IoEngine.libaio)
.block_size(Size(4, Unit.KibiByte))
.read_write(ReadWrite.randrw)
.target(f"{core.system_path}")
.direct(1)
.run_time(timedelta(minutes=4))
.time_based()
)
fio_pid = fio.run_in_background()
time.sleep(10)
with TestRun.step("Try to remove core during 'fio'"):
TestRun.executor.run_expect_fail(
cli.remove_core_cmd(f"{core.cache_id}", f"{core.core_id}")
)
with TestRun.step("Stopping 'fio'"):
TestRun.executor.kill_process(fio_pid)
with TestRun.step("Stop all caches"):
casadm.stop_all_caches()
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand]))
@pytest.mark.require_disk("core", DiskTypeLowerThan("cache"))
def test_stop_cache_during_io():
"""
title: Test for stopping cache during IO.
description: |
Creating CAS device, running fio on it and checking
if cache can be stopped during IO operations.
pass_criteria:
- Cache is not stopped.
"""
with TestRun.step("Start cache and add core"):
cache, core = prepare()
with TestRun.step("Running 'fio'"):
fio = (
Fio()
.create_command()
.io_engine(IoEngine.libaio)
.block_size(Size(4, Unit.KibiByte))
.read_write(ReadWrite.randrw)
.target(f"{core.system_path}")
.direct(1)
.run_time(timedelta(minutes=4))
.time_based()
)
fio_pid = fio.run_in_background()
time.sleep(10)
with TestRun.step("Try to stop cache during 'fio'"):
TestRun.executor.run_expect_fail(cli.stop_cmd(f"{cache.cache_id}"))
with TestRun.step("Stopping 'fio'"):
TestRun.executor.kill_process(fio_pid)
with TestRun.step("Stop all caches"):
casadm.stop_all_caches()
def prepare():
cache_dev = TestRun.disks["cache"]
cache_dev.create_partitions([Size(2, Unit.GibiByte)])
core_dev = TestRun.disks["core"]
core_dev.create_partitions([Size(1, Unit.GibiByte)])
cache = casadm.start_cache(cache_dev.partitions[0], force=True)
core = cache.add_core(core_dev.partitions[0])
return cache, core