Merge pull request #414 from Ostrokrzew/load
Disable the possibility to use the 'load' and 'force' flags at once
This commit is contained in:
commit
d4bca2756f
@ -294,6 +294,11 @@ int handle_start()
|
|||||||
int status;
|
int status;
|
||||||
struct stat device_info;
|
struct stat device_info;
|
||||||
|
|
||||||
|
if (command_args_values.state == CACHE_INIT_LOAD && command_args_values.force) {
|
||||||
|
cas_printf(LOG_ERR, "Use of 'load' and 'force' simultaneously is forbidden.\n");
|
||||||
|
return FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
cache_device = open(command_args_values.cache_device, O_RDONLY);
|
cache_device = open(command_args_values.cache_device, O_RDONLY);
|
||||||
|
|
||||||
if (cache_device < 0) {
|
if (cache_device < 0) {
|
||||||
|
@ -59,6 +59,10 @@ stop_cache_mounted_core = [
|
|||||||
r"Can\'t stop cache instance \d+\. Device /dev/cas\d+-\d+ is mounted\!"
|
r"Can\'t stop cache instance \d+\. Device /dev/cas\d+-\d+ is mounted\!"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
load_and_force = [
|
||||||
|
r"Use of \'load\' and \'force\' simultaneously is forbidden\."
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def check_stderr_msg(output: Output, expected_messages):
|
def check_stderr_msg(output: Output, expected_messages):
|
||||||
return __check_string_msg(output.stderr, expected_messages)
|
return __check_string_msg(output.stderr, expected_messages)
|
||||||
|
@ -6,7 +6,8 @@
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from api.cas import casadm, casadm_parser
|
from api.cas import casadm, casadm_parser, cli_messages
|
||||||
|
from api.cas.cli import start_cmd
|
||||||
from core.test_run import TestRun
|
from core.test_run import TestRun
|
||||||
from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan
|
from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan
|
||||||
from test_utils.size import Unit, Size
|
from test_utils.size import Unit, Size
|
||||||
@ -80,3 +81,32 @@ def test_cli_add_remove_default_value(shortcut):
|
|||||||
TestRun.fail("No cache should be present after stopping the cache")
|
TestRun.fail("No cache should be present after stopping the cache")
|
||||||
if output.stdout != "No caches running":
|
if output.stdout != "No caches running":
|
||||||
TestRun.fail(f"Invalid message, expected 'No caches running', got {output.stdout}")
|
TestRun.fail(f"Invalid message, expected 'No caches running', got {output.stdout}")
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand]))
|
||||||
|
def test_cli_load_and_force():
|
||||||
|
"""
|
||||||
|
title: Test if it is possible to use start command with 'load' and 'force' flag at once
|
||||||
|
description: |
|
||||||
|
Try to start cache with 'load' and 'force' options at the same time
|
||||||
|
and check if it is not possible to do
|
||||||
|
pass_criteria:
|
||||||
|
- Start cache command with both 'force' and 'load' options should fail
|
||||||
|
- Proper message should be received
|
||||||
|
"""
|
||||||
|
with TestRun.step("Prepare cache."):
|
||||||
|
cache_device = TestRun.disks['cache']
|
||||||
|
cache_device.create_partitions([Size(50, Unit.MebiByte)])
|
||||||
|
cache_device = cache_device.partitions[0]
|
||||||
|
cache = casadm.start_cache(cache_device)
|
||||||
|
|
||||||
|
with TestRun.step("Stop cache."):
|
||||||
|
cache.stop()
|
||||||
|
|
||||||
|
with TestRun.step("Try to load cache with 'force'."):
|
||||||
|
output = TestRun.executor.run(
|
||||||
|
start_cmd(cache_dev=cache_device.system_path, force=True, load=True)
|
||||||
|
)
|
||||||
|
if output.exit_code == 0:
|
||||||
|
TestRun.fail("Loading cache with 'force' option should fail.")
|
||||||
|
cli_messages.check_stderr_msg(output, cli_messages.load_and_force)
|
||||||
|
Loading…
Reference in New Issue
Block a user