def parse_failure(log_url, log_content): logger.accumulate_for_slack(log_url) if log_url.endswith('interrupt'): logger.accumulate_for_slack(log_content.content) if log_url.endswith('json'): analyze_test_results(log_content) elif log_url.endswith('stdio'): analyze_console_failure(log_content) logger.notify('')
def analyze_console_failure(log_content): clean_content = re.sub('\[[:0-9]*\]', '', log_content.content) splitted_clean_content = clean_content.split('\n') for word in bad_words: # todo: use regex case insensitive x = [str for str in splitted_clean_content if word in str] print('\n'.join(x)) footer = clean_content.split('#####')[1:] for line in footer: logger.accumulate_for_slack(line)
def show_tests_details_by_result(tests, result_type, tag): filtered_tests = [ i for i in tests if TestResults(i['state']) == result_type ] if len(filtered_tests) != 0: logger.accumulate_for_slack("{0} {1} Tests found\n".format( len(filtered_tests), tag)) for i in filtered_tests: print( '----------------------------------------------------------------------------------------------------' ) print(i['name'], i['message'], i['stackTrace'])
def process_running_builds(build_info, project): print("processing build results") build_number = get_build_number(build_info) if build_number == "null": print( "Build number is null; probably the build hasn't started yet. Lets wait a while before trying again" ) return False build_status = get_build_status(build_number, project) build_result_code = get_result_code(build_status) print("Processing. Build status: %s" % build_result_code) if build_result_code == KatanaResults.UNKNOWN: print("The build is still going on...") if isinstance(build_status['eta'], float): print("The eta for build completion is %s min" % (build_status['eta'] / 60)) elif build_result_code == KatanaResults.RESUME: print("The build is still going on...") if isinstance(build_status['eta'], float): print("The eta for build completion is %s min" % (build_status['eta'] / 60)) return False elif build_result_code in katana_success_results: print("Build Finished Successfully. All is green now :)") elif build_result_code in katana_failure_results: print( "Looks like the build #%s (%s) has finished but wasn't successful. The result is %s." % (build_number, project, KatanaResults( build_status['results']).name)) if build_result_code == KatanaResults.DEPENDENCY_FAILURE: analyze_dependencies(build_status) analyze_logs(build_status, project) elif build_result_code in katana_retry_results: logger.accumulate_for_slack("Looks like the build has finished but wasn't successful. " \ "The result is %s." % KatanaResults(build_status['results']).name) analyze_logs(build_status, project) return True
def analyze_test_results(log_content): test_results = json.loads(log_content.content) if len(test_results['suites'] ) == 0 and test_results['summary']['testsCount'] == 0: logger.accumulate_for_slack( 'It failed because there were no tests to run') return for suite in test_results['suites']: if TestResults(suite['summary']['result']) == TestResults.SUCCESS: continue if len(suite['tests']) == 0: if 'failureConclusion' in test_results['summary']: logger.accumulate_for_slack( test_results['summary']['failureConclusion']) logger.accumulate_for_slack(suite['failureReasons'][0]) else: show_tests_details_by_result(suite['tests'], TestResults.ERROR, 'Crashed') show_tests_details_by_result(suite['tests'], TestResults.FAILED, 'Failed')