From 77499cc693a962256a470304e96ece81e3d31fc9 Mon Sep 17 00:00:00 2001 From: Katarzyna Lapinska Date: Mon, 24 Aug 2020 10:42:43 +0200 Subject: [PATCH] Add stress test for attaching and detaching multiple core devices. Signed-off-by: Katarzyna Lapinska --- .../tests/stress/test_stress_attach_detach.py | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 test/functional/tests/stress/test_stress_attach_detach.py diff --git a/test/functional/tests/stress/test_stress_attach_detach.py b/test/functional/tests/stress/test_stress_attach_detach.py new file mode 100644 index 0000000..e85f89c --- /dev/null +++ b/test/functional/tests/stress/test_stress_attach_detach.py @@ -0,0 +1,53 @@ +# +# Copyright(c) 2020 Intel Corporation +# SPDX-License-Identifier: BSD-3-Clause-Clear +# + +import pytest +import random + +from api.cas import casadm +from core.test_run import TestRun +from storage_devices.disk import DiskTypeSet, DiskType, DiskTypeLowerThan +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_stress_attach_detach(): + """ + title: Stress test for attaching and detaching multiple core devices. + description: | + Validate the ability of CAS to attach and detach core devices using script commands. + pass_criteria: + - No system crash. + - Core devices are successfully attached and detached. + """ + iterations_number = 50 + + with TestRun.step("Prepare devices."): + cache_disk = TestRun.disks['cache'] + cache_disk.create_partitions([Size(100, Unit.MebiByte)]) + cache_part = cache_disk.partitions[0] + + core_disk = TestRun.disks['core'] + core_disk.create_partitions([Size(5, Unit.GibiByte)] * 8) + core_devices = core_disk.partitions + + with TestRun.step("Start cache."): + cache = casadm.start_cache(cache_part) + cores = [] + for dev in core_devices: + cores.append(cache.add_core(dev)) + + with TestRun.step("Attach and detach core devices in a loop."): + for _ in TestRun.iteration(range(0, iterations_number)): + TestRun.LOGGER.info("Detaching all core devices.") + for core in cores: + casadm.detach_core(cache.cache_id, core.core_id) + + random.shuffle(cores) + + TestRun.LOGGER.info("Attaching all core devices.") + for core in cores: + casadm.try_add(core.core_device, cache.cache_id, core.core_id)