-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for
repository-size
command
fixes: #3312
- Loading branch information
Showing
5 changed files
with
133 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Added support for ``repository-size`` management command. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
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): | ||
"""Test that RPM repos correctly report their on-disk artifact sizes.""" | ||
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): | ||
"""Test that kickstart RPM repos correctly report their on-disk artifact sizes.""" | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters