# HG changeset patch # User cmlenz # Date 1193156632 0 # Node ID 44c2b4ac615777fcfa7cb952c5ec350c2bca1e33 # Parent 5c9f34b18236df3c84ff8b35bdd2631b3e36f858 Add stabilization time parameter to build master. Closes #189. Many thanks to Allen Bierbaum for the patch. diff --git a/bitten/admin.py b/bitten/admin.py --- a/bitten/admin.py +++ b/bitten/admin.py @@ -47,6 +47,7 @@ req.hdf['admin.master'] = { 'build_all': master.build_all, 'adjust_timestamps': master.adjust_timestamps, + 'stabilize_wait': master.stabilize_wait, 'slave_timeout': master.slave_timeout, } add_stylesheet(req, 'bitten/admin.css') @@ -69,6 +70,11 @@ adjust_timestamps and 'yes' or 'no') changed = True + stabilize_wait = int(req.args.get('stabilize_wait', 0)) + if stabilize_wait != master.stabilize_wait: + self.config['bitten'].set('stabilize_wait', str(stabilize_wait)) + changed = True + slave_timeout = int(req.args.get('slave_timeout', 0)) if slave_timeout != master.slave_timeout: self.config['bitten'].set('slave_timeout', str(slave_timeout)) @@ -145,16 +151,16 @@ if 'add' in req.args: # Add target platform platform = self._create_platform(req, config) req.redirect(req.abs_href.admin(cat, page, config.name)) - + elif 'remove' in req.args: # Remove selected platforms self._remove_platforms(req) req.redirect(req.abs_href.admin(cat, page, config.name)) - + elif 'save' in req.args: # Save this build config self._update_config(req, config) - + req.redirect(req.abs_href.admin(cat, page)) - + # Prepare template variables data['config'] = { 'name': config.name, 'label': config.label or config.name, diff --git a/bitten/master.py b/bitten/master.py --- a/bitten/master.py +++ b/bitten/master.py @@ -44,6 +44,12 @@ build_all = BoolOption('bitten', 'build_all', False, doc= """Whether to request builds of older revisions even if a younger revision has already been built.""") + + stabilize_wait = IntOption('bitten', 'stabilize_wait', 0, doc= + """The time in seconds to wait for the repository to stabilize before + queuing up a new build. This allows time for developers to check in + a group of related changes back to back without spawning multiple + builds.""") slave_timeout = IntOption('bitten', 'slave_timeout', 3600, doc= """The time in seconds after which a build is cancelled if the slave @@ -89,7 +95,8 @@ raise HTTPNotFound('No such collection') def _process_build_creation(self, req): - queue = BuildQueue(self.env, build_all=self.build_all, + queue = BuildQueue(self.env, build_all=self.build_all, + stabilize_wait=self.stabilize_wait, timeout=self.slave_timeout) queue.populate() diff --git a/bitten/queue.py b/bitten/queue.py --- a/bitten/queue.py +++ b/bitten/queue.py @@ -97,11 +97,13 @@ repository revisions that need to be built. """ - def __init__(self, env, build_all=False, timeout=0): + def __init__(self, env, build_all=False, stabilize_wait=0, timeout=0): """Create the build queue. :param env: the Trac environment :param build_all: whether older revisions should be built + :param stabilize_wait: The time in seconds to wait before considering + the repository stable to create a build in the queue. :param timeout: the time in seconds after which an in-progress build should be considered orphaned, and reset to pending state @@ -109,6 +111,7 @@ self.env = env self.log = env.log self.build_all = build_all + self.stabilize_wait = stabilize_wait self.timeout = timeout # Build scheduling @@ -236,6 +239,13 @@ if isinstance(rev_time, datetime): # Trac>=0.11 from trac.util.datefmt import to_timestamp rev_time = to_timestamp(rev_time) + age = int(time.time()) - rev_time + if self.stabilize_wait and age < self.stabilize_wait: + self.log.info('Delaying build of revision %s until %s ' + 'seconds pass. Current age is: %s ' + 'seconds' % (rev, self.stabilize_wait, + age)) + continue build = Build(self.env, config=config.name, platform=platform.id, rev=str(rev), diff --git a/bitten/templates/bitten_admin_master.cs b/bitten/templates/bitten_admin_master.cs --- a/bitten/templates/bitten_admin_master.cs +++ b/bitten/templates/bitten_admin_master.cs @@ -29,13 +29,25 @@
+
+

+ The time in seconds to wait for the repository to stabilize after a + check-in before initiating a build. +

+
+
+

- The timeout in milliseconds after which a build started by a slave is + The timeout in seconds after which a build started by a slave is considered aborted, in case there has been no activity from that slave in that time.

diff --git a/bitten/tests/admin.py b/bitten/tests/admin.py --- a/bitten/tests/admin.py +++ b/bitten/tests/admin.py @@ -80,6 +80,7 @@ assert 'admin.master' in data self.assertEqual({ 'slave_timeout': 3600, + 'stabilize_wait': 0, 'adjust_timestamps': False, 'build_all': False, }, data['admin.master'])