diff --git a/module_build_service/builder/MockModuleBuilder.py b/module_build_service/builder/MockModuleBuilder.py index dcf239f0..81756096 100644 --- a/module_build_service/builder/MockModuleBuilder.py +++ b/module_build_service/builder/MockModuleBuilder.py @@ -779,6 +779,26 @@ class MockModuleBuilder(GenericBuilder): nvrs = set(kobo.rpmlib.make_nvr(rpm, force_epoch=True) for rpm in rpms) return list(nvrs) + def get_average_build_time(self, component): + """ + Get the average build time of the component from Koji + :param component: a ComponentBuild object + :return: a float of the average build time in seconds + """ + # We currently don't track build times in MBS directly, so we can use Koji to get a decent + # estimate + if not self.koji_session: + # If Koji is not configured on the system, then just return 0.0 for components + try: + self.koji_session = get_session(self.config, login=False) + # If the component has not been built before, then None is returned. Instead, + # let's return 0.0 so the type is consistent + return self.koji_session.getAverageBuildDuration(component.package) or 0.0 + except Exception: + log.debug( + "The Koji call to getAverageBuildDuration failed. Is Koji properly configured?") + return 0.0 + class BaseBuilder(object): def __init__(self, config, resultsdir): @@ -846,23 +866,3 @@ class SCMBuilder(BaseBuilder): if source.startswith(host): return cmds raise KeyError("No defined commands for {}".format(source)) - - def get_average_build_time(self, component): - """ - Get the average build time of the component from Koji - :param component: a ComponentBuild object - :return: a float of the average build time in seconds - """ - # We currently don't track build times in MBS directly, so we can use Koji to get a decent - # estimate - if not self.koji_session: - # If Koji is not configured on the system, then just return 0.0 for components - try: - self.koji_session = get_session(self.config, login=False) - # If the component has not been built before, then None is returned. Instead, - # let's return 0.0 so the type is consistent - return self.koji_session.getAverageBuildDuration(component.package) or 0.0 - except Exception: - log.debug( - "The Koji call to getAverageBuildDuration failed. Is Koji properly configured?") - return 0.0