-
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 support for repository-size
command
#3313
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Added support for ``repository-size`` management command. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import json | ||
import subprocess | ||
|
||
from pulp_rpm.tests.functional.constants import ( | ||
RPM_UNSIGNED_FIXTURE_URL, | ||
RPM_UNSIGNED_FIXTURE_SIZE, | ||
RPM_KICKSTART_FIXTURE_URL, | ||
RPM_KICKSTART_FIXTURE_SIZE, | ||
) | ||
|
||
|
||
def test_repo_size(init_and_sync, delete_orphans_pre, monitor_task, orphans_cleanup_api_client): | ||
"""Test that RPM repos correctly report their on-disk artifact sizes.""" | ||
monitor_task(orphans_cleanup_api_client.cleanup({"orphan_protection_time": 0}).task) | ||
repo, _ = init_and_sync(url=RPM_UNSIGNED_FIXTURE_URL, policy="on_demand") | ||
|
||
cmd = ( | ||
"pulpcore-manager", | ||
"repository-size", | ||
"--repositories", | ||
repo.pulp_href, | ||
"--include-on-demand", | ||
) | ||
run = subprocess.run(cmd, capture_output=True, check=True) | ||
out = json.loads(run.stdout) | ||
|
||
# Assert basic items of report and test on-demand sizing | ||
assert len(out) == 1 | ||
report = out[0] | ||
assert report["name"] == repo.name | ||
assert report["href"] == repo.pulp_href | ||
assert report["disk-size"] == 0 | ||
assert report["on-demand-size"] == RPM_UNSIGNED_FIXTURE_SIZE | ||
|
||
_, _ = init_and_sync(repository=repo, url=RPM_UNSIGNED_FIXTURE_URL, policy="immediate") | ||
run = subprocess.run(cmd, capture_output=True, check=True) | ||
report = json.loads(run.stdout)[0] | ||
assert report["disk-size"] == RPM_UNSIGNED_FIXTURE_SIZE | ||
assert report["on-demand-size"] == 0 | ||
|
||
|
||
def test_kickstart_repo_size( | ||
init_and_sync, delete_orphans_pre, monitor_task, orphans_cleanup_api_client | ||
): | ||
"""Test that kickstart RPM repos correctly report their on-disk artifact sizes.""" | ||
monitor_task(orphans_cleanup_api_client.cleanup({"orphan_protection_time": 0}).task) | ||
repo, _ = init_and_sync(url=RPM_KICKSTART_FIXTURE_URL, policy="on_demand") | ||
|
||
cmd = ( | ||
"pulpcore-manager", | ||
"repository-size", | ||
"--repositories", | ||
repo.pulp_href, | ||
"--include-on-demand", | ||
) | ||
run = subprocess.run(cmd, capture_output=True, check=True) | ||
out = json.loads(run.stdout) | ||
|
||
# Assert basic items of report and test on-demand sizing | ||
assert len(out) == 1 | ||
report = out[0] | ||
assert report["name"] == repo.name | ||
assert report["href"] == repo.pulp_href | ||
assert report["disk-size"] == 2275 # One file is always downloaded | ||
assert report["on-demand-size"] == 133810 # Not all remote artifacts have sizes | ||
|
||
_, _ = init_and_sync(repository=repo, url=RPM_KICKSTART_FIXTURE_URL, policy="immediate") | ||
run = subprocess.run(cmd, capture_output=True, check=True) | ||
report = json.loads(run.stdout)[0] | ||
assert report["disk-size"] == RPM_KICKSTART_FIXTURE_SIZE | ||
assert report["on-demand-size"] == 0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,6 +124,9 @@ | |
"content_summary" field on "../repositories/../versions/../". | ||
""" | ||
|
||
RPM_UNSIGNED_FIXTURE_SIZE = 79260 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these numbers manually verified? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I manually added up the sizes on the fixture. I then double checked by performing a sync on an empty system and adding up all the artifact sizes. |
||
"""Size in bytes of all the packages in the :data:`RPM_UNSIGNED_FIXTURE_URL`.""" | ||
|
||
FEDORA_MIRRORLIST_BASE = "https://mirrors.fedoraproject.org/mirrorlist" | ||
FEDORA_MIRRORLIST_PARAMS = "?repo=epel-modular-8&arch=x86_64&infra=stock&content=centos" | ||
RPM_EPEL_MIRROR_URL = FEDORA_MIRRORLIST_BASE + FEDORA_MIRRORLIST_PARAMS | ||
|
@@ -462,6 +465,8 @@ | |
RPM_PACKAGELANGPACKS_CONTENT_NAME: 1, | ||
} | ||
|
||
RPM_KICKSTART_FIXTURE_SIZE = 9917733 | ||
|
||
RPM_KICKSTART_REPOSITORY_ROOT_CONTENT = [ | ||
".treeinfo", | ||
"Dolphin/", | ||
|
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.
Is there a reason these all need to be properties as opposed to functions?
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.
That one could be a function, but
disk_size
andon_demand_size
need to be properties as that is how it is defined in pulpcore.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.
Please make this one and
on_demand_artifacts_for_version
into normal functionsThere 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.
on_demand_artifacts_for_version
has to be a static method as that is how it is in pulpcore.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.
Sorry, I misread it as
@property
. It's fine then