-
Notifications
You must be signed in to change notification settings - Fork 87
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
[RHELC-828] Add missing integration tests for single yum transaction #677
Merged
bocekm
merged 8 commits into
oamg:main
from
r0x0d:add-additional-integration-test-for-yum-transactions
Feb 16, 2023
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
789f8f8
Add missing integration tests for single yum transaction
r0x0d cc8f861
Improve tier0 description with link
r0x0d 873cccd
Fix integration test
r0x0d 9938034
Fix pre-commit
r0x0d 82b5eb7
Remove the rollback for entitlement certs
r0x0d 1aac9f0
Apply suggestions from code review
r0x0d eabbf05
Update tests/integration/tier0/single-yum-transaction-validation/test…
r0x0d 94213f9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
33 changes: 33 additions & 0 deletions
33
tests/integration/tier0/single-yum-transaction-validation/main.fmf
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,33 @@ | ||
summary: Verify single yum transaction validation | ||
|
||
description: > | ||
Verify that we are doing a proper rollback during the validation phase in | ||
our transactions. | ||
|
||
If any errors occurs during the transaction resolution, either by | ||
downloading a package, dependency resolver and etc... A rollback should | ||
start and revert the changes to the system. | ||
|
||
link: https://issues.redhat.com/browse/RHELC-576 | ||
|
||
tier: 0 | ||
|
||
tag+: | ||
- yum | ||
- dnf | ||
- transaction | ||
|
||
/transaction_validation_error: | ||
adjust+: | ||
- enabled: false | ||
when: distro == centos-8 or distro == oraclelinux-8 | ||
tag+: | ||
- transaction-validation-error | ||
test: | | ||
pytest -svv -m transaction_validation_error | ||
|
||
/package_download_error: | ||
tag+: | ||
- package-download-error | ||
test: | | ||
pytest -svv -m package_download_error |
95 changes: 95 additions & 0 deletions
95
...gration/tier0/single-yum-transaction-validation/test_single_yum_transaction_validation.py
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,95 @@ | ||
import os | ||
import shutil | ||
Check notice Code scanning / CodeQL Unused import
Import of 'shutil' is not used.
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. I can open a follow-up PR to remove this type of warning later... I don't want to wait for a couple of hours to get results for the 3rd time in a row. |
||
|
||
import pytest | ||
|
||
from conftest import SYSTEM_RELEASE_ENV | ||
from envparse import env | ||
|
||
|
||
PKI_ENTITLEMENT_CERTS_PATH = "/etc/pki/entitlement" | ||
|
||
|
||
def backup_entitlement_certs(): | ||
""" | ||
Utillity function to backup and remove the entitlment cert as soon as we | ||
notice then in the the `PKI_ENTITLEMENT_CERTS_PATH`. | ||
r0x0d marked this conversation as resolved.
Show resolved
Hide resolved
|
||
""" | ||
original_certs = os.listdir(PKI_ENTITLEMENT_CERTS_PATH) | ||
|
||
for cert in original_certs: | ||
full_cert = "{}/{}".format(PKI_ENTITLEMENT_CERTS_PATH, cert) | ||
new_cert = "{}.bk".format(full_cert) | ||
shutil.move(full_cert, new_cert) | ||
r0x0d marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
@pytest.mark.package_download_error | ||
def test_package_download_error(convert2rhel): | ||
""" | ||
Remove the entitlement certs found at /etc/pki/entitlement during package | ||
download phase for both yum and dnf transactions. | ||
|
||
This will run the conversion up to the point where we valiate the | ||
transaction, when it reaches a specific point of the validation, we remove | ||
the entitlement certs found in /etc/pki/entitlement/*.pem to ensure that the | ||
tool is doing a proper rollback when there is any failure during the package | ||
download. | ||
|
||
The package download happens in different phases for yum and dnf, yum | ||
download the packages during the `processTransaction` method call, while dnf | ||
has a specific method that process and download the packages in the | ||
transaction. | ||
""" | ||
|
||
server_sub = "CentOS Linux" | ||
pkgmanager = "yum" | ||
final_message = "There are no suitable mirrors available for the loaded repositories." | ||
|
||
if "oracle" in SYSTEM_RELEASE_ENV: | ||
server_sub = "Oracle Linux Server" | ||
|
||
if "8" in SYSTEM_RELEASE_ENV: | ||
pkgmanager = "dnf" | ||
final_message = "Failed to download the transaction packages." | ||
|
||
with convert2rhel( | ||
"-y --no-rpm-va --serverurl {} --username {} --password {} --pool {} --debug".format( | ||
env.str("RHSM_SERVER_URL"), | ||
env.str("RHSM_USERNAME"), | ||
env.str("RHSM_PASSWORD"), | ||
env.str("RHSM_POOL"), | ||
) | ||
) as c2r: | ||
c2r.expect("Adding {} packages to the {} transaction set.".format(server_sub, pkgmanager)) | ||
backup_entitlement_certs() | ||
assert c2r.expect_exact(final_message, timeout=600) == 0 | ||
|
||
assert c2r.exitstatus == 1 | ||
|
||
|
||
@pytest.mark.transaction_validation_error | ||
def test_transaction_validation_error(convert2rhel): | ||
""" | ||
Remove the entitlement certs found at /etc/pki/entitlement during transaction | ||
processing to throw the following yum error: pkgmanager.Errors.YumDownloadError | ||
|
||
This will run the conversion up to the point where we valiate the | ||
transaction, when it reaches a specific point of the validation, we remove | ||
the entitlement certs found in /etc/pki/entitlement/*.pem to ensure that the | ||
tool is doing a proper rollback when the transaction is being processed. | ||
""" | ||
with convert2rhel( | ||
"-y --no-rpm-va --serverurl {} --username {} --password {} --pool {} --debug".format( | ||
env.str("RHSM_SERVER_URL"), | ||
env.str("RHSM_USERNAME"), | ||
env.str("RHSM_PASSWORD"), | ||
env.str("RHSM_POOL"), | ||
) | ||
) as c2r: | ||
c2r.expect( | ||
"Downloading and validating the yum transaction set, no modifications to the system will happen this time." | ||
) | ||
backup_entitlement_certs() | ||
r0x0d marked this conversation as resolved.
Show resolved
Hide resolved
|
||
assert c2r.expect_exact("Failed to validate the yum transaction.", timeout=600) == 0 | ||
|
||
assert c2r.exitstatus == 1 |
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
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.
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.
I'd love to add a
because:
here to say why I'm disabling this test for centos-8 and oraclelinux-8, but since it's been a really long time, I don't remember. I will try to get the rationale at some point.