diff --git a/tests/test_kojira/test_repo_manager.py b/tests/test_kojira/test_repo_manager.py index 85ec47ef..b3cc4fc2 100644 --- a/tests/test_kojira/test_repo_manager.py +++ b/tests/test_kojira/test_repo_manager.py @@ -247,6 +247,69 @@ class RepoManagerTest(unittest.TestCase): get.return_value.text = repomd self.mgr.checkExternalRepos() + + self.session.repo.getExternalRepoData.assert_has_calls([ + mock.call(1), + mock.call(2), + ]) + self.session.repo.setExternalRepoData.assert_has_calls([ + mock.call(1, {'max_ts': 1711390493}), + mock.call(2, {'max_ts': 1711390493}), + ]) + + @mock.patch('requests.get') + def test_check_external_no_arches(self, get): + # a new system with no hosts could report no arches + self.session.getAllArches.return_value = [] + # fake ext repo data + repo1 = {'external_repo_id': 1, 'external_repo_name': 'myrepo', + 'url': 'https://localhost/NOSUCHPATH'} + repo2 = {'external_repo_id': 2, 'external_repo_name': 'myotherrepo', + 'url': 'https://localhost/FAKEPATH/$arch'} + self.session.getTagExternalRepos.return_value = [repo1, repo2] + data1 = {} + data2 = {} + self.session.repo.getExternalRepoData.side_effect = [data1, data2] + repomd_fn = os.path.dirname(__file__) + '/data/external-repomd.xml' + with open(repomd_fn, 'rt') as fo: + repomd = fo.read() + get.return_value.text = repomd + + self.mgr.checkExternalRepos() + + self.session.repo.getExternalRepoData.assert_has_calls([ + mock.call(1), + # no call for repo2 since it has $arch in the url + ]) + self.session.repo.setExternalRepoData.assert_has_calls([ + mock.call(1, {'max_ts': 1711390493}), + # no call for repo2 since it has $arch in the url + ]) + + @mock.patch('requests.get') + def test_check_external_cache(self, get): + # fake ext repo data + repo1 = {'external_repo_id': 1, 'external_repo_name': 'myrepo', + 'url': 'https://localhost/NOSUCHPATH'} + repo2 = {'external_repo_id': 2, 'external_repo_name': 'myotherrepo', + 'url': 'https://localhost/NOSUCHPATH'} # same url + self.session.getTagExternalRepos.return_value = [repo1, repo2] + data1 = {} + data2 = {} + self.session.repo.getExternalRepoData.side_effect = [data1, data2] + self.session.getAllArches.return_value = ['i386', 'x86_64', 'riscv'] + repomd_fn = os.path.dirname(__file__) + '/data/external-repomd.xml' + with open(repomd_fn, 'rt') as fo: + repomd = fo.read() + get.return_value.text = repomd + + self.mgr.checkExternalRepos() + + get.assert_called_once() + self.session.repo.getExternalRepoData.assert_has_calls([ + mock.call(1), + mock.call(2), + ]) self.session.repo.setExternalRepoData.assert_has_calls([ mock.call(1, {'max_ts': 1711390493}), mock.call(2, {'max_ts': 1711390493}), diff --git a/util/kojira b/util/kojira index 1fee2d3f..b0ec6e21 100755 --- a/util/kojira +++ b/util/kojira @@ -434,7 +434,8 @@ class RepoManager(object): # getting the list of all tag arches for all tags that might use the repo is # way more expensive if not arches: - self.logger.warning('No arches reported. Unable to check external repos with $arch') + self.logger.warning('No arches reported by hub. Are any hosts enabled? ' + 'Unable to check external repos containing $arch') ts_cache = {} for erepo_id in sorted(external_repos):