diff --git a/sktm/__init__.py b/sktm/__init__.py index 30b34cc..d4237ee 100644 --- a/sktm/__init__.py +++ b/sktm/__init__.py @@ -20,19 +20,10 @@ import time import sktm.db import sktm.jenkins +import sktm.misc import sktm.patchwork -class tresult(enum.IntEnum): - """Test result""" - SUCCESS = 0 - MERGE_FAILURE = 1 - BUILD_FAILURE = 2 - PUBLISH_FAILURE = 3 - TEST_FAILURE = 4 - BASELINE_FAILURE = 5 - - class jtype(enum.IntEnum): """Job type""" BASELINE = 0 @@ -303,12 +294,12 @@ def check_pending(self): 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: + if bres == sktm.misc.tresult.BASELINE_FAILURE: self.db.update_baseline( self.baserepo, basehash, self.jk.get_base_commitdate(self.jobname, bid), - sktm.tresult.TEST_FAILURE, + sktm.misc.tresult.TEST_FAILURE, bid ) @@ -342,7 +333,7 @@ def check_pending(self): except ValueError: pass - if bres != sktm.tresult.BASELINE_FAILURE: + if bres != sktm.misc.tresult.BASELINE_FAILURE: self.db.commit_patchtest(self.baserepo, basehash, patches, bres, bid, series) else: diff --git a/sktm/db.py b/sktm/db.py index 2b6d4a6..4447c5b 100644 --- a/sktm/db.py +++ b/sktm/db.py @@ -17,7 +17,7 @@ import os import sqlite3 import time -import sktm +import sktm.misc class skt_db(object): @@ -350,7 +350,7 @@ def get_baselineresult(self, baserepo, commithash): if not result: return None - return sktm.tresult(result[0]) + return sktm.misc.tresult(result[0]) def get_stable(self, baserepo): """Get the latest stable commit ID for a baseline Git repo URL. @@ -631,7 +631,7 @@ def dump_baseline_tests(self): # pragma: no cover for (burl, commit, res, buildid) in self.cur.fetchall(): print("repo url:", burl) print("commit id:", commit) - print("result:", sktm.tresult(res).name) + print("result:", sktm.misc.tresult(res).name) print("build id: #", buildid, sep='') print("---") diff --git a/sktm/jenkins.py b/sktm/jenkins.py index 11951fe..1fed91e 100644 --- a/sktm/jenkins.py +++ b/sktm/jenkins.py @@ -18,7 +18,7 @@ import jenkinsapi -import sktm +import sktm.misc class skt_jenkins(object): @@ -138,7 +138,7 @@ def get_result(self, jobname, buildid): logging.info("build_status=%s", bstatus) if bstatus == "SUCCESS": - return sktm.tresult.SUCCESS + return sktm.misc.tresult.SUCCESS if not build.has_resultset(): raise Exception("No results for build %d (%s)" % @@ -149,9 +149,9 @@ def get_result(self, jobname, buildid): ["PASSED", "FIXED"]): if self.get_baseretcode(jobname, buildid) != 0: logging.warning("baseline failure found during patch testing") - return sktm.tresult.BASELINE_FAILURE + return sktm.misc.tresult.BASELINE_FAILURE - return sktm.tresult.SUCCESS + return sktm.misc.tresult.SUCCESS for (key, val) in build.get_resultset().iteritems(): if not key.startswith("skt."): @@ -160,14 +160,14 @@ def get_result(self, jobname, buildid): logging.debug("key=%s; value=%s", key, val.status) if val.status == "FAILED" or val.status == "REGRESSION": if key == "skt.cmd_merge": - return sktm.tresult.MERGE_FAILURE + return sktm.misc.tresult.MERGE_FAILURE elif key == "skt.cmd_build": - return sktm.tresult.BUILD_FAILURE + return sktm.misc.tresult.BUILD_FAILURE elif key == "skt.cmd_run": - return sktm.tresult.TEST_FAILURE + return sktm.misc.tresult.TEST_FAILURE logging.warning("Unknown status. marking as test failure") - return sktm.tresult.TEST_FAILURE + return sktm.misc.tresult.TEST_FAILURE # FIXME Clarify/fix argument names def build(self, jobname, baserepo=None, ref=None, baseconfig=None, diff --git a/sktm/misc.py b/sktm/misc.py new file mode 100644 index 0000000..c4fc7fd --- /dev/null +++ b/sktm/misc.py @@ -0,0 +1,25 @@ +# Copyright (c) 2017-2018 Red Hat, Inc. All rights reserved. This copyrighted +# material is made available to anyone wishing to use, modify, copy, or +# redistribute it subject to the terms and conditions of the GNU General +# Public License v.2 or later. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +import enum + + +class tresult(enum.IntEnum): + """Test result""" + SUCCESS = 0 + MERGE_FAILURE = 1 + BUILD_FAILURE = 2 + PUBLISH_FAILURE = 3 + TEST_FAILURE = 4 + BASELINE_FAILURE = 5 diff --git a/sktm/patchwork.py b/sktm/patchwork.py index 1ef9a75..718d23a 100644 --- a/sktm/patchwork.py +++ b/sktm/patchwork.py @@ -24,7 +24,7 @@ import re import urllib import xmlrpclib -import sktm +import sktm.misc class ObjectSummary(object): @@ -588,12 +588,12 @@ 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.misc.tresult). Args: pid: The ID of the patch to add the "check" for. jurl: Jenkins build URL for the "check" to reference. - result: Test result (sktm.tresult) to feature in the "check" + result: Test result (sktm.misc.tresult) to feature in the "check" state. """ if self.apikey is None: @@ -605,9 +605,9 @@ def set_patch_check(self, pid, jurl, result): 'target_url': jurl, 'context': 'skt', 'description': 'skt boot test'} - if result == sktm.tresult.SUCCESS: + if result == sktm.misc.tresult.SUCCESS: payload['state'] = int(pwresult.SUCCESS) - elif result == sktm.tresult.BASELINE_FAILURE: + elif result == sktm.misc.tresult.BASELINE_FAILURE: payload['state'] = int(pwresult.WARNING) payload['description'] = 'Baseline failure found while testing ' 'this patch' @@ -1000,12 +1000,12 @@ def get_emails(self, pid): 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.misc.tresult). Args: pid: The ID of the patch to add the "check" for. jurl: Jenkins build URL for the "check" to reference. - result: Test result (sktm.tresult) to feature in the "check" + result: Test result (sktm.misc.tresult) to feature in the "check" state. """ # TODO: Implement this for xmlrpc