Fuzzy tests for casadm 'set cache mode' command
Signed-off-by: Katarzyna Treder <katarzyna.treder@h-partners.com>
This commit is contained in:
parent
aeb0321393
commit
7f843fd6bf
@ -0,0 +1,5 @@
|
||||
#
|
||||
# Copyright(c) 2022 Intel Corporation
|
||||
# Copyright(c) 2024 Huawei Technologies
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
@ -0,0 +1,100 @@
|
||||
#
|
||||
# Copyright(c) 2022 Intel Corporation
|
||||
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
import itertools
|
||||
import pytest
|
||||
|
||||
from api.cas.cache_config import (
|
||||
CacheMode,
|
||||
CacheLineSize,
|
||||
CleaningPolicy,
|
||||
UnalignedIo,
|
||||
KernelParameters,
|
||||
UseIoScheduler,
|
||||
)
|
||||
from api.cas.cli import set_cache_mode_cmd
|
||||
from core.test_run import TestRun
|
||||
from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan
|
||||
from test_tools.peach_fuzzer.peach_fuzzer import PeachFuzzer
|
||||
from tests.security.fuzzy.kernel.common.common import (
|
||||
prepare_cas_instance,
|
||||
get_fuzz_config,
|
||||
run_cmd_and_validate,
|
||||
)
|
||||
from tests.security.fuzzy.kernel.fuzzy_with_io.common.common import (
|
||||
get_basic_workload,
|
||||
mount_point,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand]))
|
||||
@pytest.mark.require_disk("core", DiskTypeLowerThan("cache"))
|
||||
@pytest.mark.parametrizex("cache_mode", CacheMode)
|
||||
@pytest.mark.parametrizex("cache_line_size", CacheLineSize)
|
||||
@pytest.mark.parametrizex("cleaning_policy", CleaningPolicy)
|
||||
@pytest.mark.parametrizex("unaligned_io", UnalignedIo)
|
||||
@pytest.mark.parametrizex("use_io_scheduler", UseIoScheduler)
|
||||
def test_fuzzy_cache_mode_cache_id(
|
||||
cache_mode, cache_line_size, cleaning_policy, unaligned_io, use_io_scheduler
|
||||
):
|
||||
"""
|
||||
title: Fuzzy test for casadm 'set cache mode' command - cache id.
|
||||
description: |
|
||||
Using Peach Fuzzer check Open CAS ability of handling wrong cache id in
|
||||
'set cache mode' command.
|
||||
pass_criteria:
|
||||
- System did not crash
|
||||
- Open CAS still works.
|
||||
"""
|
||||
with TestRun.step(
|
||||
"Start cache with configuration and add core device, make filesystem and mount it"
|
||||
):
|
||||
cache_disk = TestRun.disks["cache"]
|
||||
core_disk = TestRun.disks["core"]
|
||||
cache, core = prepare_cas_instance(
|
||||
cache_device=cache_disk,
|
||||
core_device=core_disk,
|
||||
cache_mode=cache_mode,
|
||||
cache_line_size=cache_line_size,
|
||||
kernel_params=KernelParameters(unaligned_io, use_io_scheduler),
|
||||
cleaning_policy=cleaning_policy,
|
||||
mount_point=mount_point,
|
||||
)
|
||||
|
||||
with TestRun.step("Run fio in background"):
|
||||
fio = get_basic_workload(mount_point)
|
||||
fio_pid = fio.run_in_background()
|
||||
if not TestRun.executor.check_if_process_exists(fio_pid):
|
||||
raise Exception("Fio is not running.")
|
||||
|
||||
with TestRun.step("Prepare PeachFuzzer"):
|
||||
valid_values = [str(cache.cache_id).encode("ascii")]
|
||||
PeachFuzzer.generate_config(get_fuzz_config("cache_id.yml"))
|
||||
generators = []
|
||||
modes = [e.name.lower() for e in list(CacheMode)]
|
||||
for mode in modes:
|
||||
base_cmd = set_cache_mode_cmd(
|
||||
cache_mode=mode, cache_id="{param}", flush_cache="no"
|
||||
)
|
||||
generator = PeachFuzzer.get_fuzzed_command(
|
||||
command_template=base_cmd,
|
||||
count=int(TestRun.usr.fuzzy_iter_count / len(modes)),
|
||||
)
|
||||
generators.append(generator)
|
||||
commands = itertools.chain(*generators)
|
||||
|
||||
for index, cmd in TestRun.iteration(
|
||||
enumerate(commands), f"Run command {TestRun.usr.fuzzy_iter_count} times"
|
||||
):
|
||||
with TestRun.step(f"Iteration {index + 1}"):
|
||||
if not TestRun.executor.check_if_process_exists(fio_pid):
|
||||
raise Exception("Fio is not running.")
|
||||
|
||||
run_cmd_and_validate(
|
||||
cmd=cmd,
|
||||
value_name="Cache id",
|
||||
is_valid=cmd.param in valid_values,
|
||||
)
|
@ -0,0 +1,91 @@
|
||||
#
|
||||
# Copyright(c) 2022 Intel Corporation
|
||||
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
import pytest
|
||||
|
||||
from api.cas.cache_config import (
|
||||
CacheMode,
|
||||
CacheLineSize,
|
||||
CleaningPolicy,
|
||||
UnalignedIo,
|
||||
KernelParameters,
|
||||
UseIoScheduler,
|
||||
)
|
||||
from api.cas.cli import set_cache_mode_cmd
|
||||
from core.test_run import TestRun
|
||||
from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan
|
||||
from test_tools.peach_fuzzer.peach_fuzzer import PeachFuzzer
|
||||
from tests.security.fuzzy.kernel.common.common import (
|
||||
prepare_cas_instance,
|
||||
get_fuzz_config,
|
||||
run_cmd_and_validate,
|
||||
)
|
||||
from tests.security.fuzzy.kernel.fuzzy_with_io.common.common import (
|
||||
get_basic_workload,
|
||||
mount_point,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand]))
|
||||
@pytest.mark.require_disk("core", DiskTypeLowerThan("cache"))
|
||||
@pytest.mark.parametrizex("cache_mode", CacheMode)
|
||||
@pytest.mark.parametrizex("cache_line_size", CacheLineSize)
|
||||
@pytest.mark.parametrizex("cleaning_policy", CleaningPolicy)
|
||||
@pytest.mark.parametrizex("unaligned_io", UnalignedIo)
|
||||
@pytest.mark.parametrizex("use_io_scheduler", UseIoScheduler)
|
||||
def test_fuzzy_cache_mode_cache_mode(
|
||||
cache_mode, cache_line_size, cleaning_policy, unaligned_io, use_io_scheduler
|
||||
):
|
||||
"""
|
||||
title: Fuzzy test for casadm 'set cache mode' command - cache mode.
|
||||
description: |
|
||||
Using Peach Fuzzer check Open CAS ability of handling wrong cache mode in
|
||||
'set cache mode' command.
|
||||
pass_criteria:
|
||||
- System did not crash
|
||||
- Open CAS still works.
|
||||
"""
|
||||
with TestRun.step(
|
||||
"Start cache with configuration and add core device, make filesystem and mount it"
|
||||
):
|
||||
cache_disk = TestRun.disks["cache"]
|
||||
core_disk = TestRun.disks["core"]
|
||||
cache, core = prepare_cas_instance(
|
||||
cache_device=cache_disk,
|
||||
core_device=core_disk,
|
||||
cache_mode=cache_mode,
|
||||
cache_line_size=cache_line_size,
|
||||
kernel_params=KernelParameters(unaligned_io, use_io_scheduler),
|
||||
cleaning_policy=cleaning_policy,
|
||||
mount_point=mount_point,
|
||||
)
|
||||
|
||||
with TestRun.step("Run fio in background"):
|
||||
fio = get_basic_workload(mount_point)
|
||||
fio_pid = fio.run_in_background()
|
||||
if not TestRun.executor.check_if_process_exists(fio_pid):
|
||||
raise Exception("Fio is not running.")
|
||||
|
||||
with TestRun.step("Prepare PeachFuzzer"):
|
||||
valid_values = [e.name.encode("ascii").lower() for e in list(CacheMode)]
|
||||
PeachFuzzer.generate_config(get_fuzz_config("cache_mode.yml"))
|
||||
base_cmd = set_cache_mode_cmd(cache_mode="{param}", cache_id=str(cache.cache_id), flush_cache="no")
|
||||
commands = PeachFuzzer.get_fuzzed_command(
|
||||
command_template=base_cmd, count=TestRun.usr.fuzzy_iter_count
|
||||
)
|
||||
|
||||
for index, cmd in TestRun.iteration(
|
||||
enumerate(commands), f"Run command {TestRun.usr.fuzzy_iter_count} times"
|
||||
):
|
||||
with TestRun.step(f"Iteration {index + 1}"):
|
||||
if not TestRun.executor.check_if_process_exists(fio_pid):
|
||||
raise Exception("Fio is not running.")
|
||||
|
||||
run_cmd_and_validate(
|
||||
cmd=cmd,
|
||||
value_name="Cache mode",
|
||||
is_valid=cmd.param in valid_values,
|
||||
)
|
@ -0,0 +1,98 @@
|
||||
#
|
||||
# Copyright(c) 2022 Intel Corporation
|
||||
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
import itertools
|
||||
import pytest
|
||||
|
||||
from api.cas.cache_config import (
|
||||
CacheMode,
|
||||
CacheLineSize,
|
||||
CleaningPolicy,
|
||||
UnalignedIo,
|
||||
KernelParameters,
|
||||
UseIoScheduler,
|
||||
)
|
||||
from api.cas.cli import set_cache_mode_cmd
|
||||
from core.test_run import TestRun
|
||||
from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan
|
||||
from test_tools.peach_fuzzer.peach_fuzzer import PeachFuzzer
|
||||
from tests.security.fuzzy.kernel.common.common import (
|
||||
prepare_cas_instance,
|
||||
get_fuzz_config,
|
||||
run_cmd_and_validate,
|
||||
)
|
||||
from tests.security.fuzzy.kernel.fuzzy_with_io.common.common import (
|
||||
get_basic_workload,
|
||||
mount_point,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand]))
|
||||
@pytest.mark.require_disk("core", DiskTypeLowerThan("cache"))
|
||||
@pytest.mark.parametrizex("cache_mode", CacheMode)
|
||||
@pytest.mark.parametrizex("cache_line_size", CacheLineSize)
|
||||
@pytest.mark.parametrizex("cleaning_policy", CleaningPolicy)
|
||||
@pytest.mark.parametrizex("unaligned_io", UnalignedIo)
|
||||
@pytest.mark.parametrizex("use_io_scheduler", UseIoScheduler)
|
||||
def test_fuzzy_cache_mode_flush_cache(
|
||||
cache_mode, cache_line_size, cleaning_policy, unaligned_io, use_io_scheduler
|
||||
):
|
||||
"""
|
||||
title: Fuzzy test for casadm 'set cache mode' command - flush cache.
|
||||
description: |
|
||||
Using Peach Fuzzer check Open CAS ability of handling wrong flush cache option
|
||||
in 'set cache mode' command.
|
||||
pass_criteria:
|
||||
- System did not crash
|
||||
- Open CAS still works.
|
||||
"""
|
||||
with TestRun.step(
|
||||
"Start cache with configuration and add core device, make filesystem and mount it"
|
||||
):
|
||||
cache_disk = TestRun.disks["cache"]
|
||||
core_disk = TestRun.disks["core"]
|
||||
cache, core = prepare_cas_instance(
|
||||
cache_device=cache_disk,
|
||||
core_device=core_disk,
|
||||
cache_mode=cache_mode,
|
||||
cache_line_size=cache_line_size,
|
||||
kernel_params=KernelParameters(unaligned_io, use_io_scheduler),
|
||||
cleaning_policy=cleaning_policy,
|
||||
mount_point=mount_point,
|
||||
)
|
||||
|
||||
with TestRun.step("Run fio in background"):
|
||||
fio = get_basic_workload(mount_point)
|
||||
fio_pid = fio.run_in_background()
|
||||
if not TestRun.executor.check_if_process_exists(fio_pid):
|
||||
raise Exception("Fio is not running.")
|
||||
|
||||
with TestRun.step("Prepare PeachFuzzer"):
|
||||
valid_values = [b"yes", b"no"]
|
||||
PeachFuzzer.generate_config(get_fuzz_config("yes_no.yml"))
|
||||
generators = []
|
||||
modes = [e.name.lower() for e in list(CacheMode)]
|
||||
for mode in modes:
|
||||
base_cmd = set_cache_mode_cmd(cache_mode=mode, cache_id=str(cache.cache_id), flush_cache="{param}")
|
||||
generator = PeachFuzzer.get_fuzzed_command(
|
||||
command_template=base_cmd,
|
||||
count=int(TestRun.usr.fuzzy_iter_count / len(modes)),
|
||||
)
|
||||
generators.append(generator)
|
||||
commands = itertools.chain(*generators)
|
||||
|
||||
for index, cmd in TestRun.iteration(
|
||||
enumerate(commands), f"Run command {TestRun.usr.fuzzy_iter_count} times"
|
||||
):
|
||||
with TestRun.step(f"Iteration {index + 1}"):
|
||||
if not TestRun.executor.check_if_process_exists(fio_pid):
|
||||
raise Exception("Fio is not running.")
|
||||
|
||||
run_cmd_and_validate(
|
||||
cmd=cmd,
|
||||
value_name="Flush cache",
|
||||
is_valid=cmd.param in valid_values,
|
||||
)
|
Loading…
Reference in New Issue
Block a user