Skip to content

Commit c89000f

Browse files
committed
A new buildbot plugin, with better reporting from the URL tests
- Legacy-Id: 292
1 parent b6c7aed commit c89000f

2 files changed

Lines changed: 91 additions & 13 deletions

File tree

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import re
2+
from buildbot.steps.shell import ShellCommand
3+
from buildbot.status.builder import SUCCESS, FAILURE, WARNINGS
4+
5+
try:
6+
import cStringIO
7+
StringIO = cStringIO.StringIO
8+
except ImportError:
9+
from StringIO import StringIO
10+
11+
class DjangoTest(ShellCommand):
12+
name = "django test"
13+
command = ["python", "manage.py", "test"]
14+
description = ["running django test"]
15+
descriptionDone = ["django test"]
16+
flunkOnFailure = False
17+
flunkingIssues = ["exception", "failure"] # any pyflakes lines like this cause FAILURE
18+
19+
msgtypes = ("exception", "failure", "skipped", "diffs", "ok")
20+
21+
def createSummary(self, log):
22+
summaries = {}
23+
typelist = {}
24+
counts = {}
25+
def count(m):
26+
if not m in counts:
27+
counts[m] = 0
28+
counts[m] += 1
29+
30+
for type in self.msgtypes:
31+
typelist[type] = set([])
32+
33+
first = True
34+
for line in StringIO(log.getText()).readlines():
35+
if re.search("^Traceback: ", line):
36+
m = "exception"
37+
typelist["exceptions"].add(m)
38+
count(m)
39+
if re.search("^Fail \d+ ", line):
40+
m = "fail_%s" % line.split()[1]
41+
typelist["failure"].add(m)
42+
count(m)
43+
if re.search("^Skipping ", line):
44+
m = "skipped"
45+
typelist["skipped"].add(m)
46+
count(m)
47+
if re.search("^Diff: .* ", line):
48+
m = "diff_%s" % line.skip()[1]
49+
typelist["diffs"].add(m)
50+
count(m)
51+
if re.search("^OK (\d+) ", line):
52+
m = "pass_%s" % line.split()[1]
53+
typelist["pass"].add(m)
54+
count(m)
55+
if re.search("^Pass (\d+) ", line):
56+
m = "pass_%s" % line.split()[1]
57+
typelist["pass"].add(m)
58+
count(m)
59+
if not m in summaries:
60+
summaries[m] = []
61+
summaries[m].append(line)
62+
63+
self.descriptionDone = self.descriptionDone[:]
64+
for type in self.msgtypes:
65+
for msg in typelist[type]:
66+
if counts[msg]:
67+
self.descriptionDone.append("%s=%d" % (msg, counts[msg]))
68+
self.addCompleteLog(msg, "".join(summaries[msg]))
69+
self.setProperty("urltest-%s" % type, sum([counts[msg] for msg in typelist[type]]))
70+
self.setProperty("urltest-total", sum(counts.values()))
71+
72+
def evaluateCommand(self, cmd):
73+
if cmd.rc != 0:
74+
return FAILURE
75+
for type in self.flunkingIssues:
76+
if self.getProperty("urltest-%s" % type):
77+
return FAILURE
78+
if self.getProperty("urltest-total"):
79+
return WARNINGS
80+
return SUCCESS

test/buildbot/master/ietfdb/master.cfg

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,12 @@ from buildbot.steps.source import SVN
9494
from buildbot.steps.dummy import Dummy
9595
from buildbot.steps.python import PyFlakes
9696
from buildbot.steps.shell import ShellCommand, Test
97-
97+
from buildbot_plugins import UrlTest
98+
9899
f1 = factory.BuildFactory()
99100
f1.addStep(SVN, svnurl="http://svn.tools.ietf.org/svn/tools/ietfdb/trunk/", username="buildbot@tools.ietf.org", password="U64#GUxr")
100101
f1.addStep(ShellCommand, name="test-setup", command=["test/test-setup"])
101-
f1.addStep(PyFlakes, command=["pyflakes", "ietf"], warnOnFailure=True)
102+
f1.addStep(PyFlakes, command=["test/run-pyflakes", "ietf"], warnOnFailure=True)
102103
f1.addStep(Test, name="django-tests", command=["python", "ietf/manage.py", "test"], env={'PYTHONPATH': ["test/lib",]} )
103104
f1.addStep(ShellCommand, name="test-teardown", command=["test/test-teardown"])
104105

@@ -121,18 +122,15 @@ c['status'] = []
121122
#from buildbot.status import html
122123
#c['status'].append(html.Waterfall(http_port=8010))
123124

124-
import trac_buildbot_html as trac_html
125-
c['status'].append(trac_html.Waterfall(http_port=8010))
126-
127-
import trac_buildbot_html_dev as trac_html_dev
128-
c['status'].append(trac_html_dev.Waterfall(http_port=8011))
125+
import buildbottrac.html
126+
c['status'].append(buildbottrac.html.Waterfall(http_port=8010))
129127

130-
# from buildbot.status import mail
131-
# c['status'].append(mail.MailNotifier(fromaddr="buildbot@tools.ietf.org",
132-
# extraRecipients=["django-project@ietf.org"],
133-
# mode="problem",
134-
# mode="failing",
135-
# sendToInterestedUsers=True))
128+
from buildbot.status import mail
129+
c['status'].append(mail.MailNotifier(fromaddr="buildbot@tools.ietf.org",
130+
extraRecipients=["django-project@ietf.org"],
131+
mode="problem",
132+
# mode="failing",
133+
sendToInterestedUsers=True))
136134

137135
# from buildbot.status import words
138136
# c['status'].append(words.IRC(host="irc.example.com", nick="bb",

0 commit comments

Comments
 (0)