MCPcopy Create free account
hub / github.com/apache/impala / error_msg_startswith

Function error_msg_startswith

tests/common/test_result_verifier.py:805–843  ·  view source on GitHub ↗

As defined in `ImpalaServer::QUERY_ERROR_FORMAT`, an error message is expected to has the following form: Query failed:\n \n This function returns True if 1. `actual_msg` contains the error prompt "Query failed:\n", and 2. `expected_msg` follows ri

(actual_msg, expected_msg="", query_id=None)

Source from the content-addressed store, hash-verified

803
804
805def error_msg_startswith(actual_msg, expected_msg="", query_id=None):
806 """
807 As defined in `ImpalaServer::QUERY_ERROR_FORMAT`, an error message is expected to
808 has the following form:
809
810 Query <query_id> failed:\n<error_detail>\n
811
812 This function returns True if
813 1. `actual_msg` contains the error prompt "Query <query_id> failed:\n", and
814 2. `expected_msg` follows right after the error prompt.
815
816 For `query_id`,
817 - If the query_id argument is not None, the function checks if the actual error
818 message contains exactly the query id.
819 - Otherwise, it checks if the `query_id` part in the actual error message matches the
820 format using the regular expression.
821
822 `expected_msg` may also be an array of strings, in which case the function checks
823 whether the actual error message starts with any of the strings in the array.
824
825 NOTE: Messages of errors such as "Invalid session id" do not contain a query id
826 since such an error may occur before a query id is generated.
827 """
828 if query_id is not None:
829 ERROR_PROMPT = "Query " + query_id + " failed:\n"
830 start = actual_msg.find(ERROR_PROMPT)
831 if start == -1:
832 return False
833 start += len(ERROR_PROMPT)
834 else:
835 ERROR_PROMPT = "Query " + QUERY_ID_REGEX + " failed:\n"
836 m = re.search(ERROR_PROMPT, actual_msg)
837 if m is None:
838 return False
839 start = m.end()
840 for msg in expected_msg if isinstance(expected_msg, list) else [expected_msg]:
841 if actual_msg.startswith(msg, start):
842 return True
843 return False
844
845
846def error_msg_equal(msg1, msg2):

Callers 15

test_malformed_queryMethod · 0.90
test_cleanupMethod · 0.90
check_responseMethod · 0.90
run_test_caseMethod · 0.90
__exit__Method · 0.90
assert_kill_errorFunction · 0.90
test_admit_no_queryMethod · 0.90

Calls 3

findMethod · 0.45
searchMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected