adjust handling for tags with no arches
This commit is contained in:
parent
6fb33731d9
commit
c09780bbb5
2 changed files with 30 additions and 5 deletions
|
|
@ -151,7 +151,13 @@ def _auto_arch_refuse(task_id):
|
|||
return
|
||||
|
||||
# from here, we're basically doing checkHostArch() for all hosts in the channel
|
||||
tag_arches = set([koji.canonArch(a) for a in taginfo['arches'].split()])
|
||||
buildconfig = context.handlers.call('getBuildConfig', taginfo['id'])
|
||||
# getBuildConfig traverses inheritance to find arches if tag does not have them
|
||||
tag_arches = set([koji.canonArch(a) for a in buildconfig['arches'].split()])
|
||||
if not tag_arches:
|
||||
logger.warning("No arches for tag %(name)s [%(id)s]", taginfo)
|
||||
# we don't error here, allowing the task itself to fail
|
||||
return
|
||||
|
||||
hosts = context.handlers.call('listHosts', channelID=info['channel_id'], enabled=True,
|
||||
queryOpts={'order': 'id'})
|
||||
|
|
|
|||
|
|
@ -29,6 +29,11 @@ class AutoRefuseTest(unittest.TestCase):
|
|||
self.get_tag = mock.patch('kojihub.kojihub.get_tag').start()
|
||||
self.context = mock.patch('kojihub.scheduler.context').start()
|
||||
self.set_refusal = mock.patch('kojihub.scheduler.set_refusal').start()
|
||||
self.handlers = {
|
||||
'getBuildConfig': mock.MagicMock(),
|
||||
'listHosts': mock.MagicMock(),
|
||||
}
|
||||
self.context.handlers.call.side_effect = self._my_handler_call
|
||||
self.set_base_data()
|
||||
|
||||
def tearDown(self):
|
||||
|
|
@ -51,8 +56,13 @@ class AutoRefuseTest(unittest.TestCase):
|
|||
}
|
||||
self.task.getInfo.return_value = self.taskinfo
|
||||
self.task.isFinished.return_value = False
|
||||
self.get_tag.return_value = {'arches': 'x86_64 s390x ppc64le aarch64'}
|
||||
self.context.handlers.call.return_value = [{'id': 'HOST', 'arches': 'x86_64 i686'}]
|
||||
self.get_tag.return_value = {'id': 'TAGID', 'name': 'MYTAG'}
|
||||
self.handlers['listHosts'].return_value = [{'id': 'HOST', 'arches': 'x86_64 i686'}]
|
||||
self.handlers['getBuildConfig'].return_value = {'arches': 'x86_64 s390x ppc64le aarch64'}
|
||||
|
||||
def _my_handler_call(self, method, *a, **kw):
|
||||
handler = self.handlers[method]
|
||||
return handler(*a, **kw)
|
||||
|
||||
def test_arch_overlap(self):
|
||||
# we mostly test the underlying function to avoid masking errors
|
||||
|
|
@ -63,20 +73,29 @@ class AutoRefuseTest(unittest.TestCase):
|
|||
self.set_refusal.assert_not_called()
|
||||
|
||||
def test_arch_disjoint(self):
|
||||
self.context.handlers.call.return_value = [{'id': 'HOST', 'arches': 'riscv128'}]
|
||||
self.handlers['listHosts'].return_value = [{'id': 'HOST', 'arches': 'riscv128'}]
|
||||
scheduler._auto_arch_refuse(100)
|
||||
|
||||
self.Task.assert_called_once_with(100)
|
||||
self.get_tag.assert_called_once_with('TAG_ID')
|
||||
self.set_refusal.assert_called_once()
|
||||
|
||||
def test_no_tag_arches(self):
|
||||
self.handlers['getBuildConfig'].return_value = {'arches': ''}
|
||||
scheduler._auto_arch_refuse(100)
|
||||
|
||||
self.Task.assert_called_once_with(100)
|
||||
self.get_tag.assert_called_once_with('TAG_ID')
|
||||
self.handlers['listHosts'].assert_not_called()
|
||||
self.set_refusal.assert_not_called()
|
||||
|
||||
def test_mixed_hosts(self):
|
||||
good1 = [{'id': n, 'arches': 'x86_64 i686'} for n in range(0,5)]
|
||||
bad1 = [{'id': n, 'arches': 'ia64'} for n in range(5,10)]
|
||||
good2 = [{'id': n, 'arches': 'aarch64'} for n in range(10,15)]
|
||||
bad2 = [{'id': n, 'arches': 'sparc64'} for n in range(15,20)]
|
||||
hosts = good1 + bad1 + good2 + bad2
|
||||
self.context.handlers.call.return_value = hosts
|
||||
self.handlers['listHosts'].return_value = hosts
|
||||
scheduler._auto_arch_refuse(100)
|
||||
|
||||
self.Task.assert_called_once_with(100)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue