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

Commit

Permalink
Merge 6fd5707 into 30305f4
Browse files Browse the repository at this point in the history
  • Loading branch information
agustinhenze committed Nov 1, 2018
2 parents 30305f4 + 6fd5707 commit 5fb8671
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
7 changes: 5 additions & 2 deletions sktm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,22 @@ def __init__(self, jenkins_project, dbpath, patch_filter, makeopts=None):
self.baserepo = None
self.baseref = None
self.cfgurl = None
self.force_enqueue_job = False

def set_baseline(self, repo, ref="master", cfgurl=None):
def set_baseline(self, repo, ref="master", cfgurl=None, force=False):
"""
Set baseline parameters.
Args:
repo: Git repository URL.
ref: Git reference to test.
cfgurl: Kernel configuration URL.
force: Force enqueue the job
"""
self.baserepo = repo
self.baseref = ref
self.cfgurl = cfgurl
self.force_enqueue_job = force

def cleanup(self):
for (pjt, bid, _) in self.pj:
Expand Down Expand Up @@ -155,7 +158,7 @@ def enqueue_baseline_job(self):
"""Enqueue a build for baseline if it was not checked already"""
current_commit = self.get_commit_hash(self.baserepo, self.baseref)
last_commit_checked = self.db.get_last_checked_baseline(self.baserepo)
if current_commit != last_commit_checked:
if self.force_enqueue_job or current_commit != last_commit_checked:
self.pj.append((JobType.BASELINE,
self.jk.build(baserepo=self.baserepo,
ref=self.baseref,
Expand Down
5 changes: 4 additions & 1 deletion sktm/executable.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ def setup_parser():
parser_baseline = subparsers.add_parser("baseline")
parser_baseline.add_argument("repo", type=str, help="Base repo URL")
parser_baseline.add_argument("ref", type=str, help="Base repo ref to test")
parser_baseline.add_argument("--force", action='store_true',
help="Force enqueue the job")
parser_baseline.set_defaults(func=cmd_baseline)

parser_patchwork = subparsers.add_parser("patchwork")
Expand Down Expand Up @@ -150,7 +152,8 @@ def setup_logging(verbose):

def cmd_baseline(sw, cfg):
logging.info("Enqueue baseline: %s [%s]", cfg.get("repo"), cfg.get("ref"))
sw.set_baseline(cfg.get("repo"), cfg.get("ref"), cfg.get("cfgurl"))
sw.set_baseline(cfg.get("repo"), cfg.get("ref"), cfg.get("cfgurl"),
cfg.get("force"))
sw.enqueue_baseline_job()


Expand Down
18 changes: 17 additions & 1 deletion tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ def test_get_commit_hash(self):
def test_check_baseline(self, mock_logging):
"""
Ensure enqueue_baseline_job only enqueues a new job if it wasn't
checked already.
checked already and check if the job is enqueued when force option is
set.
"""
baserepo = 'git://example.com/repo'
baseref = 'master'
Expand Down Expand Up @@ -119,3 +120,18 @@ def test_check_baseline(self, mock_logging):
self.watcher_obj.enqueue_baseline_job()
mock_logging.assert_called_with('Baseline %s@%s already tested',
baserepo, baseref)

self.watcher_obj.jk.build.reset_mock()
self.watcher_obj.set_baseline(
repo=baserepo,
ref=baseref,
cfgurl=cfgurl,
force=True,
)
self.watcher_obj.enqueue_baseline_job()
self.watcher_obj.jk.build.assert_called_with(
baseconfig=cfgurl,
baserepo=baserepo,
makeopts=None,
ref=baseref,
)

0 comments on commit 5fb8671

Please sign in to comment.