#4167 adjust arches warning message for external repo check
Merged 2 months ago by tkopecek. Opened 6 months ago by mikem.

@@ -247,6 +247,69 @@ 

          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}),

file modified
+2 -1
@@ -434,7 +434,8 @@ 

          # 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):

This makes the warning message a bit more informative and adds a few more unit tests.

Related: https://pagure.io/koji/issue/4165

Metadata Update from @tkopecek:
- Pull-request tagged with: testing-ready

5 months ago

Metadata Update from @mfilip:
- Pull-request tagged with: testing-done

3 months ago

Commit 9acd993 fixes this pull-request

Pull-Request has been merged by tkopecek

2 months ago