Skip to content
This repository was archived by the owner on Sep 23, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions sktm.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import logging
import os
import sktm
import sktm.jenkins


def setup_parser():
Expand Down Expand Up @@ -122,9 +123,12 @@ def load_config(args):
setup_logging(args.verbose)
cfg = load_config(args)
logging.debug("cfg=%s", cfg)
jenkins_project = sktm.jenkins.JenkinsProject(cfg.get("jjname"),
cfg.get("jurl"),
cfg.get("jlogin"),
cfg.get("jpass"))

sw = sktm.watcher(cfg.get("jurl"), cfg.get("jlogin"), cfg.get("jpass"),
cfg.get("jjname"), cfg.get("db"),
sw = sktm.watcher(jenkins_project, cfg.get("db"),
cfg.get("filter"), cfg.get("makeopts"))

args.func(sw, cfg)
Expand Down
60 changes: 22 additions & 38 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 All @@ -41,16 +32,13 @@ class jtype(enum.IntEnum):

# TODO This is no longer just a watcher. Rename/refactor/describe accordingly.
class watcher(object):
def __init__(self, jenkinsurl, jenkinslogin, jenkinspassword,
jenkinsjobname, dbpath, filter, makeopts=None):
def __init__(self, jenkins_project, dbpath, filter, makeopts=None):
"""
Initialize a "watcher".

Args:
jenkinsurl: Jenkins instance URL.
jenkinslogin: Jenkins user name.
jenkinspassword: Jenkins user password.
jenkinsjobname: Name of the Jenkins job to trigger and watch.
jenkins_project: Interface to the Jenkins project to trigger
and watch (sktm.jenkins.JenkinsProject).
dbpath: Path to the job status database file.
filter: The name of a patchset filter program.
The program should accept a list of mbox URLs
Expand All @@ -65,13 +53,10 @@ def __init__(self, jenkinsurl, jenkinslogin, jenkinspassword,
building.
"""
# FIXME Clarify/fix member variable names
# Jenkins project interface instance
self.jk = jenkins_project
# Database instance
self.db = sktm.db.skt_db(os.path.expanduser(dbpath))
# Jenkins interface instance
self.jk = sktm.jenkins.skt_jenkins(jenkinsurl, jenkinslogin,
jenkinspassword)
# Jenkins project name
self.jobname = jenkinsjobname
# Patchset filter program
self.filter = filter
# Extra arguments to pass to "make"
Expand Down Expand Up @@ -168,8 +153,7 @@ def add_pw(self, baseurl, pname, lpatch=None, apikey=None):
def check_baseline(self):
"""Submit a build for baseline"""
self.pj.append((sktm.jtype.BASELINE,
self.jk.build(self.jobname,
baserepo=self.baserepo,
self.jk.build(baserepo=self.baserepo,
ref=self.baseref,
baseconfig=self.cfgurl,
makeopts=self.makeopts),
Expand Down Expand Up @@ -262,16 +246,16 @@ def check_patchwork(self):
self.db.set_patchset_pending(cpw.baseurl, cpw.projectid,
patchset.get_patch_info_list())
# Submit and remember a Jenkins build for the patchset
url_list = patchset.get_patch_url_list()
self.pj.append((sktm.jtype.PATCHWORK,
self.jk.build(
self.jobname,
baserepo=self.baserepo,
ref=stablecommit,
baseconfig=self.cfgurl,
message_id=patchset.message_id,
subject=patchset.subject,
emails=patchset.email_addr_set,
patchwork=patchset.get_patch_url_list(),
patch_url_list=url_list,
makeopts=self.makeopts),
cpw))
logging.info("submitted message ID: %s", patchset.message_id)
Expand All @@ -282,38 +266,38 @@ def check_patchwork(self):

def check_pending(self):
for (pjt, bid, cpw) in self.pj:
if self.jk.is_build_complete(self.jobname, bid):
if self.jk.is_build_complete(bid):
logging.info("job completed: jjid=%d; type=%d", bid, pjt)
self.pj.remove((pjt, bid, cpw))
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),
self.jk.get_base_hash(bid),
self.jk.get_base_commitdate(bid),
self.jk.get_result(bid),
bid
)
elif pjt == sktm.jtype.PATCHWORK:
patches = list()
slist = list()
series = None
bres = self.jk.get_result(self.jobname, bid)
rurl = self.jk.get_result_url(self.jobname, bid)
bres = self.jk.get_result(bid)
rurl = self.jk.get_result_url(bid)
logging.info("result=%s", bres)
logging.info("url=%s", rurl)
basehash = self.jk.get_base_hash(self.jobname, bid)
basehash = self.jk.get_base_hash(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,
self.jk.get_base_commitdate(bid),
sktm.misc.tresult.TEST_FAILURE,
bid
)

patchset = self.jk.get_patchwork(self.jobname, bid)
for purl in patchset:
patch_url_list = self.jk.get_patch_url_list(bid)
for purl in patch_url_list:
match = re.match(r"(.*)/patch/(\d+)$", purl)
if match:
baseurl = match.group(1)
Expand Down Expand Up @@ -342,7 +326,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
Loading