Skip to content
This repository was archived by the owner on Sep 23, 2024. It is now read-only.
Merged
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
47 changes: 15 additions & 32 deletions sktm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@

import sktm.db
import sktm.jenkins
import sktm.misc
import sktm.patchwork
import sktm.jenkins


def join_with_slash(base, *suffix):
Expand All @@ -43,15 +45,6 @@ def join_with_slash(base, *suffix):
return '/'.join(parts) + ending


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


class jtype(enum.IntEnum):
"""Job type"""
BASELINE = 0
Expand All @@ -60,16 +53,11 @@ 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, patch_filter, makeopts=None):
def __init__(self, jenkins_project, dbpath, patch_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.
dbpath: Path to the job status database file.
patch_filter: The name of a patch series filter program.
The program should accept a list of mbox URLs
Expand All @@ -87,10 +75,7 @@ def __init__(self, jenkinsurl, jenkinslogin, jenkinspassword,
# Database instance
self.db = sktm.db.SktDb(os.path.expanduser(dbpath))
# Jenkins interface instance
self.jk = sktm.jenkins.skt_jenkins(jenkinsurl, jenkinslogin,
jenkinspassword)
# Jenkins project name
self.jobname = jenkinsjobname
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A comment on the commit message: Could you update the message to say sktm.jenkins.JenkinsProject instead of sktm.jenkins.Project? Thank you.

self.jk = jenkins_project
# Patchset filter program
self.patch_filter = patch_filter
# Extra arguments to pass to "make"
Expand Down Expand Up @@ -198,8 +183,7 @@ def add_pw(self, baseurl, pname, lpatch=None, apikey=None, skip=[]):
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 @@ -329,38 +313,37 @@ def check_patchwork(self):
self.db.set_patchset_pending(cpw.baseurl, cpw.project_id,
series.get_patch_info_list())
# Submit and remember a Jenkins build for the series
url_list = series.get_patch_url_list()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, could you please use sktm.jenkins.JenkinsProject in the commit message?

self.pj.append((sktm.jtype.PATCHWORK,
self.jk.build(
self.jobname,
baserepo=self.baserepo,
ref=stablecommit,
baseconfig=self.cfgurl,
message_id=series.message_id,
subject=series.subject,
emails=series.email_addr_set,
patchwork=series.get_patch_url_list(),
patch_url_list=url_list,
makeopts=self.makeopts),
cpw))
logging.info("submitted message ID: %s", series.message_id)
logging.info("submitted subject: %s", series.subject)
logging.info("submitted emails: %s", series.email_addr_set)
logging.info("submitted series: %s",
series.get_patch_url_list())
logging.info("submitted series: %s", url_list)

def check_pending(self):
for (pjt, bid, cpw) in self.pj:
if self.jk.is_build_complete(self.jobname, bid):
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)
if self.jk.is_build_complete(bid):
bres = self.jk.get_result(bid)
rurl = self.jk.get_result_url(bid)
basehash = self.jk.get_base_hash(bid)
basedate = self.jk.get_base_commitdate(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:
if bres == sktm.misc.TestResult.ERROR:
logging.warning("job completed with an error, ignoring")
continue

Expand All @@ -375,7 +358,7 @@ def check_pending(self):
elif pjt == sktm.jtype.PATCHWORK:
patches = list()

patch_url_list = self.jk.get_patchwork(self.jobname, bid)
patch_url_list = self.jk.get_patch_url_list(bid)
for patch_url in patch_url_list:
patches.append(self.get_patch_info_from_url(cpw,
patch_url))
Expand Down
10 changes: 5 additions & 5 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 SktDb(object):
Expand Down Expand Up @@ -321,7 +321,7 @@ def __get_baselineresult(self, baserepo, commithash):
if not result:
return None

return sktm.tresult(result[0])
return sktm.misc.TestResult(result[0])

def get_stable(self, baserepo):
"""Get the latest stable commit ID for a baseline Git repo URL.
Expand Down Expand Up @@ -434,8 +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 (an sktm.tresult).
Cannot be sktm.tresult.ERROR.
result: Result ID of the test run (an sktm.misc.TestResult).
Cannot be sktm.misc.TestResult.ERROR.
build_id: The build ID of the test run.

"""
Expand Down Expand Up @@ -550,7 +550,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.TestResult(res).name)
print("build id: #", buildid, sep='')
print("---")

Expand Down
9 changes: 7 additions & 2 deletions sktm/executable.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 @@ -129,8 +130,12 @@ def main():
cfg = load_config(args)
logging.debug("cfg=%s", cfg)

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

sw = sktm.watcher(jenkins_project, cfg.get("db"),
cfg.get("filter"), cfg.get("makeopts"))

args.func(sw, cfg)
Expand Down
Loading