From f279e0bb70bd682a9ac07b20a4c5329408535c89 Mon Sep 17 00:00:00 2001 From: Grant Gainey Date: Tue, 18 Jun 2024 13:49:23 -0400 Subject: [PATCH] Allow core/3.55+. fixes #3620. --- CHANGES/3620.bugfix | 1 + .../tests/functional/api/test_pulpimport.py | 27 +++++++-------- pulp_rpm/tests/functional/api/test_upload.py | 4 +-- pulp_rpm/tests/functional/conftest.py | 34 ++++++++++--------- requirements.txt | 2 +- 5 files changed, 35 insertions(+), 33 deletions(-) create mode 100644 CHANGES/3620.bugfix diff --git a/CHANGES/3620.bugfix b/CHANGES/3620.bugfix new file mode 100644 index 000000000..91a74628d --- /dev/null +++ b/CHANGES/3620.bugfix @@ -0,0 +1 @@ +Allow installation with pulpcore/3.55. diff --git a/pulp_rpm/tests/functional/api/test_pulpimport.py b/pulp_rpm/tests/functional/api/test_pulpimport.py index c7ab03524..8005f737f 100644 --- a/pulp_rpm/tests/functional/api/test_pulpimport.py +++ b/pulp_rpm/tests/functional/api/test_pulpimport.py @@ -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) @@ -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 @@ -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, @@ -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()) @@ -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) diff --git a/pulp_rpm/tests/functional/api/test_upload.py b/pulp_rpm/tests/functional/api/test_upload.py index be4c165ce..0dd86359a 100644 --- a/pulp_rpm/tests/functional/api/test_upload.py +++ b/pulp_rpm/tests/functional/api/test_upload.py @@ -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. @@ -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 diff --git a/pulp_rpm/tests/functional/conftest.py b/pulp_rpm/tests/functional/conftest.py index 286098d00..60cec36b4 100644 --- a/pulp_rpm/tests/functional/conftest.py +++ b/pulp_rpm/tests/functional/conftest.py @@ -112,9 +112,11 @@ 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: @@ -122,13 +124,11 @@ def signed_artifact(artifacts_api_client, tmp_path): 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): @@ -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 @@ -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] @@ -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: @@ -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 @@ -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, @@ -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 ) @@ -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] diff --git a/requirements.txt b/requirements.txt index 6168db448..b43adeb71 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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