Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/8/try-integration-test' (PR #1026)
Browse files Browse the repository at this point in the history
+autopep8
  • Loading branch information
djmitche committed Dec 25, 2013
2 parents fc89020 + f12562b commit 9d835e3
Show file tree
Hide file tree
Showing 8 changed files with 423 additions and 28 deletions.
63 changes: 37 additions & 26 deletions master/buildbot/clients/tryclient.py
Expand Up @@ -39,6 +39,10 @@
from buildbot.util.eventual import fireEventually


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


class SourceStampExtractor:

def __init__(self, treetop, branch, repository):
Expand All @@ -47,7 +51,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 @@ -110,7 +114,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 @@ -150,7 +154,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 @@ -238,15 +242,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 @@ -261,7 +265,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 @@ -350,7 +354,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 @@ -398,7 +402,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 @@ -460,7 +464,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 @@ -505,18 +509,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 @@ -536,7 +541,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 @@ -587,7 +592,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 @@ -610,7 +615,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 @@ -653,7 +658,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 @@ -682,7 +687,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 @@ -825,7 +833,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 @@ -834,7 +842,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 @@ -857,32 +865,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 @@ -899,6 +908,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 @@ -442,6 +442,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 @@ -248,7 +248,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='',
sourcestampsetid=sourcestampsetid)
# note: no way to specify patch subdir - #1769

Expand Down Expand Up @@ -282,14 +282,14 @@ def __init__(self, name, builderNames, port, userpass,
properties=properties)
self.port = port
self.userpass = userpass
self.registrations = []

def startService(self):
TryBase.startService(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 9d835e3

Please sign in to comment.