test: add footprint tests for container, wsl & vm-base image#18112
test: add footprint tests for container, wsl & vm-base image#18112bhagyapathak wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds image-footprint validation for container, VM-base, and WSL artifacts.
Changes:
- Adds installed-package and artifact-size thresholds.
- Adds RPM size querying and WSL extraction support.
- Extends pytest fixtures and image-type detection for WSL.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
base/images/tests/utils/pytest_plugin.py |
Recognizes WSL image artifacts. |
base/images/tests/utils/parsers.py |
Queries installed RPM sizes. |
base/images/tests/utils/extract.py |
Adds WSL extraction and cleanup. |
base/images/tests/README.md |
Documents the package-size fixture. |
base/images/tests/conftest.py |
Exposes WSL and package-size fixtures. |
base/images/tests/cases/static/test_footprint.py |
Adds footprint threshold tests. |
Comments suppressed due to low confidence (5)
base/images/tests/cases/static/test_footprint.py:116
- This bare assertion also triggers Ruff S101 under the repository-wide
select = ["ALL"]configuration. Convert it to an explicit failure.
assert not negative, f"packages with negative reported size: {sorted(negative)}"
base/images/tests/cases/static/test_footprint.py:119
- This bare assertion triggers Ruff S101 and will prevent the new test file from passing repository lint.
assert total > 0, "total installed footprint is zero"
base/images/tests/cases/static/test_footprint.py:133
- This threshold assertion is another Ruff S101 violation. Express the failure explicitly so lint can pass.
assert total <= cap, (
f"installed footprint {total / _BYTES_PER_MB:.1f} MB exceeds the "
f"{cap / _BYTES_PER_MB:.0f} MB cap for image '{image_name}'"
)
base/images/tests/cases/static/test_footprint.py:162
- This bare assertion triggers Ruff S101 under the root lint configuration. Use
pytest.fail(...)for the explicit value check.
assert size_bytes > 0, f"image artifact is empty: {image_path}"
base/images/tests/cases/static/test_footprint.py:166
- This final assertion also violates Ruff S101, so the file remains unlintable even after converting the earlier checks.
assert size_bytes <= cap, (
f"image artifact {size_bytes / _BYTES_PER_MB:.1f} MB exceeds the "
f"{cap / _BYTES_PER_MB:.0f} MB cap for image '{image_name}'"
)
6525323 to
50ca719
Compare
50ca719 to
e675138
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 8 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
base/images/tests/utils/parsers.py:73
- This assignment overwrites an earlier record whenever multiple installed RPM instances share the same
NAME(for example, multilib packages or parallel install-only kernel versions). The resulting total undercounts the image footprint and can let the threshold test pass incorrectly; aggregate duplicate names instead.
continue
e675138 to
eea49d3
Compare
eea49d3 to
e8d702a
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
base/images/tests/README.md:160
- The fixture table is now inconsistent with the documented WSL support: the adjacent
image_typerow still lists only"vm"and"container", although the fixture now returns"wsl"too. Update that row so users see the complete API.
| `installed_package_sizes` | session | `dict[str, int]` | Installed RPM name → on-disk size in bytes (`rpm --root`, `%{SIZE}`) |
e8d702a to
ebb43fe
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
base/images/tests/utils/extract.py:231
ruff.toml:8enables all lint rules, and S202 still flagsextractallwhen the filter is"tar"rather than"data". This therefore failsruff check. Since preserving rootfs absolute symlinks is intentional here, add the required same-line justification for the narrow suppression (or replace this with an equivalently validated custom extraction path).
tar.extractall(rootfs, filter="tar")
| A WSL image is a plain (optionally gzip-compressed) rootfs tarball, not | ||
| an OCI archive. Unpack it rootlessly with the ``tar`` filter, which | ||
| permits the absolute symlink targets normal in a rootfs while still | ||
| rejecting members that are absolute or escape the destination. |
ebb43fe to
0862d54
Compare
No description provided.