Mercurial > bitten > bitten-test
changeset 468:44c2b4ac6157
Add stabilization time parameter to build master. Closes #189. Many thanks to Allen Bierbaum for the patch.
author | cmlenz |
---|---|
date | Tue, 23 Oct 2007 16:23:52 +0000 |
parents | 5c9f34b18236 |
children | beaf9e53424e |
files | bitten/admin.py bitten/master.py bitten/queue.py bitten/templates/bitten_admin_master.cs bitten/tests/admin.py |
diffstat | 5 files changed, 43 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- 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,
--- 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()
--- 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),
--- a/bitten/templates/bitten_admin_master.cs +++ b/bitten/templates/bitten_admin_master.cs @@ -29,13 +29,25 @@ <hr /> <div class="field"> <label> + Time to wait for stabilization: + <input type="text" id="stabilize_wait" name="stabilize_wait" + value="<?cs var:admin.master.stabilize_wait ?>" size="5" /> + </label> + </div> + <p class="hint"> + The time in seconds to wait for the repository to stabilize after a + check-in before initiating a build. + </p> + <hr /> + <div class="field"> + <label> Connection timeout for build slaves: <input type="text" id="slave_timeout" name="slave_timeout" value="<?cs var:admin.master.slave_timeout ?>" size="5" /> </label> </div> <p class="hint"> - 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. </p>