Skip to content

Commit

Permalink
Merge branch 'master' into nine
Browse files Browse the repository at this point in the history
Conflicts:
	master/buildbot/clients/tryclient.py
	master/buildbot/schedulers/trysched.py
	master/buildbot/test/unit/test_util.py
	master/buildbot/util/__init__.py
  • Loading branch information
djmitche committed Dec 25, 2013
2 parents 303a23d + 9d835e3 commit c8710ec
Show file tree
Hide file tree
Showing 10 changed files with 427 additions and 30 deletions.
3 changes: 2 additions & 1 deletion master/buildbot/changes/gerritchangesource.py
Expand Up @@ -162,7 +162,8 @@ def addChangeFromEvent(self, properties, event):
'repository': u"ssh://%s@%s:%s/%s" % (
self.username, self.gerritserver,
self.gerritport, event_change["project"]),
'branch': event_change["branch"],
'branch': "%s/%s" % (event_change["branch"],
event_change['number']),
'revision': event["patchSet"]["revision"],
'revlink': event_change["url"],
'comments': event_change["subject"],
Expand Down
64 changes: 38 additions & 26 deletions master/buildbot/clients/tryclient.py
Expand Up @@ -44,6 +44,11 @@ def __init__(self, branch, revision, patch, repository=''):
self.branch = branch
self.revision = revision
self.patch = patch
self.repository = repository


def output(*msg):
print ' '.join(map(str, msg))


class SourceStampExtractor:
Expand All @@ -54,7 +59,7 @@ def __init__(self, treetop, branch, repository):
self.branch = branch
exes = which(self.vcexe)
if not exes:
print "Could not find executable '%s'." % self.vcexe
output("Could not find executable '%s'." % self.vcexe)
sys.exit(1)
self.exe = exes[0]

Expand Down Expand Up @@ -117,7 +122,7 @@ def getPatch(self, res):
# branch. A bare 'cvs diff' will tell you about the changes
# relative to your checked-out versions, but I know of no way to
# find out what those checked-out versions are.
print "Sorry, CVS 'try' builds don't work with branches"
output("Sorry, CVS 'try' builds don't work with branches")
sys.exit(1)
args = ['-q', 'diff', '-u', '-D', self.baserev]
d = self.dovc(args)
Expand Down Expand Up @@ -157,7 +162,7 @@ def parseStatus(self, res):
if m:
self.baserev = int(m.group(1))
return
print "Could not find 'Status against revision' in SVN output: %s" % res
output("Could not find 'Status against revision' in SVN output: %s" % res)
sys.exit(1)

def getPatch(self, res):
Expand Down Expand Up @@ -245,15 +250,15 @@ def parseStatus(self, res):
self.baserev = m.group(1)
return

print "Could not find change number in output: %s" % res
output("Could not find change number in output: %s" % res)
sys.exit(1)

def readPatch(self, res, patchlevel):
#
# extract the actual patch from "res"
#
if not self.branch:
print "you must specify a branch"
output("you must specify a branch")
sys.exit(1)
mpatch = ""
found = False
Expand All @@ -268,7 +273,7 @@ def readPatch(self, res, patchlevel):
mpatch += line
mpatch += "\n"
if not found:
print "could not parse patch file"
output("could not parse patch file")
sys.exit(1)
self.patch = (patchlevel, mpatch)

Expand Down Expand Up @@ -357,7 +362,7 @@ def parseStatus(self, res):
d = self.readConfig()
d.addCallback(self.parseTrackingBranch)
return d
print "Could not find current GIT branch: %s" % res
output("Could not find current GIT branch: %s" % res)
sys.exit(1)

def getPatch(self, res):
Expand Down Expand Up @@ -405,7 +410,7 @@ def getSourceStamp(vctype, treetop, branch=None, repository=None):
elif vctype == "mtn":
cls = MonotoneExtractor
else:
print "unknown vctype '%s'" % vctype
output("unknown vctype '%s'" % vctype)
sys.exit(1)
return cls(treetop, branch, repository).get()

