From 2a7070995e47791a31f86073bb448f8b2c259a04 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Thu, 28 Sep 2017 14:06:58 -0400 Subject: [PATCH] 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 --- files/subunit-gearman-worker.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/files/subunit-gearman-worker.py b/files/subunit-gearman-worker.py index ab5c72b..0679260 100644 --- a/files/subunit-gearman-worker.py +++ b/files/subunit-gearman-worker.py @@ -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)