Skip to content

Commit

Permalink
Move tresult into sktm.misc
Browse files Browse the repository at this point in the history
Move sktm.tresult to sktm.misc.tresult to fix composition, so that
modules lower in the hierarchy (e.g. sktm.jenkins) do not have to import
the module above (i.e. sktm).

Fixes cki-project#6
  • Loading branch information
spbnick committed Jun 5, 2018
1 parent 47a0572 commit b1ca0a4
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 31 deletions.
17 changes: 4 additions & 13 deletions sktm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
)

Expand Down Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions sktm/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import os
import sqlite3
import time
import sktm
import sktm.misc


class skt_db(object):
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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("---")

Expand Down
16 changes: 8 additions & 8 deletions sktm/jenkins.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import jenkinsapi

import sktm
import sktm.misc


class skt_jenkins(object):
Expand Down Expand Up @@ -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)" %
Expand All @@ -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."):
Expand All @@ -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,
Expand Down
25 changes: 25 additions & 0 deletions sktm/misc.py
Original file line number Diff line number Diff line change
@@ -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
14 changes: 7 additions & 7 deletions sktm/patchwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import re
import urllib
import xmlrpclib
import sktm
import sktm.misc


class ObjectSummary(object):
Expand Down Expand Up @@ -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:
Expand All @@ -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'
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b1ca0a4

Please sign in to comment.