Merge pull request #1309 from DocentSzachista/OC1-277

tests: add test for adding invalid cores devices to caches
This commit is contained in:
Karolina Rogowska 2022-08-19 11:55:57 +02:00 committed by GitHub
commit 39e3a0f6a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 55 additions and 0 deletions

View File

@ -21,6 +21,16 @@ start_cache_with_existing_metadata = [
r" discard on-disk metadata and start fresh cache instance\." r" discard on-disk metadata and start fresh cache instance\."
] ]
start_cache_on_already_used_dev = [
r"Error inserting cache \d+",
r"Cache device \'\/dev\/\S+\' is already used as cache\."
]
start_cache_with_existing_id = [
r"Error inserting cache \d+",
r"Cache ID already exists"
]
standby_init_with_existing_filesystem = [ standby_init_with_existing_filesystem = [
r"A filesystem exists on \S+. Specify the --force option if you wish to add the cache anyway.", r"A filesystem exists on \S+. Specify the --force option if you wish to add the cache anyway.",
r"Note: this may result in loss of data" r"Note: this may result in loss of data"

View File

@ -6,6 +6,14 @@
import pytest import pytest
from core.test_run import TestRun from core.test_run import TestRun
from api.cas import cli
from api.cas.cli_messages import (
check_stderr_msg,
start_cache_on_already_used_dev,
start_cache_with_existing_id
)
from storage_devices.disk import DiskType, DiskTypeSet
from test_utils.size import Size, Unit
def test_cas_version(): def test_cas_version():
@ -32,3 +40,40 @@ def test_cas_version():
if splitted_version[1] != file_cas_version: if splitted_version[1] != file_cas_version:
TestRun.LOGGER.error(f"""Version of {splitted_version[0]} from cmd doesn't match TestRun.LOGGER.error(f"""Version of {splitted_version[0]} from cmd doesn't match
with file. Expected: {file_cas_version} Actual: {splitted_version[1]}""") with file. Expected: {file_cas_version} Actual: {splitted_version[1]}""")
@pytest.mark.CI
@pytest.mark.require_disk("cache_1", DiskTypeSet([DiskType.nand, DiskType.optane]))
def test_negative_start_cache():
"""
title: Test start cache negative on cache device
description:
Check for negative cache start scenarios
pass criteria:
- Cache start succeeds
- Fails to start cache on the same device with another id
- Fails to start cache on another partition with the same id
"""
with TestRun.step("Set up device"):
cache_dev = TestRun.disks["cache_1"]
cache_dev.create_partitions([Size(2000, Unit.MebiByte)] * 2)
cache_dev_1 = cache_dev.partitions[0]
cache_dev_2 = cache_dev.partitions[1]
with TestRun.step("Start cache on cache device"):
TestRun.executor.run_expect_success(
cli.start_cmd(cache_dev_1.path, cache_id="1", force=True)
)
with TestRun.step("Start cache on the same device but with another ID"):
output = TestRun.executor.run_expect_fail(
cli.start_cmd(cache_dev_1.path, cache_id="2", force=True)
)
if not check_stderr_msg(output, start_cache_on_already_used_dev):
TestRun.fail(f"Received unexpected error message: {output.stderr}")
with TestRun.step("Start cache with the same ID on another cache device"):
output = TestRun.executor.run_expect_fail(
cli.start_cmd(cache_dev_2.path, cache_id="1", force=True)
)
if not check_stderr_msg(output, start_cache_with_existing_id):
TestRun.fail(f"Received unexpected error message: {output.stderr}")