def __verify_exceptions(self, expected_strs, actual_str, use_db): """ Verifies that at least one of the strings in 'expected_str' is either: * A row_regex: line that matches the actual exception string 'actual_str' * A substring of the actual exception string 'actual_str'. """ actual_str = actual_str.replace('\n', '') for expected_str in expected_strs: # In error messages, some paths are always qualified and some are not. # So, allow both $NAMENODE and $FILESYSTEM_PREFIX to be used in CATCH. expected_str = expected_str.strip() \ .replace('$FILESYSTEM_PREFIX', FILESYSTEM_PREFIX) \ .replace('$FILESYSTEM_NAME', FILESYSTEM_NAME) \ .replace('$NAMENODE', NAMENODE) \ .replace('$IMPALA_HOME', IMPALA_HOME) \ .replace('$INTERNAL_LISTEN_HOST', INTERNAL_LISTEN_HOST)\ .replace('$INTERNAL_LISTEN_IP', INTERNAL_LISTEN_IP) if use_db: expected_str = expected_str.replace('$DATABASE', use_db) # Strip newlines so we can split error message into multiple lines expected_str = expected_str.replace('\n', '') expected_regex = try_compile_regex(expected_str) if expected_regex: if expected_regex.match(actual_str): return else: # Not a regex - check if expected substring is present in actual. if expected_str in actual_str: return assert False, 'Unexpected exception string. Expected: %s\nNot found in actual: %s' % \ (expected_str, actual_str)
def __verify_exceptions(self, expected_strs, actual_str, use_db): """ Verifies that at least one of the strings in 'expected_str' is either: * A row_regex: line that matches the actual exception string 'actual_str' * A substring of the actual exception string 'actual_str'. """ actual_str = actual_str.replace('\n', '') for expected_str in expected_strs: # In error messages, some paths are always qualified and some are not. # So, allow both $NAMENODE and $FILESYSTEM_PREFIX to be used in CATCH. expected_str = expected_str.strip() \ .replace('$FILESYSTEM_PREFIX', FILESYSTEM_PREFIX) \ .replace('$FILESYSTEM_NAME', FILESYSTEM_NAME) \ .replace('$NAMENODE', NAMENODE) \ .replace('$IMPALA_HOME', IMPALA_HOME) \ .replace('$INTERNAL_LISTEN_HOST', INTERNAL_LISTEN_HOST)\ .replace('$INTERNAL_LISTEN_IP', INTERNAL_LISTEN_IP) if use_db: expected_str = expected_str.replace('$DATABASE', use_db) # Strip newlines so we can split error message into multiple lines expected_str = expected_str.replace('\n', '') expected_regex = try_compile_regex(expected_str) if expected_regex: if expected_regex.match(actual_str): return else: # Not a regex - check if expected substring is present in actual. if expected_str in actual_str: return assert False, 'Unexpected exception string. Expected: %s\nNot found in actual: %s' % \ (expected_str, actual_str)