Add support for latest SS result formats.

Updates our job data handling so that it works with the latest
SmokeStack job format updates. This includes:
 -new build status's for Failed, TestFail, and BuildFail
 -new job types (cloudcue)
 -display multiple jobs for each type (where appropriate)

Change-Id: I79fa21cfd489a2f524d4c98bc94b7a14b81ee831
This commit is contained in:
Dan Prince 2013-09-09 12:28:30 -04:00
parent e2c0efd86f
commit 41707f4003
4 changed files with 40 additions and 14 deletions

View File

@ -17,7 +17,7 @@ optparser.add_option('-o', '--out-dir', dest='out_dir',
(options, args) = optparser.parse_args()
lp = LaunchPad()
smoker = SmokeStack('https://smokestack.openstack.org/jobs.json?limit=10000')
smoker = SmokeStack('https://smokestack.openstack.org')
projects = {}
@ -34,6 +34,8 @@ for project in ['nova', 'glance', 'keystone', 'swift', 'neutron', 'cinder',
raise
dts = str(datetime.utcnow())[0:19]
name_space = {"projects": projects, "dts": dts}
config_templates = smoker.config_templates()
name_space = {"projects": projects, "dts": dts,
"config_templates": config_templates}
out_dir = options.out_dir
create_report(out_dir, name_space)

View File

@ -1,6 +1,24 @@
# Helper functions to help generate the HTML report
def config_template_name(config_template_id, config_templates):
if config_template_id in config_templates:
return config_templates[config_template_id]
else:
return 'Unknown'
def all_job_data(jobs, job_type):
""" Return an iterator over all job data. Exclude config template dups. """
conf_tmpl_ids = []
for job in jobs:
for jt, data in job.iteritems():
if jt == job_type:
if data['config_template_id'] not in conf_tmpl_ids:
conf_tmpl_ids.append(data['config_template_id'])
yield data
def job_data_for_type(jobs, job_type):
""" Return a reference to the first job of the specified type. """
for job in jobs:
@ -12,7 +30,7 @@ def job_data_for_type(jobs, job_type):
def fail_status(job_data, token):
""" Return a reference to the first job of the specified type. """
output = '<font style="color: #%s;">%s</font>'
if job_data['status'] == 'Failed':
if job_data['status'] in ['Failed', 'BuildFail', 'TestFail']:
color = 'FF0000'
elif job_data['status'] == 'Success':
color = '00AA00'

View File

@ -101,15 +101,10 @@
</td>
<td>
#set $unit_data = $helper.job_data_for_type($mp.jobs, "job_unit_tester")
#if $unit_data
<a href="https://smokestack.openstack.org/?go=/jobs/$unit_data['id']" title="$unit_data['msg']">$helper.fail_status($unit_data, 'Unit')</a>&nbsp;
#end if
#set $libvirt_data = $helper.job_data_for_type($mp.jobs, "job_puppet_libvirt")
#if $libvirt_data
<a href="https://smokestack.openstack.org/?go=/jobs/$libvirt_data['id']" title="$libvirt_data['msg']">$helper.fail_status($libvirt_data, 'Libvirt')</a>&nbsp;
#end if
#for $cloudcue_data in $helper.all_job_data($mp.jobs, "job_puppet_cloudcue")
#set $config_template_name = $helper.config_template_name($cloudcue_data['config_template_id'], $config_templates)
<a href="https://smokestack.openstack.org/?go=/jobs/$cloudcue_data['id']" title="$cloudcue_data['msg']">$helper.fail_status($cloudcue_data, $config_template_name)</a>&nbsp;
#end for
#set $xenserver_data = $helper.job_data_for_type($mp.jobs, "job_puppet_xen")
#if $xenserver_data
@ -121,7 +116,6 @@
#end for
</tbody>
</table>
<script type="text/javascript">

View File

@ -6,12 +6,14 @@ class SmokeStack(object):
def __init__(self, url):
self._jobs = None
self._config_templates = None
self.url = url
def jobs(self, git_hash=None):
if not self._jobs:
h = httplib2.Http(disable_ssl_certificate_validation=True)
resp, content = h.request(self.url, "GET")
jobs_url = self.url + '/jobs.json?limit=10000'
resp, content = h.request(jobs_url, "GET")
self._jobs = json.loads(content)
if git_hash:
jobs_with_hash = []
@ -38,3 +40,13 @@ class SmokeStack(object):
return jobs_with_hash
else:
return self._jobs
def config_templates(self):
if not self._config_templates:
h = httplib2.Http(disable_ssl_certificate_validation=True)
ct_url = self.url + '/config_templates.json'
resp, content = h.request(ct_url, "GET")
self._config_templates = {}
for ct in json.loads(content):
self._config_templates[ct['id']] = ct['name']
return self._config_templates