From 95cc460659e2f563fbdd19f8d2126cd6e65d1475 Mon Sep 17 00:00:00 2001 From: git-hyagi <45576767+git-hyagi@users.noreply.github.com> Date: Fri, 26 Apr 2024 13:53:20 -0300 Subject: [PATCH] draft/wip fix content pull tests --- pulp_container/app/cache.py | 2 +- pulp_container/app/tasks/sync_stages.py | 4 ++-- pulp_container/tests/functional/api/test_pull_content.py | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pulp_container/app/cache.py b/pulp_container/app/cache.py index 08c7d81e6..fb37bf7e8 100644 --- a/pulp_container/app/cache.py +++ b/pulp_container/app/cache.py @@ -63,7 +63,7 @@ def make_response(self, key, base_key): return None entry = json.loads(entry) response_type = entry.pop("type", None) - if binary := entry.pop("data", None): + if binary := entry.pop("content", None): # raw binary data were translated to their hexadecimal representation and saved in # the cache as a regular string; now, it is necessary to translate the data back # to its original representation that will be returned in the HTTP response BODY: diff --git a/pulp_container/app/tasks/sync_stages.py b/pulp_container/app/tasks/sync_stages.py index 96bea6fc2..11018c403 100644 --- a/pulp_container/app/tasks/sync_stages.py +++ b/pulp_container/app/tasks/sync_stages.py @@ -575,14 +575,14 @@ async def _get_blob_size_data(self, blob_data, blob_url, is_layer): is_layer (bool): Boolean to identify if this is a layer blob (the size should be retrived from manifest) or a config blob """ - if is_layer: + if is_layer and "blobSum" not in blob_data: return blob_data.get("size"), None else: downloader = self.remote.get_downloader(url=blob_url) response = await downloader.run(extra_data={"headers": V2_ACCEPT_HEADERS}) with open(response.path, "rb") as content_file: raw_data = content_file.read() - return len(raw_data), raw_data + return response.artifact_attributes['size'], raw_data async def create_signatures(self, man_dc, signature_source): """ diff --git a/pulp_container/tests/functional/api/test_pull_content.py b/pulp_container/tests/functional/api/test_pull_content.py index c0c8d399c..bb32fa681 100644 --- a/pulp_container/tests/functional/api/test_pull_content.py +++ b/pulp_container/tests/functional/api/test_pull_content.py @@ -409,7 +409,8 @@ def test_pull_image_from_repository(self): self.assertEqual(local_image[0]["Id"], remote_image[0]["Id"]) new_artifact_count = self.artifacts_api.list().count - self.assertGreater(new_artifact_count, self.artifact_count) + # with the artifactless blobs the number of articts will decrease + self.assertGreater(new_artifact_count, self.artifact_count-1) registry.rmi(REGISTRY_V2_REPO_HELLO_WORLD)