Merge pull request #713 from Ostrokrzew/test_update
Update zero metadata API and tests
This commit is contained in:
commit
be820931e1
@ -153,9 +153,9 @@ def print_version(output_format: OutputFormat = None, shortcut: bool = False):
|
|||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
||||||
def zero_metadata(cache_dev: Device, shortcut: bool = False):
|
def zero_metadata(cache_dev: Device, force: bool = False, shortcut: bool = False):
|
||||||
output = TestRun.executor.run(
|
output = TestRun.executor.run(
|
||||||
zero_metadata_cmd(cache_dev=cache_dev.path, shortcut=shortcut))
|
zero_metadata_cmd(cache_dev=cache_dev.path, force=force, shortcut=shortcut))
|
||||||
if output.exit_code != 0:
|
if output.exit_code != 0:
|
||||||
raise CmdException("Failed to wipe metadata.", output)
|
raise CmdException("Failed to wipe metadata.", output)
|
||||||
return output
|
return output
|
||||||
|
@ -115,9 +115,11 @@ def print_statistics_cmd(cache_id: str, core_id: str = None, per_io_class: bool
|
|||||||
return casadm_bin + command
|
return casadm_bin + command
|
||||||
|
|
||||||
|
|
||||||
def zero_metadata_cmd(cache_dev: str, shortcut: bool):
|
def zero_metadata_cmd(cache_dev: str, force: bool = False, shortcut: bool = False):
|
||||||
command = " --zero-metadata"
|
command = " --zero-metadata"
|
||||||
command += (" -d " if shortcut else " --device ") + cache_dev
|
command += (" -d " if shortcut else " --device ") + cache_dev
|
||||||
|
if force:
|
||||||
|
command += (" -f" if shortcut else " --force")
|
||||||
return casadm_bin + command
|
return casadm_bin + command
|
||||||
|
|
||||||
|
|
||||||
|
@ -254,6 +254,7 @@ zero_metadata_help = [
|
|||||||
r"Clear metadata from caching device",
|
r"Clear metadata from caching device",
|
||||||
r"Options that are valid with --zero-metadata are:",
|
r"Options that are valid with --zero-metadata are:",
|
||||||
r"-d --device \<DEVICE\> Path to device on which metadata would be cleared"
|
r"-d --device \<DEVICE\> Path to device on which metadata would be cleared"
|
||||||
|
r"-f --force Ignore potential dirty data on cache device"
|
||||||
]
|
]
|
||||||
|
|
||||||
unrecognized_stderr = [
|
unrecognized_stderr = [
|
||||||
|
@ -120,6 +120,14 @@ def test_user_cli():
|
|||||||
except CmdException:
|
except CmdException:
|
||||||
TestRun.LOGGER.info("Non-root user cannot remove core.")
|
TestRun.LOGGER.info("Non-root user cannot remove core.")
|
||||||
|
|
||||||
|
with TestRun.step("Try to zero metadata."):
|
||||||
|
try:
|
||||||
|
output = run_as_other_user(cli.zero_metadata_cmd(str(cache_dev)), user_name)
|
||||||
|
if output.exit_code == 0:
|
||||||
|
TestRun.LOGGER.error("Zeroing metadata should fail!")
|
||||||
|
except CmdException:
|
||||||
|
TestRun.LOGGER.info("Non-root user cannot zero metadata.")
|
||||||
|
|
||||||
with TestRun.step("Try to list caches."):
|
with TestRun.step("Try to list caches."):
|
||||||
try:
|
try:
|
||||||
output = run_as_other_user(cli.list_cmd(), user_name)
|
output = run_as_other_user(cli.list_cmd(), user_name)
|
||||||
@ -344,6 +352,13 @@ def test_user_cli():
|
|||||||
except CmdException:
|
except CmdException:
|
||||||
TestRun.LOGGER.error("Non-root sudoer user should be able to remove core from cache.")
|
TestRun.LOGGER.error("Non-root sudoer user should be able to remove core from cache.")
|
||||||
|
|
||||||
|
with TestRun.step("Try to zero metadata with 'sudo'."):
|
||||||
|
try:
|
||||||
|
run_as_other_user(cli.zero_metadata_cmd(str(cache_dev)),
|
||||||
|
user_name, True)
|
||||||
|
except CmdException:
|
||||||
|
TestRun.LOGGER.error("Non-root sudoer user should be able to zero metadata.")
|
||||||
|
|
||||||
with TestRun.step("Try to print help for casadm with 'sudo'."):
|
with TestRun.step("Try to print help for casadm with 'sudo'."):
|
||||||
try:
|
try:
|
||||||
run_as_other_user(cli.help_cmd(), user_name, True)
|
run_as_other_user(cli.help_cmd(), user_name, True)
|
||||||
|
Loading…
Reference in New Issue
Block a user