Skip to content
This repository has been archived by the owner on Nov 6, 2019. It is now read-only.

Commit

Permalink
Merge 2376057 into 48f1629
Browse files Browse the repository at this point in the history
  • Loading branch information
spbnick committed Jul 13, 2018
2 parents 48f1629 + 2376057 commit 974ba6c
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 55 deletions.
40 changes: 18 additions & 22 deletions sktm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@

class tresult(enum.IntEnum):
"""Test result"""
ERROR = -1
SUCCESS = 0
MERGE_FAILURE = 1
BUILD_FAILURE = 2
PUBLISH_FAILURE = 3
TEST_FAILURE = 4
BASELINE_FAILURE = 5


class jtype(enum.IntEnum):
Expand Down Expand Up @@ -333,40 +332,37 @@ def check_patchwork(self):
def check_pending(self):
for (pjt, bid, cpw) in self.pj:
if self.jk.is_build_complete(self.jobname, bid):
logging.info("job completed: jjid=%d; type=%d", bid, pjt)
bres = self.jk.get_result(self.jobname, bid)
rurl = self.jk.get_result_url(self.jobname, bid)
basehash = self.jk.get_base_hash(self.jobname, bid)
basedate = self.jk.get_base_commitdate(self.jobname, bid)

logging.info("job completed: "
"type=%d; jjid=%d; result=%s; url=%s",
pjt, bid, bres.name, rurl)
self.pj.remove((pjt, bid, cpw))

if bres == sktm.tresult.ERROR:
logging.warning("job completed with an error, ignoring")
continue

if pjt == sktm.jtype.BASELINE:
self.db.update_baseline(
self.baserepo,
self.jk.get_base_hash(self.jobname, bid),
self.jk.get_base_commitdate(self.jobname, bid),
self.jk.get_result(self.jobname, bid),
basehash,
basedate,
bres,
bid
)
elif pjt == sktm.jtype.PATCHWORK:
patches = list()
bres = self.jk.get_result(self.jobname, bid)
rurl = self.jk.get_result_url(self.jobname, bid)
logging.info("result=%s", bres)
logging.info("url=%s", rurl)
basehash = self.jk.get_base_hash(self.jobname, bid)
logging.info("basehash=%s", basehash)
if bres == sktm.tresult.BASELINE_FAILURE:
self.db.update_baseline(
self.baserepo,
basehash,
self.jk.get_base_commitdate(self.jobname, bid),
sktm.tresult.TEST_FAILURE,
bid
)

patch_url_list = self.jk.get_patchwork(self.jobname, bid)
for patch_url in patch_url_list:
patches.append(self.get_patch_info_from_url(cpw,
patch_url))

if bres != sktm.tresult.BASELINE_FAILURE:
self.db.commit_tested(patches)
self.db.commit_tested(patches)
else:
raise Exception("Unknown job type: %d" % pjt)

Expand Down
3 changes: 2 additions & 1 deletion sktm/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,8 @@ def update_baseline(self, baserepo, commithash, commitdate,
baserepo: Baseline Git repo URL.
commithash: Commit SHA of the baseline commit.
commitdate: Date of the commit.
result: Result ID of the test run.
result: Result ID of the test run (an sktm.tresult).
Cannot be sktm.tresult.ERROR.
build_id: The build ID of the test run.
"""
Expand Down
44 changes: 18 additions & 26 deletions sktm/jenkins.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,32 +241,24 @@ def get_result(self, jobname, buildid):

if bstatus == "SUCCESS":
return sktm.tresult.SUCCESS

# If build is UNSTABLE and all cmd_run steps are PASSED or FIXED
if bstatus == "UNSTABLE" and \
(set(self.__get_data_list(jobname, buildid,
"skt.cmd_run", "status")) <=
set(["PASSED", "FIXED"])):
# If there was at least one baseline test failure
if self.get_baseretcode(jobname, buildid) != 0:
logging.warning("baseline failure found during patch testing")
return sktm.tresult.BASELINE_FAILURE

return sktm.tresult.SUCCESS

# Find earliest (worst) step failure
step_failure_result_list = [
("skt.cmd_merge", sktm.tresult.MERGE_FAILURE),
("skt.cmd_build", sktm.tresult.BUILD_FAILURE),
("skt.cmd_run", sktm.tresult.TEST_FAILURE),
]
for (step, failure_result) in step_failure_result_list:
if set(self.__get_data_list(jobname, buildid, step, "status")) & \
set(["FAILED", "REGRESSION"]):
return failure_result

logging.warning("Unknown status. marking as test failure")
return sktm.tresult.TEST_FAILURE
elif bstatus == "UNSTABLE":
# Find earliest (worst) step failure
step_failure_result_list = [
("skt.cmd_merge", sktm.tresult.MERGE_FAILURE),
("skt.cmd_build", sktm.tresult.BUILD_FAILURE),
("skt.cmd_run", sktm.tresult.TEST_FAILURE),
]
for (step, failure_result) in step_failure_result_list:
if set(self.__get_data_list(jobname, buildid,
step, "status")) & \
set(["FAILED", "REGRESSION"]):
return failure_result
logging.warning("Build status is \"%s\", "
"but no failed steps found, reporting as error",
bstatus)
else:
logging.warning("Reporting build status \"%s\" as error", bstatus)
return sktm.tresult.ERROR

# FIXME Clarify/fix argument names
def build(self, jobname, baserepo=None, ref=None, baseconfig=None,
Expand Down
10 changes: 4 additions & 6 deletions sktm/patchwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,8 @@ def __set_patch_check(self, patch, payload):
def set_patch_check(self, pid, jurl, result):
"""
Add a patch "check" for the specified patch, with the specified
Jenkins build URL and result (sktm.tresult).
Jenkins build URL and result (sktm.tresult). The result cannot be
sktm.tresult.ERROR.
Args:
pid: The ID of the patch to add the "check" for.
Expand All @@ -678,10 +679,6 @@ def set_patch_check(self, pid, jurl, result):
'description': 'Kernel CI testing'}
if result == sktm.tresult.SUCCESS:
payload['state'] = PW_CHECK_CHOICES['success']
elif result == sktm.tresult.BASELINE_FAILURE:
payload['state'] = PW_CHECK_CHOICES['warning']
payload['description'] = 'Baseline failure found while testing '
'this patch'
else:
payload['state'] = PW_CHECK_CHOICES['fail']
payload['description'] = str(result)
Expand Down Expand Up @@ -989,7 +986,8 @@ def __get_patch_list(self, filt):
def set_patch_check(self, pid, jurl, result):
"""
Add a patch "check" for the specified patch, with the specified
Jenkins build URL and result (sktm.tresult).
Jenkins build URL and result (sktm.tresult). The result cannot be
sktm.tresult.ERROR.
Args:
pid: The ID of the patch to add the "check" for.
Expand Down

0 comments on commit 974ba6c

Please sign in to comment.