Expand Down Expand Up @@ -467,7 +472,7 @@ def getTopdir(topfile, start=None):
break # we've hit the root
here = next
toomany -= 1
print ("Unable to find topfile '%s' anywhere from %s upwards"
output("Unable to find topfile '%s' anywhere from %s upwards"
% (topfile, start))
sys.exit(1)

Expand Down Expand Up @@ -512,18 +517,19 @@ def grab(self):
self.d = defer.Deferred()
# wait a second before querying to give the master's maildir watcher
# a chance to see the job
reactor.callLater(1, self.go)
reactor.callLater(0.01, self.go)
return self.d

def go(self, dummy=None):
if self.retryCount == 0:
print "couldn't find matching buildset"
output("couldn't find matching buildset")
sys.exit(1)
self.retryCount -= 1
d = self.status.callRemote("getBuildSets")
d.addCallback(self._gotSets)

def _gotSets(self, buildsets):
print "GOT", buildsets, self.bsid
for bs, bsid in buildsets:
if bsid == self.bsid:
# got it
Expand All @@ -543,7 +549,7 @@ def __init__(self, config):
self.config = config
self.connect = self.getopt('connect')
if self.connect not in ['ssh', 'pb']:
print "you must specify a connect style: ssh or pb"
output("you must specify a connect style: ssh or pb")
sys.exit(1)
self.builderNames = self.getopt('builders')
self.project = self.getopt('project', '')
Expand Down Expand Up @@ -594,7 +600,7 @@ def createJob(self):
if topfile:
treedir = getTopdir(topfile)
else:
print "Must specify topdir or topfile."
output("Must specify topdir or topfile.")
sys.exit(1)
else:
treedir = os.getcwd()
Expand All @@ -617,7 +623,7 @@ def _createJob_1(self, ss):
def fakeDeliverJob(self):
# Display the job to be delivered, but don't perform delivery.
ss = self.sourcestamp
print ("Job:\n\tRepository: %s\n\tProject: %s\n\tBranch: %s\n\t"
output("Job:\n\tRepository: %s\n\tProject: %s\n\tBranch: %s\n\t"
"Revision: %s\n\tBuilders: %s\n%s"
% (ss.repository, self.project, ss.branch,
ss.revision,
Expand Down Expand Up @@ -660,7 +666,7 @@ def deliverJob(self):

def _deliverJob_pb(self, remote):
ss = self.sourcestamp
print "Delivering job; comment=", self.comment
output("Delivering job; comment=", self.comment)

d = remote.callRemote("try",
ss.branch,
Expand Down Expand Up @@ -689,7 +695,10 @@ def getStatus(self):
# getURLForThing() on the BuildSetStatus. To get URLs for
# individual builds would require we wait for the builds to
# start.
print "not waiting for builds to finish"
output("not waiting for builds to finish")
return
if self.connect == "ssh":
output("waiting for builds with ssh is not supported")
return
d = self.running = defer.Deferred()
if self.buildsetStatus:
Expand Down Expand Up @@ -832,7 +841,7 @@ def printStatus(self):
def statusDone(self):
if self.printloop:
self.printloop.stop()
print "All Builds Complete"
output("All Builds Complete")
# TODO: include a URL for all failing builds
names = sorted(self.buildRequests.keys())
happy = True
Expand All @@ -841,7 +850,7 @@ def statusDone(self):
t = "%s: %s" % (n, builder.Results[code])
if text:
t += " (%s)" % " ".join(text)
print t
output(t)
if code != builder.SUCCESS:
happy = False

Expand All @@ -864,32 +873,33 @@ def getAvailableBuilderNames(self):
f = pb.PBClientFactory()
d = f.login(credentials.UsernamePassword(user, passwd))
reactor.connectTCP(tryhost, tryport, f)
d.addCallback(self._getBuilderNames, self._getBuilderNames2)
d.addCallback(self._getBuilderNames)
return d
if self.connect == "ssh":
print "Cannot get available builders over ssh."
output("Cannot get available builders over ssh.")
sys.exit(1)
raise RuntimeError(
"unknown connecttype '%s', should be 'pb'" % self.connect)

def _getBuilderNames(self, remote, output):
def _getBuilderNames(self, remote):
d = remote.callRemote("getAvailableBuilderNames")
d.addCallback(self._getBuilderNames2)
d.addCallback(lambda _: remote.broker.transport.loseConnection())
return d

def _getBuilderNames2(self, buildernames):
print "The following builders are available for the try scheduler: "
output("The following builders are available for the try scheduler: ")
for buildername in buildernames:
print buildername
output(buildername)

def announce(self, message):
if not self.quiet:
print message
output(message)

def run(self):
def run(self, _inTests=False):
# we can't do spawnProcess until we're inside reactor.run(), so get
# funky
print "using '%s' connect method" % self.connect
output("using '%s' connect method" % self.connect)
self.exitcode = 0
d = fireEventually(None)
if bool(self.config.get("get-builder-names")):
Expand All @@ -906,6 +916,8 @@ def run(self):
d.addErrback(self.trapSystemExit)
d.addErrback(log.err)
d.addCallback(self.cleanup)
if _inTests:
return d
d.addCallback(lambda res: reactor.stop())

reactor.run()
Expand Down
6 changes: 6 additions & 0 deletions master/buildbot/db/model.py
Expand Up @@ -650,6 +650,12 @@ def thd(engine):
return db_version == repo_version
return self.db.pool.do_with_engine(thd)

def create(self):
# this is nice and simple, but used only for tests
def thd(engine):
self.metadata.create_all(bind=engine)
return self.db.pool.do_with_engine(thd)

def upgrade(self):

# here, things are a little tricky. If we have a 'version' table, then
Expand Down
4 changes: 2 additions & 2 deletions master/buildbot/schedulers/trysched.py
Expand Up @@ -267,7 +267,7 @@ def perspective_try(self, branch, revision, patch, repository, project,
branch=branch, revision=revision, repository=repository,
project=project, patch_level=patch[0], patch_body=patch[1],
patch_subdir='', patch_author=who or '',
patch_comment=comment or '',
patch_comment=comment or '', codebase='',
) # note: no way to specify patch subdir - #1769

requested_props = Properties()
Expand Down Expand Up @@ -300,6 +300,7 @@ def __init__(self, name, builderNames, port, userpass,
properties=properties)
self.port = port
self.userpass = userpass
self.registrations = []

@defer.inlineCallbacks
def activate(self):
Expand All @@ -308,7 +309,6 @@ def activate(self):
# register each user/passwd with the pbmanager
def factory(mind, username):
return Try_Userpass_Perspective(self, username)
self.registrations = []
for user, passwd in self.userpass:
self.registrations.append(
self.master.pbmanager.register(
Expand Down
1 change: 1 addition & 0 deletions master/buildbot/status/client.py
Expand Up @@ -228,6 +228,7 @@ def remote_subscribe(self, observer, updateInterval=None):
self.observers.append(observer)
s = BuildSubscriber(observer)
self.b.subscribe(s, updateInterval)
observer.notifyOnDisconnect(lambda _: self.b.unsubscribe(s))

def remote_unsubscribe(self, observer):
# TODO: is the observer automatically unsubscribed when the build
Expand Down

0 comments on commit c8710ec

Please sign in to comment.