From fb8860bf393c378fc5e8bfd970f2453fe9ef5ee4 Mon Sep 17 00:00:00 2001 From: Katarzyna Lapinska Date: Wed, 15 Jul 2020 12:03:03 +0200 Subject: [PATCH] Initialize tests cleanup Signed-off-by: Katarzyna Lapinska --- test/functional/test-framework | 2 +- test/functional/tests/initialize/__init__.py | 0 .../tests/initialize/test_initialize_load.py | 2 +- .../tests/initialize/test_negative_load.py | 61 +++++++++++++++++++ .../test_startup_init_config.py} | 0 test/functional/tests/load/test_load.py | 59 ------------------ 6 files changed, 63 insertions(+), 61 deletions(-) create mode 100644 test/functional/tests/initialize/__init__.py create mode 100644 test/functional/tests/initialize/test_negative_load.py rename test/functional/tests/{startup/test_startup.py => initialize/test_startup_init_config.py} (100%) delete mode 100644 test/functional/tests/load/test_load.py diff --git a/test/functional/test-framework b/test/functional/test-framework index 0156c9f..e01877e 160000 --- a/test/functional/test-framework +++ b/test/functional/test-framework @@ -1 +1 @@ -Subproject commit 0156c9ff20db765c11f547a042a2146b3ce06ddc +Subproject commit e01877eb8d47a6b2ffd38fea7913e24cf15b92ad diff --git a/test/functional/tests/initialize/__init__.py b/test/functional/tests/initialize/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/test/functional/tests/initialize/test_initialize_load.py b/test/functional/tests/initialize/test_initialize_load.py index 96b4682..da868b3 100644 --- a/test/functional/tests/initialize/test_initialize_load.py +++ b/test/functional/tests/initialize/test_initialize_load.py @@ -287,7 +287,7 @@ def test_load_x_to_one_with_params(cache_mode, cleaning_policy, cache_line_size, @pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand])) @pytest.mark.require_disk("core", DiskTypeLowerThan("cache")) def test_load_x_to_one_diff_params(cache_mode, cleaning_policy, cache_line_size, cores_amount): - f""" + """ title: Test for loading CAS with 1 cache and 1 or 4 cores with different params. description: | Verify that loading cache configurations works properly in every mode diff --git a/test/functional/tests/initialize/test_negative_load.py b/test/functional/tests/initialize/test_negative_load.py new file mode 100644 index 0000000..4544913 --- /dev/null +++ b/test/functional/tests/initialize/test_negative_load.py @@ -0,0 +1,61 @@ +# +# Copyright(c) 2019-2020 Intel Corporation +# SPDX-License-Identifier: BSD-3-Clause-Clear +# + + +import pytest +from api.cas import casadm, casadm_parser +from core.test_run import TestRun +from storage_devices.disk import DiskType, DiskTypeSet, 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_load_occupied_id(): + """ + title: Negative test for loading cache with occupied ID. + description: | + Verify that loading cache with occupied ID is not permitted. + pass_criteria: + - Loading cache with occupied ID should fail. + """ + + with TestRun.step("Create partitions for test."): + cache_device = TestRun.disks['cache'] + core_device = TestRun.disks['core'] + cache_device.create_partitions([Size(500, Unit.MebiByte), Size(500, Unit.MebiByte)]) + core_device.create_partitions([Size(1, Unit.GibiByte)]) + cache_device_1 = cache_device.partitions[0] + cache_device_2 = cache_device.partitions[1] + core_device = core_device.partitions[0] + + with TestRun.step("Start cache with default id and one core."): + cache1 = casadm.start_cache(cache_device_1, force=True) + cache1.add_core(core_device) + + with TestRun.step("Stop cache."): + cache1.stop() + + with TestRun.step("Start cache with default id on different device."): + casadm.start_cache(cache_device_2, force=True) + + with TestRun.step("Attempt to load metadata from first cache device."): + try: + casadm.load_cache(cache_device_1) + TestRun.fail("Cache loaded successfully but it should not.") + except Exception: + pass + + caches = casadm_parser.get_caches() + if len(caches) != 1: + TestRun.LOGGER.error("Inappropriate number of caches after load!") + if caches[0].cache_device.system_path != cache_device_2.system_path: + TestRun.LOGGER.error("Wrong cache device system path!") + if caches[0].cache_id != 1: + TestRun.LOGGER.error("Wrong cache id.") + + cores = caches[0].get_core_devices() + if len(cores) != 0: + TestRun.LOGGER.error("Inappropriate number of cores after load!") diff --git a/test/functional/tests/startup/test_startup.py b/test/functional/tests/initialize/test_startup_init_config.py similarity index 100% rename from test/functional/tests/startup/test_startup.py rename to test/functional/tests/initialize/test_startup_init_config.py diff --git a/test/functional/tests/load/test_load.py b/test/functional/tests/load/test_load.py deleted file mode 100644 index 7cc1926..0000000 --- a/test/functional/tests/load/test_load.py +++ /dev/null @@ -1,59 +0,0 @@ -# -# Copyright(c) 2019-2020 Intel Corporation -# SPDX-License-Identifier: BSD-3-Clause-Clear -# - - -import pytest -from api.cas import casadm, casadm_parser -from core.test_run import TestRun -from storage_devices.disk import DiskType, DiskTypeSet, 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_load_occupied_id(): - """ - 1. Start new cache instance (don't specify cache id) - 2. Add core to newly create cache. - 3. Stop cache instance. - 4. Start new cache instance on another device (don't specify cache id). - 5. Try to load metadata from first device. - * Load should fail. - """ - - cache_device = TestRun.disks['cache'] - core_device = TestRun.disks['core'] - - TestRun.LOGGER.info("Creating partitons for test") - cache_device.create_partitions([Size(500, Unit.MebiByte), Size(500, Unit.MebiByte)]) - core_device.create_partitions([Size(1, Unit.GibiByte)]) - - cache_device_1 = cache_device.partitions[0] - cache_device_2 = cache_device.partitions[1] - core_device = core_device.partitions[0] - - TestRun.LOGGER.info("Starting cache with default id and one core") - cache1 = casadm.start_cache(cache_device_1, force=True) - cache1.add_core(core_device) - - TestRun.LOGGER.info("Stopping cache") - cache1.stop() - - TestRun.LOGGER.info("Starting cache with default id on different device") - cache2 = casadm.start_cache(cache_device_2, force=True) - - TestRun.LOGGER.info("Attempt to load metadata from first cache device") - try: - casadm.load_cache(cache_device_1) - except Exception: - pass - - caches = casadm_parser.get_caches() - assert len(caches) == 1, "Inappropirate number of caches after load!" - assert caches[0].cache_device.system_path == cache_device_2.system_path - assert caches[0].cache_id == 1 - - cores = caches[0].get_core_devices() - assert len(cores) == 0