-
Notifications
You must be signed in to change notification settings - Fork 96
Add IOCTL tests #664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Add IOCTL tests #664
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
eb83431
Add ioctl test for starting cache
Ostrokrzew cc2ddc1
Add ioctl test for interrupting cache start
Ostrokrzew bc9d5de
Add ioctl test for stopping clean cache
Ostrokrzew 9c2a692
Add ioctl test for interrupting clean cache stop
Ostrokrzew ae605e2
Add common utilities for ioctl tests
Ostrokrzew File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,29 @@ | ||
| # | ||
| # Copyright(c) 2021 Intel Corporation | ||
| # SPDX-License-Identifier: BSD-3-Clause-Clear | ||
| # | ||
|
|
||
| from api.cas.cli_messages import __check_string_msg | ||
| from core.test_run import TestRun | ||
|
|
||
|
|
||
| interrupt_stop = [ | ||
| r"Waiting for cache stop interrupted\. Stop will finish asynchronously\." | ||
| ] | ||
|
|
||
| interrupt_start = [ | ||
| r"Cache added successfully, but waiting interrupted\. Rollback" | ||
| ] | ||
|
|
||
| load_and_force = [ | ||
| r"cache\d+: Using \'force\' flag is forbidden for load operation\." | ||
| ] | ||
|
|
||
|
|
||
| def clear_dmesg(): | ||
| TestRun.executor.run_expect_success('dmesg -C') | ||
|
|
||
|
|
||
| def check_dmesg(searched_phrase: str): | ||
| dmesg_out = TestRun.executor.run_expect_success("dmesg").stdout | ||
| __check_string_msg(dmesg_out, searched_phrase) |
This file contains hidden or 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,112 @@ | ||
| # | ||
| # Copyright(c) 2021 Intel Corporation | ||
| # SPDX-License-Identifier: BSD-3-Clause-Clear | ||
| # | ||
|
|
||
| import pytest | ||
| from time import sleep | ||
|
|
||
| from api.cas.casadm import start_cache | ||
| from api.cas.casadm_parser import get_caches | ||
| from core.test_run import TestRun | ||
| from storage_devices.disk import DiskType, DiskTypeSet | ||
| from test_tools.cas_ioctl.cas_requests import StartCacheRequest | ||
| from test_tools.cas_ioctl.cas_structs import CacheMode, CacheLineSize, InitCache | ||
| from test_tools.cas_ioctl.ioctl import cas_ioctl | ||
| from test_utils.size import Size, Unit | ||
| from tests.ioctl import common_utils | ||
|
|
||
| cache_id = 3 | ||
|
|
||
|
|
||
| @pytest.mark.parametrizex("force", [0, 1]) | ||
| @pytest.mark.parametrizex("load", InitCache) | ||
| @pytest.mark.parametrizex("cache_mode", CacheMode) | ||
| @pytest.mark.parametrizex("cache_line_size", CacheLineSize) | ||
| @pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand])) | ||
| def test_ioctl_start(cache_mode, cache_line_size, load, force): | ||
| """ | ||
| title: Start the cache without casadm. | ||
| description: | | ||
| Test of the ability to start the cache with IOCTL request bypassing native | ||
| OpenCAS manager - casadm. | ||
| pass_criteria: | ||
| - Cache started successfully without any errors. | ||
| - When 'force' and 'load' flags are used cache is not started. | ||
| """ | ||
| with TestRun.step("Prepare cache device."): | ||
| cache_dev = TestRun.disks['cache'] | ||
| cache_dev.create_partitions([Size(2, Unit.GiB)]) | ||
| cache_part = cache_dev.partitions[0] | ||
|
|
||
| with TestRun.step("Create IOCTL request for cache start."): | ||
| start_config = StartCacheRequest( | ||
| cache_path_name=cache_part.path, caching_mode=cache_mode, cache_id=cache_id, | ||
| init_cache=load, force=force, line_size=cache_line_size | ||
| ) | ||
|
|
||
| if load.value: | ||
| with TestRun.step("Start and stop cache before loading."): | ||
| cache = start_cache(cache_part, cache_id=cache_id, force=True) | ||
| cache.stop() | ||
|
|
||
| with TestRun.step("Start cache with IOCTL request bypassing casadm."): | ||
| cas_ioctl(start_config) | ||
|
|
||
| with TestRun.step( | ||
| f"Check if cache is {'running' if not (load.value and force) else 'not running'}." | ||
| ): | ||
| if not (load.value and force): | ||
| if len(get_caches()) != 1: | ||
| TestRun.fail("Cache is missing!") | ||
| else: | ||
| if len(get_caches()) != 0: | ||
| TestRun.fail("Cache should not be loaded!") | ||
|
|
||
|
|
||
| @pytest.mark.parametrizex("force", [0, 1]) | ||
| @pytest.mark.parametrizex("load", InitCache) | ||
| @pytest.mark.parametrizex("cache_mode", CacheMode) | ||
| @pytest.mark.parametrizex("cache_line_size", CacheLineSize) | ||
| @pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand])) | ||
| def test_ioctl_start_interrupt(cache_mode, cache_line_size, load, force): | ||
| """ | ||
| title: Interrupt cache start without casadm. | ||
| description: | | ||
| Negative test of the ability to interrupt the cache start with IOCTL request sent | ||
| outside native OpenCAS manager - casadm. | ||
| pass_criteria: | ||
| - Cache is not started. | ||
| """ | ||
| with TestRun.step("Prepare cache device."): | ||
| cache_dev = TestRun.disks['cache'] | ||
| cache_dev.create_partitions([Size(128, Unit.GiB)]) | ||
| cache_part = cache_dev.partitions[0] | ||
|
|
||
| with TestRun.step("Create IOCTL request for cache start."): | ||
| start_config = StartCacheRequest( | ||
| cache_path_name=cache_part.path, caching_mode=cache_mode, cache_id=cache_id, | ||
| init_cache=load, force=force, line_size=cache_line_size | ||
| ) | ||
|
|
||
| if load.value: | ||
| with TestRun.step("Start and stop cache before loading."): | ||
| cache = start_cache(cache_part, cache_id=cache_id, force=True) | ||
| cache.stop() | ||
|
|
||
| with TestRun.step("Clear dmesg."): | ||
| common_utils.clear_dmesg() | ||
|
|
||
| with TestRun.step("Interrupt starting cache with IOCTL request bypassing casadm."): | ||
| cas_ioctl(start_config, True) | ||
| sleep(8) # wait for rollback after interruption | ||
|
|
||
| with TestRun.step(f"Check if cache is not running."): | ||
| if len(get_caches()) > 0: | ||
| TestRun.fail('Start process finished. Interruption failed.') | ||
| else: | ||
| TestRun.LOGGER.info('Start process is dead as expected.') | ||
|
|
||
| with TestRun.step("Check dmesg for interruption log."): | ||
| common_utils.check_dmesg(common_utils.load_and_force if (load.value and force) | ||
| else common_utils.interrupt_start) | ||
This file contains hidden or 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,88 @@ | ||
| # | ||
| # Copyright(c) 2021 Intel Corporation | ||
| # SPDX-License-Identifier: BSD-3-Clause-Clear | ||
| # | ||
|
|
||
| import pytest | ||
| from time import sleep | ||
|
|
||
| from api.cas.casadm import start_cache | ||
| from api.cas.casadm_parser import get_caches | ||
| from core.test_run import TestRun | ||
| from storage_devices.disk import DiskType, DiskTypeSet | ||
| from test_tools.cas_ioctl.cas_requests import StopCacheRequest | ||
| from test_tools.cas_ioctl.ioctl import cas_ioctl | ||
| from test_utils.size import Size, Unit | ||
| from tests.ioctl import common_utils | ||
|
|
||
| cache_id = 4 | ||
|
|
||
|
|
||
| @pytest.mark.parametrizex("flush_data", [0, 1]) | ||
| @pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand])) | ||
| def test_ioctl_stop_clean_cache(flush_data): | ||
| """ | ||
| title: Stop the cache without casadm. | ||
| description: | | ||
| Test of the ability to stop the cache with IOCTL request bypassing native | ||
| OpenCAS manager - casadm. The cache is clean and no flush will be triggered during stop. | ||
| pass_criteria: | ||
| - Cache stopped successfully without any errors. | ||
| """ | ||
| with TestRun.step("Prepare cache device."): | ||
| cache_dev = TestRun.disks['cache'] | ||
| cache_dev.create_partitions([Size(2, Unit.GiB)]) | ||
| cache_part = cache_dev.partitions[0] | ||
|
|
||
| with TestRun.step("Create IOCTL request for cache stopping."): | ||
| stop_config = StopCacheRequest(cache_id=cache_id, flush_data=flush_data) | ||
|
|
||
| with TestRun.step("Start cache before stop."): | ||
| start_cache(cache_part, cache_id=cache_id, force=True) | ||
|
|
||
| with TestRun.step("Stop cache with IOCTL request bypassing casadm."): | ||
| cas_ioctl(stop_config) | ||
|
|
||
| with TestRun.step(f"Check if cache is not running."): | ||
| if len(get_caches()) != 0: | ||
| TestRun.fail("Cache should be stopped despite the interruption!") | ||
|
|
||
|
|
||
| @pytest.mark.parametrizex("flush_data", [0, 1]) | ||
| @pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand])) | ||
| def test_ioctl_stop_interrupt_clean_cache(flush_data): | ||
| """ | ||
| title: Interrupt cache stop without casadm. | ||
| description: | | ||
| Negative test of the ability to interrupt the cache stop with IOCTL request sent | ||
| outside native OpenCAS manager - casadm. The cache is clean and no flush can be | ||
| interrupted during stop. | ||
| pass_criteria: | ||
| - Cache is stopped. | ||
| """ | ||
| with TestRun.step("Prepare cache device."): | ||
| cache_dev = TestRun.disks['cache'] | ||
| cache_dev.create_partitions([Size(128, Unit.GiB)]) | ||
| cache_part = cache_dev.partitions[0] | ||
|
|
||
| with TestRun.step("Create IOCTL request for cache stop."): | ||
| stop_config = StopCacheRequest(cache_id=cache_id, flush_data=flush_data) | ||
|
|
||
| with TestRun.step("Start cache before stopping."): | ||
| start_cache(cache_part, cache_id=cache_id, force=True) | ||
|
|
||
| with TestRun.step("Clear dmesg."): | ||
| common_utils.clear_dmesg() | ||
|
|
||
| with TestRun.step("Interrupt stopping cache with IOCTL request bypassing casadm."): | ||
| cas_ioctl(stop_config, True) | ||
| sleep(8) # wait for thread to finish asynchronously after interruption | ||
|
|
||
| with TestRun.step(f"Check if cache is not running."): | ||
| if len(get_caches()) > 0: | ||
| TestRun.fail("Cache should be stopped despite the interruption!") | ||
| else: | ||
| TestRun.LOGGER.info('Stop process finished as expected.') | ||
|
|
||
| with TestRun.step("Check dmesg for interruption log."): | ||
| common_utils.check_dmesg(common_utils.interrupt_stop) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first bullet is in the opposite to the second one. Shouldn't all the pass criteria be fulfilled?