Ensure that build_names are unique per project

With the migration to zuul v3 project names for common jobs, like unit
tests, no longer are unique per project. This causes issues for
openstack-health and subunit2sql because we can longer easily filter a
unit test job between projects. This commit adds a function to ensure
that the project name is in the build_name in the metadata. (assuming
devstack or tempest is not in the job_name) This way we can still filter
based on the job name per project.

Change-Id: I5231105af975d987d5f5e5f77c6ac038e10cd832
This commit is contained in:
Matthew Treinish 2017-09-28 14:06:58 -04:00
parent ebf675e02c
commit 2a7070995e
No known key found for this signature in database
GPG Key ID: FD12A0F214C9E177
1 changed files with 10 additions and 0 deletions

View File

@ -67,10 +67,20 @@ class SubunitRetriever(object):
self.extra_targets = shell.get_targets(extensions)
self.mqtt = mqtt
def _uniquify_name(self, meta):
job_name = meta.pop('build_name')
if 'tempest' not in job_name and 'dsvm' not in job_name:
project = meta['project'].split('/')[-1]
if project not in job_name:
job_name = '-'.join([job_name, project])
meta['build_name'] = job_name
return meta
def _write_to_db(self, subunit):
subunit_v2 = subunit.pop('subunit')
# Set run metadata from gearman
log_url = subunit.pop('log_url', None)
subunit = self._uniquify_name(subunit)
if log_url:
log_dir = os.path.dirname(log_url)