Skip to content
This repository has been archived by the owner on Dec 7, 2022. It is now read-only.

Commit

Permalink
Add units which did not pass signature filter to the task report.
Browse files Browse the repository at this point in the history
  • Loading branch information
ipanova committed Sep 14, 2016
1 parent 61417cd commit 9ac632e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
6 changes: 3 additions & 3 deletions server/pulp/server/controllers/repository.py
Expand Up @@ -1152,13 +1152,13 @@ def check_publish(repo_obj, dist_id, dist_inst, transfer_repo, conduit, call_con
not predistributor_last_published))
# Check if content has not changed since last publish and a predistributor is not defined.
unchanged_content_and_no_predistributor = last_published and not last_updated and \
not units_removed and not predistributor_id
not units_removed and not predistributor_id
# We want to skip based on predistributor conditions. We also want to skip if repository
# content has not changed since last publish and no predistributor is defined. We want to not
# skip if 'force_full' is configured or the distributor config has changed since last publish.
if (skip_for_predistributor and not last_published) or\
(last_published and not force_full and not dist_updated and same_override
and (skip_for_predistributor or unchanged_content_and_no_predistributor)):
(last_published and not force_full and not dist_updated and same_override and
(skip_for_predistributor or unchanged_content_and_no_predistributor)):

publish_result_coll = RepoPublishResult.get_collection()
publish_start_timestamp = _now_timestamp()
Expand Down
7 changes: 6 additions & 1 deletion server/pulp/server/managers/repo/unit_association.py
Expand Up @@ -271,7 +271,12 @@ def associate_from_repo(cls, source_repo_id, dest_repo_id, criteria,
copied_units = importer_instance.import_units(
transfer_source_repo, transfer_dest_repo, conduit, call_config,
units=transfer_units)

if isinstance(copied_units, tuple):
suc_units_ids = [u.to_id_dict() for u in copied_units[0] if u is not None]
unsuc_units_ids = [u.to_id_dict() for u in copied_units[1]]
repo_controller.rebuild_content_unit_counts(dest_repo)
return {'units_successful': suc_units_ids,
'units_failed_signature_filter': unsuc_units_ids}
unit_ids = [u.to_id_dict() for u in copied_units if u is not None]
repo_controller.rebuild_content_unit_counts(dest_repo)
return {'units_successful': unit_ids}
Expand Down
22 changes: 22 additions & 0 deletions server/test/unit/server/managers/repo/test_unit_association.py
Expand Up @@ -230,6 +230,28 @@ def test_associate_from_repo_no_matching_units(self, mock_importer, mock_plugin,
self.assertEqual(1, mock_imp_inst.import_units.call_count)
self.assertEqual(ret.get('units_successful'), [])

@mock.patch('pulp.server.controllers.repository.rebuild_content_unit_counts', spec_set=True)
@mock.patch('pulp.server.managers.repo.unit_association.UnitAssociationCriteria')
@mock.patch('pulp.server.managers.repo.unit_association.plugin_api')
@mock.patch('pulp.server.managers.repo.unit_association.model.Importer')
def test_associate_from_repo_return_tuple(self, mock_importer, mock_plugin, mock_repo,
mock_crit, mock_rebuild_count):
mock_imp_inst = mock.MagicMock()
mock_plugin.get_importer_by_id.return_value = (mock_imp_inst, mock.MagicMock())
source_repo = mock.MagicMock(repo_id='source-repo')
dest_repo = mock.MagicMock(repo_id='dest-repo')

with mock.patch('pulp.server.controllers.importer.remove_importer'):
importer_controller.set_importer(source_repo, 'mock-importer', {})
importer_controller.set_importer(dest_repo, 'mock-importer', {})

mock_imp_inst.import_units.return_value = (list(), list())
ret = self.manager.associate_from_repo('source_repo', 'dest_repo', mock_crit)

self.assertEqual(1, mock_imp_inst.import_units.call_count)
self.assertEqual(ret.get('units_successful'), [])
self.assertEqual(ret.get('units_failed_signature_filter'), [])

@mock.patch('pulp.server.managers.repo.unit_association.UnitAssociationCriteria')
def test_associate_from_repo_missing_source(self, mock_repo, mock_crit):
importer_controller.set_importer('dest_repo', 'mock-importer', {})
Expand Down

0 comments on commit 9ac632e

Please sign in to comment.