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

Commit

Permalink
merge default->production
Browse files Browse the repository at this point in the history
--HG--
branch : production-0.8
  • Loading branch information
escapewindow committed Jun 4, 2012
2 parents da773c3 + 55838f1 commit 6c773d8
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 11 deletions.
7 changes: 3 additions & 4 deletions misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@
from buildbotcustom.status.generators import buildTryChangeMessage
from buildbotcustom.env import MozillaEnvironments
from buildbotcustom.misc_scheduler import tryChooser, buildIDSchedFunc, \
buildUIDSchedFunc, lastGoodFunc
from buildbotcustom.status.log_handlers import SubprocessLogHandler
from build.paths import getRealpath
buildUIDSchedFunc, lastGoodFunc, lastRevFunc

# This file contains misc. helper function that don't make sense to put in
# other files. For example, functions that are called in a master.cfg
Expand Down Expand Up @@ -873,8 +871,9 @@ def generateBranchObjects(config, name, secrets=None):

if len(periodicPgoBuilders) > 0:
pgo_scheduler = makePropertiesScheduler(
Nightly,
SpecificNightly,
[buildIDSchedFunc, buildUIDSchedFunc])(
ssFunc=lastRevFunc(config['repo_path'], triggerBuildIfNoChanges=False),
name="%s pgo" % name,
branch=config['repo_path'],
builderNames=periodicPgoBuilders,
Expand Down
28 changes: 28 additions & 0 deletions misc_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,3 +314,31 @@ def ssFunc(scheduler, t):
rev = later_rev
return SourceStamp(branch=scheduler.branch, revision=rev)
return ssFunc

def lastRevFunc(branch, triggerBuildIfNoChanges=True):
"""Returns a function that returns the latest revision on branch."""
def ssFunc(scheduler, t):
#### NOTE: called in a thread!
db = scheduler.parent.db

c = lastChange(db, t, branch)
if not c:
return None

rev = c.revision
log.msg("lastChange returned %s" % (rev))

# Find the last revision our scheduler's builders have built. This can
# include forced builds.
last_built_rev = getLastBuiltRevision(db, t, branch,
scheduler.builderNames)
log.msg("lastBuiltRevision was %s" % last_built_rev)

if last_built_rev is not None:
# Make sure that rev is newer than the last revision we built.
later_rev = getLatestRev(db, t, branch, rev, last_built_rev)
if later_rev == last_built_rev and not triggerBuildIfNoChanges:
log.msg("lastGoodRev: Skipping %s since we've already built it" % rev)
return None
return SourceStamp(branch=scheduler.branch, revision=rev)
return ssFunc
8 changes: 2 additions & 6 deletions process/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -7137,9 +7137,7 @@ def addSetupSteps(self):
name='cleanup device',
workdir='.',
description="Cleanup Device",
command=['python', '/builds/sut_tools/cleanup.py',
WithProperties("%(sut_ip)s"),
],
command=['python', '/builds/sut_tools/cleanup.py'],
haltOnFailure=True)
)
self.addStep(ShellCommand(
Expand Down Expand Up @@ -7506,9 +7504,7 @@ def addCleanupSteps(self):
name='cleanup device',
workdir=self.workdirBase,
description="Cleanup Device",
command=['python', '/builds/sut_tools/cleanup.py',
WithProperties("%(sut_ip)s"),
],
command=['python', '/builds/sut_tools/cleanup.py'],
env=self.env,
haltOnFailure=True)
)
Expand Down
29 changes: 28 additions & 1 deletion test/test_misc_scheduler_nightly.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from buildbot.changes.changes import Change

from buildbotcustom.misc_scheduler import lastChange, lastGoodRev, \
getLatestRev, getLastBuiltRevision, lastGoodFunc
getLatestRev, getLastBuiltRevision, lastGoodFunc, lastRevFunc
from buildbotcustom.scheduler import SpecificNightly

import mock
Expand Down Expand Up @@ -177,6 +177,33 @@ def test_lastGoodFunc(self):
ss = self.dbc.runInteractionNow(lambda t: ssFunc(self.s, t))
self.assertEquals(ss, None)

def test_lastRevFunc(self):
createTestData(self.dbc)
self.s.builderNames = ['builder1']

# Check that ssFunc returns something for both branches
ssFunc = lastRevFunc('b1')
ss = self.dbc.runInteractionNow(lambda t: ssFunc(self.s, t))
self.assertEquals(ss.revision, 'r1')

ssFunc = lastRevFunc('b2')
ss = self.dbc.runInteractionNow(lambda t: ssFunc(self.s, t))
self.assertEquals(ss.revision, 'r234567890')

# Check that ssFunc returns None if triggerBuildIfNoChanges=False
# and we already built the revision
ssFunc = lastRevFunc('b1', triggerBuildIfNoChanges=False)
ss = self.dbc.runInteractionNow(lambda t: ssFunc(self.s, t))
self.assertEquals(ss, None)

# Check that ssFunc returns the later revision if we already built something old
c1 = Change(who='me!', branch='b1', revision='r345', files=[], comments='really important', when=2, revlink='from poller')
self.dbc.addChangeToDatabase(c1)
ssFunc = lastRevFunc('b1', triggerBuildIfNoChanges=False)
ss = self.dbc.runInteractionNow(lambda t: ssFunc(self.s, t))
self.assertEquals(ss.revision, 'r345')


class TestSpecificNightlyScheduler(unittest.TestCase):
basedir = "test_misc_scheduler_nightly_scheduler"
def setUp(self):
Expand Down

0 comments on commit 6c773d8

Please sign in to comment.