mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-02-03 05:03:43 +08:00
MockModuleBuilder: move get_average_build_time() to the right class
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user