HBASE-19382 Update report-flakies.py script to handle yetus builds.

This commit is contained in:
Apekshit Sharma 2017-11-29 17:53:16 -08:00
parent 4f4aac77e1
commit fd9c4322c5
2 changed files with 29 additions and 10 deletions

View File

@ -76,7 +76,8 @@ def get_bad_tests(console_url):
failed_tests_set.add(test_case) failed_tests_set.add(test_case)
if test_case not in hanging_tests_set: if test_case not in hanging_tests_set:
print ("ERROR! No test '{}' found in hanging_tests. Might get wrong results " print ("ERROR! No test '{}' found in hanging_tests. Might get wrong results "
"for this test.".format(test_case)) "for this test. This may also happen if maven is set to retry failing "
"tests.".format(test_case))
else: else:
hanging_tests_set.remove(test_case) hanging_tests_set.remove(test_case)
result3 = re.match("^\\s+(\\w*).*\\sTestTimedOut", line) result3 = re.match("^\\s+(\\w*).*\\sTestTimedOut", line)

View File

@ -51,6 +51,9 @@ parser.add_argument('--max-builds', metavar='n', action='append', type=int,
help='The maximum number of builds to use (if available on jenkins). Specify ' help='The maximum number of builds to use (if available on jenkins). Specify '
'0 to analyze all builds. Not required, but if specified, number of uses ' '0 to analyze all builds. Not required, but if specified, number of uses '
'should be same as that of --urls since the values are matched.') 'should be same as that of --urls since the values are matched.')
parser.add_argument('--is-yetus', metavar='True/False', action='append', choices=['True', 'False'],
help='True, if build is yetus style i.e. look for maven output in artifacts; '
'False, if maven output is in <url>/consoleText itself.')
parser.add_argument( parser.add_argument(
"--mvn", action="store_true", "--mvn", action="store_true",
help="Writes two strings for including/excluding these flaky tests using maven flags. These " help="Writes two strings for including/excluding these flaky tests using maven flags. These "
@ -66,17 +69,28 @@ if args.verbose:
logger.setLevel(logging.INFO) logger.setLevel(logging.INFO)
def get_bad_tests(build_url): def get_bad_tests(build_url, is_yetus):
""" """
Given url of an executed build, analyzes its console text, and returns Given url of an executed build, analyzes its maven output, and returns
[list of all tests, list of timeout tests, list of failed tests]. [list of all tests, list of timeout tests, list of failed tests].
Returns None if can't get console text or if there is any other error. Returns None if can't get maven output from the build or if there is any other error.
""" """
logger.info("Analyzing %s", build_url) logger.info("Analyzing %s", build_url)
response = requests.get(build_url + "/api/json").json() response = requests.get(build_url + "/api/json").json()
if response["building"]: if response["building"]:
logger.info("Skipping this build since it is in progress.") logger.info("Skipping this build since it is in progress.")
return {} return {}
console_url = None
if is_yetus:
for artifact in response["artifacts"]:
if artifact["fileName"] == "patch-unit-root.txt":
console_url = build_url + "/artifact/" + artifact["relativePath"]
break
if console_url is None:
logger.info("Can't find 'patch-unit-root.txt' artifact for Yetus build %s\n. Ignoring "
"this build.", build_url)
return
else:
console_url = build_url + "/consoleText" console_url = build_url + "/consoleText"
build_result = findHangingTests.get_bad_tests(console_url) build_result = findHangingTests.get_bad_tests(console_url)
if not build_result: if not build_result:
@ -93,6 +107,7 @@ def expand_multi_config_projects(cli_args):
job_urls = cli_args.urls job_urls = cli_args.urls
excluded_builds_arg = cli_args.excluded_builds excluded_builds_arg = cli_args.excluded_builds
max_builds_arg = cli_args.max_builds max_builds_arg = cli_args.max_builds
is_yetus_arg = cli_args.is_yetus
if excluded_builds_arg is not None and len(excluded_builds_arg) != len(job_urls): if excluded_builds_arg is not None and len(excluded_builds_arg) != len(job_urls):
raise Exception("Number of --excluded-builds arguments should be same as that of --urls " raise Exception("Number of --excluded-builds arguments should be same as that of --urls "
"since values are matched.") "since values are matched.")
@ -102,6 +117,9 @@ def expand_multi_config_projects(cli_args):
final_expanded_urls = [] final_expanded_urls = []
for (i, job_url) in enumerate(job_urls): for (i, job_url) in enumerate(job_urls):
max_builds = 10000 # Some high number max_builds = 10000 # Some high number
is_yetus = False
if is_yetus_arg is not None:
is_yetus = is_yetus_arg[i] == "True"
if max_builds_arg is not None and max_builds_arg[i] != 0: if max_builds_arg is not None and max_builds_arg[i] != 0:
max_builds = int(max_builds_arg[i]) max_builds = int(max_builds_arg[i])
excluded_builds = [] excluded_builds = []
@ -111,10 +129,10 @@ def expand_multi_config_projects(cli_args):
if response.has_key("activeConfigurations"): if response.has_key("activeConfigurations"):
for config in response["activeConfigurations"]: for config in response["activeConfigurations"]:
final_expanded_urls.append({'url':config["url"], 'max_builds': max_builds, final_expanded_urls.append({'url':config["url"], 'max_builds': max_builds,
'excludes': excluded_builds}) 'excludes': excluded_builds, 'is_yetus': is_yetus})
else: else:
final_expanded_urls.append({'url':job_url, 'max_builds': max_builds, final_expanded_urls.append({'url':job_url, 'max_builds': max_builds,
'excludes': excluded_builds}) 'excludes': excluded_builds, 'is_yetus': is_yetus})
return final_expanded_urls return final_expanded_urls
@ -149,7 +167,7 @@ for url_max_build in expanded_urls:
build_id = build["number"] build_id = build["number"]
if build_id in excludes: if build_id in excludes:
continue continue
result = get_bad_tests(build["url"]) result = get_bad_tests(build["url"], url_max_build['is_yetus'])
if not result: if not result:
continue continue
if len(result[0]) > 0: if len(result[0]) > 0: