Skip to content

Commit aecbeb6

Browse files
author
buildbot
committed
Made the error buildbot counting for the test-crawler more sophisticated.
- Legacy-Id: 11983
1 parent c9339c9 commit aecbeb6

File tree

1 file changed

+107
-6
lines changed

1 file changed

+107
-6
lines changed

buildbot/masters/datatracker/master.cfg

Lines changed: 107 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ c['schedulers'] = [
8282
# Periodic Schedulers
8383
Nightly(name="lin_test_old_libs", hour=16, minute=12, branch="trunk", builderNames=["Verify Minimum Libs"],),
8484
Nightly(name="lin_test_libs", hour=16, minute=42, branch="trunk", builderNames=["Verify Latest Libs"],),
85-
NightlyTriggerable(name="crawler", hour=[5,7,9,11,13,15,17], minute=00, builderNames=["Test-Crawler"],),
85+
NightlyTriggerable(name="crawler", hour=[5,7,9,11,13,15,17], minute=00, builderNames=["Test-Crawler"],),
8686

8787
# Force schedulers
8888
ForceScheduler(name="force_pyflakes", builderNames=["Check PyFlakes"]),
@@ -124,7 +124,102 @@ class TestCrawlerShellCommand(WarningCountingShellCommand):
124124
flunkOnFailure = 1
125125
descriptionDone = ["test crawler"]
126126
command=["bin/test-crawl"]
127-
warningPattern = '.* FAIL '
127+
128+
warningPatterns = {
129+
"exceptions": "^Traceback",
130+
"failed": " FAIL",
131+
"warnings": " WARN",
132+
"slow": " SLOW",
133+
"invalid_html": " invalid html:",
134+
}
135+
136+
logline = "^ *(?P<elapsed>\d+:\d+:\d+) +(?P<pages>\d+) +(?P<queue>\d+) +(?P<result>\d+) +(?P<runtime>\d+.\d+)s +(?P<message>.+)"
137+
138+
def setTestResults(self, **kwargs):
139+
"""
140+
Called by subclasses to set the relevant statistics; this actually
141+
adds to any statistics already present
142+
"""
143+
for kw in kwargs:
144+
value = kwargs[kw]
145+
if value.isdigit():
146+
# Counter
147+
value = int(value)
148+
value += self.step_status.getStatistic(kw, 0)
149+
elif re.search("^[0-9]+\.[0-9]+$", value):
150+
# Runtime
151+
value = float(value)
152+
value += self.step_status.getStatistic(kw, 0)
153+
else:
154+
# This is a percentage, and we can't add them
155+
pass
156+
self.step_status.setStatistic(kw, value)
157+
158+
def createSummary(self, log):
159+
"""
160+
Match log lines against warningPattern.
161+
162+
Warnings are collected into another log for this step, and the
163+
build-wide 'warnings-count' is updated."""
164+
165+
warnings = {}
166+
wregex = {}
167+
168+
regex_class = re.compile("").__class__
169+
170+
if not isinstance(self.logline, regex_class):
171+
self.logline = re.compile(self.logline)
172+
173+
for key in self.warningPatterns:
174+
warnings[key] = []
175+
pattern = self.warningPatterns[key]
176+
if not isinstance(pattern, regex_class):
177+
wregex[key] = re.compile(pattern)
178+
else:
179+
wregex[key] = pattern
180+
181+
# Count matches to the various warning patterns
182+
for line in log.getText().split("\n"):
183+
for key in wregex:
184+
match = re.search(wregex[key], line)
185+
if match:
186+
warnings[key].append(line)
187+
if re.search(self.logline, line):
188+
last_line = line
189+
190+
# If there were any warnings, make the log if lines with warnings
191+
# available
192+
log = syslog.syslog
193+
for key in warnings:
194+
if len(warnings[key]) > 0:
195+
self.addCompleteLog("%s (%d)" % (key, len(warnings[key])),
196+
"\n".join(warnings[key]) + "\n")
197+
self.step_status.setStatistic(key, len(warnings[key]))
198+
self.setProperty(key, len(warnings[key]), "TestCrawlerShellCommand")
199+
200+
match = re.search(self.logline, last_line)
201+
for key in ['elapsed', 'pages']:
202+
info = match.group(key)
203+
self.step_status.setStatistic(key, info)
204+
self.setProperty(key, info, "TestCrawlerShellCommand")
205+
206+
def describe(self, done=False):
207+
description = WarningCountingShellCommand.describe(self, done)
208+
if done:
209+
description = description[:] # make a private copy
210+
for name in ["time", "elapsed", "pages", "failed", "warnings", "slow", "invalid_html", ]:
211+
if name in self.step_status.statistics:
212+
value = self.step_status.getStatistic(name)
213+
displayName = name.replace('_', ' ')
214+
# special case. Mph.
215+
if type(value) is float: # this is run-time
216+
description.append('%s: %.2fs' % (displayName, value))
217+
elif type(value) is int:
218+
description.append('%s: %d' % (displayName, value))
219+
else:
220+
description.append('%s: %s' % (displayName, value))
221+
return description
222+
128223

129224
class UnitTest(WarningCountingShellCommand):
130225

@@ -156,7 +251,7 @@ class UnitTest(WarningCountingShellCommand):
156251
# Counter
157252
value = int(value)
158253
value += self.step_status.getStatistic(kw, 0)
159-
elif re.match("[0-9]+\.[0-9]+$", value):
254+
elif re.search("^[0-9]+\.[0-9]+$", value):
160255
# Runtime
161256
value = float(value)
162257
value += self.step_status.getStatistic(kw, 0)
@@ -170,7 +265,7 @@ class UnitTest(WarningCountingShellCommand):
170265
for line in log.getText().split("\n"):
171266
for key in self.regexPatterns:
172267
regex = self.regexPatterns[key]
173-
match = re.match(regex, line)
268+
match = re.search(regex, line)
174269
if match:
175270
info[key] = match.group(1)
176271
self.setTestResults(**info)
@@ -198,7 +293,7 @@ class UnitTest(WarningCountingShellCommand):
198293
else:
199294
description.append('%s: %s' % (displayName, value))
200295
return description
201-
296+
202297

203298
## Set up builders
204299

@@ -259,6 +354,12 @@ factory.addStep(SVN(
259354
descriptionSuffix=[Interpolate('%(src::branch)s %(src::revision)s')],
260355
))
261356
factory.addStep(RemovePYCs(workdir=Interpolate('build/%(src::branch)s')))
357+
factory.addStep(ShellCommand(
358+
descriptionDone="remove tmp-* dirs",
359+
workdir=Interpolate('build/%(src::branch)s'),
360+
haltOnFailure=True,
361+
command=["rm", "-rf", "tmp-*/"],
362+
))
262363
factory.addStep(ShellCommand(
263364
descriptionDone="install requirements",
264365
workdir=Interpolate('build/%(src::branch)s'),
@@ -300,7 +401,7 @@ c['builders'].append(BuilderConfig(name="[personal] Test Suite", factory=factory
300401
# to the steps above
301402
factory.addStep(Trigger(schedulerNames=['crawler'],
302403
waitForFinish=False,
303-
updateSourceStamp=False,
404+
alwaysUseLatest=True,
304405
set_properties={},
305406
))
306407

0 commit comments

Comments
 (0)