Merge pull request #300 from aplanas/master

If any goodrepo have no missing, the request have no missings.
This commit is contained in:
Stephan Kulow 2015-02-26 12:06:00 +01:00
commit 69902f2b82
4 changed files with 31 additions and 43 deletions

View File

@ -32,7 +32,7 @@ MAX_LINES = 6
class OpenQAReport(object): class OpenQAReport(object):
def __init__(self, api): def __init__(self, api):
self.api = api self.api = api
self.comment = CommentAPI(self.api.apiurl) self.comment = CommentAPI(api.apiurl)
def _package_url(self, package): def _package_url(self, package):
link = 'https://build.opensuse.org/package/live_build_log/%s/%s/%s/%s' % ( link = 'https://build.opensuse.org/package/live_build_log/%s/%s/%s/%s' % (
@ -64,9 +64,9 @@ class OpenQAReport(object):
project = project.replace(_prefix, '') project = project.replace(_prefix, '')
query = {'format': 'json'} query = {'format': 'json'}
url = api.makeurl(('project', 'staging_projects', url = self.api.makeurl(('project', 'staging_projects',
api.project, project), query=query) self.api.project, project), query=query)
info = json.load(api.retried_GET(url)) info = json.load(self.api.retried_GET(url))
return info return info
def get_broken_package_status(self, info): def get_broken_package_status(self, info):

View File

@ -33,6 +33,7 @@ from osc import oscerr
# Expand sys.path to search modules inside the pluging directory # Expand sys.path to search modules inside the pluging directory
PLUGINDIR = os.path.dirname(os.path.realpath(__file__.replace('.pyc', '.py'))) PLUGINDIR = os.path.dirname(os.path.realpath(__file__.replace('.pyc', '.py')))
sys.path.append(PLUGINDIR) sys.path.append(PLUGINDIR)
from osclib.conf import Config
from osclib.checkrepo import CheckRepo from osclib.checkrepo import CheckRepo
from osclib.checkrepo import BINCACHE, DOWNLOADS from osclib.checkrepo import BINCACHE, DOWNLOADS
from osclib.cycle import CycleDetector from osclib.cycle import CycleDetector
@ -201,8 +202,14 @@ def _check_repo_group(self, id_, requests, debug=False):
request.updated = True request.updated = True
for rq in requests: for rq in requests:
# Check if there are any goodrepo without missing packages
missing_repos = set(rq.missings.keys())
if any(r not in missing_repos for r in rq.goodrepos):
continue
smissing = [] smissing = []
for package in rq.missings: all_missing_packages = {item for sublist in rq.missings.values() for item in sublist}
for package in all_missing_packages:
alreadyin = False alreadyin = False
for t in packs: for t in packs:
if package == t.tgt_package: if package == t.tgt_package:
@ -442,7 +449,11 @@ def do_check_repo(self, subcmd, opts, *args):
pass pass
os.makedirs(DOWNLOADS) os.makedirs(DOWNLOADS)
self.checkrepo = CheckRepo(self.get_api_url(), opts.project, readonly=opts.dry, debug=opts.verbose) Config('openSUSE:%s' % opts.project)
self.checkrepo = CheckRepo(self.get_api_url(),
'openSUSE:%s' % opts.project,
readonly=opts.dry,
debug=opts.verbose)
if opts.skip: if opts.skip:
if not len(args): if not len(args):

View File

@ -27,7 +27,6 @@ from osc.core import http_DELETE
from osc.core import http_GET from osc.core import http_GET
from osc.core import http_POST from osc.core import http_POST
from osc.core import makeurl from osc.core import makeurl
from osclib.conf import Config
from osclib.stagingapi import StagingAPI from osclib.stagingapi import StagingAPI
from osclib.memoize import memoize from osclib.memoize import memoize
from osclib.pkgcache import PkgCache from osclib.pkgcache import PkgCache
@ -58,7 +57,7 @@ class Request(object):
self.verifymd5 = verifymd5 self.verifymd5 = verifymd5
self.group = group self.group = group
self.goodrepos = goodrepos if goodrepos else [] self.goodrepos = goodrepos if goodrepos else []
self.missings = missings if missings else [] self.missings = missings if missings else {}
self.is_shadow = is_shadow self.is_shadow = is_shadow
self.shadow_src_project = shadow_src_project self.shadow_src_project = shadow_src_project
@ -93,7 +92,7 @@ class Request(object):
# Assigned in is_buildsuccess # Assigned in is_buildsuccess
self.goodrepos = [] self.goodrepos = []
self.missings = [] self.missings = {}
# Detect if the request comes from Factory to a openSUSE # Detect if the request comes from Factory to a openSUSE
# release, and adjust the source and target projects # release, and adjust the source and target projects
@ -138,11 +137,10 @@ class Request(object):
class CheckRepo(object): class CheckRepo(object):
def __init__(self, apiurl, project='Factory', readonly=False, force_clean=False, debug=False): def __init__(self, apiurl, project, readonly=False, force_clean=False, debug=False):
"""CheckRepo constructor.""" """CheckRepo constructor."""
self.apiurl = apiurl self.apiurl = apiurl
self.project = 'openSUSE:%s' % project self.project = project
Config(self.project)
self.staging = StagingAPI(apiurl, self.project) self.staging = StagingAPI(apiurl, self.project)
self.pkgcache = PkgCache(BINCACHE, force_clean=force_clean) self.pkgcache = PkgCache(BINCACHE, force_clean=force_clean)
@ -705,28 +703,6 @@ class CheckRepo(object):
return False return False
def get_missings(self, request):
"""Get the list of packages that are in missing status."""
missings = set()
# XXX TODO - This piece is contained in
# is_buildsuccess(). Integrate both.
repos_to_check = self.repositories_to_check(request)
for repository in repos_to_check:
for arch in repository.findall('arch'):
if arch.attrib['arch'] not in ('i586', 'x86_64'):
continue
if 'missing' in arch.attrib:
for package in arch.attrib['missing'].split(','):
if not self.is_binary(
request.src_project,
repository.attrib['name'],
arch.attrib['arch'],
package):
missings.add(package)
return sorted(missings)
def is_buildsuccess(self, request): def is_buildsuccess(self, request):
"""Return True if the request is correctly build """Return True if the request is correctly build
@ -750,17 +726,18 @@ class CheckRepo(object):
return False return False
result = False result = False
missings = set()
alldisabled = True alldisabled = True
foundbuilding = None foundbuilding = None
foundfailed = None foundfailed = None
for repository in repos_to_check: for repository in repos_to_check:
repo_name = repository.attrib['name']
self.debug("checking repo", ET.tostring(repository)) self.debug("checking repo", ET.tostring(repository))
isgood = True isgood = True
founddisabled = False founddisabled = False
r_foundbuilding = None r_foundbuilding = None
r_foundfailed = None r_foundfailed = None
missings = []
for arch in repository.findall('arch'): for arch in repository.findall('arch'):
if arch.attrib['arch'] not in ('i586', 'x86_64'): if arch.attrib['arch'] not in ('i586', 'x86_64'):
continue continue
@ -768,10 +745,10 @@ class CheckRepo(object):
for package in arch.attrib['missing'].split(','): for package in arch.attrib['missing'].split(','):
if not self.is_binary( if not self.is_binary(
request.src_project, request.src_project,
repository.attrib['name'], repo_name,
arch.attrib['arch'], arch.attrib['arch'],
package): package):
missings.add(package) missings.append(package)
if arch.attrib['result'] not in ('succeeded', 'excluded'): if arch.attrib['result'] not in ('succeeded', 'excluded'):
isgood = False isgood = False
if arch.attrib['result'] == 'excluded' and arch.attrib['arch'] == 'x86_64': if arch.attrib['result'] == 'excluded' and arch.attrib['arch'] == 'x86_64':
@ -782,9 +759,9 @@ class CheckRepo(object):
# Sometimes an unknown status is equivalent to # Sometimes an unknown status is equivalent to
# disabled, but we map it as failed to have a human # disabled, but we map it as failed to have a human
# check (no autoreject) # check (no autoreject)
r_foundfailed = repository.attrib['name'] r_foundfailed = repo_name
if arch.attrib['result'] == 'building': if arch.attrib['result'] == 'building':
r_foundbuilding = repository.attrib['name'] r_foundbuilding = repo_name
if arch.attrib['result'] == 'outdated': if arch.attrib['result'] == 'outdated':
msg = "%s's sources were changed after submissions and the old sources never built. Please resubmit" % request.src_package msg = "%s's sources were changed after submissions and the old sources never built. Please resubmit" % request.src_package
print 'DECLINED', msg print 'DECLINED', msg
@ -796,7 +773,7 @@ class CheckRepo(object):
if not founddisabled: if not founddisabled:
alldisabled = False alldisabled = False
if isgood: if isgood:
_goodrepo = (request.src_project, repository.attrib['name']) _goodrepo = (request.src_project, repo_name)
self.debug("good repo", _goodrepo) self.debug("good repo", _goodrepo)
if _goodrepo not in request.goodrepos: if _goodrepo not in request.goodrepos:
request.goodrepos.append(_goodrepo) request.goodrepos.append(_goodrepo)
@ -805,8 +782,8 @@ class CheckRepo(object):
foundbuilding = r_foundbuilding foundbuilding = r_foundbuilding
if r_foundfailed: if r_foundfailed:
foundfailed = r_foundfailed foundfailed = r_foundfailed
if missings:
request.missings = sorted(missings) request.missings[repo_name] = missings
if result: if result:
return True return True

View File

@ -30,7 +30,7 @@ class TestCheckRepoCalls(unittest.TestCase):
self.obs = OBS() self.obs = OBS()
Config('openSUSE:Factory') Config('openSUSE:Factory')
self.checkrepo = CheckRepo(APIURL, force_clean=True) self.checkrepo = CheckRepo(APIURL, project='openSUSE:Factory', force_clean=True)
# Des-memoize some functions # Des-memoize some functions
self.checkrepo.build = self.checkrepo._build self.checkrepo.build = self.checkrepo._build
self.checkrepo.last_build_success = self.checkrepo._last_build_success self.checkrepo.last_build_success = self.checkrepo._last_build_success