Skip to content

Commit

Permalink
Allow core/3.55+.
Browse files Browse the repository at this point in the history
fixes pulp#3620.
  • Loading branch information
ggainey committed Jun 18, 2024
1 parent 80cd799 commit f279e0b
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 33 deletions.
1 change: 1 addition & 0 deletions CHANGES/3620.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow installation with pulpcore/3.55.
27 changes: 13 additions & 14 deletions pulp_rpm/tests/functional/api/test_pulpimport.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def _import_export_repositories(


@pytest.fixture
def create_exporter(gen_object_with_cleanup, exporters_pulp_api_client, import_export_repositories):
def create_exporter(gen_object_with_cleanup, pulpcore_bindings, import_export_repositories):
def _create_exporter(import_repos=None, export_repos=None, url=RPM_UNSIGNED_FIXTURE_URL):
if not export_repos:
_, export_repos = import_export_repositories(import_repos, export_repos, url=url)
Expand All @@ -72,37 +72,37 @@ def _create_exporter(import_repos=None, export_repos=None, url=RPM_UNSIGNED_FIXT
"repositories": [r.pulp_href for r in export_repos],
"path": f"/tmp/{uuid.uuid4()}/",
}
exporter = gen_object_with_cleanup(exporters_pulp_api_client, body)
exporter = gen_object_with_cleanup(pulpcore_bindings.ExportersPulpApi, body)
return exporter

return _create_exporter


@pytest.fixture
def create_export(exporters_pulp_exports_api_client, create_exporter, monitor_task):
def create_export(pulpcore_bindings, create_exporter, monitor_task):
def _create_export(
import_repos=None, export_repos=None, url=RPM_UNSIGNED_FIXTURE_URL, exporter=None
):
if not exporter:
exporter = create_exporter(import_repos, export_repos, url=url)

export_response = exporters_pulp_exports_api_client.create(exporter.pulp_href, {})
export_response = pulpcore_bindings.ExportersPulpExportsApi.create(exporter.pulp_href, {})
export_href = monitor_task(export_response.task).created_resources[0]
export = exporters_pulp_exports_api_client.read(export_href)
export = pulpcore_bindings.ExportersPulpExportsApi.read(export_href)
return export

return _create_export


@pytest.fixture
def create_chunked_export(exporters_pulp_exports_api_client, create_exporter, monitor_task):
def create_chunked_export(pulpcore_bindings, create_exporter, monitor_task):
def _create_chunked_export(import_repos, export_repos, url=RPM_UNSIGNED_FIXTURE_URL):
exporter = create_exporter(import_repos, export_repos, url=url)
export_response = exporters_pulp_exports_api_client.create(
export_response = pulpcore_bindings.ExportersPulpExportsApi.create(
exporter.pulp_href, {"chunk_size": "5KB"}
)
export_href = monitor_task(export_response.task).created_resources[0]
export = exporters_pulp_exports_api_client.read(export_href)
export = pulpcore_bindings.ExportersPulpExportsApi.read(export_href)
return export

return _create_chunked_export
Expand Down Expand Up @@ -299,8 +299,7 @@ def test_create_missing_repos(
rpm_repository_api,
rpm_content_distribution_trees_api,
monitor_task,
exporters_pulp_api_client,
exporters_pulp_exports_api_client,
pulpcore_bindings,
orphans_cleanup_api_client,
importers_pulp_api_client,
gen_object_with_cleanup,
Expand Down Expand Up @@ -342,13 +341,13 @@ def test_create_missing_repos(
"repositories": [entity_map["rpm-repo"].pulp_href, entity_map["ks-repo"].pulp_href],
"path": f"/tmp/{uuid.uuid4()}/",
}
exporter = gen_object_with_cleanup(exporters_pulp_api_client, body)
exporter = gen_object_with_cleanup(pulpcore_bindings.ExportersPulpApi, body)
entity_map["exporter-path"] = exporter.path

# Step 3, export
export_response = exporters_pulp_exports_api_client.create(exporter.pulp_href, {})
export_response = pulpcore_bindings.ExportersPulpExportsApi.create(exporter.pulp_href, {})
export_href = monitor_task(export_response.task).created_resources[0]
export = exporters_pulp_exports_api_client.read(export_href)
export = pulpcore_bindings.ExportersPulpExportsApi.read(export_href)
filenames = [
f
for f in list(export.output_file_info.keys())
Expand All @@ -363,7 +362,7 @@ def test_create_missing_repos(
assert "//" not in an_export_filename

# Step 4, exporter/repo-cleanup, orphans
exporters_pulp_api_client.delete(exporter.pulp_href)
pulpcore_bindings.ExportersPulpApi.delete(exporter.pulp_href)
rpm_rpmremote_api.delete(entity_map["rpm-remote"].pulp_href)
rpm_rpmremote_api.delete(entity_map["ks-remote"].pulp_href)
rpm_repository_api.delete(entity_map["rpm-repo"].pulp_href)
Expand Down
4 changes: 2 additions & 2 deletions pulp_rpm/tests/functional/api/test_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@


def test_single_request_unit_and_duplicate_unit(
delete_orphans_pre, rpm_package_api, monitor_task, tasks_api_client
delete_orphans_pre, rpm_package_api, monitor_task, pulpcore_bindings
):
"""Test single request upload unit.
Expand Down Expand Up @@ -61,7 +61,7 @@ def test_single_request_unit_and_duplicate_unit(
monitor_task(upload.task)
except PulpTaskError:
pass
task_report = tasks_api_client.read(upload.task)
task_report = pulpcore_bindings.TasksApi.read(upload.task)
assert task_report.created_resources[0] == package.pulp_href


Expand Down
34 changes: 18 additions & 16 deletions pulp_rpm/tests/functional/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,23 +112,23 @@ def rpm_copy_api(rpm_client):


@pytest.fixture
def signed_artifact(artifacts_api_client, tmp_path):
def signed_artifact(pulpcore_bindings, tmp_path):
data = requests.get(RPM_SIGNED_URL).content
artifacts = artifacts_api_client.list(sha256=hashlib.sha256(data).hexdigest(), limit=1)
artifacts = pulpcore_bindings.ArtifactsApi.list(
sha256=hashlib.sha256(data).hexdigest(), limit=1
)
try:
return artifacts.results[0].to_dict()
except IndexError:
pass

temp_file = tmp_path / str(uuid.uuid4())
temp_file.write_bytes(data)
return artifacts_api_client.create(temp_file).to_dict()
return pulpcore_bindings.ArtifactsApi.create(temp_file).to_dict()


@pytest.fixture
def rpm_artifact_factory(
artifacts_api_client, gen_object_with_cleanup, pulp_domain_enabled, tmp_path
):
def rpm_artifact_factory(pulpcore_bindings, gen_object_with_cleanup, pulp_domain_enabled, tmp_path):
"""Return an artifact created from uploading an RPM file."""

def _rpm_artifact_factory(url=RPM_SIGNED_URL, pulp_domain=None):
Expand All @@ -139,7 +139,7 @@ def _rpm_artifact_factory(url=RPM_SIGNED_URL, pulp_domain=None):
if not pulp_domain_enabled:
raise RuntimeError("Server does not have domains enabled.")
kwargs["pulp_domain"] = pulp_domain
return gen_object_with_cleanup(artifacts_api_client, temp_file, **kwargs)
return gen_object_with_cleanup(pulpcore_bindings.ArtifactsApi, temp_file, **kwargs)

return _rpm_artifact_factory

Expand Down Expand Up @@ -194,13 +194,13 @@ def rpm_kickstart_repo_immediate(init_and_sync):


@pytest.fixture(scope="session")
def rpm_metadata_signing_service(signing_service_api_client):
results = signing_service_api_client.list(name="sign-metadata")
def rpm_metadata_signing_service(pulpcore_bindings):
results = pulpcore_bindings.SigningServicesApi.list(name="sign-metadata")
signing_service = None
if results.count == 0:
result = init_signed_repo_configuration()
if result.returncode == 0:
results = signing_service_api_client.list(name="sign-metadata")
results = pulpcore_bindings.SigningServicesApi.list(name="sign-metadata")
if results.count == 1:
signing_service = results.results[0]

Expand Down Expand Up @@ -286,7 +286,7 @@ def _from_results(advisory_id, vers_href):

@pytest.fixture
def setup_domain(
gen_object_with_cleanup, domains_api_client, rpm_rpmremote_api, rpm_repository_api, monitor_task
gen_object_with_cleanup, pulpcore_bindings, rpm_rpmremote_api, rpm_repository_api, monitor_task
):
def _setup_domain(sync=True, url=RPM_SIGNED_FIXTURE_URL, pulp_domain=None):
if not pulp_domain:
Expand All @@ -295,7 +295,7 @@ def _setup_domain(sync=True, url=RPM_SIGNED_FIXTURE_URL, pulp_domain=None):
"storage_class": "pulpcore.app.models.storage.FileSystem",
"storage_settings": {"MEDIA_ROOT": "/var/lib/pulp/media/"},
}
pulp_domain = gen_object_with_cleanup(domains_api_client, body)
pulp_domain = gen_object_with_cleanup(pulpcore_bindings.DomainsApi, body)

remote = gen_object_with_cleanup(
rpm_rpmremote_api, {"name": str(uuid.uuid4()), "url": url}, pulp_domain=pulp_domain.name
Expand All @@ -320,7 +320,7 @@ def _setup_domain(sync=True, url=RPM_SIGNED_FIXTURE_URL, pulp_domain=None):


@pytest.fixture
def cleanup_domains(orphans_cleanup_api_client, monitor_task, rpm_repository_api):
def cleanup_domains(pulpcore_bindings, monitor_task, rpm_repository_api):
def _cleanup_domains(
domains,
content_api_client=None,
Expand All @@ -336,7 +336,7 @@ def _cleanup_domains(
monitor_task(repository_api_client.delete(repo.pulp_href).task)
# Let orphan-cleanup reap the resulting abandoned content
monitor_task(
orphans_cleanup_api_client.cleanup(
pulpcore_bindings.OrphansCleanupApi.cleanup(
{"orphan_protection_time": 0}, pulp_domain=domain.name
).task
)
Expand Down Expand Up @@ -552,5 +552,7 @@ def _rpm_package_signing_service_name(


@pytest.fixture
def rpm_package_signing_service(_rpm_package_signing_service_name, signing_service_api_client):
return signing_service_api_client.list(name=_rpm_package_signing_service_name).results[0]
def rpm_package_signing_service(_rpm_package_signing_service_name, pulpcore_bindings):
return pulpcore_bindings.SigningServicesApi.list(
name=_rpm_package_signing_service_name
).results[0]
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ django_readonly_field~=1.1.1
jsonschema>=4.6,<5.0
libcomps>=0.1.20.post1,<0.2
productmd~=1.33.0
pulpcore>=3.44.1,<3.55
pulpcore>=3.44.1,<3.70
solv~=0.7.21
aiohttp_xmlrpc~=1.5.0
importlib-resources~=6.4.0

0 comments on commit f279e0b

Please sign in to comment.