Skip to content
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

test_add:test_fault_injection_core_in_raid #1387

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Kgierszx
Copy link
Contributor

Signed-off-by: Kamil Gierszewski kamilx.gierszewski@intel.com

@Kgierszx Kgierszx force-pushed the test_fault_injection branch 4 times, most recently from 864d4ce to d76f81a Compare October 20, 2022 13:25
Comment on lines 259 to 274
def check_stdout_msg(output: Output, expected_messages, negate=False):
return __check_string_msg(output.stdout, expected_messages, negate)


def __check_string_msg(text: str, expected_messages, negate=False):
def check_string_msg_all(text: str, expected_messages):
msg_ok = True
for msg in expected_messages:
matches = re.search(msg, text)
if not matches and not negate:
if not matches:
TestRun.LOGGER.error(f"Message is incorrect, expected: {msg}\n actual: {text}.")
msg_ok = False
elif matches and negate:
TestRun.LOGGER.error(f"Message is incorrect, expected to not find: {msg}\n "
f"actual: {text}.")
msg_ok = False
return msg_ok


def check_string_msg_any(text: str, expected_messages):
msg_ok = False
for msg in expected_messages:
matches = re.search(msg, text)
if matches:
msg_ok = True
break
if not msg_ok:
TestRun.LOGGER.error(f"Message is incorrect: {text}.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check_string_msg_all() and check_string_msg_any() are perfect opportunities to use python's all() and any(). Consider the following:

def check_string_msg_all(text: str, expected_messages):
    if all([re.match(m, text) for m in expected_messages]):
        return True
     
    TestRun.LOGGER.error(f"Message is incorrect, expected: {msg}\n Got: {text}.")
    return False

and

def check_string_msg_any(text: str, expected_messages):
    if any([re.match(m, text) for m in expected_messages]):
        return True
     
    TestRun.LOGGER.error(f"Message is incorrect, expected at least one of: {msg}\n Got: {text}.")
    return False

Comment on lines 14 to 15
partition_not_suitable_for_array,
device_or_resource_busy,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find partition_not_suitable_for_array and device_or_resource_busy in cli_messages.py, so I guess you've forgotten to add them to the index. Additionally, as the are mdadm's error messages not casadm's, I suggest adding some kind of prefix to make it clear.

Signed-off-by: Kamil Gierszewski <kamilx.gierszewski@intel.com>
Signed-off-by: Kamil Gierszewski <kamilx.gierszewski@intel.com>
Comment on lines +255 to +261
mdadm_partition_not_suitable_for_array = [
r"\S+ is not suitable for this array"
]

mdadm_device_or_resource_busy = [
r"mdadm: cannot open \S+: Device or resource busy"
]
Copy link
Contributor

@Deixx Deixx Aug 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be probably moved to test-framework/test_tools/mdadm.py or just to test/functional/tests/fault_injection/test_fault_injection_core_in_raid.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants