Skip to content

Commit

Permalink
Merge branch 'mtrlogobserver' of git://github.com/knielsen/buildbot
Browse files Browse the repository at this point in the history
  • Loading branch information
Dustin J. Mitchell committed Aug 6, 2009
2 parents 549ce4a + 00b2fac commit 16e657e
Show file tree
Hide file tree
Showing 7 changed files with 717 additions and 9 deletions.
8 changes: 8 additions & 0 deletions NEWS
@@ -1,5 +1,13 @@
User visible changes in Buildbot. -*- outline -*-

** New buildstep `MTR'

A new class buildbot.process.mtrlogobserver.MTR was added. This buildstep is
used to run test suites using mysql-test-run. It parses the stdio output for
test failures and summarises them on the waterfall page. It also makes server
error logs available for debugging failures, and optionally inserts
information about test runs and test failures into an external database.

* Release 0.7.11p (July 16, 2009)

Fixes a few test failures in 0.7.11, and gives a default value for branchType
Expand Down
41 changes: 34 additions & 7 deletions buildbot/process/buildstep.py
Expand Up @@ -256,6 +256,7 @@ class LoggedRemoteCommand(RemoteCommand):

def __init__(self, *args, **kwargs):
self.logs = {}
self.delayedLogs = {}
self._closeWhenFinished = {}
RemoteCommand.__init__(self, *args, **kwargs)

Expand Down Expand Up @@ -290,9 +291,15 @@ def useLog(self, loog, closeWhenFinished=False, logfileName=None):
if not logfileName:
logfileName = loog.getName()
assert logfileName not in self.logs
assert logfileName not in self.delayedLogs
self.logs[logfileName] = loog
self._closeWhenFinished[logfileName] = closeWhenFinished

def useLogDelayed(self, logfileName, activateCallBack, closeWhenFinished=False):
assert logfileName not in self.logs
assert logfileName not in self.delayedLogs
self.delayedLogs[logfileName] = (activateCallBack, closeWhenFinished)

def start(self):
log.msg("LoggedRemoteCommand.start")
if 'stdio' not in self.logs:
Expand All @@ -313,6 +320,14 @@ def addHeader(self, data):
self.logs['stdio'].addHeader(data)

def addToLog(self, logname, data):
# Activate delayed logs on first data.
if logname in self.delayedLogs:
(activateCallBack, closeWhenFinished) = self.delayedLogs[logname]
del self.delayedLogs[logname]
loog = activateCallBack(self)
self.logs[logname] = loog
self._closeWhenFinished[logname] = closeWhenFinished

if logname in self.logs:
self.logs[logname].addStdout(data)
else:
Expand Down Expand Up @@ -964,15 +979,17 @@ class LoggingBuildStep(BuildStep):
progressMetrics = ('output',)
logfiles = {}

parms = BuildStep.parms + ['logfiles']
parms = BuildStep.parms + ['logfiles', 'lazylogfiles']

def __init__(self, logfiles={}, *args, **kwargs):
def __init__(self, logfiles={}, lazylogfiles=False, *args, **kwargs):
BuildStep.__init__(self, *args, **kwargs)
self.addFactoryArguments(logfiles=logfiles)
self.addFactoryArguments(logfiles=logfiles,
lazylogfiles=lazylogfiles)
# merge a class-level 'logfiles' attribute with one passed in as an
# argument
self.logfiles = self.logfiles.copy()
self.logfiles.update(logfiles)
self.lazylogfiles = lazylogfiles
self.addLogObserver('stdio', OutputProgressObserver("output"))

def describe(self, done=False):
Expand Down Expand Up @@ -1015,10 +1032,20 @@ def setupLogfiles(self, cmd, logfiles):
"""Set up any additional logfiles= logs.
"""
for logname,remotefilename in logfiles.items():
# tell the BuildStepStatus to add a LogFile
newlog = self.addLog(logname)
# and tell the LoggedRemoteCommand to feed it
cmd.useLog(newlog, True)
if self.lazylogfiles:
# Ask LoggedRemoteCommand to watch a logfile, but only add
# it when/if we see any data.
#
# The dummy default argument local_logname is a work-around for
# Python name binding; default values are bound by value, but
# captured variables in the body are bound by name.
callback = lambda cmd_arg, local_logname=logname: self.addLog(local_logname)
cmd.useLogDelayed(logname, callback, True)
else:
# tell the BuildStepStatus to add a LogFile
newlog = self.addLog(logname)
# and tell the LoggedRemoteCommand to feed it
cmd.useLog(newlog, True)

def interrupt(self, reason):
# TODO: consider adding an INTERRUPTED or STOPPED status to use
Expand Down

0 comments on commit 16e657e

Please sign in to comment.