Add a test printHistory function

I frequently add something like this ad-hoc when debugging a test.
Make it a convenient function that's easy to add when needed, and
also run it at the completion of every test so a developer can
easily survey the logs to see what happened.

Change-Id: I3d3810f51245d92855f086b875edfd52bdd86983
This commit is contained in:
James E. Blair 2016-12-22 18:07:20 -08:00
parent 10fc1eb487
commit 6ac368c57b
1 changed files with 12 additions and 0 deletions

View File

@ -1369,6 +1369,7 @@ class ZuulTestCase(BaseTestCase):
threads = threading.enumerate()
if len(threads) > 1:
self.log.error("More than one thread is running: %s" % threads)
self.printHistory()
def init_repo(self, project):
parts = project.split('/')
@ -1670,6 +1671,17 @@ class ZuulTestCase(BaseTestCase):
self.log.error("No completed builds")
raise
def printHistory(self):
"""Log the build history.
This can be useful during tests to summarize what jobs have
completed.
"""
self.log.debug("Build history:")
for build in self.history:
self.log.debug(build)
def getPipeline(self, name):
return self.sched.abide.tenants.values()[0].layout.pipelines.get(name)