Refactor container user test to use better helpers - #716
Merged
evgeni merged 1 commit intoJul 31, 2026
Conversation
This was referenced Jul 31, 2026
evgeni
reviewed
Jul 31, 2026
evgeni
reviewed
Jul 31, 2026
ekohl
force-pushed
the
clean-up-container-root-user-test
branch
from
July 31, 2026 10:02
b6a329d to
a10b89f
Compare
evgeni
approved these changes
Jul 31, 2026
ekohl
commented
Jul 31, 2026
evgeni
reviewed
Jul 31, 2026
ekohl
force-pushed
the
clean-up-container-root-user-test
branch
2 times, most recently
from
July 31, 2026 11:00
bb61993 to
bfdd756
Compare
evgeni
reviewed
Jul 31, 2026
| for container in containers: | ||
| with subtests.test(container.name): | ||
| user = container.inspect()['Config']['User'] | ||
| if container.name in EXPECTED_ROOT_IMAGES: |
Member
There was a problem hiding this comment.
Suggested change
| if container.name in EXPECTED_ROOT_IMAGES: | |
| if container.inspect()['Config']['Image'] in EXPECTED_ROOT_IMAGES: |
or we need to update the list to use names, but I think images is more representative
Member
Author
There was a problem hiding this comment.
Agreed, images are better. Only downside is that when we branch, we'll need to update nightly to the stable version but I think that is acceptable.
This uses pytest's subtests to simplify the testing. It still reports each individual container that fails, but written in a cleaner way. Then uses testinfra's podman infrastructure to simplify it even further. Link: https://docs.pytest.org/en/stable/how-to/subtests.html Link: https://testinfra.readthedocs.io/en/latest/modules.html#testinfra.modules.podman.Podman.get_containers
ekohl
force-pushed
the
clean-up-container-root-user-test
branch
from
July 31, 2026 11:53
bfdd756 to
b719e69
Compare
evgeni
enabled auto-merge (rebase)
July 31, 2026 12:08
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why are you introducing these changes? (Problem description, related links)
In #711 (comment) it was pointed out this could be improved, which also made spot the possible testinfra improvement.
What are the changes introduced in this pull request?
This uses pytest's subtests to simplify the testing. It still reports each individual container that fails, but written in a cleaner way. Then uses testinfra's podman infrastructure to simplify it even further.
How to test this pull request
Steps to reproduce:
Checklist