Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
Fix migration for the case when no importer is specified.
Browse files Browse the repository at this point in the history
closes #8389
https://pulp.plan.io/issues/8389
backports #8382
https://pulp.plan.io/issues/8382

(cherry picked from commit a217610)
  • Loading branch information
goosemania committed Mar 11, 2021
1 parent c45e472 commit 5fb9881
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES/8389.bugfix
@@ -0,0 +1 @@
Fixed a migraiton failure when no importer was specified in the migration plan.
4 changes: 2 additions & 2 deletions pulp_2to3_migration/app/models/base.py
Expand Up @@ -434,7 +434,7 @@ def set_importer(cls, repo_id, repo_type, importer_repo_id):
pulp2_resource_type=cls.IMPORTER,
pulp2_repo_type=repo_type,
pulp2_repo_id=repo_id,
pulp2_resource_repo_id=importer_repo_id,
pulp2_resource_repo_id=importer_repo_id or '',
defaults={'status': cls.NEW}
)

Expand Down Expand Up @@ -478,7 +478,7 @@ def set_distributors(cls, repo_id, repo_type, distributor_repo_ids):
pulp2_resource_type=cls.DISTRIBUTOR,
pulp2_repo_type=repo_type,
pulp2_repo_id=repo_id,
pulp2_resource_repo_id=distributor_repo_id,
pulp2_resource_repo_id=distributor_repo_id or '',
status=cls.NEW,
)
except IntegrityError:
Expand Down
33 changes: 33 additions & 0 deletions pulp_2to3_migration/tests/functional/test_migration_behaviour.py
Expand Up @@ -107,6 +107,23 @@
}]
})

NO_IMPORTER_PLAN = json.dumps({
"plugins": [{
"type": "iso",
"repositories": [
{
"name": "file",
"repository_versions": [
{
"pulp2_repository_id": "file", # content count: iso - 3
"pulp2_distributor_repository_ids": ["file"]
}
]
}
]
}]
})

CONTENT_COUNT = {
'file': 3,
'file2': 3,
Expand Down Expand Up @@ -303,3 +320,19 @@ def test_no_immediate_importer(self):

self.assertEqual(self.file_repo_versions_api.list(pulp3_repo.pulp_href).count, 2)
self.assertEqual(repo_content.count, 3)

def test_no_importer(self):
"""Test that if there is no importer specified at all, migraiton is still working fine."""
self.run_migration(NO_IMPORTER_PLAN)
pulp3_repo = self.file_repo_api.list().results[0]
repo_content = self.file_content_api.list(repository_version=pulp3_repo.latest_version_href)
pulp2repository = self.pulp2repositories_api.list().results[0]
pulp3_pub = self.file_publication_api.read(pulp2repository.pulp3_publication_href)
pulp3_dist = self.file_distribution_api.read(pulp2repository.pulp3_distribution_hrefs[0])

self.assertEqual(self.file_repo_versions_api.list(pulp3_repo.pulp_href).count, 2)
self.assertEqual(repo_content.count, 3)
self.assertEqual(pulp2repository.pulp2_repo_id, 'file')
self.assertEqual(pulp3_pub.repository_version, pulp2repository.pulp3_repository_version)
self.assertEqual(pulp3_pub.distributions[0], pulp3_dist.pulp_href)
self.assertEqual(pulp3_dist.base_path, 'file')

0 comments on commit 5fb9881

Please sign in to comment.