-
Notifications
You must be signed in to change notification settings - Fork 96
test_add:test_fault_injection_core_in_raid #1387
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
base: master
Are you sure you want to change the base?
Conversation
test/functional/tests/fault_injection/test_fault_injection_core_in_raid.py
Outdated
Show resolved
Hide resolved
test/functional/tests/fault_injection/test_fault_injection_core_in_raid.py
Outdated
Show resolved
Hide resolved
test/functional/tests/fault_injection/test_fault_injection_core_in_raid.py
Outdated
Show resolved
Hide resolved
157ce76 to
7bf49e3
Compare
test/functional/tests/fault_injection/test_fault_injection_core_in_raid.py
Outdated
Show resolved
Hide resolved
864d4ce to
d76f81a
Compare
d76f81a to
edce577
Compare
| 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}.") |
There was a problem hiding this comment.
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
| partition_not_suitable_for_array, | ||
| device_or_resource_busy, |
There was a problem hiding this comment.
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.
c470d87 to
12733eb
Compare
Signed-off-by: Kamil Gierszewski <[email protected]>
be4e5f1 to
2f0a684
Compare
Signed-off-by: Kamil Gierszewski <[email protected]>
| 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" | ||
| ] |
There was a problem hiding this comment.
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
Signed-off-by: Kamil Gierszewski [email protected]