From acc0ba0833d73753e8d5180dda4d2bd0c9a93d91 Mon Sep 17 00:00:00 2001 From: Fabian Vogt Date: Fri, 4 Sep 2020 11:31:09 +0200 Subject: [PATCH] TTM: Verify that all successfully built products are mentioned in the config This is to avoid that added container images or appliance flavors are never released due to the missing config addition. --- ttm/releaser.py | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/ttm/releaser.py b/ttm/releaser.py index 055beaa6..1fca5fe7 100644 --- a/ttm/releaser.py +++ b/ttm/releaser.py @@ -47,6 +47,10 @@ class ToTestReleaser(ToTestManager): self.logger.debug('not snapshotable') return QAResult.failed + if not self.all_built_products_in_config(): + self.logger.debug('config incomplete') + return QAResult.failed + self.update_totest(new_snapshot) self.update_status('testing', new_snapshot) self.update_status('failed', '') @@ -135,6 +139,51 @@ class ToTestReleaser(ToTestManager): return True + def all_built_products_in_config(self): + """Verify that all succeeded products are mentioned in the ttm config""" + + # Don't return false early, to show all errors at once + all_found = True + + product_archs = {} # {'foo:ftp': ['local'], some-image': ['x86_64'], ...} + for simple_product in self.project.ftp_products + self.project.main_products: + product_archs[simple_product] = [self.project.product_arch] + for image_product in self.project.image_products + self.project.container_products: + product_archs[image_product.package] = image_product.archs + + # Get all results for the product repo from OBS + url = self.api.makeurl(['build', self.project.name, "_result"], + {'repository': self.project.product_repo, + 'multibuild': 1}) + f = self.api.retried_GET(url) + resultlist = ET.parse(f).getroot() + + # Loop through all successfully built products and check whether they are part of + # product_archs + for result in resultlist.findall('result'): + arch = result.get('arch') + for package in result.findall('status[@code="succeeded"]'): + packagename = package.get('package') + released_archs = None + if packagename in product_archs: + released_archs = product_archs[packagename] + elif ':' in packagename: + # For multibuild, it's enough to release the container + multibuildcontainer = packagename.split(':')[0] + if multibuildcontainer in product_archs: + released_archs = product_archs[multibuildcontainer] + + if released_archs is None: + self.logger.error("%s is built for %s, but not mentioned as product" % ( + packagename, arch)) + all_found = False + elif arch not in released_archs: + self.logger.error("%s is built for %s, but that arch is not mentioned" % ( + packagename, arch)) + all_found = False + + return all_found + def is_snapshotable(self): """Check various conditions required for factory to be snapshotable