CG: allow reimports into failed/cancelled builds
Related: https://pagure.io/koji/issue/3776
This commit is contained in:
parent
475501f0b8
commit
23350af251
2 changed files with 33 additions and 18 deletions
|
|
@ -6708,10 +6708,12 @@ class CG_Importer(object):
|
|||
raise koji.GenericError('Reservation token given, but no build_id '
|
||||
'in metadata')
|
||||
else:
|
||||
# no build reservation
|
||||
buildinfo = get_build(metadata['build'], strict=False)
|
||||
if buildinfo and not metadata['build'].get('build_id'):
|
||||
# TODO : allow in some cases
|
||||
raise koji.GenericError("Build already exists: %r" % buildinfo)
|
||||
if buildinfo:
|
||||
if (koji.BUILD_STATES[buildinfo['state']] not in ('CANCELED', 'FAILED')):
|
||||
raise koji.GenericError("Build already exists: %r" % buildinfo)
|
||||
# note: the checks in recycle_build will also apply when we call new_build later
|
||||
# gather needed data
|
||||
buildinfo = dslice(metadata['build'], ['name', 'version', 'release', 'extra', 'source'])
|
||||
if 'build_id' in metadata['build']:
|
||||
|
|
|
|||
|
|
@ -27,6 +27,32 @@ class TestCGImporter(unittest.TestCase):
|
|||
self.lexists = mock.patch('os.path.lexists').start()
|
||||
self.path_build = mock.patch('koji.pathinfo.build').start()
|
||||
self.new_build = mock.patch('kojihub.kojihub.new_build').start()
|
||||
self.buildinfo = {
|
||||
'id': 43,
|
||||
'package_id': 1,
|
||||
'package_name': 'testpkg',
|
||||
'name': 'testpkg',
|
||||
'version': '1.0.1e',
|
||||
'release': '42.el7',
|
||||
'epoch': None,
|
||||
'nvr': 'testpkg-1.0.1-1.fc24',
|
||||
'state': koji.BUILD_STATES['COMPLETE'],
|
||||
'task_id': 1,
|
||||
'owner_id': 1,
|
||||
'owner_name': 'jvasallo',
|
||||
'volume_id': 'id-1212',
|
||||
'volume_name':'testvolume',
|
||||
'creation_event_id': '',
|
||||
'creation_time': '',
|
||||
'creation_ts': 424242424242,
|
||||
'start_time': None,
|
||||
'start_ts': None,
|
||||
'completion_time': None,
|
||||
'completion_ts': None,
|
||||
'source': 'https://example.com',
|
||||
'extra': {},
|
||||
}
|
||||
|
||||
|
||||
def tearDown(self):
|
||||
if os.path.exists(self.TMP_PATH):
|
||||
|
|
@ -121,7 +147,7 @@ class TestCGImporter(unittest.TestCase):
|
|||
|
||||
def test_prep_build_exists(self):
|
||||
self.path_work.return_value = os.path.dirname(__file__)
|
||||
self.get_build.return_value = True
|
||||
self.get_build.return_value = self.buildinfo
|
||||
x = kojihub.CG_Importer()
|
||||
x.get_metadata('default.json', 'cg_importer_json')
|
||||
with self.assertRaises(GenericError):
|
||||
|
|
@ -140,20 +166,7 @@ class TestCGImporter(unittest.TestCase):
|
|||
x.assert_cg_access()
|
||||
x.prep_build()
|
||||
x.prepped_outputs = []
|
||||
self.get_build.return_value = {'id': 43, 'package_id': 1,
|
||||
'package_name': 'testpkg',
|
||||
'name': 'testpkg', 'version': '1.0.1e',
|
||||
'release': '42.el7', 'epoch': None,
|
||||
'nvr': 'testpkg-1.0.1-1.fc24',
|
||||
'state': 'complete', 'task_id': 1,
|
||||
'owner_id': 1, 'owner_name': 'jvasallo',
|
||||
'volume_id': 'id-1212', 'volume_name': 'testvolume',
|
||||
'creation_event_id': '', 'creation_time': '',
|
||||
'creation_ts': 424242424242,
|
||||
'start_time': None, 'start_ts': None,
|
||||
'completion_time': None, 'completion_ts': None,
|
||||
'source': 'https://example.com', 'extra': {}
|
||||
}
|
||||
self.get_build.return_value = self.buildinfo
|
||||
self.new_build.return_value = 43
|
||||
x.get_build()
|
||||
assert x.buildinfo
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue