-
-
Notifications
You must be signed in to change notification settings - Fork 354
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
host.package().is_installed
is returning True incorrectly when the RPM database is corrupted.
#758
Comments
narmaku
added a commit
to narmaku/pytest-testinfra
that referenced
this issue
Apr 1, 2024
This new logic verifies if there is a "not installed" string in the stdout when "rpm -q %s" command returns 1. As seen in bug pytest-dev#758, if rpm command failed because of other reasons (such as database corruption), the old implementation was returning True, making the end-user think that the package was installed, however it was never queried.
philpep
pushed a commit
to narmaku/pytest-testinfra
that referenced
this issue
May 26, 2024
This new logic verifies if there is a "not installed" string in the stdout when "rpm -q %s" command returns 1. As seen in bug pytest-dev#758, if rpm command failed because of other reasons (such as database corruption), the old implementation was returning True, making the end-user think that the package was installed, however it was never queried.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Summary
When calling
host.package().is_installed
in a system using RPMs (in our case, RHEL), and the actual RPM database is corrupted, the command returns True, but the package could not even be queried to know if it's installed or not.We got a false positive in this test case:
Source: https://github.com/osbuild/cloud-image-val/blob/5e2d95961646dd66e5962c9f8c65133713b1ee40/test_suite/cloud/test_aws.py#L199
I found this issue debugging the tool and adding more information in some of our test results, as you can see below:
Source: https://github.com/osbuild/cloud-image-val/blob/5e2d95961646dd66e5962c9f8c65133713b1ee40/test_suite/cloud/test_aws.py#L320
Expected behavior
is_installed fails since it cannot check for the package existence as rpm command crashed unexpectedly due to a DB error, or any other reason. And this reason is thrown as an a exception so the user know what happened.
Actual behavior
is_installed returns True when there is a rpm command failure and it is returning 1.
Suggestion / Proposal
Make RPM database integrity check, or at least improve the is_installed function to throw an exception when the rpm query could not be done (considering that other errors can actually also return 1 when running rpm command).
We can check the stdout to really know that the package is not installed:
package <pkg> is not installed
(return code 1)If not matching, we can print the actual stdout + stderr, or the CommandOutput object itself, such as it is being done in the rest of the project.
The text was updated successfully, but these errors were encountered: