From c89000f2538b37e0d11f80e3a80da615d322843f Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Sun, 10 Jun 2007 16:42:27 +0000 Subject: [PATCH] A new buildbot plugin, with better reporting from the URL tests - Legacy-Id: 292 --- .../master/ietfdb/buildbot_plugins.py | 80 +++++++++++++++++++ test/buildbot/master/ietfdb/master.cfg | 24 +++--- 2 files changed, 91 insertions(+), 13 deletions(-) create mode 100644 test/buildbot/master/ietfdb/buildbot_plugins.py diff --git a/test/buildbot/master/ietfdb/buildbot_plugins.py b/test/buildbot/master/ietfdb/buildbot_plugins.py new file mode 100644 index 000000000..2c6c28ca9 --- /dev/null +++ b/test/buildbot/master/ietfdb/buildbot_plugins.py @@ -0,0 +1,80 @@ +import re +from buildbot.steps.shell import ShellCommand +from buildbot.status.builder import SUCCESS, FAILURE, WARNINGS + +try: + import cStringIO + StringIO = cStringIO.StringIO +except ImportError: + from StringIO import StringIO + +class DjangoTest(ShellCommand): + name = "django test" + command = ["python", "manage.py", "test"] + description = ["running django test"] + descriptionDone = ["django test"] + flunkOnFailure = False + flunkingIssues = ["exception", "failure"] # any pyflakes lines like this cause FAILURE + + msgtypes = ("exception", "failure", "skipped", "diffs", "ok") + + def createSummary(self, log): + summaries = {} + typelist = {} + counts = {} + def count(m): + if not m in counts: + counts[m] = 0 + counts[m] += 1 + + for type in self.msgtypes: + typelist[type] = set([]) + + first = True + for line in StringIO(log.getText()).readlines(): + if re.search("^Traceback: ", line): + m = "exception" + typelist["exceptions"].add(m) + count(m) + if re.search("^Fail \d+ ", line): + m = "fail_%s" % line.split()[1] + typelist["failure"].add(m) + count(m) + if re.search("^Skipping ", line): + m = "skipped" + typelist["skipped"].add(m) + count(m) + if re.search("^Diff: .* ", line): + m = "diff_%s" % line.skip()[1] + typelist["diffs"].add(m) + count(m) + if re.search("^OK (\d+) ", line): + m = "pass_%s" % line.split()[1] + typelist["pass"].add(m) + count(m) + if re.search("^Pass (\d+) ", line): + m = "pass_%s" % line.split()[1] + typelist["pass"].add(m) + count(m) + if not m in summaries: + summaries[m] = [] + summaries[m].append(line) + + self.descriptionDone = self.descriptionDone[:] + for type in self.msgtypes: + for msg in typelist[type]: + if counts[msg]: + self.descriptionDone.append("%s=%d" % (msg, counts[msg])) + self.addCompleteLog(msg, "".join(summaries[msg])) + self.setProperty("urltest-%s" % type, sum([counts[msg] for msg in typelist[type]])) + self.setProperty("urltest-total", sum(counts.values())) + + def evaluateCommand(self, cmd): + if cmd.rc != 0: + return FAILURE + for type in self.flunkingIssues: + if self.getProperty("urltest-%s" % type): + return FAILURE + if self.getProperty("urltest-total"): + return WARNINGS + return SUCCESS diff --git a/test/buildbot/master/ietfdb/master.cfg b/test/buildbot/master/ietfdb/master.cfg index 535c5346a..c810e5836 100644 --- a/test/buildbot/master/ietfdb/master.cfg +++ b/test/buildbot/master/ietfdb/master.cfg @@ -94,11 +94,12 @@ from buildbot.steps.source import SVN from buildbot.steps.dummy import Dummy from buildbot.steps.python import PyFlakes from buildbot.steps.shell import ShellCommand, Test - +from buildbot_plugins import UrlTest + f1 = factory.BuildFactory() f1.addStep(SVN, svnurl="http://svn.tools.ietf.org/svn/tools/ietfdb/trunk/", username="buildbot@tools.ietf.org", password="U64#GUxr") f1.addStep(ShellCommand, name="test-setup", command=["test/test-setup"]) -f1.addStep(PyFlakes, command=["pyflakes", "ietf"], warnOnFailure=True) +f1.addStep(PyFlakes, command=["test/run-pyflakes", "ietf"], warnOnFailure=True) f1.addStep(Test, name="django-tests", command=["python", "ietf/manage.py", "test"], env={'PYTHONPATH': ["test/lib",]} ) f1.addStep(ShellCommand, name="test-teardown", command=["test/test-teardown"]) @@ -121,18 +122,15 @@ c['status'] = [] #from buildbot.status import html #c['status'].append(html.Waterfall(http_port=8010)) -import trac_buildbot_html as trac_html -c['status'].append(trac_html.Waterfall(http_port=8010)) +import buildbottrac.html +c['status'].append(buildbottrac.html.Waterfall(http_port=8010)) -import trac_buildbot_html_dev as trac_html_dev -c['status'].append(trac_html_dev.Waterfall(http_port=8011)) - -# from buildbot.status import mail -# c['status'].append(mail.MailNotifier(fromaddr="buildbot@tools.ietf.org", -# extraRecipients=["django-project@ietf.org"], -# mode="problem", -# mode="failing", -# sendToInterestedUsers=True)) +from buildbot.status import mail +c['status'].append(mail.MailNotifier(fromaddr="buildbot@tools.ietf.org", + extraRecipients=["django-project@ietf.org"], + mode="problem", +# mode="failing", + sendToInterestedUsers=True)) # from buildbot.status import words # c['status'].append(words.IRC(host="irc.example.com", nick="bb",