import random import time import pytest from api.cas import casadm, casadm_parser from api.cas.core import CoreStatus, CacheMode, CacheStatus from api.cas.init_config import InitConfig from core.test_run import TestRun from storage_devices.disk import DiskTypeSet, DiskTypeLowerThan, DiskType from storage_devices.raid import RaidConfiguration, Raid, Level, MetadataVariant from test_utils.size import Size, Unit @pytest.mark.os_dependent @pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand])) @pytest.mark.require_disk("core", DiskTypeLowerThan("cache")) def test_udev_core_partition(): """ title: | CAS udev rule execution after re-attaching partitions existing in configuration file as cores. description: | Verify if CAS udev rule is executed when partitions existing in CAS configuration file as cores are being attached. pass_criteria: - No kernel error - Created partitions are added to core pool after attaching core drive. """ cores_count = 4
from api.cas import casadm, casadm_parser, cli, cli_messages from api.cas.cache_config import CacheMode from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan from core.test_run import TestRun from test_tools import fs_utils from test_tools.disk_utils import Filesystem from test_utils.size import Size, Unit mount_point = "/mnt/cas" test_file_path = f"{mount_point}/test_file" @pytest.mark.parametrize("cache_mode", CacheMode) @pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand])) @pytest.mark.require_disk("core", DiskTypeLowerThan("cache")) def test_load_cache_with_mounted_core(cache_mode): """ title: Fault injection test for adding mounted core on cache load. description: | Negative test of the ability of CAS to add to cache while its loading core device which is mounted. pass_criteria: - No system crash while loading cache. - Adding mounted core while loading cache fails. """ with TestRun.step("Prepare cache and core devices. Start CAS."): cache_dev = TestRun.disks['cache'] cache_dev.create_partitions([Size(1, Unit.GibiByte)]) cache_part = cache_dev.partitions[0]
# SPDX-License-Identifier: BSD-3-Clause # import os from datetime import timedelta import pytest from api.cas import casadm from api.cas.cache_config import CacheMode, CacheLineSize from core.test_run import TestRun from storage_devices.disk import DiskTypeSet, DiskType from test_tools.disk_utils import Filesystem from test_utils.size import Size, Unit @pytest.mark.require_disk("cache", DiskTypeSet( [DiskType.optane, DiskType.nand, DiskType.sata])) @pytest.mark.require_disk("core", DiskTypeSet( [DiskType.optane, DiskType.nand, DiskType.sata])) @pytest.mark.parametrizex("cache_mode", CacheMode) @pytest.mark.parametrizex("cache_line_size", CacheLineSize) @pytest.mark.require_plugin("vdbench") def test_trim_stress(cache_mode, cache_line_size): """ title: Trim support on cache devices in different cache modes stress test. description: | Stress test validating the ability of CAS to handle trim requests in different modes, on different filesystem types. pass_criteria: - No kernel bug. - Cache should still work correctly.
# # Copyright(c) 2020-2021 Intel Corporation # SPDX-License-Identifier: BSD-3-Clause # import pytest from core.test_run import TestRun from storage_devices.disk import DiskType, DiskTypeSet @pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand])) @pytest.mark.require_plugin("power_control") def test_create_example_partitions(): """ title: Example test doing power cycle description: | Example usage of power_control plugin. NOTE: This test uses plugin that is not included in test-framework. It should be provided by user as external_plugin. pass_criteria: - DUT should reboot successfully. """ with TestRun.step("Power cycle DUT"): power_control = TestRun.plugin_manager.get_plugin('power_control') power_control.power_cycle()
import pytest import re from api.cas import casadm from api.cas.cache_config import CacheMode, CacheModeTrait, CleaningPolicy from core.test_run import TestRun from test_tools import fs_utils from test_tools.disk_utils import Filesystem from test_utils import os_utils from test_utils.size import Size, Unit from test_tools.fio.fio import Fio from test_tools.blktrace import BlkTrace, BlkTraceMask, RwbsKind from test_tools.fio.fio_param import ReadWrite, IoEngine from storage_devices.disk import DiskType, DiskTypeSet @pytest.mark.require_disk("cache", DiskTypeSet([DiskType.nand])) def test_trim_start_discard(): """ title: Check discarding cache device at cache start description: | Create 2 partitions on trim-supporting device, write pattern to both partitions, start blktrace against first one, start cache on first partition and check if discard requests were sent at all and only to the first partition. pass_criteria: - Partition used for cache is discarded. - Second partition is untouched - written pattern is preserved. """ with TestRun.step("Clearing dmesg"): TestRun.executor.run_expect_success("dmesg -C") with TestRun.step("Preparing cache device"):
from test_tools.fs_utils import create_random_test_file from test_utils import os_utils from test_utils.size import Size, Unit mount_point = "/mnt/cas" syslog_path = "/var/log/messages" @pytest.mark.os_dependent @pytest.mark.require_plugin("scsi_debug_fua_signals", dev_size_mb="4096", opts="1") @pytest.mark.parametrizex("cache_mode", CacheMode.with_traits(CacheModeTrait.LazyWrites)) @pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand])) def test_flush_signal_core(cache_mode): """ title: Test for FLUSH nad FUA signals sent to core device in modes with lazy writes. description: | Test if OpenCAS transmits FLUSH and FUA signals to core device in modes with lazy writes. pass_criteria: - FLUSH requests should be passed to core device. - FUA requests should be passed to core device. """ with TestRun.step( "Set mark in syslog to not read entries existing before the test." ): Logs._read_syslog(Logs.last_read_line) with TestRun.step("Prepare devices for cache and core."):
# Copyright(c) 2020-2021 Intel Corporation # SPDX-License-Identifier: BSD-3-Clause # import pytest from api.cas import casadm, casadm_parser from core.test_run import TestRun from test_utils.os_utils import sync from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan from test_utils.size import Unit, Size from test_tools.dd import Dd @pytest.mark.require_disk("cache", DiskTypeSet([DiskType.nand, DiskType.optane])) @pytest.mark.require_disk("core", DiskTypeLowerThan("cache")) @pytest.mark.parametrize("purge_target", ["cache", "core"]) def test_purge(purge_target): """ title: Call purge without and with `--script` switch description: | Check if purge is called only when `--script` switch is used. pass_criteria: - casadm returns an error when `--script` is missing - cache is wiped when purge command is used properly """ with TestRun.step("Prepare devices"): cache_device = TestRun.disks["cache"] core_device = TestRun.disks["core"]
from core.test_run import TestRun from storage_devices.disk import DiskType, DiskTypeSet from storage_devices.raid import Raid, RaidConfiguration, MetadataVariant, Level from test_tools import fs_utils from test_tools.disk_utils import Filesystem from test_utils.size import Size, Unit mount_point = "/mnt/test" test_file_path = f"{mount_point}/test_file" test_file_tmp_path = "/tmp/filetmp" test_file_size = Size(500, Unit.KiloByte) files_number = 100 @pytest.mark.parametrizex("cache_mode", CacheMode) @pytest.mark.require_disk("core", DiskTypeSet([DiskType.optane, DiskType.nand])) @pytest.mark.require_disk("cache1", DiskTypeSet([DiskType.sata, DiskType.hdd])) @pytest.mark.require_disk("cache2", DiskTypeSet([DiskType.sata, DiskType.hdd])) def test_raid_as_cache(cache_mode): """ title: Test if SW RAID1 can be a cache device. description: | Test if SW RAID1 can be a cache for CAS device. pass_criteria: - Successful creation of RAID and building CAS device with it. - Files copied successfully, the md5sum match the origin one. """ with TestRun.step("Create RAID1."): raid_disk = TestRun.disks['cache1'] raid_disk.create_partitions([Size(2, Unit.GibiByte)]) raid_disk_1 = raid_disk.partitions[0]
# Copyright(c) 2020 Intel Corporation # SPDX-License-Identifier: BSD-3-Clause-Clear # import os from datetime import timedelta import pytest from api.cas import casadm from api.cas.cache_config import CacheMode, CacheLineSize from core.test_run import TestRun from storage_devices.disk import DiskTypeSet, DiskType from test_tools.disk_utils import Filesystem from test_utils.size import Size, Unit @pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand, DiskType.sata])) @pytest.mark.require_disk("core", DiskTypeSet([DiskType.optane, DiskType.nand, DiskType.sata])) @pytest.mark.parametrizex("cache_mode", CacheMode) @pytest.mark.parametrizex("cache_line_size", CacheLineSize) @pytest.mark.require_plugin("vdbench") def test_trim_stress(cache_mode, cache_line_size): """ title: Trim support on cache devices in different cache modes stress test. description: | Stress test validating the ability of CAS to handle trim requests in different modes, on different filesystem types. pass_criteria: - No kernel bug. - Cache should still work correctly. """