Skip to content

Commit

Permalink
Check for failed download in metadata downloader
Browse files Browse the repository at this point in the history
Check for failed download in metadata downloader

closes #1732
https://pulp.plan.io/issues/1732
  • Loading branch information
pcreech committed Mar 14, 2016
1 parent ee17aba commit 2a2b80d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions plugins/pulp_rpm/plugins/importers/yum/repomd/metadata.py
Expand Up @@ -200,6 +200,9 @@ def download_metadata_files(self):
download_request_list.append(request)

self.downloader.download(download_request_list)
if self.event_listener.failed_reports:
error_report = self.event_listener.failed_reports[0]
raise IOError(error_report.error_msg)

def verify_metadata_files(self):
"""
Expand Down
16 changes: 16 additions & 0 deletions plugins/test/unit/plugins/importers/yum/repomd/test_metadata.py
Expand Up @@ -8,6 +8,7 @@

import mock
from nectar.config import DownloaderConfig
from nectar.report import DownloadReport

from pulp_rpm.devel.skip import skip_broken
from pulp_rpm.plugins.importers.yum.utils import RepoURLModifier
Expand Down Expand Up @@ -206,6 +207,21 @@ def test_does_not_skip_unknown_sqlite_files(self):
self.assertTrue(requests[0].destination.endswith('primary'))
self.assertTrue(requests[1].destination.endswith('pkgtags.sqlite.gz'))

def test_failed_reports(self):
self.metadata_files.downloader.download = mock.MagicMock(
spec_set=self.metadata_files.downloader.download
)
self.metadata_files.metadata = {
'primary': file_info_factory('primary'),
}

report = DownloadReport('url', '/destination')
report.download_failed()
self.metadata_files.event_listener.failed_reports.append(report)

# Ensure an exception is raised if the download failed
self.assertRaises(IOError, self.metadata_files.download_metadata_files)


class TestQueryAuthToken(unittest.TestCase):
def setUp(self):
Expand Down

0 comments on commit 2a2b80d

Please sign in to comment.