-
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.
Fuzzy tests for casadm 'print statistics' command
Signed-off-by: Katarzyna Treder <katarzyna.treder@h-partners.com>
- Loading branch information
Katarzyna Treder
committed
Sep 2, 2024
1 parent
8cc21d1
commit 4187cb3
Showing
25 changed files
with
1,403 additions
and
745 deletions.
There are no files selected for viewing
96 changes: 96 additions & 0 deletions
96
...y/fuzzy/kernel/fuzzy_with_io/fuzzy_statistics/test_fuzzy_print_statistics_cache_filter.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,96 @@ | ||
# | ||
# Copyright(c) 2022 Intel Corporation | ||
# Copyright(c) 2024 Huawei Technologies Co., Ltd. | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# | ||
|
||
import pytest | ||
|
||
from api.cas import casadm | ||
from api.cas.cache_config import ( | ||
CacheMode, | ||
CacheLineSize, | ||
CleaningPolicy, | ||
UnalignedIo, | ||
KernelParameters, | ||
UseIoScheduler, | ||
) | ||
from api.cas.casadm_params import StatsFilter | ||
from api.cas.cli import print_statistics_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 ( | ||
get_fuzz_config, | ||
prepare_cas_instance, | ||
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_print_statistics_cache_filter( | ||
cache_mode, cache_line_size, cleaning_policy, unaligned_io, use_io_scheduler | ||
): | ||
""" | ||
title: Fuzzy test for casadm 'print statistics' command for cache - filter | ||
description: | | ||
Using Peach Fuzzer check Open CAS ability of handling wrong filter for cache in casadm | ||
'print statistics' 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, | ||
) | ||
casadm.load_io_classes(cache_id=cache.cache_id, file="/etc/opencas/ioclass-config.csv") | ||
|
||
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") for e in list(StatsFilter)] | ||
PeachFuzzer.generate_config(get_fuzz_config("filter.yml")) | ||
base_cmd = print_statistics_cmd( | ||
cache_id=str(core.cache_id), filter="{param}", by_id_path=False | ||
) | ||
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="Filter", | ||
is_valid=cmd.param in valid_values, | ||
) |
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
99 changes: 99 additions & 0 deletions
99
...ernel/fuzzy_with_io/fuzzy_statistics/test_fuzzy_print_statistics_cache_io_class_filter.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,99 @@ | ||
# | ||
# Copyright(c) 2022 Intel Corporation | ||
# Copyright(c) 2024 Huawei Technologies Co., Ltd. | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# | ||
|
||
import pytest | ||
|
||
from api.cas import casadm | ||
from api.cas.cache_config import ( | ||
CacheMode, | ||
CacheLineSize, | ||
CleaningPolicy, | ||
UnalignedIo, | ||
KernelParameters, | ||
UseIoScheduler, | ||
) | ||
from api.cas.casadm_params import StatsFilter | ||
from api.cas.cli import print_statistics_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 ( | ||
get_fuzz_config, | ||
prepare_cas_instance, | ||
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_print_statistics_cache_io_class_filter( | ||
cache_mode, cache_line_size, cleaning_policy, unaligned_io, use_io_scheduler | ||
): | ||
""" | ||
title: Fuzzy test for casadm 'print statistics' command for cache IO class - filter | ||
description: | | ||
Using Peach Fuzzer check Open CAS ability of handling wrong filter for cache IO class | ||
in casadm 'print statistics' 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, | ||
) | ||
casadm.load_io_classes(cache_id=cache.cache_id, file="/etc/opencas/ioclass-config.csv") | ||
|
||
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") for e in list(StatsFilter)] | ||
PeachFuzzer.generate_config(get_fuzz_config("filter.yml")) | ||
base_cmd = print_statistics_cmd( | ||
cache_id=str(core.cache_id), | ||
io_class_id="0", | ||
filter="{param}", | ||
by_id_path=False, | ||
) | ||
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="Filter", | ||
is_valid=cmd.param in valid_values, | ||
) |
Oops, something went wrong.