-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add compression_type option for publish #3367
Conversation
7d9fc35
to
319c067
Compare
ALLOWED_CHECKSUM_ERROR_MSG, | ||
CHECKSUM_TYPES, | ||
PACKAGES_DIRECTORY, | ||
COMPRESSION_TYPES, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind alphabetizing the imports?
"""Sync and publish an RPM repository w/ zstd compression and verify it exists.""" | ||
# 1. Publish and distribute | ||
publish_data = RpmRpmPublication( | ||
repository=rpm_unsigned_repo_immediate.pulp_href, compression_type="zstd" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The compression_type
value here isn't actually parameterized, it's only using zstd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, my bad
) | ||
for elem in metadata_elements: | ||
elem_href = elem.find(xpath_location).get("href") | ||
assert elem_href.endswith(".zst") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise the test is only checking for a .zst
extension regardless of the value of compression_type
requests.get(os.path.join(distribution.base_url, "repodata/repomd.xml")).text | ||
) | ||
xpath_data = "{{{}}}data".format(RPM_NAMESPACES["metadata/repo"]) | ||
xpath_location = "{{{}}}location".format(RPM_NAMESPACES["metadata/repo"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can refactor this along with _get_updateinfo_xml_path
into a shared helper function that returns the "data" value (primary, filelists, other, updateinfo, etc.) as dictionary keys and the href as dictionary values.
def get_repomd_metadata_urls(self, repomd_url: str):
repomd_xml = requests.get(os.path.join(distribution.base_url, "repodata/repomd.xml")).text
repomd = ElementTree.fromstring(repomd_xml)
xpath_data = "{{{}}}data".format(RPM_NAMESPACES["metadata/repo"])
xpath_location = "{{{}}}location".format(RPM_NAMESPACES["metadata/repo"])
hrefs = {}
for elem in repomd.findall(xpath_data):
md_type = elem.get("type")
hrefs[md_type] = elem.find(xpath_location).get("href")
return hrefs
# usage
for md_type, location in self.get_repomd_metadata_urls(url).items():
if md_type in {"primary", "filelists", "other"}:
assert location.endswith(".zst")
update_xml_url = self._get_updateinfo_xml_path(repomd)["updateinfo"]
# ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for snippet
Add compression_type option for publishing with support for zstd. closes pulp#3316
319c067
to
0d11485
Compare
>>> get_repomd_metadata(distribution.base_url) | ||
{ | ||
"primary": "repodata/.../primary.xml.gz", | ||
"filelists": "repodata/.../listfiles.xml.gz", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
listfiles.xml.gz
-> filelists.xml.gz
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved apart from a minor typo
- Use new "get_repomd_metadata_urls" helper function in the "test_validate_no_checksum_tag" and remove the old specific helper function. - Typos [noissue]
0d11485
to
46648a0
Compare
With support for zstd compression.
closes #3316