Skip to content

Conversation

@Kgierszx
Copy link
Contributor

Signed-off-by: Kamil Gierszewski [email protected]

@Kgierszx Kgierszx force-pushed the test_fault_injection branch 4 times, most recently from 864d4ce to d76f81a Compare October 20, 2022 13:25
@Kgierszx Kgierszx force-pushed the test_fault_injection branch from d76f81a to edce577 Compare October 27, 2022 13:33
kajakoltan
kajakoltan previously approved these changes Oct 27, 2022
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.

@Kgierszx Kgierszx force-pushed the test_fault_injection branch 2 times, most recently from c470d87 to 12733eb Compare December 6, 2022 15:35
Signed-off-by: Kamil Gierszewski <[email protected]>
@Kgierszx Kgierszx force-pushed the test_fault_injection branch from be4e5f1 to 2f0a684 Compare December 6, 2022 16:17
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